PDA

View Full Version : Two-sided lighting of GL_POINTS



AxonP
12-31-2010, 04:50 AM
I have a bunch of points which I display as GL_POINTS. Each one has a normal
vector, and if the normal points towards the camera, then it gets nicely lit,
but if it points away, then we see the "back" of the point, which isn't lit.

Is there some way of getting two-sided lighting of GL_POINTS like we can with
polygons?

mobeen
12-31-2010, 05:01 AM
Could u please elaborate a bit more? like are u using fixed func. pipeline (FFP) or are u doing it on your own in a shader?

AxonP
12-31-2010, 05:08 AM
Hi mobeen, I've considered having only diffuse lighting with pairs of opposing
lights, but I really want specular lighting. I think I might be able to do it
with a spherical texture map, or I could write a shader. I'm just wondering if
I've missed something simple before I set off down one of these paths.

mobeen
12-31-2010, 06:35 AM
Hi mobeen, I've considered having only diffuse lighting with pairs of opposing
lights, but I really want specular lighting. I think I might be able to do it
with a spherical texture map, or I could write a shader. I'm just wondering if
I've missed something simple before I set off down one of these paths.

Yeah i think u should go ahead with a custom shader it gives u full control. Two sided lighting should be quite easy since for basic diffuse model we do something like this


float NdotL = max(dot(N,L),0);

For two sided lighting you could do this


float NdotL = abs(dot(N,L));

You should start with diffuse lighting and make sure it works before u move on to specular lighting.

I dont think the FFP has anything like two sided lighting for GL_POINTS but this is based on my meager knowledge.

Hope this helps,
Mobeen

V-man
12-31-2010, 02:17 PM
Or you could render triangles and turn on point mode rendering : glPolygonMode(GL_POINT).

If you are comfortable with shaders, sure, go for it. FFP is old news.

AxonP
01-04-2011, 04:11 AM
Thanks for the replies, I wrote a shader.