.link = shader_model_character_view_link,
.vs =
{
+.orig_file = "shaders/model_skinned.vs",
.static_src =
"layout (location=0) in vec3 a_co;\n"
"layout (location=1) in vec3 a_norm;\n"
""},
.fs =
{
+.orig_file = "shaders/model_character_view.fs",
.static_src =
"uniform sampler2D uTexMain;\n"
"uniform vec3 uCamera;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
"\n"
"in vec4 aColour;\n"
"in vec2 aUv;\n"
" vec4 g_water_plane;\n"
" vec4 g_depth_bounds;\n"
" float g_water_fog;\n"
+" float g_time;\n"
" int g_light_count;\n"
" int g_light_preview;\n"
" int g_shadow_samples;\n"
"\n"
-" vec4 g_point_light_positions[32];\n"
-" vec4 g_point_light_colours[32];\n"
+" int g_debug_indices;\n"
+" int g_debug_complexity;\n"
+"\n"
+" // g_time ?\n"
+"\n"
+" //vec4 g_point_light_positions[32];\n"
+" //vec4 g_point_light_colours[32];\n"
"};\n"
"\n"
"uniform sampler2D g_world_depth;\n"
" return texture( g_world_depth, depth_coord ).r;\n"
"}\n"
"\n"
+"float world_water_depth( vec3 pos )\n"
+"{\n"
+" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
+" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
+" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+"}\n"
+"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec3 sample_pos = aWorldCo + vdir;\n"
" return clamp( fdelta, 0.1, 0.2 )-0.1;\n"
"}\n"
"\n"
-"float sdLine( vec3 p, vec3 a, vec3 b )\n"
-"{\n"
-" vec3 pa = p - a;\n"
-" vec3 ba = b - a;\n"
-"\n"
-" float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );\n"
-" return length( pa - ba*h );\n"
-"}\n"
-"\n"
"vec3 apply_fog( vec3 vfrag, float fdist )\n"
"{\n"
" float dist = pow(fdist*0.0008,1.2);\n"
" return g_ambient_colour.rgb;\n"
"}\n"
"\n"
-"float newlight_compute_sun_shadow()\n"
+"float newlight_compute_sun_shadow( vec3 dir )\n"
"{\n"
" if( g_shadow_samples == 0 )\n"
" {\n"
" }\n"
"\n"
" float fspread = g_light_colours[0].w;\n"
-" vec3 vdir = g_light_directions[0].xyz;\n"
+" vec3 vdir = dir;\n"
" float flength = g_light_directions[0].w;\n"
"\n"
" float famt = 0.0;\n"
" famt+=shadow_sample((vdir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n"
" famt+=shadow_sample((vdir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n"
"\n"
-" // player shadow\n"
-" float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
-" float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
-" player_shadow *= player_shadow*player_shadow*player_shadow;\n"
-"\n"
-" return 1.0 - max( player_shadow*0.8, famt );\n"
+" return 1.0 - famt;\n"
"}\n"
"\n"
"vec3 newlight_compute_world_diffuse( vec3 wnormal )\n"
" return vcolour*spec*fintensity;\n"
"}\n"
"\n"
+"float newlight_specular( vec3 wnormal, vec3 dir, vec3 halfview, float exponent )\n"
+"{\n"
+" vec3 specdir = reflect( -dir, wnormal );\n"
+" return pow(max(dot( halfview, specdir ), 0.0), exponent);\n"
+"}\n"
+"\n"
"vec3 newlight_compute_quadratic( vec3 wnormal, vec3 halfview, \n"
-" vec3 light_pos, vec3 light_colour )\n"
+" vec3 light_colour, vec3 light_pos )\n"
"{\n"
" vec3 light_delta = (light_pos-aWorldCo) * 10.0;\n"
"\n"
" return light_colour*attenuation;\n"
"}\n"
"\n"
-"#line 13 0 \n"
+"vec3 newlight_compute_spot( vec3 wnormal, vec3 halfview, \n"
+" vec3 light_colour, vec3 light_pos,\n"
+" vec4 light_dir )\n"
+"{\n"
+" vec3 light_delta = (light_pos-aWorldCo) * 10.0;\n"
+"\n"
+" float quadratic = dot(light_delta,light_delta);\n"
+" float attenuation = 1.0f/( 1.0f + quadratic );\n"
+"\n"
+" light_delta = normalize( light_delta );\n"
+" attenuation *= max( 0.0, dot( light_delta, wnormal ) );\n"
+"\n"
+" float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) ),\n"
+" falloff = max( 0.0,( spot_theta - light_dir.w ) / (1.0-light_dir.w) );\n"
+"\n"
+" return light_colour*attenuation*falloff;\n"
+"}\n"
+"\n"
+"#line 11 0 \n"
"#line 1 2 \n"
"const float k_motion_lerp_amount = 0.01;\n"
"\n"
" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
"}\n"
"\n"
-"#line 14 0 \n"
+"#line 12 0 \n"
"\n"
"void main()\n"
"{\n"
" vec3 total_light = newlight_compute_ambient();\n"
" vec3 world_light = newlight_compute_world_diffuse( qnorm );\n"
"\n"
-" float world_shadow = newlight_compute_sun_shadow();\n"
+" float world_shadow = newlight_compute_sun_shadow( vec3(1.0) );\n"
" total_light += world_light * world_shadow;\n"
"\n"
" vfrag = apply_fog( vfrag * total_light, fdist );\n"
static GLuint _uniform_model_character_view_uTransforms;
static GLuint _uniform_model_character_view_uTexMain;
static GLuint _uniform_model_character_view_uCamera;
-static GLuint _uniform_model_character_view_uBoard0;
-static GLuint _uniform_model_character_view_uBoard1;
static GLuint _uniform_model_character_view_g_world_depth;
static void shader_model_character_view_uPv(m4x4f m){
glUniformMatrix4fv(_uniform_model_character_view_uPv,1,GL_FALSE,(float*)m);
static void shader_model_character_view_uCamera(v3f v){
glUniform3fv(_uniform_model_character_view_uCamera,1,v);
}
-static void shader_model_character_view_uBoard0(v3f v){
- glUniform3fv(_uniform_model_character_view_uBoard0,1,v);
-}
-static void shader_model_character_view_uBoard1(v3f v){
- glUniform3fv(_uniform_model_character_view_uBoard1,1,v);
-}
static void shader_model_character_view_g_world_depth(int i){
glUniform1i(_uniform_model_character_view_g_world_depth,i);
}
_uniform_model_character_view_uTransforms = glGetUniformLocation( _shader_model_character_view.id, "uTransforms" );
_uniform_model_character_view_uTexMain = glGetUniformLocation( _shader_model_character_view.id, "uTexMain" );
_uniform_model_character_view_uCamera = glGetUniformLocation( _shader_model_character_view.id, "uCamera" );
- _uniform_model_character_view_uBoard0 = glGetUniformLocation( _shader_model_character_view.id, "uBoard0" );
- _uniform_model_character_view_uBoard1 = glGetUniformLocation( _shader_model_character_view.id, "uBoard1" );
_uniform_model_character_view_g_world_depth = glGetUniformLocation( _shader_model_character_view.id, "g_world_depth" );
}
#endif /* SHADER_model_character_view_H */