Explorar o código

ToneMapShader: Use linearToRelativeLuminance()

Mugen87 %!s(int64=8) %!d(string=hai) anos
pai
achega
b549ba7ae1
Modificáronse 1 ficheiros con 6 adicións e 6 borrados
  1. 6 6
      examples/js/shaders/ToneMapShader.js

+ 6 - 6
examples/js/shaders/ToneMapShader.js

@@ -31,6 +31,8 @@ THREE.ToneMapShader = {
 
 	fragmentShader: [
 
+		"#include <common>",
+
 		"uniform sampler2D tDiffuse;",
 
 		"varying vec2 vUv;",
@@ -43,19 +45,17 @@ THREE.ToneMapShader = {
 		"#else",
 			"uniform float averageLuminance;",
 		"#endif",
-		
-		"const vec3 LUM_CONVERT = vec3(0.299, 0.587, 0.114);",
 
 		"vec3 ToneMap( vec3 vColor ) {",
 			"#ifdef ADAPTED_LUMINANCE",
-				// Get the calculated average luminance 
+				// Get the calculated average luminance
 				"float fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;",
 			"#else",
 				"float fLumAvg = averageLuminance;",
 			"#endif",
-			
+
 			// Calculate the luminance of the current pixel
-			"float fLumPixel = dot(vColor, LUM_CONVERT);",
+			"float fLumPixel = linearToRelativeLuminance( vColor );",
 
 			// Apply the modified operator (Eq. 4)
 			"float fLumScaled = (fLumPixel * middleGrey) / max( minLuminance, fLumAvg );",
@@ -67,7 +67,7 @@ THREE.ToneMapShader = {
 		"void main() {",
 
 			"vec4 texel = texture2D( tDiffuse, vUv );",
-			
+
 			"gl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );",
 
 		"}"