diff --git a/src/globe/navara/movers/modelMover.js b/src/globe/navara/movers/modelMover.js index b9e3b26fa..4f029b424 100644 --- a/src/globe/navara/movers/modelMover.js +++ b/src/globe/navara/movers/modelMover.js @@ -47,7 +47,8 @@ const scratchTranslation = new Vector3(); const scratchScale = new Vector3(); /** - * Mixes the instance colour into the material's colour by uGevBlend (the + * Mixes the instance colour, decoded from sRGB (as Cesium takes colours; + * the material works in linear), into the material's colour by uGevBlend (the * set's colorBlend, as Cesium's colorBlendAmount); the instance alpha is the * model's opacity (Cesium: a model colour's alpha makes it translucent; the * aircraft fade with distance through it), not a blend weight. @@ -75,7 +76,7 @@ function blendInstanceColor(material, uniforms) { ) .replace( '#include ', - '#include \ndiffuseColor.rgb = mix(diffuseColor.rgb, vGevColor.rgb, uGevBlend);\ndiffuseColor.a *= vGevColor.a;', + '#include \ndiffuseColor.rgb = mix(diffuseColor.rgb, sRGBTransferEOTF(vGevColor).rgb, uGevBlend);\ndiffuseColor.a *= vGevColor.a;', ); }; material.customProgramCacheKey = () => 'gev-mover-model-blend'; diff --git a/src/globe/navara/movers/modelMover.test.mjs b/src/globe/navara/movers/modelMover.test.mjs index 28c2c9562..f3aefbc45 100644 --- a/src/globe/navara/movers/modelMover.test.mjs +++ b/src/globe/navara/movers/modelMover.test.mjs @@ -88,7 +88,7 @@ test('a far model keeps its minimum pixel size', async () => { ); }); -test("the instance colour tints by the set's blend amount; its alpha is opacity, as Cesium's model colour", async () => { +test("the instance colour (sRGB, decoded) tints by the set's blend amount; its alpha is opacity, as Cesium's model colour", async () => { const store = createMoverStore(options); const mover = createModelMover(options, store, { load: async () => fakeGltf(), @@ -110,7 +110,7 @@ test("the instance colour tints by the set's blend amount; its alpha is opacity, mesh.material.onBeforeCompile(shader); assert.match( shader.fragmentShader, - /diffuseColor\.rgb = mix\(diffuseColor\.rgb, vGevColor\.rgb, uGevBlend\);\s*diffuseColor\.a \*= vGevColor\.a;/, + /diffuseColor\.rgb = mix\(diffuseColor\.rgb, sRGBTransferEOTF\(vGevColor\)\.rgb, uGevBlend\);\s*diffuseColor\.a \*= vGevColor\.a;/, ); // Ambient light on the tinted surface (Cesium's image-based lighting). assert.match(