Eye Shader parallax refraction help

Started by
1 comment, last by fire67 7 years, 6 months ago

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:

xzIuKA3.png

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:

2015-07-12_11-43-59.png

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:

NeoDniN.png

Does anyone have an idea how this is supposed to work ?

Advertisement

Any news about this ?

I've added the refraction vector calculations which gives interesting results.


float cosine = dot(viewDir, worldNormal);
float sine = sqrt(1 - cosine * cosine);

float sine2 = (_IOR * sine);
float cosine2 = sqrt(1 - sine2 * sine2);

float3 x = -worldNormal;
float3 y = normalize(cross(cross(viewDir, worldNormal), worldNormal));
float3 refractedW = x * cosine2 + y * sine2;

But I am having some issues when looking at grazing angles and I don't know how to get rid of this issue. Here is an image representing the issue when having a high parallax scale.

y1sCY.jpg

Is there any way to get rid of that ?

Thanks a lot !

This topic is closed to new replies.

Advertisement