From e21683640daa2c5b42f98f12b2cfc5098b173696 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sat, 8 Nov 2025 17:17:20 +0100 Subject: [PATCH] [orx-dnk3] Work-around problems with GLES back-end --- orx-jvm/orx-dnk3/src/main/kotlin/Facet.kt | 2 +- orx-jvm/orx-dnk3/src/main/kotlin/PBRMaterial.kt | 2 +- orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt | 6 +++++- orx-jvm/orx-dnk3/src/main/kotlin/SceneRenderer.kt | 2 -- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/Facet.kt b/orx-jvm/orx-dnk3/src/main/kotlin/Facet.kt index 533471b9..0cc99a62 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/Facet.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/Facet.kt @@ -109,7 +109,7 @@ class ViewDepthFacet : ColorBufferFacetCombiner(setOf(FacetType.VIEW_POSITION), override fun generateShader(): String = "o_$targetOutput.r = v_viewPosition.z;" } class ClipDepthFacet : ColorBufferFacetCombiner(setOf(FacetType.CLIP_POSITION), "clipDepth", ColorFormat.R, ColorType.FLOAT32) { - override fun generateShader(): String = "o_$targetOutput.r = gl_FragCoord.z;" + override fun generateShader(): String = "o_$targetOutput = gl_FragCoord.z;" } diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/PBRMaterial.kt b/orx-jvm/orx-dnk3/src/main/kotlin/PBRMaterial.kt index c038e3ac..6e8a7e50 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/PBRMaterial.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/PBRMaterial.kt @@ -644,7 +644,7 @@ class PBRMaterial : Material { light.projection(it) * look) if (light.shadows is Shadows.DepthMappedShadows) { - shadeStyle.parameter("lightShadowMap$index", it.depthBuffer ?: TODO()) + shadeStyle.parameter("lightShadowMap$index", it.depthBuffer?:error("no depth buffer for $it")) } if (light.shadows is Shadows.ColorMappedShadows) { diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt b/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt index ec8a218f..8b324c40 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/RenderPass.kt @@ -20,7 +20,7 @@ val IrradianceProbePass = RenderPass(listOf(DiffuseIrradianceFacet())) val DefaultOpaquePass = RenderPass(listOf(LDRColorFacet()), renderOpaque = true, renderTransparent = false) val DefaultTransparentPass = RenderPass(listOf(LDRColorFacet()), renderOpaque = false, renderTransparent = true, depthWrite = false) -val LightPass = RenderPass(emptyList()) +val LightPass = RenderPass(listOf(ClipDepthFacet())) val VSMLightPass = RenderPass(listOf(MomentsFacet())) fun RenderPass.createPassTarget(width: Int, height: Int, depthFormat: DepthFormat = DepthFormat.DEPTH24, multisample: BufferMultisample = this.multisample): RenderTarget { @@ -31,6 +31,10 @@ fun RenderPass.createPassTarget(width: Int, height: Int, depthFormat: DepthForma colorBuffer(combiner.targetOutput, combiner.format, combiner.type) } } + // Temporary fix for GLES back-end + if (combiners.isEmpty()) { + colorBuffer() + } depthBuffer(depthFormat) } } diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/SceneRenderer.kt b/orx-jvm/orx-dnk3/src/main/kotlin/SceneRenderer.kt index c7082069..e62672c5 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/SceneRenderer.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/SceneRenderer.kt @@ -86,8 +86,6 @@ class SceneRenderer { val mapSize = (shadowLight.shadows as Shadows.MappedShadows).mapSize pass.createPassTarget(mapSize, mapSize, DepthFormat.DEPTH_STENCIL) } - target.clearDepth(depth = 1.0) - val look = shadowLight.view(it.node) val materialContext = MaterialContext(pass, context.lights, context.fogs, shadowLightTargets, emptyMap(), 0) drawer.isolatedWithTarget(target) {