X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fgpos.h;h=d140abbf36a45208faa2b9733aabc657000e47c0;hb=98ecdd9f0377f1563566fe4d3d3b8185a055ec4d;hp=6b8d9cbd0576d32a4c240e75ce057a735b596492;hpb=ecc4dfbfb3adf91d2dfc03ba0ec9a821fcc2390c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/gpos.h b/shaders/gpos.h index 6b8d9cb..d140abb 100644 --- a/shaders/gpos.h +++ b/shaders/gpos.h @@ -23,14 +23,17 @@ static struct vg_shader _shader_gpos = { "out vec2 aUv;\n" "out vec3 aNorm;\n" "out vec3 aCo;\n" +"out vec3 aWorldCo;\n" "\n" "void main()\n" "{\n" -" gl_Position = uPv * vec4( uMdl * vec4(a_co,1.0), 1.0 );\n" +" vec3 world_pos = uMdl * vec4(a_co,1.0);\n" +" gl_Position = uPv * vec4( world_pos, 1.0 );\n" " aColour = a_colour;\n" " aUv = a_uv;\n" " aNorm = mat3(uMdl) * a_norm;\n" " aCo = a_co;\n" +" aWorldCo = world_pos;\n" "}\n" ""}, .fs = @@ -45,16 +48,20 @@ static struct vg_shader _shader_gpos = { "in vec2 aUv;\n" "in vec3 aNorm;\n" "in vec3 aCo;\n" +"in vec3 aWorldCo;\n" "\n" "#line 1 1 \n" "layout (std140) uniform ub_world_lighting\n" "{\n" -" vec3 g_directional;\n" -" vec3 g_sun_colour;\n" -" vec3 g_shadow_colour;\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" @@ -64,15 +71,28 @@ static struct vg_shader _shader_gpos = { "\n" "vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n" "{\n" -" float flight = dot( g_directional, wnormal )*0.5+0.5;\n" -" return vfrag * mix( g_shadow_colour, g_sun_colour, flight );\n" +" vec3 vtotal = g_ambient_colour.rgb;\n" +"\n" +" for( int i=0; i