X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fmodel_character_view.fs;h=efee606c86b7b0151505dd268d258af035f9d8cd;hb=1d06671f87a9d24596fc6808d8e0db889a818750;hp=5f9ee647c90e2e8734d787b34ce7e149e139396c;hpb=02e009ae6e20938675277e9ce2f467e17b170cc7;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/model_character_view.fs b/shaders/model_character_view.fs index 5f9ee64..efee606 100644 --- a/shaders/model_character_view.fs +++ b/shaders/model_character_view.fs @@ -3,6 +3,7 @@ uniform sampler2D uTexSceneDepth; uniform vec3 uCamera; uniform vec3 uInverseRatioDepth; uniform vec3 uInverseRatioMain; +uniform bool uDepthCompare; in vec4 aColour; in vec2 aUv; @@ -30,19 +31,22 @@ void main() float dist = distance( aWorldCo, uCamera ) - 0.08; float opacity = clamp( dist*dist, 0.0, 1.0 ); - vec2 back_coord = gl_FragCoord.xy*uInverseRatioMain.xy*uInverseRatioDepth.xy; - float back_depth = texture( uTexSceneDepth, back_coord ).r; - float front_depth = gl_FragCoord.z/gl_FragCoord.w; + if( uDepthCompare ){ + vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy + * uInverseRatioDepth.xy; + float back_depth = texture( uTexSceneDepth, back_coord ).r; + float front_depth = gl_FragCoord.z/gl_FragCoord.w; - back_depth = linear_depth( back_depth, 0.1, 2100.0 ); - float diff = back_depth - front_depth; + back_depth = linear_depth( back_depth, 0.1, 2100.0 ); + float diff = back_depth - front_depth; - vec2 ssuv = gl_FragCoord.xy; - vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) ); - float dither = fract( vDither.g / 71.0 ) - 0.5; + vec2 ssuv = gl_FragCoord.xy; + vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) ); + float dither = fract( vDither.g / 71.0 ) - 0.5; - if( step(0.0,diff)+dither<0.3 ) - discard; + if( step(0.0,diff)+dither<0.3 ) + discard; + } oColour = vec4( composite, opacity ); }