X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fmodel_character_view.h;h=5394dc8c0445de3e145fc9af09b22cd77dd2d355;hb=c52dacb7bc07e300312e45d605d206222dcbb181;hp=55f88315930ada60967f19ca9a849fe215ea3eb2;hpb=02e009ae6e20938675277e9ce2f467e17b170cc7;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/model_character_view.h b/shaders/model_character_view.h index 55f8831..5394dc8 100644 --- a/shaders/model_character_view.h +++ b/shaders/model_character_view.h @@ -79,6 +79,7 @@ static struct vg_shader _shader_model_character_view = { "uniform vec3 uCamera;\n" "uniform vec3 uInverseRatioDepth;\n" "uniform vec3 uInverseRatioMain;\n" +"uniform bool uDepthCompare;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" @@ -388,7 +389,7 @@ static struct vg_shader _shader_model_character_view = { " return scene_apply_fog( diffuse * total_light, fog_colour, fdist );\n" "}\n" "\n" -"#line 14 0 \n" +"#line 15 0 \n" "#line 1 2 \n" "const float k_motion_lerp_amount = 0.01;\n" "\n" @@ -408,7 +409,7 @@ static struct vg_shader _shader_model_character_view = { " oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" -"#line 15 0 \n" +"#line 16 0 \n" "\n" "float linear_depth( float depth, float near, float far ) \n" "{\n" @@ -427,19 +428,22 @@ static struct vg_shader _shader_model_character_view = { " float dist = distance( aWorldCo, uCamera ) - 0.08;\n" " float opacity = clamp( dist*dist, 0.0, 1.0 );\n" "\n" -" vec2 back_coord = gl_FragCoord.xy*uInverseRatioMain.xy*uInverseRatioDepth.xy;\n" -" float back_depth = texture( uTexSceneDepth, back_coord ).r;\n" -" float front_depth = gl_FragCoord.z/gl_FragCoord.w;\n" +" if( uDepthCompare ){\n" +" vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy \n" +" * uInverseRatioDepth.xy;\n" +" float back_depth = texture( uTexSceneDepth, back_coord ).r;\n" +" float front_depth = gl_FragCoord.z/gl_FragCoord.w;\n" "\n" -" back_depth = linear_depth( back_depth, 0.1, 2100.0 );\n" -" float diff = back_depth - front_depth;\n" +" back_depth = linear_depth( back_depth, 0.1, 2100.0 );\n" +" float diff = back_depth - front_depth;\n" "\n" -" vec2 ssuv = gl_FragCoord.xy;\n" -" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" -" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" +" vec2 ssuv = gl_FragCoord.xy;\n" +" vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );\n" +" float dither = fract( vDither.g / 71.0 ) - 0.5;\n" "\n" -" if( step(0.0,diff)+dither<0.3 )\n" -" discard;\n" +" if( step(0.0,diff)+dither<0.3 )\n" +" discard;\n" +" }\n" "\n" " oColour = vec4( composite, opacity );\n" "}\n" @@ -453,6 +457,7 @@ static GLuint _uniform_model_character_view_uTexSceneDepth; static GLuint _uniform_model_character_view_uCamera; static GLuint _uniform_model_character_view_uInverseRatioDepth; static GLuint _uniform_model_character_view_uInverseRatioMain; +static GLuint _uniform_model_character_view_uDepthCompare; static GLuint _uniform_model_character_view_g_world_depth; static GLuint _uniform_model_character_view_uLightsArray; static GLuint _uniform_model_character_view_uLightsIndex; @@ -474,6 +479,9 @@ static void shader_model_character_view_uInverseRatioDepth(v3f v){ static void shader_model_character_view_uInverseRatioMain(v3f v){ glUniform3fv(_uniform_model_character_view_uInverseRatioMain,1,v); } +static void shader_model_character_view_uDepthCompare(int b){ + glUniform1f(_uniform_model_character_view_uDepthCompare,b); +} static void shader_model_character_view_g_world_depth(int i){ glUniform1i(_uniform_model_character_view_g_world_depth,i); } @@ -489,6 +497,7 @@ static void shader_model_character_view_link(void){ _uniform_model_character_view_uCamera = glGetUniformLocation( _shader_model_character_view.id, "uCamera" ); _uniform_model_character_view_uInverseRatioDepth = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioDepth" ); _uniform_model_character_view_uInverseRatioMain = glGetUniformLocation( _shader_model_character_view.id, "uInverseRatioMain" ); + _uniform_model_character_view_uDepthCompare = glGetUniformLocation( _shader_model_character_view.id, "uDepthCompare" ); _uniform_model_character_view_g_world_depth = glGetUniformLocation( _shader_model_character_view.id, "g_world_depth" ); _uniform_model_character_view_uLightsArray = glGetUniformLocation( _shader_model_character_view.id, "uLightsArray" ); _uniform_model_character_view_uLightsIndex = glGetUniformLocation( _shader_model_character_view.id, "uLightsIndex" );