Browse Source

Match previous behaviour in non-color-managed state

Olli Etuaho 1 year ago
parent
commit
c43358030f
1 changed files with 22 additions and 2 deletions
  1. 22 2
      src/renderers/webgl/WebGLMaterials.js

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

@@ -1,4 +1,5 @@
-import { BackSide, LinearSRGBColorSpace } from '../../constants.js';
+import { BackSide, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
+import { ColorManagement } from '../../math/ColorManagement.js';
 
 function WebGLMaterials( renderer, properties ) {
 
@@ -16,7 +17,26 @@ function WebGLMaterials( renderer, properties ) {
 
 	function refreshFogUniforms( uniforms, fog ) {
 
-		fog.color.getRGB( uniforms.fogColor.value, LinearSRGBColorSpace );
+		if ( ColorManagement.enabled ) {
+
+			fog.color.getRGB( uniforms.fogColor.value, LinearSRGBColorSpace );
+
+		} else {
+
+			if ( getUnlitUniformColorSpace( renderer ) === SRGBColorSpace ) {
+
+				// We do this to match previous behaviour, though it's a bit unintuitive to apply color management operations in case color management is disabled.
+
+				_color.copySRGBToLinear( fog.color );
+				_color.getRGB( uniforms.fogColor.value );
+
+			} else {
+
+				fog.color.getRGB( uniforms.fogColor.value );
+
+			}
+
+		}
 
 		if ( fog.isFog ) {