Просмотр исходного кода

Apply fog before color space

This makes behavior more consistent between rendering to an SRGB texture and rendering to the WebGL default framebuffer. Encoding the color values should always happen after fog has been applied.
Olli Etuaho 2 лет назад
Родитель
Сommit
f82fedcac3

+ 1 - 1
examples/jsm/effects/OutlineEffect.js

@@ -165,8 +165,8 @@ class OutlineEffect {
 			'	gl_FragColor = vec4( outlineColor, outlineAlpha );',
 
 			'	#include <tonemapping_fragment>',
-			'	#include <colorspace_fragment>',
 			'	#include <fog_fragment>',
+			'	#include <colorspace_fragment>',
 			'	#include <premultiplied_alpha_fragment>',
 
 			'}'

+ 1 - 1
examples/jsm/lines/LineMaterial.js

@@ -426,8 +426,8 @@ ShaderLib[ 'line' ] = {
 			gl_FragColor = vec4( diffuseColor.rgb, alpha );
 
 			#include <tonemapping_fragment>
-			#include <colorspace_fragment>
 			#include <fog_fragment>
+			#include <colorspace_fragment>
 			#include <premultiplied_alpha_fragment>
 
 		}

+ 1 - 1
examples/jsm/loaders/LDrawLoader.js

@@ -133,8 +133,8 @@ class LDrawConditionalLineMaterial extends ShaderMaterial {
 				outgoingLight = diffuseColor.rgb; // simple shader
 				gl_FragColor = vec4( outgoingLight, diffuseColor.a );
 				#include <tonemapping_fragment>
-				#include <colorspace_fragment>
 				#include <fog_fragment>
+				#include <colorspace_fragment>
 				#include <premultiplied_alpha_fragment>
 			}
 			`,

+ 1 - 1
examples/jsm/materials/MeshGouraudMaterial.js

@@ -294,8 +294,8 @@ const GouraudShader = {
 
 			#include <opaque_fragment>
 			#include <tonemapping_fragment>
-			#include <colorspace_fragment>
 			#include <fog_fragment>
+			#include <colorspace_fragment>
 			#include <premultiplied_alpha_fragment>
 			#include <dithering_fragment>
 

+ 1 - 1
examples/jsm/objects/Water.js

@@ -181,8 +181,8 @@ class Water extends Mesh {
 					gl_FragColor = vec4( outgoingLight, alpha );
 
 					#include <tonemapping_fragment>
+					#include <fog_fragment>
 					#include <colorspace_fragment>
-					#include <fog_fragment>	
 				}`
 
 		};

+ 1 - 1
examples/jsm/objects/Water2.js

@@ -348,8 +348,8 @@ Water.WaterShader = {
 			gl_FragColor = vec4( color, 1.0 ) * mix( refractColor, reflectColor, reflectance );
 
 			#include <tonemapping_fragment>
-			#include <colorspace_fragment>
 			#include <fog_fragment>
+			#include <colorspace_fragment>
 
 		}`
 

+ 1 - 1
src/renderers/shaders/ShaderLib/linedashed.glsl.js

@@ -67,8 +67,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 
 }

+ 1 - 1
src/renderers/shaders/ShaderLib/meshbasic.glsl.js

@@ -105,8 +105,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 	#include <dithering_fragment>
 

+ 1 - 1
src/renderers/shaders/ShaderLib/meshlambert.glsl.js

@@ -113,8 +113,8 @@ void main() {
 	#include <envmap_fragment>
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 	#include <dithering_fragment>
 

+ 1 - 1
src/renderers/shaders/ShaderLib/meshmatcap.glsl.js

@@ -100,8 +100,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 	#include <dithering_fragment>
 

+ 1 - 1
src/renderers/shaders/ShaderLib/meshphong.glsl.js

@@ -115,8 +115,8 @@ void main() {
 	#include <envmap_fragment>
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 	#include <dithering_fragment>
 

+ 1 - 1
src/renderers/shaders/ShaderLib/meshphysical.glsl.js

@@ -213,8 +213,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 	#include <dithering_fragment>
 

+ 1 - 1
src/renderers/shaders/ShaderLib/meshtoon.glsl.js

@@ -107,8 +107,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 	#include <dithering_fragment>
 

+ 1 - 1
src/renderers/shaders/ShaderLib/points.glsl.js

@@ -78,8 +78,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 	#include <premultiplied_alpha_fragment>
 
 }

+ 1 - 1
src/renderers/shaders/ShaderLib/shadow.glsl.js

@@ -47,8 +47,8 @@ void main() {
 	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
 
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 
 }
 `;

+ 1 - 1
src/renderers/shaders/ShaderLib/sprite.glsl.js

@@ -74,8 +74,8 @@ void main() {
 
 	#include <opaque_fragment>
 	#include <tonemapping_fragment>
-	#include <colorspace_fragment>
 	#include <fog_fragment>
+	#include <colorspace_fragment>
 
 }
 `;

+ 2 - 3
src/renderers/webgl/WebGLMaterials.js

@@ -1,5 +1,4 @@
-import { BackSide } from '../../constants.js';
-import { getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
+import { BackSide, LinearSRGBColorSpace } from '../../constants.js';
 
 function WebGLMaterials( renderer, properties ) {
 
@@ -17,7 +16,7 @@ function WebGLMaterials( renderer, properties ) {
 
 	function refreshFogUniforms( uniforms, fog ) {
 
-		fog.color.getRGB( uniforms.fogColor.value, getUnlitUniformColorSpace( renderer ) );
+		fog.color.getRGB( uniforms.fogColor.value, LinearSRGBColorSpace );
 
 		if ( fog.isFog ) {