Slight improvement to light sources and shadows

This commit is contained in:
jgk
2021-02-23 13:14:23 +01:00
parent e855d303e8
commit 5bdd646900
5 changed files with 34 additions and 21 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ void main()
vec2 pos = gl_FragCoord.xy;
float dist = min(1 , 2*distance(pos,cenPosT) / (gParams.x));
//float c = pow(gParams.y*dist,2);
float c = pow(1-dist,2);
float c = gParams.y * pow(1-dist,2);
fColor = vec4( c,c,c ,c );
// fColor = vec4( 1,0,0 , 1);
// fColor = vec4( 1,0,0 , pow(dist,2) );
+12 -12
View File
@@ -12,18 +12,18 @@ void main()
vec2 posc = vBackPoss[0].xy;
vec2 posd = vBackPoss[0].zw;
gl_Position = vec4 (posa, 0 , 1);
EmitVertex();
gl_Position = vec4 (posa + (200 * (posa - lightPos)), 0 , 1);
EmitVertex();
gl_Position = vec4 (posb, 0 , 1);
EmitVertex();
gl_Position = vec4 (posb + (200 * (posb - lightPos)), 0 , 1);
EmitVertex();
gl_Position = vec4 (posb + (200 * (posb - lightPos)), 0 , 1);
EmitVertex();
gl_Position = vec4 (posd, 0 , 1);
EmitVertex();
// gl_Position = vec4 (posa, 0 , 1);
// EmitVertex();
// gl_Position = vec4 (posa + (200 * (posa - lightPos)), 0 , 1);
// EmitVertex();
// gl_Position = vec4 (posb, 0 , 1);
// EmitVertex();
// gl_Position = vec4 (posb + (200 * (posb - lightPos)), 0 , 1);
// EmitVertex();
// gl_Position = vec4 (posb + (200 * (posb - lightPos)), 0 , 1);
// EmitVertex();
// gl_Position = vec4 (posd, 0 , 1);
// EmitVertex();
gl_Position = vec4 (posd, 0 , 1);
EmitVertex();
gl_Position = vec4 (posd + (200 * (posd - lightPos)), 0 , 1);
+2 -2
View File
@@ -16,8 +16,8 @@ lightAt p i =
LS {_lsID = i
,_lsPos = p
,_lsDir = 0
,_lsRad = 300
,_lsIntensity = 0.5
,_lsRad = 600
,_lsIntensity = 0.75
}
basicLS = PutLS ls dec
+10 -1
View File
@@ -63,7 +63,7 @@ lev1 = do
-- $ roomRect 300 300]
++ [randomiseLinks =<< shooterRoom]
++ (replicate 3 $ randomiseLinks corridor)
++ [return $ connectRoom corridor]
++ [return $ connectRoom (set rmPS [PS (20,40) 0 basicLS] corridor)]
-- ++ [randomiseLinks =<< longRoom]
++ [return $ connectRoom corridor]
++ firstWeapon
@@ -364,6 +364,7 @@ miniRoom1 = do
,PS (0,0) 0 $ PutWindowBlock (wth-wllen,40+4*hf) (60,40+4*hf)
,PS (crx,cry) 0 $ PutCrit miniGunCrit
,PS (wth-20,hgt/2+40) 0 $ randC
,PS (wth/2,hgt/2) 0 basicLS
]
++ putWallBlocks ( 0, 40+1*hf) (wllen,40+1*hf)
++ putWallBlocks (wth-wllen, 40+2*hf) ( wth,40+2*hf)
@@ -412,6 +413,7 @@ miniRoom3 = do
,PS cp (pi/8+5*pi/4) b
,PS cp (pi/8+6*pi/4) b
,PS cp (pi/8+7*pi/4) b
,PS (w/2,h/2) 0 basicLS
]
randomiseLinks $ set rmPS plmnts $ roomRect w h
@@ -451,6 +453,9 @@ roomCenterPillar = changeLinkTo ((\p -> dist p (120,0) < 10) . fst)
$ set rmPS plmnts $ roomRect' 240 240 2 2
where plmnts = putWallBlocks (110,110) (110,130)
++ putWallBlocks (130,110) (130,130)
++ [PS (40,120) 0 basicLS
,PS (200,120) 0 basicLS
]
roomOctogon :: Room
roomOctogon = Room
@@ -512,6 +517,7 @@ weaponEmptyRoom = do
let plmnts = [PS (w/2,h-40) 0 $ RandPS randFirstWeapon
,PS (20,20) (pi/2) $ randC1
,PS (w-20,20) (pi/2) $ randC1
,PS (w/2,h/2) 0 $ basicLS
]
randomiseLinks =<< (changeLinkTo ((\p -> dist p (w/2,0) < 10) . fst)
$ set rmPS plmnts $ roomRect' w h 2 2)
@@ -750,6 +756,7 @@ shooterRoom = do
,PS ( 75,h-60) 0 $ PutCrit explosiveBarrel
,PS ( 85,h-10) 0 $ PutCrit explosiveBarrel
,PS ( 85,h-45) 0 $ PutCrit explosiveBarrel
,PS ( 75,h-80) 0 basicLS
]
)
$ roomRect' 100 h 1 1
@@ -771,6 +778,7 @@ shootersRoom1 = do
let blv x y = putBlockV (x+25) (x-25) (y+10) (y)
let plmnts = bln x1 y1 ++ bln x2 y2 ++ bln x3 y3 ++ blv x4 y4
++ [PS p (-pi/2) $ PutCrit autoCrit
,PS (w/2,200) 0 basicLS
]
return $ set rmPS plmnts $ roomRect w 600
@@ -791,6 +799,7 @@ shootersRoom = do
++ [PS (x1,y1-10) (-pi/2) $ PutCrit autoCrit
,PS (x2,y2-10) (-pi/2) $ PutCrit autoCrit
,PS (x3,y3-10) (-pi/2) $ PutCrit autoCrit
,PS (w/2,200) 0 basicLS
]
return $ set rmPS plmnts $ roomRect w 600
+9 -5
View File
@@ -315,11 +315,6 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
bindVertexArrayObject $= Just (_vao $ _triVAO pdata)
bindArrayBuffers nTriVs $ _vaoBufferTargets $ _triVAO pdata
drawArrays Triangles (fromIntegral firstIndex) (fromIntegral $ nTriVs)
-- draw lines, don't need to change the program or vaos, just need to bind the
-- vbos and draw
bindVertexArrayObject $= Just (_vao $ _lineVAO pdata)
bindArrayBuffers nTriVs $ _vaoBufferTargets $ _lineVAO pdata
drawArrays Lines (fromIntegral firstIndex) (fromIntegral $ nLineVs)
-- draw circles
currentProgram $= Just (_circShader pdata)
uniform (_uniWinSize pdata) $= Vector2 winx winy
@@ -334,6 +329,15 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
bindVertexArrayObject $= Just (_vao $ _arcVAO pdata)
bindArrayBuffers nArcVs $ _vaoBufferTargets $ _arcVAO pdata
drawArrays Points (fromIntegral firstIndex) (fromIntegral $ nArcVs)
-- reset blend so that light map doesn't apply
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
-- draw lines
currentProgram $= Just (_basicShader pdata)
bindVertexArrayObject $= Just (_vao $ _lineVAO pdata)
bindArrayBuffers nTriVs $ _vaoBufferTargets $ _lineVAO pdata
drawArrays Lines (fromIntegral firstIndex) (fromIntegral $ nLineVs)
-- draw text
currentProgram $= Just (_textShader pdata)
bindVertexArrayObject $= Just (_vao $ _textVAO pdata)