Use depth fail and front cap for geometry shadows (TODO back cap)

This commit is contained in:
2021-08-30 21:47:01 +01:00
parent f87b53bbf9
commit f797530cbc
3 changed files with 16 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ void main()
vec4 p0 = gl_in[0].gl_Position ;
vec4 p1 = gl_in[1].gl_Position ;
vec4 p2 = gl_in[2].gl_Position ;
if ( dot( lightPos, cross( p0.xyz - p1.xyz, p1.xyz - p2.xyz)) < 0)
if ( dot( p0.xyz - lightPos, cross( p0.xyz - p1.xyz, p1.xyz - p2.xyz)) < 0)
{
gl_Position = theMat * p0; EmitVertex();
gl_Position = theMat * p1; EmitVertex();
+2 -1
View File
@@ -93,7 +93,8 @@ youLight =
TLS { _tlsPos = V3 0 0 0
,_tlsRad = 300
,_tlsIntensity = 0.1
,_tlsUpdate = \w _ -> (w, Just (youLight {_tlsPos = f $ _crPos (you w)}))
,_tlsUpdate = \w _ -> (w, Nothing)
--,_tlsUpdate = \w _ -> (w, Just (youLight {_tlsPos = f $ _crPos (you w)}))
,_tlsTime = 0
}
where
+13 -1
View File
@@ -38,6 +38,7 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
clear [ColorBuffer,DepthBuffer]
--colorMask $= Color4 Disabled Disabled Disabled Disabled
cullFace $= Just Back
cullFace $= Nothing
-- we assume that the camera position uniforms have been correctly set elsewhere
-- draw wall surfaces from the camera's point of view in order to set z buffer
drawShader (_lightingWallShader pdata) nWalls
@@ -59,6 +60,7 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
depthFunc $= Just Lequal
flip VS.mapM_ (VS.fromList lightPoints) $ \(V3 x y z,rad,V3 r g b) -> do
--forM_ lightPoints $ \(V3 x y z,r,lum) -> do
depthFunc $= Just Less
-- stencil out shadows
colorMask $= Color4 Disabled Disabled Disabled Disabled
clear [StencilBuffer]
@@ -72,6 +74,8 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
drawShader (_lightingOccludeShader pdata) nWalls
--stencilOp $= (OpKeep,OpDecr,OpKeep)
stencilOpSeparate Front $= (OpKeep,OpDecrWrap,OpKeep)
stencilOpSeparate Back $= (OpKeep,OpIncrWrap,OpKeep)
currentProgram $= Just (_shaderProgram $ _lightingLineShadowShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingLineShadowShader pdata)
$= Vector3 x y z
@@ -79,8 +83,16 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
drawShader (_lightingLineShadowShader pdata) nSils
depthClamp $= Disabled
--stencilOp $= (OpKeep,OpDecrWrap,OpKeep)
currentProgram $= Just (_shaderProgram $ _lightingCapShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingCapShader pdata)
$= Vector3 x y z
drawShader (_lightingCapShader pdata) (nSils - 6)
depthFunc $= Just Lequal
-- draw geometry surfaces
cullFace $= Just Back
--cullFace $= Just Back
cullFace $= Nothing
--colorMask $= Color4 Disabled Disabled Disabled Enabled
colorMask $= Color4 Enabled Enabled Enabled Enabled
stencilOp $= (OpKeep,OpKeep,OpKeep)