diff --git a/shader/ceiling/stencil.vert b/shader/ceiling/stencil.vert index 76812fc0c..a961ff25f 100644 --- a/shader/ceiling/stencil.vert +++ b/shader/ceiling/stencil.vert @@ -12,7 +12,7 @@ void main() { vec4 pp = data[gl_VertexID / 6].pospos; int j = indices[gl_VertexID % 6]; - float z = (j > 1.5 ? 5000 : 100); + float z = (j / 2 > 0.5 ? 5000 : 100); vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw); gl_Position = theMat * vec4(xy,z,1); } diff --git a/shader/lighting/wallShadow.vert b/shader/lighting/wallShadow.vert index ffb827dbb..bf06eade0 100644 --- a/shader/lighting/wallShadow.vert +++ b/shader/lighting/wallShadow.vert @@ -1,6 +1,39 @@ #version 450 core -layout (location = 0) in vec4 poss; -void main() -{ - gl_Position = poss; +//layout (location = 0) in vec4 poss; +//void main() +//{ +// gl_Position = poss; +//} +struct PosTex { vec4 pospos; vec4 texang; }; +layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; +layout (std430, binding = 2) readonly buffer Pos { PosTex data[]; }; +layout(location=0) uniform vec3 lightPos; +layout(location=1) uniform float rad; +int indices[18] = + {5,1,7 // 6----7 + ,7,1,3 // /| /| + ,7,3,6 // 2-+--3 | + ,6,3,2 // | 4 | 5 + ,6,2,4 // 0 1 + ,4,2,0 + }; +vec2 shift(vec2 p) { + return vec2(lightPos.xy + (rad * normalize(p - lightPos.xy))); +} +float detV(vec2 p, vec2 q) { + return p.x*q.y - p.y*q.x; +} +float isLHS(vec2 p, vec2 q) { + return sign(-detV(p,q)); +} +void main() { + vec4 pp = data[gl_VertexID / 18].pospos; + int j = indices[gl_VertexID % 18]; + vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw); + float z = ((j / 2) % 2 > 0.5 ? 100 : -500); + vec2 xyo = ( j > 3.5 ? shift(xy) : xy); + vec4 p = theMat * vec4(xyo,z,1); + gl_Position = (isLHS(pp.xy-lightPos.xy,pp.zw-lightPos.xy) < 0 + ? p + : vec4(1,1,1,0)); } diff --git a/src/Framebuffer/Update.hs b/src/Framebuffer/Update.hs index 311e265b1..776fd5157 100644 --- a/src/Framebuffer/Update.hs +++ b/src/Framebuffer/Update.hs @@ -27,8 +27,10 @@ sizeFBOs cfig rdata = GL_NEAREST GL_NEAREST GL_RGBA8 - GL_RGBA16F -- i am not sure if this should not be GL_RGBA32F - GL_RGBA16F + GL_RGBA16F -- could possibly recover using depth in a clever way + -- but probably not, because the projection matrix is + -- not always on-center + GL_RGBA16F -- make this smaller? ) rdata [fboBase, fboCloud] diff --git a/src/Preload/Render.hs b/src/Preload/Render.hs index b4bbb5531..b02cd71d5 100644 --- a/src/Preload/Render.hs +++ b/src/Preload/Render.hs @@ -83,7 +83,8 @@ preloadRender = do wallshader <- makeShaderUsingVBO "wall/basic" [vert, geom, frag] (toFloatVAs [4, 4]) pmPoints wallvbo putStrLn "Setup lighting shaders" lightingWallShadShad <- - makeShaderUsingVBO "lighting/wallShadow" [vert, geom] (toFloatVAs [4]) pmPoints wallvbo + --makeShaderUsingVBO "lighting/wallShadow" [vert, geom] (toFloatVAs [4]) pmPoints wallvbo + makeShaderUsingVAO "lighting/wallShadow" [vert] pmTriangles (VAO dummyvao) lightingCapShad <- makeShaderUsingVAO "lighting/cap" [vert, geom] pmTriangles shPosVAO lightingLineShadowShad <- diff --git a/src/Render.hs b/src/Render.hs index fb7f16a26..7c40e5bb8 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -173,11 +173,12 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li glUseProgram (_shaderUINT lwallShad) glUniform3f 0 x y z glUniform1f 1 rad - glBindVertexArray $ lwallShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO lwallShad) + --glBindVertexArray $ lwallShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO lwallShad) + glBindVertexArray $ pdata ^. dummyVAO . vaoName -- Just (_vao $ _shadVAO lwallShad) glDrawArrays (_unPrimitiveMode $ _shaderPrimitive lwallShad) 0 - nWalls + (nWalls * 18) case shadrendertype of GeoObjShads -> do --draw silhouette shadows