Commit before fully removing uniforms other than the matrix
This commit is contained in:
@@ -2,10 +2,9 @@
|
|||||||
in vec2 gTexPos;
|
in vec2 gTexPos;
|
||||||
out vec4 fColor;
|
out vec4 fColor;
|
||||||
|
|
||||||
uniform sampler2D aTexture;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// fColor = vec4 (1,1,0,1);
|
fColor = vec4 (0.5,0.2,0,1);
|
||||||
fColor = texture(aTexture, gTexPos);
|
// fColor = texture(aTexture, gTexPos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,15 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
layout (points) in;
|
layout (points) in;
|
||||||
layout (triangle_strip, max_vertices = 4) out;
|
layout (triangle_strip, max_vertices = 4) out;
|
||||||
in vec4 vParams [];
|
|
||||||
in vec2 vWinSize [];
|
|
||||||
out vec2 gTexPos;
|
|
||||||
|
|
||||||
uniform vec2 winSize;
|
|
||||||
uniform vec2 translation;
|
|
||||||
uniform float zoom;
|
|
||||||
uniform float rotation;
|
|
||||||
|
|
||||||
vec2 rotBy( float rot, vec2 v)
|
|
||||||
{
|
|
||||||
return vec2 ( v.x * cos(rot) - v.y * sin(rot)
|
|
||||||
, v.x * sin(rot) + v.y * cos(rot)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 cPos = vec2(translation.x / 250 , translation.y /250 );
|
|
||||||
// float zoom = vParams[0].w;
|
|
||||||
float rot = 0 - rotation;
|
|
||||||
|
|
||||||
float x = winSize.x / (500*zoom) ;
|
|
||||||
float y = winSize.y / (500*zoom) ;
|
|
||||||
gTexPos = cPos + rotBy(-rot , vec2(x,y));
|
|
||||||
gl_Position = vec4 (1,1,0.9,1);
|
gl_Position = vec4 (1,1,0.9,1);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
gTexPos = cPos + rotBy(-rot , vec2(x,-y));
|
|
||||||
gl_Position = vec4 (1,-1,0.9,1);
|
gl_Position = vec4 (1,-1,0.9,1);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
gTexPos = cPos + rotBy(-rot , vec2(-x,y));
|
|
||||||
gl_Position = vec4 (-1,1,0.9,1);
|
gl_Position = vec4 (-1,1,0.9,1);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
gTexPos = cPos + rotBy(-rot , vec2(-x,-y));
|
|
||||||
gl_Position = vec4 (-1,-1,0.9,1);
|
gl_Position = vec4 (-1,-1,0.9,1);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,8 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
layout (location = 0) in vec4 params;
|
layout (location = 0) in vec4 params;
|
||||||
layout (location = 1) in vec2 texCoor;
|
layout (location = 1) in vec2 texCoor;
|
||||||
out vec4 vParams;
|
|
||||||
out vec2 vWinSize;
|
|
||||||
|
|
||||||
uniform vec2 winSize;
|
|
||||||
uniform float zoom;
|
|
||||||
uniform vec2 translation;
|
|
||||||
uniform float rotation;
|
|
||||||
uniform mat4 worldMat;
|
uniform mat4 worldMat;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(0,0,0,0);
|
gl_Position = vec4(0,0,0,0);
|
||||||
vParams = params;
|
|
||||||
vWinSize = winSize;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
in float lum;
|
in float lum;
|
||||||
|
|
||||||
in vec2 dField;
|
in vec2 dField;
|
||||||
|
|
||||||
out vec4 fColor;
|
out vec4 fColor;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float c = pow (1 - min(1, dot(dField,dField)) , 2) * lum ;
|
float c = pow (1 - min(1, dot(dField,dField)) , 2) * lum ;
|
||||||
|
|||||||
@@ -4,31 +4,25 @@ layout (triangle_strip, max_vertices = 4) out;
|
|||||||
out float lum;
|
out float lum;
|
||||||
out vec2 dField;
|
out vec2 dField;
|
||||||
|
|
||||||
uniform vec2 winSize;
|
|
||||||
uniform float zoom;
|
|
||||||
uniform mat4 worldMat;
|
uniform mat4 worldMat;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
lum = gl_in[0].gl_Position.w;
|
lum = gl_in[0].gl_Position.w;
|
||||||
vec4 cenPos = worldMat * vec4( gl_in[0].gl_Position.xy, 0 , 1);
|
vec4 cenPos = vec4( gl_in[0].gl_Position.xy, 0 , 1);
|
||||||
float gRad = gl_in[0].gl_Position.z * zoom * 2;
|
float gRad = gl_in[0].gl_Position.z;
|
||||||
|
|
||||||
dField = vec2 ( 1, 1);
|
dField = vec2 ( 1, 1);
|
||||||
gl_Position
|
gl_Position = worldMat * vec4 (cenPos.x + gRad, cenPos.y + gRad, -0 , 1);
|
||||||
= vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, -0 , 1);
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
dField = vec2 (-1, 1);
|
dField = vec2 (-1, 1);
|
||||||
gl_Position
|
gl_Position = worldMat * vec4 (cenPos.x - gRad, cenPos.y + gRad, -0 , 1);
|
||||||
= vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, -0 , 1);
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
dField = vec2 ( 1,-1);
|
dField = vec2 ( 1,-1);
|
||||||
gl_Position
|
gl_Position = worldMat * vec4 (cenPos.x + gRad, cenPos.y - gRad, -0 , 1);
|
||||||
= vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, -0 , 1);
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
dField = vec2 (-1,-1);
|
dField = vec2 (-1,-1);
|
||||||
gl_Position
|
gl_Position = worldMat * vec4 (cenPos.x - gRad, cenPos.y - gRad, -0 , 1);
|
||||||
= vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, -0 , 1);
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
|||||||
@@ -11,94 +11,14 @@ import Dodge.Item.Data
|
|||||||
import Dodge.Creature.Stance.Data
|
import Dodge.Creature.Stance.Data
|
||||||
import Dodge.Creature.State.Data
|
import Dodge.Creature.State.Data
|
||||||
import Dodge.Creature.AlertLevel.Data
|
import Dodge.Creature.AlertLevel.Data
|
||||||
import Dodge.Debug.Flag.Data
|
|
||||||
import Dodge.Data.Menu
|
|
||||||
import Dodge.SoundLogic
|
import Dodge.SoundLogic
|
||||||
import Dodge.Base
|
|
||||||
import Dodge.Picture.Layer
|
import Dodge.Picture.Layer
|
||||||
import Dodge.Config.Data
|
|
||||||
import Dodge.Config.KeyConfig
|
|
||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import System.Random
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified Data.Map as M
|
|
||||||
import qualified Data.Set as S
|
|
||||||
import Data.Graph.Inductive.Graph hiding ((&))
|
|
||||||
import Data.List
|
import Data.List
|
||||||
defaultWorld :: World
|
|
||||||
defaultWorld = World
|
|
||||||
{ _keys = S.empty
|
|
||||||
, _mouseButtons = S.empty
|
|
||||||
, _cameraCenter = (0,0)
|
|
||||||
, _cameraRot = 0
|
|
||||||
, _cameraZoom = 1
|
|
||||||
, _cameraViewFrom = (0,0)
|
|
||||||
, _creatures = IM.empty
|
|
||||||
, _creaturesZone = IM.empty
|
|
||||||
, _creatureGroups = IM.empty
|
|
||||||
, _clouds = IM.empty
|
|
||||||
, _cloudsZone = IM.empty
|
|
||||||
, _itemPositions = IM.empty
|
|
||||||
, _projectiles = IM.empty
|
|
||||||
, _particles = []
|
|
||||||
, _staticWalls = []
|
|
||||||
, _walls = IM.empty
|
|
||||||
, _wallsZone = IM.empty
|
|
||||||
, _forceFields = IM.empty
|
|
||||||
, _floorItems = IM.empty
|
|
||||||
, _randGen = mkStdGen 2
|
|
||||||
, _mousePos = (0,0)
|
|
||||||
, _testString = []
|
|
||||||
, _yourID = 0
|
|
||||||
, _worldEvents = id
|
|
||||||
, _pressPlates = IM.empty
|
|
||||||
, _buttons = IM.empty
|
|
||||||
, _soundQueue = []
|
|
||||||
, _sounds = M.empty
|
|
||||||
, _corpses = IM.empty
|
|
||||||
, _decorations = IM.empty
|
|
||||||
, _storedLevel = Nothing
|
|
||||||
, _menuLayers = [LevelMenu 1]
|
|
||||||
, _worldState = M.empty
|
|
||||||
, _worldTriggers = S.empty
|
|
||||||
, _clickMousePos = (0,0)
|
|
||||||
, _pathGraph = Data.Graph.Inductive.Graph.empty
|
|
||||||
, _pathGraph' = []
|
|
||||||
, _pathPoints = IM.empty
|
|
||||||
, _pathInc = M.empty
|
|
||||||
, _carteDisplay = False
|
|
||||||
, _carteCenter = (0,0)
|
|
||||||
, _carteZoom = 0.5
|
|
||||||
, _carteRot = 0
|
|
||||||
, _lightSources = IM.empty
|
|
||||||
, _tempLightSources = [youLight]
|
|
||||||
, _closeActiveObjects = []
|
|
||||||
, _seenLocations = IM.fromList
|
|
||||||
[(0, (_crPos . you, "CURRENT POSITION"))
|
|
||||||
,(1, (const (0,0) , "START POSITION"))
|
|
||||||
]
|
|
||||||
, _selLocation = 0
|
|
||||||
, _keyConfig = defaultKeyConfigSDL
|
|
||||||
, _config = defaultConfig
|
|
||||||
, _sideEffects = []
|
|
||||||
, _doneSideEffects = []
|
|
||||||
, _debugFlags = defaultDebugFlags
|
|
||||||
, _inventoryMode = TopInventory
|
|
||||||
, _lClickHammer = HammerUp
|
|
||||||
, _foregroundDecorations =
|
|
||||||
[ setDepth (-0.1) $ color orange $ pictures
|
|
||||||
[ polygon $ rectNSEW 50 40 140 (-20)
|
|
||||||
, translate 60 45 $ scale 0.5 1 $ thickArc 0 pi 75 10
|
|
||||||
]
|
|
||||||
, setDepth (-0.2) $ rotate 0.75 $ pictures
|
|
||||||
$ map f [5,25,45,65]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
where
|
|
||||||
f x = polygon $ rectNSEW (x - 20) (x-22) 500 0
|
|
||||||
|
|
||||||
defaultCreature :: Creature
|
defaultCreature :: Creature
|
||||||
defaultCreature = Creature
|
defaultCreature = Creature
|
||||||
@@ -255,18 +175,6 @@ defaultPP = PressPlate
|
|||||||
, _ppID = -1
|
, _ppID = -1
|
||||||
, _ppText = "Pressure plate"
|
, _ppText = "Pressure plate"
|
||||||
}
|
}
|
||||||
defaultDebugFlags :: DebugFlags
|
|
||||||
defaultDebugFlags = DebugFlags
|
|
||||||
{ _noClip = False
|
|
||||||
, _displaySecondsPerFrame = True
|
|
||||||
}
|
|
||||||
youLight :: TempLightSource
|
|
||||||
youLight =
|
|
||||||
TLS { _tlsPos = (0,0)
|
|
||||||
,_tlsRad = 300
|
|
||||||
,_tlsIntensity = 0.1
|
|
||||||
,_tlsUpdate = \w _ -> (w, Just (youLight {_tlsPos = _crPos (you w)}))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Dodge.Initialisation where
|
module Dodge.Initialisation where
|
||||||
import Dodge.Default
|
import Dodge.Default.World
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Data.Menu
|
import Dodge.Data.Menu
|
||||||
import Dodge.Creature
|
import Dodge.Creature
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ doDrawing pdata w = do
|
|||||||
:: IO (GLmatrix GLfloat)
|
:: IO (GLmatrix GLfloat)
|
||||||
-- draw the lightmap. Probably changes the bound framebufferObject
|
-- draw the lightmap. Probably changes the bound framebufferObject
|
||||||
createLightMap pdata (w ^. config . shadow_resolution) wallPoints lightPoints viewFroms pmat
|
createLightMap pdata (w ^. config . shadow_resolution) wallPoints lightPoints viewFroms pmat
|
||||||
|
(foregroundPics w)
|
||||||
|
|
||||||
|
-- -- set the coordinate uniforms ready for drawing elements using world coordinates
|
||||||
|
-- setCommonUniforms pdata rot camzoom trans wins
|
||||||
|
|
||||||
-- draw the background. Assumes that depth testing is not enabled or that
|
-- draw the background. Assumes that depth testing is not enabled or that
|
||||||
-- the depth buffer is ready to be drawn on
|
-- the depth buffer is ready to be drawn on
|
||||||
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
||||||
|
|||||||
+11
-2
@@ -64,9 +64,10 @@ createLightMap
|
|||||||
-> [(Point2,Point2)] -- Wall pairs
|
-> [(Point2,Point2)] -- Wall pairs
|
||||||
-> [Point4] -- Lights
|
-> [Point4] -- Lights
|
||||||
-> (Float,Float) -- View from position
|
-> (Float,Float) -- View from position
|
||||||
-> GLmatrix GLfloat
|
-> GLmatrix GLfloat -- perspective matrix
|
||||||
|
-> Picture -- foreground pictures
|
||||||
-> IO ()
|
-> IO ()
|
||||||
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat = do
|
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat _ = do
|
||||||
|
|
||||||
-- get viewport size so we can reset it later
|
-- get viewport size so we can reset it later
|
||||||
(vppos,vpsize) <- get viewport
|
(vppos,vpsize) <- get viewport
|
||||||
@@ -99,6 +100,14 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat =
|
|||||||
$= (0 :: Float)
|
$= (0 :: Float)
|
||||||
cullFace $= Just Back
|
cullFace $= Just Back
|
||||||
drawShader (_lightingOccludeShader pdata) nWalls
|
drawShader (_lightingOccludeShader pdata) nWalls
|
||||||
|
|
||||||
|
cullFace $= Nothing
|
||||||
|
---- draw foreground elements to set z buffer
|
||||||
|
-- forM_ (_pictureShaders pdata) $ \shad -> do
|
||||||
|
-- currentProgram $= Just (_shaderProgram shad)
|
||||||
|
-- uniform (_shaderUniforms shad !! 4) $= pmat
|
||||||
|
-- _ <- renderFoldable pdata $ picToLTree (Just 0) fpics
|
||||||
|
|
||||||
-- for each of the lights:
|
-- for each of the lights:
|
||||||
-- stencil out the walls from this light's point of view
|
-- stencil out the walls from this light's point of view
|
||||||
-- draw fading lightmap circles on the floor
|
-- draw fading lightmap circles on the floor
|
||||||
|
|||||||
Reference in New Issue
Block a user