Hey Guys,
I'm trying to implement the parallax mapping for an eye shader based on the code that can be found in Jimenez presentation: http://www.iryoku.com/downloads/Next-Generation-Character-Rendering-v6.pptx (on slide 232) but can't quite seem to understand how it works exactly.
If you don't have it already or don't want to download that presentation here's a screen of the slide I'm talking about:
There are many variables that are given no description to what they are or in what range so that adds to the confusion.
I'm currently trying to do the parallax mapping first (on the left of the slide) before doing the physically correct refraction.
This is my code in the VS (I guess this should be done in the VertexShader?):
#ifdef IsEyeShading
// Calculate distance from iris to the cornea
const float eyeIrisDepth = 0.001f;
const float parallaxScale = 0.001f;
float3 V = camera_Position - output.PosWS;
float height = max(-input.PositionOS.z - eyeIrisDepth, 0.0f);
float2 viewL = mul(V, (float3x2)mat4x4_InverseWorld);
float2 offset = height * viewL;
offset.y = -offset.y;
output.TexCoord -= parallaxScale * offset;
#endif
Which should be pretty much what you can see in the slide. I'm guessing that "ViewW" in his slide is the view vector towards the camera (?). And eyeIrisDepth and parallaxScale are user defined variables to control the effect.
As far as I understand the eye mesh is split into two parts which are sclera and cornea as you can see here:
so that in the shader you calculate the "depth" and shift it depending on direction to the camera and distance (height).
However this just gets me the following result:
Does anyone have an idea how this is supposed to work ?