PickleWorld
05-18-2006, 01:59 PM
So implementing displacement mapping via a vertex program is quite straight forward but lighting it is proving to be tricky.
Assuming one has a working vertex shader for displacing a surface... anyone have a good plan on how to light it?
Specifically my normal is now wrong and I don't have any way to fix it from within the vertex/fragment shader (as I only have 1/3 of the vertices that make up the triangle).
Static lighting is not an option.. I need correct normals (or at least fairly close) normals for the rest of my fragment program.
Bump mapping methods (ie perturbing the normal based on the rate of change in the displacement map) seem to work well as long as the displacement is small and gradual. However once you move the surface a significant amount (especially if you do it sharply.. like a faceted surface) then the bump mapping techniques seem to perform poorly.
I guess what I am really looking for is a hack to be able to calculate a new surface normal inside one of my shaders. Anyone read anything interesting on this?
Assuming one has a working vertex shader for displacing a surface... anyone have a good plan on how to light it?
Specifically my normal is now wrong and I don't have any way to fix it from within the vertex/fragment shader (as I only have 1/3 of the vertices that make up the triangle).
Static lighting is not an option.. I need correct normals (or at least fairly close) normals for the rest of my fragment program.
Bump mapping methods (ie perturbing the normal based on the rate of change in the displacement map) seem to work well as long as the displacement is small and gradual. However once you move the surface a significant amount (especially if you do it sharply.. like a faceted surface) then the bump mapping techniques seem to perform poorly.
I guess what I am really looking for is a hack to be able to calculate a new surface normal inside one of my shaders. Anyone read anything interesting on this?