Browse Source

MeshNormalNodeMaterial: Convert packed normal to working color space (#30590)

* Convert packed normal to working color space

* Convert packed normal to working color space

* Clean up

* Update screenshots
WestLangley 10 months ago
parent
commit
e0005b7434

BIN
examples/screenshots/misc_raycaster_helper.jpg


BIN
examples/screenshots/webgpu_compute_geometry.jpg


BIN
examples/screenshots/webgpu_water.jpg


+ 5 - 1
src/materials/nodes/MeshNormalNodeMaterial.js

@@ -3,7 +3,9 @@ import { diffuseColor } from '../../nodes/core/PropertyNode.js';
 import { directionToColor } from '../../nodes/utils/Packing.js';
 import { materialOpacity } from '../../nodes/accessors/MaterialNode.js';
 import { transformedNormalView } from '../../nodes/accessors/Normal.js';
+import { colorSpaceToWorking } from '../../nodes/display/ColorSpaceNode.js';
 import { float, vec4 } from '../../nodes/tsl/TSLBase.js';
+import { SRGBColorSpace } from '../../constants.js';
 
 import { MeshNormalMaterial } from '../MeshNormalMaterial.js';
 
@@ -54,7 +56,9 @@ class MeshNormalNodeMaterial extends NodeMaterial {
 
 		const opacityNode = this.opacityNode ? float( this.opacityNode ) : materialOpacity;
 
-		diffuseColor.assign( vec4( directionToColor( transformedNormalView ), opacityNode ) );
+		// By convention, a normal packed to RGB is in sRGB color space. Convert it to working color space.
+
+		diffuseColor.assign( colorSpaceToWorking( vec4( directionToColor( transformedNormalView ), opacityNode ), SRGBColorSpace ) );
 
 	}
 

粤ICP备19079148号