Lower walls and performance improvement for shadows
This commit is contained in:
+14
-10
@@ -6,29 +6,28 @@ uniform vec2 lightPos;
|
||||
uniform mat4 perpMat;
|
||||
uniform mat4 worldMat;
|
||||
|
||||
vec2 lightPosa = lightPos;
|
||||
vec2 lightPosa = ( perpMat * vec4(lightPos,0,1) ).xy;
|
||||
|
||||
vec4 shift (vec4 p)
|
||||
{ return vec4 (p.xy + (200 * (p.xy-lightPosa)), 0 , 1);
|
||||
{ return vec4 (p.xy + (200 * (p.xy-lightPos)), 0 , 1);
|
||||
}
|
||||
float isLHS (vec2 startV, vec2 testV)
|
||||
{
|
||||
return sign( -startV.x * testV.y + startV.y * testV.x);
|
||||
}
|
||||
// construct a box with opening on bottom face
|
||||
|
||||
// construct a box with openings on bottom face and face away from wall
|
||||
void main()
|
||||
{
|
||||
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
|
||||
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
|
||||
if (isLHS (p1.xy - lightPosa, p2.xy - lightPosa) < 0)
|
||||
if (isLHS (p1.xy - lightPos, p2.xy - lightPos) < 0)
|
||||
{
|
||||
vec4 p3 = vec4 (p1.xy,-0.5,1);
|
||||
vec4 p4 = vec4 (p2.xy,-0.5,1);
|
||||
vec4 p3 = vec4 (p1.xy,-0.2,1);
|
||||
vec4 p4 = vec4 (p2.xy,-0.2,1);
|
||||
vec4 p5 = shift(p1);
|
||||
vec4 p6 = shift(p2);
|
||||
vec4 p7 = vec4 (p6.xy,-0.5,1);
|
||||
vec4 p8 = vec4 (p5.xy,-0.5,1);
|
||||
vec4 p7 = vec4 (p6.xy,-0.2,1);
|
||||
vec4 p8 = vec4 (p5.xy,-0.2,1);
|
||||
|
||||
vec4 a1 = perpMat * p1;
|
||||
vec4 a2 = perpMat * p2;
|
||||
@@ -39,6 +38,11 @@ vec4 a6 = perpMat * p6;
|
||||
vec4 a7 = perpMat * p7;
|
||||
vec4 a8 = perpMat * p8;
|
||||
|
||||
// gl_Position = a1; EmitVertex();
|
||||
// gl_Position = a5; EmitVertex();
|
||||
// gl_Position = a2; EmitVertex();
|
||||
// gl_Position = a6; EmitVertex();
|
||||
|
||||
gl_Position = a4; EmitVertex();
|
||||
gl_Position = a3; EmitVertex();
|
||||
gl_Position = a7; EmitVertex();
|
||||
@@ -50,7 +54,7 @@ vec4 a8 = perpMat * p8;
|
||||
gl_Position = a2; EmitVertex();
|
||||
gl_Position = a7; EmitVertex();
|
||||
gl_Position = a6; EmitVertex();
|
||||
// gl_Position = a5; EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
} else {}
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ worldPictures w
|
||||
where tst x y sc t = translate x y $ scale sc sc $ color white $ text t
|
||||
|
||||
testPic :: World -> [Picture]
|
||||
testPic w = --[blank]
|
||||
[setLayer 1 $ onLayerL [99] $ bezierQuad white red 5 5 (00,00) (300,305) (50,000) ]
|
||||
testPic w = [blank]
|
||||
-- [setLayer 1 $ onLayerL [99] $ bezierQuad white red 5 5 (00,00) (300,305) (50,000) ]
|
||||
-- $ uncurry translate (mouseWorldPos w)
|
||||
|
||||
|
||||
|
||||
@@ -68,9 +68,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints
|
||||
|
||||
currentProgram $= Just (_shaderProgram $ _wallShadowShader pdata)
|
||||
uniform (head $ fromJust $ _shaderCustomUnis $ _wallShadowShader pdata)
|
||||
$= Vector2 viewFromx viewFromy -- hopefully this draws as if from the center
|
||||
-- it does, but this is not correct when
|
||||
-- the camera center is not the player position
|
||||
$= Vector2 viewFromx viewFromy
|
||||
pmat <- (newMatrix RowMajor
|
||||
$ perspectiveMatrix rot zoom (tranx,trany) (winx,winy) (viewFromx,viewFromy)
|
||||
) :: IO (GLmatrix GLfloat)
|
||||
@@ -85,6 +83,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints
|
||||
stencilTest $= Enabled
|
||||
forM_ lightPoints $ \(x,y,r,lum) -> do
|
||||
-- depthFunc $= Just Less
|
||||
colorMask $= (Color4 Disabled Disabled Disabled Disabled)
|
||||
clear [StencilBuffer]
|
||||
cullFace $= Just Back
|
||||
-- stencilOp $= (OpKeep,OpKeep,OpReplace)
|
||||
@@ -103,6 +102,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints
|
||||
|
||||
cullFace $= Nothing
|
||||
|
||||
colorMask $= (Color4 Enabled Enabled Enabled Enabled)
|
||||
let lightPtr = (\(_,ptr,_) -> ptr) $ head
|
||||
$ _vaoBufferTargets $ _shaderVAO $ _lightSourceShader pdata
|
||||
(x',y') = zTran $ rotateV (0 - rot) $ (x,y) -.- (tranx,trany)
|
||||
|
||||
Reference in New Issue
Block a user