From 0491a71da197e862b849c1c93c4fb59e463118d1 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 20 Nov 2025 12:34:36 +0000 Subject: [PATCH] Improve window drawing --- shader/pull/window.frag | 1 - shader/pull/window.vert | 14 +++++++++----- src/Dodge/Render.hs | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/shader/pull/window.frag b/shader/pull/window.frag index 41a9e5ff7..b112743c2 100644 --- a/shader/pull/window.frag +++ b/shader/pull/window.frag @@ -10,5 +10,4 @@ void main() float cloudz = texture(cloudpos, vScreenPos).z; fColOverCloud = ( cloudz > vPos.z ? vec4(0) : vCol); fColUnderCloud = ( cloudz > vPos.z ? vCol : vec4(0)); - fColUnderCloud = vec4(0); } diff --git a/shader/pull/window.vert b/shader/pull/window.vert index 1ad2a79e0..bfad01a30 100644 --- a/shader/pull/window.vert +++ b/shader/pull/window.vert @@ -5,18 +5,22 @@ layout (std430, binding = 1) readonly buffer Pos { PosCol data[]; }; out vec4 vCol; out vec4 vPos; out vec2 vScreenPos; -//int indices[6] = {0,1,3,0,3,2}; int indices[6] = {0,3,1 ,0,2,3}; // note reversed compared to walls void main() { - vCol = data[gl_VertexID / 6].col; - vec4 pp = data[gl_VertexID / 6].pospos; + vCol = data[gl_VertexID / 12].col; + vec4 pp = data[gl_VertexID / 12].pospos; int j = indices[gl_VertexID % 6]; - //float z = (j > 1.5 ? 5000 : 0); - float z = (j > 1.5 ? 200 : 0); + bool t = gl_VertexID % 12 > 5.5; + float z = (j > 1.5 + ? (t ? 100 : 5000) + : (t ? 0 : 100) + ); + // we draw two quads: one which can be below clouds, + // and one which is always above vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw); vPos = vec4( xy, z, 1); gl_Position = theMat * vPos; diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 840dbac8f..e6e6087f4 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -310,10 +310,11 @@ doDrawing' win pdata u = do glEnable GL_BLEND --glBlendFunc GL_SRC_ALPHA GL_ONE glBindTextureUnit 3 (pdata ^. fboPos . _2 . unTO) + -- with all source alphas 0.25, alpha -> 0.5 glBlendFunc GL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_SRC_ALPHA glUseProgram $ pdata ^. windowPullShader glBindVertexArray $ pdata ^. dummyVAO - glDrawArrays GL_TRIANGLES 0 (fromIntegral nWins * 6) + glDrawArrays GL_TRIANGLES 0 (fromIntegral nWins * 12) glDisable GL_DEPTH_CLAMP glDisable GL_CULL_FACE glInvalidateBufferData (pdata ^. vboShapes . vboName)