Simplify reflection enabled condition and handle null render target

This commit is contained in:
2026-04-07 08:31:54 +02:00
parent 691b0ca645
commit ebafda0833
2 changed files with 11 additions and 6 deletions

View File

@@ -657,7 +657,7 @@ export class RuntimeHost {
contactPatches,
reflection: {
texture: null,
enabled: faceId === "posY" && this.getWaterReflectionMode() !== "none"
enabled: faceId === "posY"
}
});
@@ -833,7 +833,6 @@ export class RuntimeHost {
for (const binding of this.runtimeWaterContactUniforms) {
if (
reflectionMode === "none" ||
binding.reflectionRenderTarget === null ||
binding.reflectionTextureUniform === null ||
binding.reflectionMatrixUniform === null ||
binding.reflectionEnabledUniform === null
@@ -844,6 +843,10 @@ export class RuntimeHost {
continue;
}
if (binding.reflectionRenderTarget === null) {
binding.reflectionRenderTarget = this.createWaterReflectionRenderTarget();
}
const canRenderReflection = updatePlanarReflectionCamera(
binding.brush,
this.camera,
@@ -851,7 +854,7 @@ export class RuntimeHost {
binding.reflectionMatrixUniform.value
);
if (!canRenderReflection) {
if (!canRenderReflection || binding.reflectionRenderTarget === null) {
binding.reflectionEnabledUniform.value = 0;
continue;
}