X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=shaders%2Fmodel_character_view.h;h=2017f7db76b844a612d883e67393a0a50df45751;hb=791f807111a1f740f745c67db642aa7a8bee56e8;hp=18d5c19062ec5d9afc1b92e55b68d3d1e19ec2e3;hpb=409edea2cf6271956137918e4e0b4f1c2addf620;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/model_character_view.h b/shaders/model_character_view.h index 18d5c19..2017f7d 100644 --- a/shaders/model_character_view.h +++ b/shaders/model_character_view.h @@ -7,6 +7,7 @@ static struct vg_shader _shader_model_character_view = { .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" @@ -71,6 +72,7 @@ static struct vg_shader _shader_model_character_view = { ""}, .fs = { +.orig_file = "shaders/model_character_view.fs", .static_src = "uniform sampler2D uTexMain;\n" "uniform vec3 uCamera;\n" @@ -93,10 +95,14 @@ static struct vg_shader _shader_model_character_view = { " 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" +" int g_debug_indices;\n" +" int g_debug_complexity;\n" +"\n" " // g_time ?\n" "\n" " //vec4 g_point_light_positions[32];\n" @@ -141,7 +147,7 @@ static struct vg_shader _shader_model_character_view = { " 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" @@ -149,7 +155,7 @@ static struct vg_shader _shader_model_character_view = { " }\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" @@ -191,8 +197,14 @@ static struct vg_shader _shader_model_character_view = { " 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" @@ -203,6 +215,24 @@ static struct vg_shader _shader_model_character_view = { " return light_colour*attenuation;\n" "}\n" "\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" @@ -242,7 +272,7 @@ static struct vg_shader _shader_model_character_view = { " 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"