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