There’s a bug in Steep Parallax Mapping of the Lighting shader. At low angles, the mapping looks deformed (see video).
http://www.youtube.com/watch?v=gFaNNZAIxKI
The problem is, that steepParallaxOffset() needs vViewDir unnormalized. After applying the patch below, it looks like this:
http://www.youtube.com/watch?v=_13cQcVwlbE
I found this bug while trying to implement "Dynamic Parallax Occlusion Mapping with Approximate Soft Shadows". It's not yet done, but here's a first preview:
http://www.youtube.com/watch?v=y-I3LtwUhxI
Btw, is there an easy way to get the compiled assembler output of a jme shader (without adjusting the shader to RenderMonkey or the like)?
Warning: The backslash before "No newline at end of file" has been swallowed by WordPress. Press "quote" to see it. No idea if these lines are needed anyway.
[patch]
Index: Lighting.vert
--- Lighting.vert Base (BASE)
+++ Lighting.vert Locally Modified (Based On LOCAL)
@@ -158,7 +158,7 @@
mat3 tbnMat = mat3(wvTangent, wvBinormal * -inTangent.w,wvNormal);
//vPosition = wvPosition * tbnMat;
- vViewDir = viewDir * tbnMat;
No newline at end of file
+ vViewDir = -wvPosition * tbnMat;
No newline at end of file
lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir);
vLightDir.xyz = (vLightDir.xyz * tbnMat).xyz;
#elif !defined(VERTEX_LIGHTING)
[/patch]
[patch]
Index: Lighting.frag
--- Lighting.frag Base (BASE)
+++ Lighting.frag Locally Modified (Based On LOCAL)
@@ -249,8 +249,9 @@
#else
vec4 lightDir = vLightDir;
lightDir.xyz = normalize(lightDir.xyz);
+ vec3 viewDir = normalize(vViewDir);
- vec2 light = computeLighting(normal, vViewDir.xyz, lightDir.xyz) * spotFallOff;
+ vec2 light = computeLighting(normal, viewDir, lightDir.xyz) * spotFallOff;
#ifdef COLORRAMP
diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb;
specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb;
[/patch]