terrain normals

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

terrain normals

Post by Seven »

How would I access the normals of the terrain node vertexes inside a shader?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: terrain normals

Post by CuteAlien »

TerrainSceneNode seems to always use the IdentityMatrix. Not quite sure how that works (sorry, I still haven't worked myself with it). Maybe it re-calculates the terrain when the node is moved and mesh has absolute coordinates. Or the node can't be moved? I guess it's because the mesh has to change based on camera.

In that case I guess the normal passed to the vertex-shader should already be the correct normal without any need for further transformation. All you probably need to do is pass it on to the pixel-shader and normalize it in there once more.
No guarantees... I didn't try myself.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply