Jump to content
  • Advertisement
Sign in to follow this  
Viper173

Normal maps

This topic is 5475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

yuuhuuu! I finally have a working pixel shader.... now I wanna do normal mapping and i already created my maps too. But how can I get the global Normal Vector of my pixel when I'm in my pixel shader. the vertex shader doesn't even have them because of vertex normals. In order to lighten my flat surface correctly per pixel I gotta have this vector right? (binding a cgParameter to the pixel shader and update it every time i draw a new tri is kind of slow...) thanx for your help

Share this post


Link to post
Share on other sites
Advertisement
or is it possible to pass the vertexnormal from the vertex shader and have it in the pixel shader as interpolated vector between all other vertex normals.....?
that would be perfect

Share this post


Link to post
Share on other sites
Per-pixel lighting is most often done in texture/tangent space. Thus, the normal you fetch from the normal map already are in the right space. What you have to do is, transform other involved vectors to texture space; and this is done in the vertex shader.

http://www.terathon.com/code/tangent.html

Quote:
or is it possible to pass the vertexnormal from the vertex shader and have it in the pixel shader as interpolated vector between all other vertex normals.....?

Yes, this is what called varying in GLSL. This is only needed if you are doing phong shading, not when using normal maps.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hello, I`m and artist

This tangent calculation solves the mirrored mesh problems with normal maps?

How it could be solved? I know, that a pixel shader should handle it, but looking at the code in the given link may I assume that the vertex tangent should be recalculated for each mirrored triangles?

As I mentioned above, I`m an artist, with a slight (microscopical) understanding of programming...


Thanks


Szabolcs Matefy

Share this post


Link to post
Share on other sites
Can you explain this mirroring in more detail? The only thing I can see is face/vertex normal vector reversing direction and thus when crossed with tangent it creates incorrectly pointed binormal. To fix this you can store both tangent and binormal calculated from face's three vertices and their texture coords then cross vertex/face normal with tangent and get new binormal and dot that binormal with the stored one and if they point in opposite direction the stored binormal needs to be scaled by -1 to flip it. Is this it or something else's going on?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!