|
@@ -91,13 +91,18 @@ THREE.ShaderChunk = {
|
|
|
|
|
|
" vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );",
|
|
|
|
|
|
+ // http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations
|
|
|
+ // "Transforming Normal Vectors with the Inverse Transformation"
|
|
|
+
|
|
|
+ " vec3 worldNormal = normalize( vec3( vec4( normal, 0.0 ) * viewMatrix ) );",
|
|
|
+
|
|
|
" if ( useRefract ) {",
|
|
|
|
|
|
- " reflectVec = refract( cameraToVertex, normal, refractionRatio );",
|
|
|
+ " reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );",
|
|
|
|
|
|
" } else { ",
|
|
|
|
|
|
- " reflectVec = reflect( cameraToVertex, normal );",
|
|
|
+ " reflectVec = reflect( cameraToVertex, worldNormal );",
|
|
|
|
|
|
" }",
|
|
|
|