From 4319bad3c312545e56c236a0515d1c1e9cdbf03d Mon Sep 17 00:00:00 2001 From: Joshua Rahm Date: Tue, 22 Apr 2014 02:58:19 -0600 Subject: refined sun, added ability to grab input without full screening --- Resources.hs | 5 +++++ shaders/sky.frag | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Resources.hs b/Resources.hs index 79681ca..45a5416 100644 --- a/Resources.hs +++ b/Resources.hs @@ -142,7 +142,12 @@ eventHandle event res = do ret <- reshape 1920 1080 res SDL.toggleFullscreen $ rSurface ret SDL.showCursor False + SDL.grabInput True return ret + KeyUp (Keysym SDLK_g _ _) -> do + SDL.showCursor False + SDL.grabInput True + return res _ -> return res displayHandle :: Resources -> IO Resources diff --git a/shaders/sky.frag b/shaders/sky.frag index c81c8b0..6d47adb 100644 --- a/shaders/sky.frag +++ b/shaders/sky.frag @@ -13,17 +13,21 @@ uniform sampler2D night_tex ; in vec2 texcoord; in vec4 position ; +float exp1( float x ) { + return 2 / (1+exp(-x))-1; +} void main() { // the sun vec3 lighttofrag = vec3(position*10000000 - lightpos) ; vec3 lighttocamera = vec3(lightpos) ; - vec4 mul = vec4(vec3( sqrt(0.001 / (1 - dot(normalize(lighttocamera), normalize(lighttofrag))))), 1) ; - mul *= vec4(1.0,0.95,0.8,1.0) ; + float coef = 1 - dot(normalize(lighttocamera), normalize(lighttofrag)); + vec4 mul = vec4(vec3( pow(0.0005 / coef,0.8)), 1) ; + mul *= vec4(1.0,0.85,0.5,1.0) ; frag_color = mix(texture2D(night_tex,texcoord) * (1-globalAmbient.a), texture2D(texture,texcoord) * vec4(normalize(globalAmbient.xyz),1), - (globalAmbient.a + 1) / 2) ; - frag_color += mul ; + (globalAmbient.a + 1) / 2) * 1.8 ; + frag_color = frag_color + mul ; } -- cgit