Add hard edge to non-visible areas
This commit is contained in:
@@ -3,14 +3,14 @@ layout (lines_adjacency) in;
|
||||
layout (triangle_strip, max_vertices = 4) out;
|
||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||
uniform vec3 lightPos;
|
||||
vec4 shift (vec4 p) { return (vec4 (p.xyz + (2000*(p.xyz-lightPos)), 1));}
|
||||
vec4 shift (vec4 p) { return (vec4 (p.xyz + (1000*(p.xyz-lightPos)), 1));}
|
||||
vec4 f (vec4 p) {return (theMat * p);}
|
||||
void main()
|
||||
{
|
||||
vec4 p0 = gl_in[0].gl_Position;
|
||||
vec3 n0 = gl_in[2].gl_Position.xyz;
|
||||
vec3 n1 = gl_in[3].gl_Position.xyz;
|
||||
vec3 n2 = n0 + n1; // assumes the summands are normalized
|
||||
//vec3 n2 = n0 + n1; // assumes the summands are normalized
|
||||
vec3 lightDir = p0.xyz - lightPos.xyz;
|
||||
// first test if the edge is part of the silhouette
|
||||
// that is, if the normals of the faces connected by the edge point in
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
out vec4 fColor;
|
||||
void main()
|
||||
{
|
||||
fColor = vec4 (0.9,0.5,0,0);
|
||||
fColor = vec4 (0.9,0.5,0,1);
|
||||
}
|
||||
|
||||
@@ -34,18 +34,36 @@ vec4 a6 = theMat * p6;
|
||||
vec4 a7 = theMat * p7;
|
||||
vec4 a8 = theMat * p8;
|
||||
|
||||
gl_Position = a4; EmitVertex();
|
||||
gl_Position = a3; EmitVertex();
|
||||
gl_Position = a7; EmitVertex();
|
||||
gl_Position = a8; EmitVertex();
|
||||
//gl_Position = a4; EmitVertex();
|
||||
//gl_Position = a3; EmitVertex();
|
||||
//gl_Position = a7; EmitVertex();
|
||||
//gl_Position = a8; EmitVertex();
|
||||
//gl_Position = a5; EmitVertex();
|
||||
//gl_Position = a3; EmitVertex();
|
||||
//gl_Position = a1; EmitVertex();
|
||||
//gl_Position = a4; EmitVertex();
|
||||
//gl_Position = a2; EmitVertex();
|
||||
//gl_Position = a7; EmitVertex();
|
||||
//gl_Position = a6; EmitVertex();
|
||||
|
||||
gl_Position = a1; EmitVertex();
|
||||
gl_Position = a5; EmitVertex();
|
||||
gl_Position = a3; EmitVertex();
|
||||
gl_Position = a1; EmitVertex();
|
||||
gl_Position = a8; EmitVertex();
|
||||
gl_Position = a4; EmitVertex();
|
||||
gl_Position = a2; EmitVertex();
|
||||
gl_Position = a7; EmitVertex();
|
||||
gl_Position = a2; EmitVertex();
|
||||
gl_Position = a6; EmitVertex();
|
||||
|
||||
//gl_Position = a5; EmitVertex();
|
||||
//gl_Position = a1; EmitVertex();
|
||||
//gl_Position = a8; EmitVertex();
|
||||
//gl_Position = a3; EmitVertex();
|
||||
//gl_Position = a7; EmitVertex();
|
||||
//gl_Position = a4; EmitVertex();
|
||||
//gl_Position = a6; EmitVertex();
|
||||
//gl_Position = a2; EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
} else {}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ float isLHS (vec2 startV, vec2 testV)
|
||||
return sign( -startV.x * testV.y + startV.y * testV.x);
|
||||
}
|
||||
vec4 shiftCloser (vec4 v)
|
||||
{ return vec4 (v.xy , v.z-0.0001 , v.w) ; }
|
||||
{ return vec4 (v.xy , v.z , v.w) ; }
|
||||
//{ return vec4 (v.xy , v.z-0.0001 , v.w) ; }
|
||||
void main()
|
||||
{
|
||||
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
|
||||
|
||||
@@ -21,8 +21,8 @@ void main()
|
||||
vec4 a1 = theMat * p1;
|
||||
vec4 a2 = theMat * p2;
|
||||
// if (0 > isLHS (a1.xy - a2.xy, a1.xy - "viewFromPoint")) {
|
||||
vec4 p3 = vec4 (p1.xy,150,1);
|
||||
vec4 p4 = vec4 (p2.xy,150,1);
|
||||
vec4 p3 = vec4 (p1.xy,100,1);
|
||||
vec4 p4 = vec4 (p2.xy,100,1);
|
||||
vec4 a3 = theMat * p3;
|
||||
vec4 a4 = theMat * p4;
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ void main()
|
||||
|
||||
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
|
||||
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
|
||||
vec4 p3 = vec4 (p1.xy,150,1);
|
||||
vec4 p4 = vec4 (p2.xy,150,1);
|
||||
vec4 p3 = vec4 (p1.xy,100,1);
|
||||
vec4 p4 = vec4 (p2.xy,100,1);
|
||||
|
||||
vec4 a1 = theMat * p1;
|
||||
vec4 a2 = theMat * p2;
|
||||
|
||||
@@ -17,7 +17,7 @@ import Dodge.WorldEvent.Sound
|
||||
import Dodge.Creature.Update hiding (CRUpdate)
|
||||
import Picture
|
||||
import qualified IntMapHelp as IM
|
||||
import Geometry
|
||||
--import Geometry
|
||||
import Geometry.Vector3D
|
||||
import Polyhedra
|
||||
|
||||
|
||||
+9
-1
@@ -11,7 +11,7 @@ import Dodge.Base
|
||||
--import Dodge.Render.MenuScreen
|
||||
import Dodge.Render.Picture
|
||||
--import Dodge.Render.PerspectiveMatrix
|
||||
import Geometry
|
||||
--import Geometry
|
||||
import Geometry.Data
|
||||
--import Picture
|
||||
import Render
|
||||
@@ -67,6 +67,14 @@ doDrawing pdata w = do
|
||||
createLightMap pdata (w ^. config . shadow_resolution) wallPoints lightPoints viewFroms
|
||||
(foregroundPics w) scPol
|
||||
clear [DepthBuffer]
|
||||
|
||||
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
|
||||
bindShaderBuffers [_lightingOccludeShader pdata] [nWalls]
|
||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
$= Vector2 viewFromx viewFromy
|
||||
drawShader (_lightingOccludeShader pdata) nWalls
|
||||
|
||||
depthFunc $= Just Less
|
||||
-- set blending to depend upon the alpha level already present
|
||||
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
||||
|
||||
@@ -51,10 +51,7 @@ diagonalLinesRect pa pb w d ang = zip lhsPoints $ map findDiPoint lhsPoints
|
||||
highPipe :: Float -> Point2 -> Point2 -> [Polyhedra]
|
||||
highPipe h x@(xx,xy) y =
|
||||
[ Polyhedron . map (map ( (,orange) . (+.+.+ (xx,xy,h))))
|
||||
$ boxABC (a,b,0) (a',b',0) (0,0,10)
|
||||
-- ,verticalPipe 5 orange x 0 100
|
||||
-- ,verticalPipe 5 orange y 0 100
|
||||
-- ,verticalPipe 5 orange (0.5 *.* (x +.+ y)) 50 100
|
||||
$ boxABC (a,b,0) (a',b',0) (0,0,5)
|
||||
]
|
||||
where
|
||||
(a,b) = y -.- x
|
||||
|
||||
+24
-36
@@ -65,54 +65,48 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) fpics s
|
||||
-- set the viewport size to that of the render buffer
|
||||
viewport $= (vppos, divideSize resDiv vpsize)
|
||||
bindFramebuffer Framebuffer $= _spareFBO pdata
|
||||
|
||||
-- store wall and light positions into buffer
|
||||
nWallLights <- F.foldM (pokeShader $ _lightingWallShader pdata) (map Render22 wallPoints)
|
||||
bindShaderBuffers [_lightingWallShader pdata] [nWallLights]
|
||||
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
|
||||
bindShaderBuffers [_lightingOccludeShader pdata] [nWalls]
|
||||
|
||||
-- store foreground silhouette geometry into buffer
|
||||
nSils <- F.foldM (pokeShader $ _lightingLineShadowShader pdata) (concatMap polyToRender fpics)
|
||||
bindShaderBuffers [_lightingLineShadowShader pdata] [nSils]
|
||||
|
||||
-- store foreground geometry and floor into buffer
|
||||
let addC (xx,yy) = (xx,yy,0)
|
||||
nsurfVs <- F.foldM (pokeShader (_lightingSurfaceShader pdata))
|
||||
$ [Render3 $ polyToTris $ map addC $ scPol ]
|
||||
++ concatMap polyToGeoRender (fpics)
|
||||
bindShaderBuffers [_lightingSurfaceShader pdata] [nsurfVs]
|
||||
|
||||
|
||||
-- clear buffer to full alpha and furthest depth
|
||||
-- clearColor is specified in preloadRender
|
||||
clear [ColorBuffer,DepthBuffer]
|
||||
-- draw walls from your point of view in order to set z buffer
|
||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
$= Vector2 viewFromx viewFromy
|
||||
cullFace $= Just Back
|
||||
drawShader (_lightingOccludeShader pdata) nWalls
|
||||
|
||||
cullFace $= Nothing
|
||||
|
||||
-- draw walls from your point of view in order to set z buffer
|
||||
currentProgram $= Just (_shaderProgram $ _lightingWallShader pdata)
|
||||
drawShader (_lightingWallShader pdata) nWallLights
|
||||
--colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
--currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||
--uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
-- $= Vector2 viewFromx viewFromy
|
||||
--drawShader (_lightingOccludeShader pdata) nWalls
|
||||
---- draw foreground elements to set z buffer
|
||||
--_ <- renderFoldable pdata $ picToLTree (Just 0) (polysToPic fpics)
|
||||
currentProgram $= Just (_shaderProgram $ _lightingSurfaceShader pdata)
|
||||
drawShader (_lightingSurfaceShader pdata) nsurfVs
|
||||
|
||||
-- for each of the lights:
|
||||
-- stencil out the walls from this light's point of view
|
||||
-- draw fading lightmap circles on the floor
|
||||
-- draw fading lightmaps on the walls
|
||||
--cullFace $= Nothing
|
||||
depthMask $= Disabled
|
||||
blendFunc $= (Zero, OneMinusSrcAlpha)
|
||||
stencilTest $= Enabled
|
||||
--depthFunc $= Just Less
|
||||
forM_ lightPoints $ \((x,y,z),r,lum) -> do
|
||||
-- stencil out walls
|
||||
depthFunc $= Just Less
|
||||
-- stencil out shadows
|
||||
--depthFunc $= Just Less
|
||||
depthFunc $= Just Lequal
|
||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
clear [StencilBuffer]
|
||||
cullFace $= Just Back
|
||||
@@ -122,7 +116,6 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) fpics s
|
||||
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
$= Vector3 x y z
|
||||
drawShader (_lightingOccludeShader pdata) nWalls
|
||||
|
||||
--cullFace $= Nothing
|
||||
currentProgram $= Just (_shaderProgram $ _lightingLineShadowShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingLineShadowShader pdata)
|
||||
@@ -137,21 +130,20 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) fpics s
|
||||
currentProgram $= Just (_shaderProgram $ _lightingLineShadowShader pdata)
|
||||
drawShader (_lightingLineShadowShader pdata) nSils
|
||||
depthFunc $= Just Lequal
|
||||
-- draw floor light circles
|
||||
cullFace $= Nothing
|
||||
-- draw geometry surfaces
|
||||
cullFace $= Just Back
|
||||
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
||||
stencilFunc $= (Equal, 0, 255)
|
||||
-- draw floor surface
|
||||
currentProgram $= Just (_shaderProgram $ _lightingSurfaceShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingSurfaceShader pdata)
|
||||
$= Vector3 x y z
|
||||
uniform (_shaderCustomUnis (_lightingSurfaceShader pdata) !! 1)
|
||||
$= Vector2 r lum
|
||||
drawShader (_lightingSurfaceShader pdata) nsurfVs
|
||||
|
||||
-- draw wall light "circles"
|
||||
-- draw wall light "circles"
|
||||
--cullFace $= Nothing
|
||||
currentProgram $= Just (_shaderProgram $ _lightingWallShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingWallShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingWallShader pdata)
|
||||
$= Vector3 x y z
|
||||
uniform (_shaderCustomUnis (_lightingWallShader pdata) !! 1)
|
||||
$= Vector2 r lum
|
||||
@@ -159,30 +151,26 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) fpics s
|
||||
cullFace $= Nothing
|
||||
stencilTest $= Disabled
|
||||
blend $= Disabled
|
||||
|
||||
-- set the viewport size to that of the window
|
||||
-- set the viewport size to that of the window
|
||||
viewport $= (vppos, vpsize)
|
||||
-- disable depth testing for blurring
|
||||
-- disable depth testing for blurring
|
||||
depthFunc $= Just Always
|
||||
-- draw the lightmap on a full size fbo
|
||||
-- draw the lightmap on a full size fbo
|
||||
bindFramebuffer Framebuffer $= fst3 (_fbo2 pdata)
|
||||
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
||||
bindShaderBuffers [_boxBlurShader pdata] [4]
|
||||
textureBinding Texture2D $= Just (_fboTexture pdata)
|
||||
-- by upscaling the shadowmap texture and using Linear' magnification
|
||||
-- interpolation, we get a poor mans blur, not sure about performance
|
||||
-- by upscaling the shadowmap texture and using Linear' magnification
|
||||
-- interpolation, we get a poor mans blur, not sure about performance
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
-- ping pong blur between '_fbo2' and '_fbo3' as many times as desired
|
||||
-- ping pong blur between '_fbo2' and '_fbo3' as many times as desired
|
||||
replicateM_ 3 $ pingPongBlur pdata
|
||||
|
||||
-- reset drawing parameters ready for drawing on top of the light map
|
||||
-- reset drawing parameters ready for drawing on top of the light map
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
depthMask $= Enabled
|
||||
blend $= Enabled
|
||||
|
||||
{- |
|
||||
Blur between two framebuffers.
|
||||
Assumes no depth testing is done (depthFunc %= Just Always).
|
||||
|
||||
Reference in New Issue
Block a user