diff --git a/shader/arc.vert b/shader/arc.vert index e436d45c0..9f1d9b726 100644 --- a/shader/arc.vert +++ b/shader/arc.vert @@ -10,10 +10,26 @@ uniform float zoom; uniform vec2 translation; uniform float rotation; +vec2 tran(vec2 v) +{ + return (v - translation); +} +vec2 rot(vec2 v) +{ + return vec2 ( v.x * cos(-rotation) - v.y * sin(-rotation) + , v.x * sin(-rotation) + v.y * cos(-rotation) + ); +} +vec2 scal(vec2 v) +{ + return vec2 ( 2 * v.x * zoom / winSize.x + , 2 * v.y * zoom / winSize.y + ); +} + void main() { - gl_Position = vec4(position,1); - //gl_Position = vec4(0,0,0,1); + gl_Position = vec4(scal(rot(tran(position.xy))),position.z,1); vColor = color; vparams = saEaRadWdth; } diff --git a/shader/background.geom b/shader/background.geom index 7a7529817..adee13cd6 100644 --- a/shader/background.geom +++ b/shader/background.geom @@ -6,6 +6,8 @@ in vec2 vWinSize []; out vec2 gTexPos; uniform vec2 translation; +uniform float zoom; +uniform float rotation; vec2 rotBy( float rot, vec2 v) { @@ -18,8 +20,8 @@ vec2 rotBy( float rot, vec2 v) void main() { vec2 cPos = vec2(translation.x / 250 , translation.y /250 ); - float zoom = vParams[0].w; - float rot = 0 - vParams[0].z; +// float zoom = vParams[0].w; + float rot = 0 - rotation; float x = vWinSize[0].x / (500*zoom) ; float y = vWinSize[0].y / (500*zoom) ; diff --git a/shader/basic.vert b/shader/basic.vert index c1a82c0a8..748c5ebfc 100644 --- a/shader/basic.vert +++ b/shader/basic.vert @@ -8,8 +8,25 @@ uniform float zoom; uniform float rotation; uniform vec2 translation; +vec2 tran(vec2 v) +{ + return (v - translation); +} +vec2 rot(vec2 v) +{ + return vec2 ( v.x * cos(-rotation) - v.y * sin(-rotation) + , v.x * sin(-rotation) + v.y * cos(-rotation) + ); +} +vec2 scal(vec2 v) +{ + return vec2 ( 2 * v.x * zoom / winSize.x + , 2 * v.y * zoom / winSize.y + ); +} + void main() { - gl_Position = vec4(position,1); + gl_Position = vec4(scal(rot(tran(position.xy))),position.z,1); vColor = color; } diff --git a/shader/circle.vert b/shader/circle.vert index 32bf3612f..108c229d1 100644 --- a/shader/circle.vert +++ b/shader/circle.vert @@ -10,10 +10,25 @@ uniform float zoom; uniform vec2 translation; uniform float rotation; +vec2 tran(vec2 v) +{ + return (v - translation); +} +vec2 rot(vec2 v) +{ + return vec2 ( v.x * cos(-rotation) - v.y * sin(-rotation) + , v.x * sin(-rotation) + v.y * cos(-rotation) + ); +} +vec2 scal(vec2 v) +{ + return vec2 ( 2 * v.x * zoom / winSize.x + , 2 * v.y * zoom / winSize.y + ); +} void main() { - gl_Position = vec4(position,1); - //gl_Position = vec4(0,0,0,1); + gl_Position = vec4(scal(rot(tran(position.xy))),position.z,1); vColor = color; vRad = rad; } diff --git a/src/Dodge/Rendering.hs b/src/Dodge/Rendering.hs index d87f6034e..52488dcf4 100644 --- a/src/Dodge/Rendering.hs +++ b/src/Dodge/Rendering.hs @@ -72,8 +72,8 @@ worldPictures w , smokeShadows ] where - screenShift = scale zoomx zoomy . rotate (0 - (_cameraRot w) ) - . uncurry translate ((0,0) -.- _cameraPos w) + screenShift = id--scale zoomx zoomy . rotate (0 - (_cameraRot w) ) + -- . uncurry translate ((0,0) -.- _cameraPos w) zoomx = 2 * _cameraZoom w / _windowX w zoomy = 2 * _cameraZoom w / _windowY w scaler = scale (2 / _windowX w) (2 / _windowY w) diff --git a/src/Picture/Render.hs b/src/Picture/Render.hs index e139f06a6..7cb6253b0 100644 --- a/src/Picture/Render.hs +++ b/src/Picture/Render.hs @@ -358,13 +358,27 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One)) clear [DepthBuffer] -- draw layer 0 - renderTree pdata rot zoom (tranx,trany) (winx,winy) (picToList 0 pic) + renderTree pdata rot zoom (tranx,trany) (winx,winy) (picToFTree 0 pic) -- reset blend so that light map doesn't apply blendFunc $= (SrcAlpha,OneMinusSrcAlpha) - renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToList 1 pic + renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 1 pic -- set drawing for on top blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One)) - renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToList 2 pic + renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 2 pic +-- reset uniforms (hacky for now) + forM_ [_basicShader pdata + ,_textShader pdata + ,_circShader pdata + ,_arcShader pdata + ,_fadeCircleShader pdata + ,_backShader pdata + ,_wallShadowShader pdata + ] $ \shad -> do + currentProgram $= Just (fst shad) + uniform (snd shad !! 0) $= Vector2 (2::Float) 2 + uniform (snd shad !! 1) $= (1::Float) + uniform (snd shad !! 2) $= (0::Float) + uniform (snd shad !! 3) $= Vector2 (0::Float) 0 bufferOffset :: Integral a => a -> Ptr b