Sign in to follow this  
BaSSraf

Per pixel lighting using only 1 constant normal (for quads)

Recommended Posts

BaSSraf    109
Hey guys, Looking into simple per pixel lighting, just to get rid of vertex lighting on large surfaces (quads in my case) I wondered, do I need a normal map? It seems to me, when you create a normal map for a flat surface all normals will be the same anyway, so why cant I have 1 constant normal (say {0,0,-1}) ? All I want is to have point and spotlights working on a per pixel basis and I only need them on quads.. Am I overlooking something ? Thanks :)

Share this post


Link to post
Share on other sites
Scoob Droolins    258
You dont need a normal map. But using a "constant" normal of (0, 0, -1) wont work for just any tri - it must be properly oriented with respect to the triangle. You would have to tranform it and pack it into constant registers for each triangle - not a good way to go.

Just pass vertex normals to the pixel shader, and do your N.L there. If you have the space in your pixel shader, you should renormalize the normal to keep spec highlights hot.

You can use a constant tangent-space normal map (all purple), but you'll have to do your light math in tangent space, which puts a little more heat on the vertex shader, and at that point, you're doing normal mapping.

Share this post


Link to post
Share on other sites
BaSSraf    109
Ok, let me see if I get this :)

I can use the re-normalized interpolated normals from the vertexshader (so no normal map) and simply do all lighting (spots, point etc) in the pixelshader instead of the vertex shader (as I am doing now) ?

To avoid losing an arm and a leg performance wise, are there any other values I can use "pre-calculated" from the vertexshader (and passed interpolated to the ps) ?

Thanks Scoob !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this