edvakf/MMD.js — Issue #2: Self shadow on Defoko's face is wrong
Author: edvakf
Created: 2011-10-29 17:35:37+00:00
State: open

http://f.hatena.ne.jp/edvakf/20111030023201

This is because Defoko's textures are made such that the middle is darker than the bottom. Not sure why this doesn't break in MMD, but below is a hacky fix.

```diff
diff --git a/src/MMD.FragmentShaderSource.coffee b/src/MMD.FragmentShaderSource.coffee
index 3706eb5..35d53eb 100644
--- a/src/MMD.FragmentShaderSource.coffee
+++ b/src/MMD.FragmentShaderSource.coffee
@@ -115,7 +115,7 @@ MMD.FragmentShaderSource = '''
vec4 rgbaDepth = texture2D(uShadowMap, lightCoord.xy);
float depth = unpack_depth(rgbaDepth);
if (depth < lightCoord.z - 0.01) {
- toonCoord = vec2(0.0, 1.0);
+ toonCoord = vec2(0.0, 0.55);
}
}
```