Refactor uniform creation in water material shaders and tests

This commit is contained in:
2026-04-07 07:50:20 +02:00
parent 372a5551aa
commit 691b0ca645
3 changed files with 41 additions and 36 deletions

View File

@@ -933,24 +933,22 @@ export function createWaterMaterial(options) {
}
`;
const uniforms = UniformsUtils.merge([
UniformsLib.fog,
{
time: animationUniform,
waterColor: { value: [cr, cg, cb] },
surfaceOpacity: { value: clampedOpacity },
waveStrength: { value: waveStrength },
isTopFace: { value: topFaceFlag },
surfaceDisplacementEnabled: surfaceDisplacementEnabledUniform,
halfSize: { value: halfSize },
contactPatches: contactPatchesUniform,
contactPatchAxes: contactPatchAxesUniform,
contactPatchShapes: contactPatchShapesUniform,
reflectionTexture: reflectionTextureUniform,
reflectionMatrix: reflectionMatrixUniform,
reflectionEnabled: reflectionEnabledUniform
}
]);
const uniforms = UniformsUtils.clone(UniformsLib.fog);
Object.assign(uniforms, {
time: animationUniform,
waterColor: { value: [cr, cg, cb] },
surfaceOpacity: { value: clampedOpacity },
waveStrength: { value: waveStrength },
isTopFace: { value: topFaceFlag },
surfaceDisplacementEnabled: surfaceDisplacementEnabledUniform,
halfSize: { value: halfSize },
contactPatches: contactPatchesUniform,
contactPatchAxes: contactPatchAxesUniform,
contactPatchShapes: contactPatchShapesUniform,
reflectionTexture: reflectionTextureUniform,
reflectionMatrix: reflectionMatrixUniform,
reflectionEnabled: reflectionEnabledUniform
});
const material = new ShaderMaterial({
vertexShader,

View File

@@ -1188,24 +1188,22 @@ export function createWaterMaterial(options: WaterMaterialOptions): WaterMateria
}
`;
const uniforms = UniformsUtils.merge([
UniformsLib.fog,
{
time: animationUniform,
waterColor: { value: [cr, cg, cb] },
surfaceOpacity: { value: clampedOpacity },
waveStrength: { value: waveStrength },
isTopFace: { value: topFaceFlag },
surfaceDisplacementEnabled: surfaceDisplacementEnabledUniform,
halfSize: { value: halfSize },
contactPatches: contactPatchesUniform,
contactPatchAxes: contactPatchAxesUniform,
contactPatchShapes: contactPatchShapesUniform,
reflectionTexture: reflectionTextureUniform,
reflectionMatrix: reflectionMatrixUniform,
reflectionEnabled: reflectionEnabledUniform
}
]);
const uniforms = UniformsUtils.clone(UniformsLib.fog);
Object.assign(uniforms, {
time: animationUniform,
waterColor: { value: [cr, cg, cb] },
surfaceOpacity: { value: clampedOpacity },
waveStrength: { value: waveStrength },
isTopFace: { value: topFaceFlag },
surfaceDisplacementEnabled: surfaceDisplacementEnabledUniform,
halfSize: { value: halfSize },
contactPatches: contactPatchesUniform,
contactPatchAxes: contactPatchAxesUniform,
contactPatchShapes: contactPatchShapesUniform,
reflectionTexture: reflectionTextureUniform,
reflectionMatrix: reflectionMatrixUniform,
reflectionEnabled: reflectionEnabledUniform
});
const material = new ShaderMaterial({
vertexShader,