return world_depth_sample( pos ) - ref_depth;
}
-float shadow_sample( vec3 vdir )
-{
- vec3 sample_pos = aWorldCo + vdir;
- float height_sample = world_depth_sample( sample_pos );
+float shadow_sample( vec3 co ){
+ float height_sample = world_depth_sample( co );
- float fdelta = height_sample - sample_pos.y;
+ float fdelta = height_sample - co.y;
return clamp( fdelta, 0.2, 0.4 )-0.2;
}
-float newlight_compute_sun_shadow( vec3 dir )
-{
- if( g_shadow_samples == 0 )
- {
+float newlight_compute_sun_shadow( vec3 co, vec3 dir ){
+ if( g_shadow_samples == 0 ){
return 1.0;
}
float flength = g_shadow_length;
float famt = 0.0;
- famt += shadow_sample((dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);
- famt += shadow_sample((dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);
- famt += shadow_sample((dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);
- famt += shadow_sample((dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);
+ famt += shadow_sample(co+(dir+vec3(-0.56,0.55, 0.30)*fspread)*flength*0.1);
+ famt += shadow_sample(co+(dir+vec3( 0.80,0.68, 0.34)*fspread)*flength*0.2);
+ famt += shadow_sample(co+(dir+vec3( 0.78,0.07,-0.06)*fspread)*flength*0.3);
+ famt += shadow_sample(co+(dir+vec3(-0.59,0.07,-0.42)*fspread)*flength*0.4);
- //famt+=shadow_sample((dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);
- //famt+=shadow_sample((dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);
- //famt+=shadow_sample((dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);
- //famt+=shadow_sample((dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);
+ //famt+=shadow_sample(co+(dir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);
+ //famt+=shadow_sample(co+(dir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);
+ //famt+=shadow_sample(co+(dir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);
+ //famt+=shadow_sample(co+(dir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);
return 1.0 - famt;
}
return pow(max(dot( halfview, specdir ), 0.0), exponent);
}
-vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist )
-{
+vec3 scene_apply_fog( vec3 vfrag, vec3 colour, float fdist ){
float dist = pow(fdist*0.0010,0.78);
return mix( vfrag, colour, min( 1.0, dist ) );
}
-vec3 rand33(vec3 p3)
-{
- p3 = fract(p3 * vec3(.1031, .1030, .0973));
- p3 += dot(p3, p3.yxz+33.33);
- return fract((p3.xxy + p3.yxx)*p3.zyx);
-}
-
vec3 scene_calculate_light( int light_index,
vec3 halfview, vec3 co, vec3 normal )
{
float fdist = length(halfview);
halfview /= fdist;
- float world_shadow = newlight_compute_sun_shadow( g_sun_dir.xyz
- * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );
+ float world_shadow = newlight_compute_sun_shadow(
+ co, g_sun_dir.xyz * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );
vec3 total_light = clearskies_lighting(
normal, min( light_mask, world_shadow ), halfview );