nr-filter-specularlighting.cpp revision 423740a942b7c6ce5313bfd4d09fe02c4feabbe7
/*
* 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-units.h"
#include "display/nr-filter-utils.h"
#include "display/nr-light.h"
#include "libnr/nr-pixblock.h"
#include "libnr/nr-rect-l.h"
#include "color.h"
namespace Inkscape {
namespace Filters {
{
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)
if (!in) {
return 1;
}
//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
true);
//No light, nothing to do
switch (light_type) {
case DISTANT_LIGHT:
//the light vector is constant
{
dl->light_vector(L);
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
++j;
}
delete dl;
}
break;
case POINT_LIGHT:
{
//TODO we need a reference to the filter to determine primitiveUnits
//if objectBoundingBox is used, use a different matrix for light_vector
// UPDATE: trans is now correct matrix from primitiveUnits to
// pixblock coordinates
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
pl->light_vector(L,
i % w + x0,
i / w + y0,
++j;
}
delete pl;
}
break;
case SPOT_LIGHT:
{
//TODO we need a reference to the filter to determine primitiveUnits
//if objectBoundingBox is used, use a different matrix for light_vector
// UPDATE: trans is now correct matrix from primitiveUnits to
// pixblock coordinates
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
sl->light_vector(L,
i % w + x0,
i / w + y0,
++j;
}
delete sl;
}
break;
//else unknown light source, doing nothing
case NO_LIGHT:
default:
{
if (light_type != NO_LIGHT)
}
}
//finishing
//nr_pixblock_release(in);
//delete in;
return 0;
}
return TRAIT_PARALLER;
}
} /* namespace Filters */
} /* namespace Inkscape */
/*
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 :