X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fmodel_character_view.fs;h=6330f9bf13ebf5635c694ae3d6cfdbaeaf41813b;hb=137d40d96fe923600d8378b8e138e3c276f27ff4;hp=efee606c86b7b0151505dd268d258af035f9d8cd;hpb=f1fe55f957a3dbdb6ca20a696f0c1171e2d5e7ca;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/model_character_view.fs b/shaders/model_character_view.fs index efee606..6330f9b 100644 --- a/shaders/model_character_view.fs +++ b/shaders/model_character_view.fs @@ -1,9 +1,5 @@ uniform sampler2D uTexMain; -uniform sampler2D uTexSceneDepth; uniform vec3 uCamera; -uniform vec3 uInverseRatioDepth; -uniform vec3 uInverseRatioMain; -uniform bool uDepthCompare; in vec4 aColour; in vec2 aUv; @@ -13,15 +9,10 @@ in vec3 aWorldCo; #include "common_world.glsl" #include "motion_vectors_fs.glsl" +#include "depth_compare.glsl" -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 main() -{ +void main(){ + depth_compare_dither(); compute_motion_vectors(); vec3 qnorm = aNorm; @@ -31,22 +22,5 @@ void main() float dist = distance( aWorldCo, uCamera ) - 0.08; float opacity = clamp( dist*dist, 0.0, 1.0 ); - 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; - - 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; - } - oColour = vec4( composite, opacity ); }