Hello,
I am using a custom shader to enlight my scene thanks to a spot light.
I have got a problem considering enlightment of some shapes.
Objects loaded from 3ds file seems to be correctly enlighted.
But, when I create a simple object like a Cone, it is not enlighted correctly,
and I can't understand why.
I observe that only vertices are enlighted. I suppose that is a per vertex /
per pixel lighting problem...
On my 3ds Objects, I think I can't see the problem because they contains a lot
of vertex.
That is part of my Fragment shader which compute the Spot light Intensity.
Code:
float computeSpotInfluence()
{
float att = 0;
if(KSter_spot == true)
{
float spotEffect = dot(normalize(gl_LightSource[1].spotDirection), (-lightDir));
spotEffect = exp(-abs(spotEffect-1.)/(.035));
att = spotEffect/(1+.01*distLightVertex+.015*pow(distLightVertex,2.));
att*=gl_LightSource[1].diffuse[0];
}
return att;
}
And, here is my Vertex shader :
Code:
vec4 ecPos;
ecPos = gl_ModelViewMatrix * gl_Vertex;
if(spot_enabled)
{
vec3 aux;
aux = vec3(gl_LightSource[1].position-ecPos);
lightDir = normalize(aux);
distLightVertex = length(aux);
distCamVertex = length(ecPos);
}
I would like to knwo two things :
1. How to tell to OSG to generate more vertices ??
2. All samples I had seen use gl_normal to compute the spot influence, should
that we solve my problem ?
Cheers, Adrien
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32699#32699
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org