X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=shaders%2Fscene_fxglow.h;h=b54f58f35ae2328363b1ad394c334f8361d0180e;hb=2c91a71533b4ce86b9e7fd708420ae05c74d8f52;hp=e67c665709aa28ad647d1ff36a8cc089161cd0f9;hpb=4c673ebccdd6d12e2eb6c2804b79602da98ea8b1;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/scene_fxglow.h b/shaders/scene_fxglow.h index e67c665..b54f58f 100644 --- a/shaders/scene_fxglow.h +++ b/shaders/scene_fxglow.h @@ -7,7 +7,7 @@ static struct vg_shader _shader_scene_fxglow = { .link = shader_scene_fxglow_link, .vs = { -.orig_file = "shaders/scene.vs", +.orig_file = "shaders/scene_fxglow.vs", .static_src = "layout (location=0) in vec3 a_co;\n" "layout (location=1) in vec4 a_norm;\n" @@ -36,6 +36,7 @@ static struct vg_shader _shader_scene_fxglow = { "uniform mat4x3 uMdl;\n" "uniform mat4 uPv;\n" "uniform mat4 uPvmPrev;\n" +"uniform vec2 uUvOffset;\n" "\n" "out vec2 aUv;\n" "out vec4 aNorm;\n" @@ -52,7 +53,7 @@ static struct vg_shader _shader_scene_fxglow = { "\n" " gl_Position = vproj0;\n" "\n" -" aUv = a_uv;\n" +" aUv = a_uv + uUvOffset;\n" " aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n" " aCo = a_co;\n" " aWorldCo = world_pos0;\n" @@ -208,19 +209,15 @@ static struct vg_shader _shader_scene_fxglow = { " return world_depth_sample( pos ) - ref_depth;\n" "}\n" "\n" -"float shadow_sample( vec3 vdir )\n" -"{\n" -" vec3 sample_pos = aWorldCo + vdir;\n" -" float height_sample = world_depth_sample( sample_pos );\n" +"float shadow_sample( vec3 co ){\n" +" float height_sample = world_depth_sample( co );\n" "\n" -" float fdelta = height_sample - sample_pos.y;\n" +" float fdelta = height_sample - co.y;\n" " return clamp( fdelta, 0.2, 0.4 )-0.2;\n" "}\n" "\n" -"float newlight_compute_sun_shadow( vec3 dir )\n" -"{\n" -" if( g_shadow_samples == 0 )\n" -" {\n" +"float newlight_compute_sun_shadow( vec3 co, vec3 dir ){\n" +" if( g_shadow_samples == 0 ){\n" " return 1.0;\n" " }\n" "\n" @@ -228,15 +225,15 @@ static struct vg_shader _shader_scene_fxglow = { " float flength = g_shadow_length;\n" "\n" " float famt = 0.0;\n" -" famt += shadow_sample((dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" -" famt += shadow_sample((dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" -" famt += shadow_sample((dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" -" famt += shadow_sample((dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" +" famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);\n" +" famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);\n" +" famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);\n" +" famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);\n" "\n" -" //famt+=shadow_sample((dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" -" //famt+=shadow_sample((dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" -" //famt+=shadow_sample((dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" -" //famt+=shadow_sample((dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" +" //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n" +" //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n" +" //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n" +" //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n" "\n" " return 1.0 - famt;\n" "}\n" @@ -273,7 +270,7 @@ static struct vg_shader _shader_scene_fxglow = { " light_delta = normalize( light_delta );\n" "\n" " float quadratic = dist2*100.0;\n" -" float attenuation = 1.0f/( 1.0f + quadratic );\n" +" float attenuation = 1.0/( 1.0 + quadratic );\n" " attenuation *= max( dot( light_delta, normal ), 0.0 );\n" "\n" " float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n" @@ -324,8 +321,8 @@ static struct vg_shader _shader_scene_fxglow = { " float fdist = length(halfview);\n" " halfview /= fdist;\n" "\n" -" float world_shadow = newlight_compute_sun_shadow( g_sun_dir.xyz \n" -" * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" +" float world_shadow = newlight_compute_sun_shadow( \n" +" co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );\n" "\n" " vec3 total_light = clearskies_lighting( \n" " normal, min( light_mask, world_shadow ), halfview );\n" @@ -424,9 +421,8 @@ static struct vg_shader _shader_scene_fxglow = { "\n" "#line 6 0 \n" "\n" -"void main()\n" -"{\n" -" compute_motion_vectors();\n" +"void main(){\n" +" oMotionVec = vec2(0.0);\n" "\n" " vec4 vsamplemain = texture( uTexMain, aUv );\n" "\n" @@ -445,6 +441,7 @@ static struct vg_shader _shader_scene_fxglow = { static GLuint _uniform_scene_fxglow_uMdl; static GLuint _uniform_scene_fxglow_uPv; static GLuint _uniform_scene_fxglow_uPvmPrev; +static GLuint _uniform_scene_fxglow_uUvOffset; static GLuint _uniform_scene_fxglow_uTexMain; static GLuint _uniform_scene_fxglow_uCamera; static GLuint _uniform_scene_fxglow_g_world_depth; @@ -459,6 +456,9 @@ static void shader_scene_fxglow_uPv(m4x4f m){ static void shader_scene_fxglow_uPvmPrev(m4x4f m){ glUniformMatrix4fv(_uniform_scene_fxglow_uPvmPrev,1,GL_FALSE,(float*)m); } +static void shader_scene_fxglow_uUvOffset(v2f v){ + glUniform2fv(_uniform_scene_fxglow_uUvOffset,1,v); +} static void shader_scene_fxglow_uTexMain(int i){ glUniform1i(_uniform_scene_fxglow_uTexMain,i); } @@ -476,6 +476,7 @@ static void shader_scene_fxglow_link(void){ _uniform_scene_fxglow_uMdl = glGetUniformLocation( _shader_scene_fxglow.id, "uMdl" ); _uniform_scene_fxglow_uPv = glGetUniformLocation( _shader_scene_fxglow.id, "uPv" ); _uniform_scene_fxglow_uPvmPrev = glGetUniformLocation( _shader_scene_fxglow.id, "uPvmPrev" ); + _uniform_scene_fxglow_uUvOffset = glGetUniformLocation( _shader_scene_fxglow.id, "uUvOffset" ); _uniform_scene_fxglow_uTexMain = glGetUniformLocation( _shader_scene_fxglow.id, "uTexMain" ); _uniform_scene_fxglow_uCamera = glGetUniformLocation( _shader_scene_fxglow.id, "uCamera" ); _uniform_scene_fxglow_g_world_depth = glGetUniformLocation( _shader_scene_fxglow.id, "g_world_depth" );