nr-filter-diffuselighting.cpp revision 0f1b8f53ed81c3a02f55223cd3eb359f123bc565
/*
* feDiffuseLighting 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 "display/nr-3dutils.h"
#include "display/nr-arena-item.h"
#include "display/nr-filter-diffuselighting.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 {
{
diffuseConstant = 1;
surfaceScale = 1;
lighting_color = 0xffffffff;
}
return new FilterDiffuseLighting();
}
{}
do {\
}while(0)
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);
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
data_o[j++] = 255;
}
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,
data_o[j++] = 255;
}
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,
data_o[j++] = 255;
}
delete sl;
}
break;
//else unknown light source, doing nothing
case NO_LIGHT:
default:
{
if (light_type != NO_LIGHT)
for (i = 0; i < w*h; i++) {
}
}
}
//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 :