瀏覽代碼

Fix unpack bug

WestLangley 7 年之前
父節點
當前提交
efa028e2fe
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      examples/js/shaders/SAOShader.js
  2. 1 1
      src/renderers/shaders/ShaderChunk/packing.glsl

+ 1 - 1
examples/js/shaders/SAOShader.js

@@ -102,7 +102,7 @@ THREE.SAOShader = {
 
 		"vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {",
 		"	#if NORMAL_TEXTURE == 1",
-		"	return -unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );",
+		"	return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );",
 		"	#else",
 		"	return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );",
 		"	#endif",

+ 1 - 1
src/renderers/shaders/ShaderChunk/packing.glsl

@@ -3,7 +3,7 @@ vec3 packNormalToRGB( const in vec3 normal ) {
 }
 
 vec3 unpackRGBToNormal( const in vec3 rgb ) {
-	return 1.0 - 2.0 * rgb.xyz;
+	return 2.0 * rgb.xyz - 1.0;
 }
 
 const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)