I’ve managed to edit a GLSL shader so that it can use a displacement map to displace along the normal rather than in the y direction like my other one but now have run into a slight difficulty. The shader displaces the geometry properly but the normals do not seem to be updated. I just realized the other shader I was working on probably has the same problem. I would like to figure this out on my own but it is taking time to learn GLSL. My shader is below if someone has the time to take a look.

cheers
Keith
displacement.toe (7.78 KB)

Recalculating normals is very difficult. If you are just displacing a plane, then sample the pixels that the neighboring vertices will be using so you know their height and you can figure out the slope of the current vertex should be. If your surface is more complex then you may want to look around online for some solutions, but there is no ‘solution’ to this problem in general. Some cases may have solutions, some won’t. Some solutions be require some pretty complex math.

Thanks I did some looking around online and found that I’m not the first person to ask this question and doesn’t really seem to be solved except for a plane. I did think of one possible way to get around it though.

Would it be possible to export the displaced geometry to fbx or obj and then import it into Maya. The normals could then be calculated in Maya by the cpu. After that import the normal data into Touch and then use the vertex shader to interpolate the normal values between the displaced/non-displaced normal values relating to the displacement multiplier. I just realized the same effect could also be achieved with the blend SOP.

This still wouldn’t work though if the displacement map itself was changing.

I some point in the future I would like to animate characters in realtime. Will I still have the same problem with deformers?

thanks
keith

Rotations for joints work fine, the normals will get rotated also. Uniform scales and translations work fine too. If you do a bone movement that pushes out a piece of the geometry like a displacement though, you’ll have the same surface slope issue as above.