X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fcharacter.h;h=e592a94cddb753285badc6a66d3906bee818150d;hb=1030b1e134d422a3cbc1e06102053447da59ceba;hp=6c3ce7af268215a296fe765a81877c34db7c8048;hpb=1f1d636056450dcd23cce55c0795ec6276272531;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/character.h b/shaders/character.h index 6c3ce7a..e592a94 100644 --- a/shaders/character.h +++ b/shaders/character.h @@ -24,18 +24,21 @@ static struct vg_shader _shader_character = { "out vec2 aUv;\n" "out vec3 aNorm;\n" "out vec3 aCo;\n" +"out vec3 aWorldCo;\n" "out float aOpacity;\n" "\n" "void main()\n" "{\n" " vec3 world_pos = uMdl * vec4(a_co,1.0);\n" -" gl_Position = uPv * vec4(world_pos,1.0);\n" +" vec4 clip_pos = uPv * vec4(world_pos,1.0);\n" +" gl_Position = clip_pos;\n" "\n" " aColour = a_colour;\n" " aUv = a_uv;\n" " aNorm = mat3(uMdl) * a_norm;\n" +" aWorldCo = world_pos;\n" " aCo = a_co;\n" -" aOpacity = 1.0-(gl_Position.y+0.5)*uOpacity;\n" +" aOpacity = max(clip_pos.w*3.0,0.1);// 1.0-(gl_Position.y+0.5)*uOpacity;\n" "}\n" ""}, .fs = @@ -46,17 +49,130 @@ static struct vg_shader _shader_character = { "\n" "uniform sampler2D uTexMain;\n" "uniform vec4 uColour;\n" +"uniform vec3 uCamera;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" "in vec3 aNorm;\n" "in vec3 aCo;\n" +"in vec3 aWorldCo;\n" "in float aOpacity;\n" "\n" +"#line 1 1 \n" +"layout (std140) uniform ub_world_lighting\n" +"{\n" +" vec4 g_light_colours[3];\n" +" vec4 g_light_directions[3];\n" +" vec4 g_ambient_colour;\n" +"\n" +" vec4 g_water_plane;\n" +" vec4 g_depth_bounds;\n" +" float g_water_fog;\n" +" int g_light_count;\n" +" int g_light_preview;\n" +"};\n" +"\n" +"uniform sampler2D g_world_depth;\n" +"\n" +"// Standard diffuse + spec models\n" +"// ==============================\n" +"\n" +"vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n" +"{\n" +" vec3 vtotal = g_ambient_colour.rgb;\n" +"\n" +" for( int i=0; i