Add "cap" shadow shader

This commit is contained in:
2021-08-29 18:13:55 +01:00
parent d23f36ea95
commit eba8ff121c
12 changed files with 66 additions and 8 deletions
+6
View File
@@ -0,0 +1,6 @@
#version 430 core
out vec4 fColor;
void main()
{
fColor = vec4(0,1,0,1);
}
+19
View File
@@ -0,0 +1,19 @@
#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
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)
{
gl_Position = theMat * p0; EmitVertex();
gl_Position = theMat * p1; EmitVertex();
gl_Position = theMat * p2; EmitVertex();
EndPrimitive();
}
else {}
}
+11
View File
@@ -0,0 +1,11 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
uniform vec4 lumRad;
out vec3 dField;
out vec3 lum;
void main()
{
gl_Position = vec4(position,1);
}
+13
View File
@@ -0,0 +1,13 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
uniform vec4 lumRad;
out vec3 dField;
out vec3 lum;
void main()
{
dField = (position - lightPos) / lumRad.a;
lum = lumRad.rgb;
gl_Position = theMat * vec4(position,1);
}
+1
View File
@@ -16,6 +16,7 @@ data RenderData = RenderData
, _lightingWallShader :: FullShader
, _lightingSurfaceShader :: FullShader
, _lightingLineShadowShader :: FullShader
, _lightingCapShader :: FullShader
, _wallBlankShader :: FullShader
, _wallTextureShader :: FullShader
, _textureArrayShader :: FullShader
-3
View File
@@ -21,7 +21,6 @@ import qualified Data.IntMap.Strict as IM
import qualified Data.Vector as V
import Data.List
import Data.Monoid
defaultCreature :: Creature
defaultCreature = Creature
{ _crPos = V2 0 0
@@ -178,7 +177,6 @@ defaultPP = PressPlate
, _ppID = -1
, _ppText = "Pressure plate"
}
defaultTLS :: TempLightSource
defaultTLS = TLS
{ _tlsPos = 0
@@ -192,4 +190,3 @@ defaultTLS = TLS
| _tlsTime t <= 0
= (w, Nothing)
| otherwise = (w, Just $ t & tlsTime -~ 1)
+1 -1
View File
@@ -274,7 +274,7 @@ withMuzFlareI :: ChainEffect
withMuzFlareI f it cr w = tempLightForAt 3 pos2 -- . muzzleFlashAt pos2
$ f it cr w
where
pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
--pos = _crPos cr +.+ _crRad cr *.* unitVectorAtAngle (_crDir cr)
pos2 = _crPos cr +.+ (2 * _crRad cr) *.* unitVectorAtAngle (_crDir cr)
{- | Applies the effect to a randomly rotated creature. -}
withRandomDirI
-1
View File
@@ -19,7 +19,6 @@ colorLightAt col pos i =
lightAt :: Point3 -> Int -> LightSource
lightAt = colorLightAt 0.75
tLightFade :: Int -> Float -> (Int -> Float) -> Point2 -> TempLightSource
tLightFade 0 rmax intensityF (V2 x y) = TLS
{ _tlsPos = V3 x y 0
+2 -1
View File
@@ -60,8 +60,8 @@ doDrawing pdata w = do
let addC (V2 xx yy) = V3 xx yy 0
nsurfVs <- pokePoint3s (shadVBOptr $ _lightingSurfaceShader pdata)
$ youBox w
++ polyToTris (map addC $ screenPolygon w)
++ concatMap polyToGeoRender (foregroundPics w)
++ polyToTris (map addC $ screenPolygon w)
-- bind wall points, silhouette data, surface geometry
uncurry bindShaderBuffers $ unzip
[ ( _wallTextureShader pdata, nWalls)
@@ -174,6 +174,7 @@ doDrawing pdata w = do
viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
depthFunc $= Just Always
blendFunc $= (One,Zero)
-- perform any radial distortion
case _radDistortion w of
[] -> do
+5 -2
View File
@@ -4,10 +4,11 @@ Explosions: creation of shockwave and particles at a given point.
module Dodge.WorldEvent.Explosion
where
import Dodge.Data
import Dodge.Default
import Dodge.Base.Zone
import Dodge.Base.Collide
import Dodge.WorldEvent.SpawnParticle
import Dodge.WorldEvent.Flash
--import Dodge.WorldEvent.Flash
import Dodge.RandomHelp
import Dodge.SoundLogic
import Dodge.SoundLogic.Synonyms
@@ -69,9 +70,11 @@ makeExplosionAt
makeExplosionAt p w
= soundOncePos grenadeBang p
. addFlames
. explosionFlashAt p
-- . explosionFlashAt p
. over tempLightSources (theTLS :)
$ makeShockwaveAt [] p 50 50 1 white w
where
theTLS = defaultTLS {_tlsPos = addZ 20 p, _tlsIntensity = V3 1 0.5 0, _tlsTime = 20, _tlsRad = 150}
fVs = replicateM 15 (randInCirc 1) & evalState $ _randGen w
fPs'' = replicateM 15 (fmap (15 *.*.*) randInHemisphere) & evalState $ _randGen w
(fPs',zs) = let (a,b,c) = unzip3 $ map fromV3 fPs''
+4
View File
@@ -61,6 +61,9 @@ preloadRender = do
lightingSurfaceShad
<- makeShader "lighting/surface" [vert,frag] [3] ETriangles
>>= addUniforms ["lightPos","lumRad"]
lightingCapShad
<- makeShaderUsingShaderVAO "lighting/cap" [vert,geom,frag] ETriangles lightingSurfaceShad
>>= addUniforms ["lightPos"]
lightingLineShadowShad
<- makeShader "lighting/lineShadow" [vert,geom,frag] [3] ELinesAdjacency
>>= addUniforms ["lightPos"]
@@ -133,6 +136,7 @@ preloadRender = do
return $ RenderData
{ _pictureShaders = shadV
, _lightingSurfaceShader = lightingSurfaceShad
, _lightingCapShader = lightingCapShad
, _lightingLineShadowShader = lightingLineShadowShad
, _lightingOccludeShader = wsShad {_shaderVAO = wpVAO}
, _lightingWallShader = wlLightShad {_shaderVAO = wpVAO}
+4
View File
@@ -69,6 +69,8 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
$= Vector3 x y z
drawShader (_lightingOccludeShader pdata) nWalls
--stencilOp $= (OpKeep,OpDecr,OpKeep)
currentProgram $= Just (_shaderProgram $ _lightingLineShadowShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingLineShadowShader pdata)
$= Vector3 x y z
@@ -80,6 +82,8 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
stencilOp $= (OpKeep,OpKeep,OpDecr)
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
drawShader (_lightingOccludeShader pdata) nWalls
--stencilOp $= (OpKeep,OpIncr,OpKeep)
currentProgram $= Just (_shaderProgram $ _lightingLineShadowShader pdata)
depthClamp $= Enabled
drawShader (_lightingLineShadowShader pdata) nSils