nr-filter-specularlighting.cpp revision 0f1b8f53ed81c3a02f55223cd3eb359f123bc565
/*
* feSpecularLighting renderer
*
* Authors:
* Niko Kiirala <niko@kiirala.com>
* Jean-Rene Reinhard <jr@komite.net>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <glib/gmessages.h>
#include <cmath>
#include "display/nr-3dutils.h"
#include "display/nr-arena-item.h"
#include "display/nr-filter-specularlighting.h"
#include "display/nr-filter-getalpha.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-utils.h"
#include "display/nr-light.h"
#include "libnr/nr-pixblock.h"
#include "libnr/nr-matrix.h"
#include "libnr/nr-rect-l.h"
#include "color.h"
namespace NR {
{
specularConstant = 1;
specularExponent = 1;
surfaceScale = 1;
lighting_color = 0xffffffff;
}
return new FilterSpecularLighting();
}
{}
//Investigating Phong Lighting model we should not take N.H but
//R.E which equals to 2*N.H^2 - 1
//replace the second line by
//gdouble scal = scalar_product((N), (H)); scal = 2 * scal * scal - 1;\
//to get the expected formula
do {\
if (scal <= 0)\
(inter) = 0;\
else\
}while(0)
//Fvector *L = NULL; //vector to the light
int i, j;
//As long as FilterRes and kernel unit is not supported we hardcode the
//default value
//surface scale
//TODO for the time being, assumes userSpaceOnUse
true);
//No light, nothing to do
switch (light_type) {
case DISTANT_LIGHT:
//the light vector is constant
{
dl->light_vector(L);
normalized_sum(H, L, EYE_VECTOR);
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
}
delete dl;
}
break;
case POINT_LIGHT:
{
//TODO we need a reference to the filter to determine primitiveUnits
//slot._arena_item->filter seems to be ok on simple examples
//for now assume userSpaceOnUse
//if objectBoundingBox is used, use a different matrix for light_vector
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
pl->light_vector(L,
i % w + x0,
i / w + y0,
normalized_sum(H, L, EYE_VECTOR);
}
delete pl;
}
break;
case SPOT_LIGHT:
{
//TODO we need a reference to the filter to determine primitiveUnits
//slot._arena_item->filter seems to be ok on simple examples
//for now assume userSpaceOnUse
//if objectBoundingBox is used, use a different matrix for light_vector
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
sl->light_vector(L,
i % w + x0,
i / w + y0,
normalized_sum(H, L, EYE_VECTOR);
}
delete sl;
}
break;
//else unknown light source, doing nothing
case NO_LIGHT:
default:
{
if (light_type != NO_LIGHT)
}
}
//finishing
delete in;
return 0;
}
} /* namespace NR */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :