Commit before attempt to unify picture rendering

This commit is contained in:
jgk
2021-06-09 21:32:26 +02:00
parent 71d9a24eed
commit 822db37a58
7 changed files with 47 additions and 11 deletions
+4 -4
View File
@@ -25,8 +25,8 @@ if (isLHS (p1.xy - lightPos, p2.xy - lightPos) < 0)
lum = radLum.y;
float rad = radLum.x;
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);
vec2 d1 = p1.xy - lightPos;
vec2 d2 = p2.xy - lightPos;
@@ -39,13 +39,13 @@ if (isLHS (p1.xy - lightPos, p2.xy - lightPos) < 0)
dField = vec3( d1.x/rad, d1.y/rad, 0);
gl_Position = a1;
EmitVertex();
dField = vec3( d1.x/rad, d1.y/rad, 1);
dField = vec3( d1.x/rad, d1.y/rad, 0);
gl_Position = a3;
EmitVertex();
dField = vec3( d2.x/rad, d2.y/rad, 0);
gl_Position = a2;
EmitVertex();
dField = vec3( d2.x/rad, d2.y/rad, 1);
dField = vec3( d2.x/rad, d2.y/rad, 0);
gl_Position = a4;
EmitVertex();
+4 -4
View File
@@ -3,10 +3,10 @@ layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
out vec4 vColor;
uniform vec2 winSize;
uniform float zoom;
uniform float rotation;
uniform vec2 translation;
//uniform vec2 winSize;
//uniform float zoom;
//uniform float rotation;
//uniform vec2 translation;
uniform mat4 worldMat;
void main()
+2 -2
View File
@@ -20,8 +20,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,-0.5,1);
vec4 p4 = vec4 (p2.xy,-0.5,1);
vec4 p3 = vec4 (p1.xy,-0.3,1);
vec4 p4 = vec4 (p2.xy,-0.3,1);
vec4 a1 = perpMat * p1;
vec4 a2 = perpMat * p2;
+2
View File
@@ -73,6 +73,8 @@ data World = World
, _soundQueue :: [(Int,Int16)]
, _sounds :: M.Map SoundOrigin Sound
, _decorations :: IM.IntMap Picture
, _foregroundDecorations :: [Picture]
, _midgroundDecorations :: [Picture]
, _corpses :: IM.IntMap (IM.IntMap [Corpse])
, _clickMousePos :: (Float,Float)
, _pathGraph :: ~(Gr Point2 Float)
+13
View File
@@ -88,7 +88,20 @@ defaultWorld = World
, _debugFlags = defaultDebugFlags
, _inventoryMode = TopInventory
, _lClickHammer = HammerUp
, _foregroundDecorations =
[setDepth (-0.2) $ rotate 0.75 $ pictures
$ map f [5,25,45,65]
]
, _midgroundDecorations =
[setDepth (-0.1) $ color orange $ pictures
[ polygon $ rectNSEW 50 40 140 (-20)
, translate 60 45 $ thickArc 0 pi 75 10
]
]
}
where
f x = polygon $ rectNSEW (x - 20) (x-22) 500 0
defaultCreature :: Creature
defaultCreature = Creature
{ _crPos = (0,0)
+17 -1
View File
@@ -52,7 +52,7 @@ doDrawing pdata w = do
viewFroms@(viewFromx,viewFromy) = _cameraViewFrom w
pic = worldPictures w
wallPoints = map fst wallPointsCol
-- set the coordinate uniforms ready for drawing elements with using world coordinates
-- set the coordinate uniforms ready for drawing elements using world coordinates
setCommonUniforms pdata rot camzoom trans wins
depthFunc $= Just Less
pmat <- (newMatrix RowMajor $ perspectiveMatrix rot camzoom trans wins viewFroms)
@@ -88,7 +88,22 @@ doDrawing pdata w = do
-- render transparent walls
-- the ordering between these and transparent clouds perhaps presents a challenge
renderBlankWalls pdata windowPoints pmat
setShaderUniforms rot (camzoom * (1/ 0.9)) trans wins
$ map extractProgAndUnis $ _pictureShaders pdata
depthFunc $= Just Lequal
_ <- renderFoldable pdata $ picToLTree (Just 0) (midgroundPics w)
--depthMask $= Enabled
-- set the coordinate uniforms for the foreground
setShaderUniforms rot (camzoom * (1/ 0.8)) trans wins
$ map extractProgAndUnis $ _pictureShaders pdata
blendFunc $= (One,Zero)
depthFunc $= Just Always
_ <- renderFoldable pdata $ picToLTree (Just 0) (foregroundPics w)
depthMask $= Enabled
-- draw the fbo to the screen
-- allows for post-processing
-- first, bind the screen fbo
@@ -107,6 +122,7 @@ doDrawing pdata w = do
bindShaderBuffers [_grayscaleShader pdata] [4]
drawShader (_grayscaleShader pdata) 4
blend $= Enabled
-- reset the coordinate uniforms for pictures that are drawn wrt to window
-- coordinates
resetShaderUniforms (map extractProgAndUnis $ _pictureShaders pdata)
+5
View File
@@ -28,6 +28,11 @@ worldPictures w = pictures $ concat
, map drawWallFloor (wallFloorsToDraw w)
, testPic w
]
midgroundPics :: World -> Picture
midgroundPics = pictures . _midgroundDecorations
foregroundPics :: World -> Picture
foregroundPics = pictures . _foregroundDecorations
fixedCoordPictures :: World -> Picture
fixedCoordPictures w = case _menuLayers w of