X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fdepth_compare.glsl;fp=shaders%2Fdepth_compare.glsl;h=c03b8f76e7a7b20a69fa1cba7020a5ba6eba793a;hb=1a194c3888293733939b2dd944251ae1b6c398ce;hp=5e02144f17b8a18b8f09b7537a4e1cfa8e006966;hpb=14851c4c820eb07a0db0ec0366a70bdd6518c331;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/depth_compare.glsl b/shaders/depth_compare.glsl index 5e02144..c03b8f7 100644 --- a/shaders/depth_compare.glsl +++ b/shaders/depth_compare.glsl @@ -1,15 +1,18 @@ uniform sampler2D uTexSceneDepth; uniform vec3 uInverseRatioDepth; uniform vec3 uInverseRatioMain; -uniform bool uDepthCompare; +uniform int uDepthMode; +uniform float uDitherCutoff; float linear_depth( float depth, float near, float far ) { float z = depth * 2.0 - 1.0; return (2.0 * near * far) / (far + near - z * (far - near)); } -void depth_compare_dither(){ - if( uDepthCompare ){ +void depth_compare_dither() +{ + if( uDepthMode == 1 ) + { vec2 back_coord = gl_FragCoord.xy * uInverseRatioMain.xy * uInverseRatioDepth.xy; float back_depth = texture( uTexSceneDepth, back_coord ).r; @@ -25,4 +28,12 @@ void depth_compare_dither(){ if( step(0.0,diff)+dither<0.3 ) discard; } + + if( uDepthMode == 2 ) + { + vec2 ssuv = gl_FragCoord.xy; + vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) ); + float dither = fract( vDither.g / 71.0 ); + if( dither