diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-08-14 22:37:31 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-08-14 22:46:13 +0300 |
commit | 4a3348cfe049620b9f8bcf421562ff8264bc79fa (patch) | |
tree | 54392240b6a6f491be64899de7efee0ae13b69ea /source/blender/gpu/shaders | |
parent | 4fcca6a0abb4bc19854c0a41c00725954345248d (diff) |
GPUShader: Remove some of the unused shaders
keeping GPU_SHADER_SMOKE until other occurences are removed.
Diffstat (limited to 'source/blender/gpu/shaders')
14 files changed, 0 insertions, 980 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl b/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl deleted file mode 100644 index c4e7cff2b0b..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl +++ /dev/null @@ -1,15 +0,0 @@ -uniform sampler2D depthbuffer; - -in vec4 uvcoordsvar; - -void main(void) -{ - float depth = texture(depthbuffer, uvcoordsvar.xy).r; - - /* XRay background, discard */ - if (depth >= 1.0) { - discard; - } - - gl_FragDepth = depth; -} diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl deleted file mode 100644 index 15d30e75969..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl +++ /dev/null @@ -1,209 +0,0 @@ -/* amount of offset to move one pixel left-right. - * In second pass some dimensions are zero to control verical/horizontal convolution */ -uniform vec2 invrendertargetdim; -// color buffer -uniform sampler2D colorbuffer; -//blurred color buffer for DOF effect -uniform sampler2D blurredcolorbuffer; -// slightly blurred buffer -uniform sampler2D mblurredcolorbuffer; -// depth buffer -uniform sampler2D depthbuffer; - -// this includes focal distance in x and aperture size in y -uniform vec4 dof_params; - -// viewvectors for reconstruction of world space -uniform vec4 viewvecs[3]; - -// coordinates on framebuffer in normalized (0.0-1.0) uv space -in vec4 uvcoordsvar; - -/* color texture coordinates, offset by a small amount */ -in vec2 color_uv1; -in vec2 color_uv2; - -in vec2 depth_uv1; -in vec2 depth_uv2; -in vec2 depth_uv3; -in vec2 depth_uv4; - -out vec4 FragColor; - -float calculate_far_coc(in float zdepth) -{ - float coc = dof_params.x * max(1.0 - dof_params.y / zdepth, 0.0); - - /* multiply by 1.0 / sensor size to get the normalized size */ - return coc * dof_params.z; -} - -/* near coc only! when distance is nearer than focus plane first term is bigger than one */ -vec4 calculate_near_coc(in vec4 zdepth) -{ - vec4 coc = dof_params.x * max(vec4(dof_params.y) / zdepth - vec4(1.0), vec4(0.0)); - - /* multiply by 1.0 / sensor size to get the normalized size */ - return coc * dof_params.z; -} - -/* first pass blurs the color buffer heavily and gets the near coc only. - * There are many texture accesses here but they are done on a - * lower resolution image so overall bandwidth is not a concern */ -void first_pass() -{ - vec4 depth; - vec4 zdepth; - vec4 coc; - float final_coc; - - /* amount to add to uvs so that they move one row further */ - vec2 offset_row[3]; - offset_row[0] = vec2(0.0, invrendertargetdim.y); - offset_row[1] = 2.0 * offset_row[0]; - offset_row[2] = 3.0 * offset_row[0]; - - /* heavily blur the image */ - vec4 color = texture(colorbuffer, color_uv1); - color += texture(colorbuffer, color_uv1 + offset_row[1]); - color += texture(colorbuffer, color_uv2); - color += texture(colorbuffer, color_uv2 + offset_row[1]); - color /= 4.0; - - depth.r = texture(depthbuffer, depth_uv1).r; - depth.g = texture(depthbuffer, depth_uv2).r; - depth.b = texture(depthbuffer, depth_uv3).r; - depth.a = texture(depthbuffer, depth_uv4).r; - - zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth); - coc = calculate_near_coc(zdepth); - - depth.r = texture(depthbuffer, depth_uv1 + offset_row[0]).r; - depth.g = texture(depthbuffer, depth_uv2 + offset_row[0]).r; - depth.b = texture(depthbuffer, depth_uv3 + offset_row[0]).r; - depth.a = texture(depthbuffer, depth_uv4 + offset_row[0]).r; - - zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth); - coc = max(calculate_near_coc(zdepth), coc); - - depth.r = texture(depthbuffer, depth_uv1 + offset_row[1]).r; - depth.g = texture(depthbuffer, depth_uv2 + offset_row[1]).r; - depth.b = texture(depthbuffer, depth_uv3 + offset_row[1]).r; - depth.a = texture(depthbuffer, depth_uv4 + offset_row[1]).r; - - zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth); - coc = max(calculate_near_coc(zdepth), coc); - - depth.r = texture(depthbuffer, depth_uv1 + offset_row[2]).r; - depth.g = texture(depthbuffer, depth_uv2 + offset_row[2]).r; - depth.b = texture(depthbuffer, depth_uv3 + offset_row[2]).r; - depth.a = texture(depthbuffer, depth_uv4 + offset_row[2]).r; - - zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth); - coc = max(calculate_near_coc(zdepth), coc); - - final_coc = max(max(coc.x, coc.y), max(coc.z, coc.w)); - FragColor = vec4(color.rgb, final_coc); -} - -/* second pass, gaussian blur the downsampled image */ -void second_pass() -{ - vec4 depth = vec4(texture(depthbuffer, uvcoordsvar.xy).r); - - /* clever sampling to sample 2 pixels at once. Of course it's not real gaussian sampling this way */ - vec4 color = texture(colorbuffer, uvcoordsvar.xy) * 0.3125; - color += texture(colorbuffer, uvcoordsvar.xy + invrendertargetdim) * 0.234375; - color += texture(colorbuffer, uvcoordsvar.xy + 2.5 * invrendertargetdim) * 0.09375; - color += texture(colorbuffer, uvcoordsvar.xy + 4.5 * invrendertargetdim) * 0.015625; - color += texture(colorbuffer, uvcoordsvar.xy - invrendertargetdim) * 0.234375; - color += texture(colorbuffer, uvcoordsvar.xy - 2.5 * invrendertargetdim) * 0.09375; - color += texture(colorbuffer, uvcoordsvar.xy - 4.5 * invrendertargetdim) * 0.015625; - - FragColor = color; -} - - -/* third pass, calculate the final coc from blurred and unblurred images */ -void third_pass() -{ - vec4 color = texture(colorbuffer, uvcoordsvar.xy); - vec4 color_blurred = texture(blurredcolorbuffer, uvcoordsvar.xy); - float coc = 2.0 * max(color_blurred.a, color.a); -color.a; - FragColor = vec4(color.rgb, coc); -} - - -/* fourth pass, blur the final coc once to get rid of discontinuities */ -void fourth_pass() -{ - vec4 color = texture(colorbuffer, uvcoordsvar.xz); - color += texture(colorbuffer, uvcoordsvar.yz); - color += texture(colorbuffer, uvcoordsvar.xw); - color += texture(colorbuffer, uvcoordsvar.yw); - - FragColor = color / 4.0; -} - -vec4 small_sample_blur(in sampler2D colorbuffer, in vec2 uv, in vec4 color) -{ - float weight = 1.0 / 17.0; - vec4 result = weight * color; - weight *= 4.0; - - result += weight * texture(colorbuffer, uv + color_uv1.xy); - result += weight * texture(colorbuffer, uv - color_uv1.xy); - result += weight * texture(colorbuffer, uv + color_uv1.yx); - result += weight * texture(colorbuffer, uv - color_uv1.yx); - - return result; -} - - -/* fourth pass, just visualize the third pass contents */ -void fifth_pass() -{ - vec4 factors; - vec4 color_orig = texture(colorbuffer, uvcoordsvar.xy); - vec4 highblurred = texture(blurredcolorbuffer, uvcoordsvar.xy); - vec4 mediumblurred = texture(mblurredcolorbuffer, uvcoordsvar.xy); - vec4 smallblurred = small_sample_blur(colorbuffer, uvcoordsvar.xy, color_orig); - float depth = texture(depthbuffer, uvcoordsvar.xy).r; - - float zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), vec4(depth)).r; - float coc_far = clamp(calculate_far_coc(zdepth), 0.0, 1.0); - - /* calculate final coc here */ - float coc = max(max(coc_far, mediumblurred.a), 0.0); - - float width = 2.5; - float radius = 0.2; - - factors.x = 1.0 - clamp(width * coc, 0.0, 1.0); - factors.y = 1.0 - clamp(abs(width * (coc - 2.0 * radius)), 0.0, 1.0); - factors.z = 1.0 - clamp(abs(width * (coc - 3.0 * radius)), 0.0, 1.0); - factors.w = 1.0 - clamp(abs(width * (coc - 4.0 * radius)), 0.0, 1.0); - /* blend! */ - vec4 color = factors.x * color_orig + factors.y * smallblurred + factors.z * mediumblurred + factors.w * highblurred; - - color /= dot(factors, vec4(1.0)); - /* using original color is not correct, but use that for now because alpha of - * blurred buffers uses CoC instead */ - FragColor = vec4(color.rgb, color_orig.a); -} - - -void main() -{ -#ifdef FIRST_PASS - first_pass(); -#elif defined(SECOND_PASS) - second_pass(); -#elif defined(THIRD_PASS) - third_pass(); -#elif defined(FOURTH_PASS) - fourth_pass(); -#elif defined(FIFTH_PASS) - fifth_pass(); -#endif -} diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl deleted file mode 100644 index c41c1d0820b..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_frag.glsl +++ /dev/null @@ -1,173 +0,0 @@ -/* amount of offset to move one pixel left-right. - * In second pass some dimensions are zero to control verical/horizontal convolution */ -uniform vec2 invrendertargetdim; - -uniform ivec2 rendertargetdim; - -/* color buffer */ -uniform sampler2D colorbuffer; -uniform sampler2D farbuffer; -uniform sampler2D nearbuffer; - -/* depth buffer */ -uniform sampler2D depthbuffer; - -uniform sampler2D cocbuffer; - -/* this includes aperture size in x and focal distance in y */ -uniform vec4 dof_params; - -/* viewvectors for reconstruction of world space */ -uniform vec4 viewvecs[3]; - -/* initial uv coordinate */ -in vec2 uvcoord; - -/* coordinate used for calculating radius et al set in geometry shader */ -in vec2 particlecoord; -flat in vec4 color; - -/* downsampling coordinates */ -in vec2 downsample1; -in vec2 downsample2; -in vec2 downsample3; -in vec2 downsample4; - -layout(location = 0) out vec4 fragData0; -layout(location = 1) out vec4 fragData1; -layout(location = 2) out vec4 fragData2; - -#define M_PI 3.1415926535897932384626433832795 - -/* calculate 4 samples at once */ -vec4 calculate_coc(in vec4 zdepth) -{ - vec4 coc = dof_params.x * (vec4(dof_params.y) / zdepth - vec4(1.0)); - - /* multiply by 1.0 / sensor size to get the normalized size */ - return coc * dof_params.z; -} - -#define THRESHOLD 0.0 - -/* downsample the color buffer to half resolution */ -void downsample_pass() -{ - vec4 depth; - vec4 zdepth; - vec4 coc; - float far_coc, near_coc; - - /* custom downsampling. We need to be careful to sample nearest here to avoid leaks */ - vec4 color1 = texture(colorbuffer, downsample1); - vec4 color2 = texture(colorbuffer, downsample2); - vec4 color3 = texture(colorbuffer, downsample3); - vec4 color4 = texture(colorbuffer, downsample4); - - depth.r = texture(depthbuffer, downsample1).r; - depth.g = texture(depthbuffer, downsample2).r; - depth.b = texture(depthbuffer, downsample3).r; - depth.a = texture(depthbuffer, downsample4).r; - - zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depth); - coc = calculate_coc(zdepth); - vec4 coc_far = -coc; - - /* now we need to write the near-far fields premultiplied by the coc */ - vec4 near_weights = vec4((coc.x >= THRESHOLD) ? 1.0 : 0.0, (coc.y >= THRESHOLD) ? 1.0 : 0.0, - (coc.z >= THRESHOLD) ? 1.0 : 0.0, (coc.w >= THRESHOLD) ? 1.0 : 0.0); - vec4 far_weights = vec4((coc_far.x >= THRESHOLD) ? 1.0 : 0.0, (coc_far.y >= THRESHOLD) ? 1.0 : 0.0, - (coc_far.z >= THRESHOLD) ? 1.0 : 0.0, (coc_far.w >= THRESHOLD) ? 1.0 : 0.0); - - near_coc = max(max(max(coc.x, coc.y), max(coc.z, coc.w)), 0.0); - far_coc = max(max(max(coc_far.x, coc_far.y), max(coc_far.z, coc_far.w)), 0.0); - - float norm_near = dot(near_weights, vec4(1.0)); - float norm_far = dot(far_weights, vec4(1.0)); - - /* now write output to weighted buffers. */ - fragData0 = color1 * near_weights.x + color2 * near_weights.y + color3 * near_weights.z + - color4 * near_weights.w; - fragData1 = color1 * far_weights.x + color2 * far_weights.y + color3 * far_weights.z + - color4 * far_weights.w; - - if (norm_near > 0.0) - fragData0 /= norm_near; - if (norm_far > 0.0) - fragData1 /= norm_far; - fragData2 = vec4(near_coc, far_coc, 0.0, 1.0); -} - -/* accumulate color in the near/far blur buffers */ -void accumulate_pass(void) { - float theta = atan(particlecoord.y, particlecoord.x); - float r; - - if (dof_params.w == 0.0) - r = 1.0; - else - r = cos(M_PI / dof_params.w) / - (cos(theta - (2.0 * M_PI / dof_params.w) * floor((dof_params.w * theta + M_PI) / (2.0 * M_PI)))); - - if (dot(particlecoord, particlecoord) > r * r) - discard; - - fragData0 = color; -} - -#define MERGE_THRESHOLD 4.0 -/* combine the passes, */ -void final_pass(void) { - vec4 finalcolor; - float totalweight; - float depth = texture(depthbuffer, uvcoord).r; - - vec4 zdepth = get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), vec4(depth)); - float coc_near = calculate_coc(zdepth).r; - float coc_far = max(-coc_near, 0.0); - coc_near = max(coc_near, 0.0); - - vec4 farcolor = texture(farbuffer, uvcoord); - float farweight = farcolor.a; - if (farweight > 0.0) - farcolor /= farweight; - vec4 nearcolor = texture(nearbuffer, uvcoord); - - vec4 srccolor = texture(colorbuffer, uvcoord); - - vec4 coc = texture(cocbuffer, uvcoord); - - float mixfac = smoothstep(1.0, MERGE_THRESHOLD, coc_far); - finalcolor = mix(srccolor, farcolor, mixfac); - - farweight = mix(1.0, farweight, mixfac); - - float nearweight = nearcolor.a; - if (nearweight > 0.0) { - nearcolor /= nearweight; - } - - if (coc_near > 1.0) { - nearweight = 1.0; - finalcolor = nearcolor; - } - else { - totalweight = nearweight + farweight; - finalcolor = mix(finalcolor, nearcolor, nearweight / totalweight); - } - - fragData0 = finalcolor; - // fragData0 = vec4(nearweight, farweight, 0.0, 1.0); - // fragData0 = vec4(nearcolor.rgb, 1.0); -} - -void main() -{ -#ifdef FIRST_PASS - downsample_pass(); -#elif defined(SECOND_PASS) - accumulate_pass(); -#elif defined(THIRD_PASS) - final_pass(); -#endif -} diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_geo.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_geo.glsl deleted file mode 100644 index 52d0a9be499..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_geo.glsl +++ /dev/null @@ -1,55 +0,0 @@ -uniform ivec2 rendertargetdim; -uniform sampler2D colorbuffer; - -uniform vec2 layerselection; - -uniform sampler2D cocbuffer; - -layout(points) in; -layout(triangle_strip, max_vertices = 4) out; - -#define POS gl_in[0].gl_Position - -in vec2 uvcoord[]; -out vec2 particlecoord; -flat out vec4 color; - -#define M_PI 3.1415926535897932384626433832795 - -void main() -{ - vec4 coc = textureLod(cocbuffer, uvcoord[0], 0.0); - - float offset_val = dot(coc.rg, layerselection); - if (offset_val < 1.0) - return; - - vec4 colortex = textureLod(colorbuffer, uvcoord[0], 0.0); - - /* find the area the pixel will cover and divide the color by it */ - float alpha = 1.0 / (offset_val * offset_val * M_PI); - colortex *= alpha; - colortex.a = alpha; - - vec2 offset_far = vec2(offset_val * 0.5) / vec2(rendertargetdim.x, rendertargetdim.y); - - color = colortex; - - gl_Position = POS + vec4(-offset_far.x, -offset_far.y, 0.0, 0.0); - particlecoord = vec2(-1.0, -1.0); - EmitVertex(); - - gl_Position = POS + vec4(-offset_far.x, offset_far.y, 0.0, 0.0); - particlecoord = vec2(-1.0, 1.0); - EmitVertex(); - - gl_Position = POS + vec4(offset_far.x, -offset_far.y, 0.0, 0.0); - particlecoord = vec2(1.0, -1.0); - EmitVertex(); - - gl_Position = POS + vec4(offset_far.x, offset_far.y, 0.0, 0.0); - particlecoord = vec2(1.0, 1.0); - EmitVertex(); - - EndPrimitive(); -} diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl deleted file mode 100644 index 86b338e528e..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_dof_hq_vert.glsl +++ /dev/null @@ -1,62 +0,0 @@ - -in vec2 pos; -in vec2 uvs; -/* initial uv coordinate */ -out vec2 uvcoord; - -/* coordinate used for calculating radius et al set in geometry shader */ -out vec2 particlecoord; - -/* downsampling coordinates */ -out vec2 downsample1; -out vec2 downsample2; -out vec2 downsample3; -out vec2 downsample4; - -uniform vec2 invrendertargetdim; -uniform ivec2 rendertargetdim; - -void vert_dof_downsample() -{ - /* gather pixels from neighbors. half dimensions means we offset half a pixel to - * get this right though it's possible we may lose a pixel at some point */ - downsample1 = uvs.xy + vec2(-0.5, -0.5) * invrendertargetdim; - downsample2 = uvs.xy + vec2(-0.5, 0.5) * invrendertargetdim; - downsample3 = uvs.xy + vec2(0.5, 0.5) * invrendertargetdim; - downsample4 = uvs.xy + vec2(0.5, -0.5) * invrendertargetdim; - - gl_Position = vec4(pos, 0.0, 1.0); -} - -/* geometry shading pass, calculate a texture coordinate based on the indexed id */ -void vert_dof_coc_scatter_pass() -{ - vec2 pixel = vec2(rendertargetdim.x, rendertargetdim.y); - /* some math to get the target pixel */ - int row = gl_InstanceID / rendertargetdim.x; - int column = gl_InstanceID % rendertargetdim.x; - uvcoord = (vec2(column, row) + vec2(0.5)) / pixel; - - vec2 pos = uvcoord * 2.0 - vec2(1.0); - gl_Position = vec4(pos.x, pos.y, 0.0, 1.0); - -// uvcoord = vec2(0.5, 0.5); -// gl_Position = vec4(0.0, 0.0, 0.0, 1.0); -} - -void vert_dof_final() -{ - uvcoord = uvs; - gl_Position = vec4(pos, 0.0, 1.0); -} - -void main() -{ -#if defined(FIRST_PASS) - vert_dof_downsample(); -#elif defined(SECOND_PASS) - vert_dof_coc_scatter_pass(); -#else - vert_dof_final(); -#endif -} diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl deleted file mode 100644 index b4576f75d19..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl +++ /dev/null @@ -1,74 +0,0 @@ -uniform vec2 invrendertargetdim; - -in vec2 pos; -in vec2 uvs; - -/* texture coordinates for framebuffer read */ -out vec4 uvcoordsvar; - -/* color texture coordinates, offset by a small amount */ -out vec2 color_uv1; -out vec2 color_uv2; - -out vec2 depth_uv1; -out vec2 depth_uv2; -out vec2 depth_uv3; -out vec2 depth_uv4; - -//very simple shader for gull screen FX, just pass values on - -void vert_generic() -{ - uvcoordsvar = vec4(uvs, 0.0, 0.0); - gl_Position = vec4(pos, 0.0, 1.0); -} - -void vert_dof_first_pass() -{ - /* we offset the texture coordinates by 1.5 pixel, - * then we reuse that to sample the surrounding pixels */ - color_uv1 = uvs.xy + vec2(-1.5, -1.5) * invrendertargetdim; - color_uv2 = uvs.xy + vec2(0.5, -1.5) * invrendertargetdim; - - depth_uv1 = uvs.xy + vec2(-1.5, -1.5) * invrendertargetdim; - depth_uv2 = uvs.xy + vec2(-0.5, -1.5) * invrendertargetdim; - depth_uv3 = uvs.xy + vec2(0.5, -1.5) * invrendertargetdim; - depth_uv4 = uvs.xy + vec2(1.5, -1.5) * invrendertargetdim; - - gl_Position = vec4(pos, 0.0, 1.0); -} - -void vert_dof_fourth_pass() -{ - vec4 halfpixel = vec4(-0.5, 0.5, -0.5, 0.5); - uvcoordsvar = uvs.xxyy + - halfpixel * - vec4(invrendertargetdim.x, - invrendertargetdim.x, - invrendertargetdim.y, - invrendertargetdim.y); - - gl_Position = vec4(pos, 0.0, 1.0); -} - -void vert_dof_fifth_pass() -{ - vec4 halfpixel = vec4(-0.5, 0.5, -0.5, 0.5); - color_uv1 = vec2(0.5, 1.5) * invrendertargetdim; - - uvcoordsvar = vec4(uvs, 0.0, 0.0); - gl_Position = vec4(pos, 0.0, 1.0); -} - -void main() -{ -#ifdef FIRST_PASS - vert_dof_first_pass(); -#elif defined(FOURTH_PASS) - vert_dof_fourth_pass(); -#elif defined(FIFTH_PASS) - vert_dof_fifth_pass(); -#else - vert_generic(); -#endif -} diff --git a/source/blender/gpu/shaders/gpu_shader_fx_lib.glsl b/source/blender/gpu/shaders/gpu_shader_fx_lib.glsl deleted file mode 100644 index 7aa6786d292..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_lib.glsl +++ /dev/null @@ -1,42 +0,0 @@ -uniform mat4 ProjectionMatrix; - -/* simple depth reconstruction, see http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer - * we change the factors from the article to fit the OpennGL model. */ -#ifdef PERSP_MATRIX - - -/* perspective camera code */ - -vec3 get_view_space_from_depth(in vec2 uvcoords, in vec3 viewvec_origin, in vec3 viewvec_diff, in float depth) -{ - float d = 2.0 * depth - 1.0; - - float zview = -ProjectionMatrix[3][2] / (d + ProjectionMatrix[2][2]); - - return zview * (viewvec_origin + vec3(uvcoords, 0.0) * viewvec_diff); -} - -vec4 get_view_space_z_from_depth(in vec4 near, in vec4 range, in vec4 depth) -{ - vec4 d = 2.0 * depth - vec4(1.0); - - /* return positive value, so sign differs! */ - return vec4(ProjectionMatrix[3][2]) / (d + vec4(ProjectionMatrix[2][2])); -} - -#else -/* orthographic camera code */ - -vec3 get_view_space_from_depth(in vec2 uvcoords, in vec3 viewvec_origin, in vec3 viewvec_diff, in float depth) -{ - vec3 offset = vec3(uvcoords, depth); - - return vec3(viewvec_origin + offset * viewvec_diff); -} - -vec4 get_view_space_z_from_depth(in vec4 near, in vec4 range, in vec4 depth) -{ - return -(near + depth * range); -} - -#endif diff --git a/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl deleted file mode 100644 index 4904010c841..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl +++ /dev/null @@ -1,97 +0,0 @@ - -// color buffer -uniform sampler2D colorbuffer; - -// jitter texture for ssao -uniform sampler2D jitter_tex; - -// concentric sample texture for ssao -uniform sampler1D ssao_concentric_tex; - -// depth buffer -uniform sampler2D depthbuffer; - -// coordinates on framebuffer in normalized (0.0-1.0) uv space -in vec4 uvcoordsvar; -out vec4 FragColor; - -/* ssao_params.x : pixel scale for the ssao radious */ -/* ssao_params.y : factor for the ssao darkening */ -uniform vec4 ssao_params; -uniform vec3 ssao_sample_params; -uniform vec4 ssao_color; - -/* store the view space vectors for the corners of the view frustum here. - * It helps to quickly reconstruct view space vectors by using uv coordinates, - * see http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */ -uniform vec4 viewvecs[3]; - -vec3 calculate_view_space_normal(in vec3 viewposition) -{ - vec3 normal = cross(normalize(dFdx(viewposition)), - ssao_params.w * normalize(dFdy(viewposition))); - return normalize(normal); -} - -float calculate_ssao_factor(float depth) -{ - /* take the normalized ray direction here */ - vec2 rotX = texture(jitter_tex, uvcoordsvar.xy * ssao_sample_params.yz).rg; - vec2 rotY = vec2(-rotX.y, rotX.x); - - /* occlusion is zero in full depth */ - if (depth == 1.0) - return 0.0; - - vec3 position = get_view_space_from_depth(uvcoordsvar.xy, viewvecs[0].xyz, viewvecs[1].xyz, depth); - vec3 normal = calculate_view_space_normal(position); - - /* find the offset in screen space by multiplying a point - * in camera space at the depth of the point by the projection matrix. */ - vec2 offset; - float homcoord = ProjectionMatrix[2][3] * position.z + ProjectionMatrix[3][3]; - offset.x = ProjectionMatrix[0][0] * ssao_params.x / homcoord; - offset.y = ProjectionMatrix[1][1] * ssao_params.x / homcoord; - /* convert from -1.0...1.0 range to 0.0..1.0 for easy use with texture coordinates */ - offset *= 0.5; - - float factor = 0.0; - int x; - int num_samples = int(ssao_sample_params.x); - - for (x = 0; x < num_samples; x++) { - vec2 dir_sample = texture(ssao_concentric_tex, (float(x) + 0.5) / ssao_sample_params.x).rg; - - /* rotate with random direction to get jittered result */ - vec2 dir_jittered = vec2(dot(dir_sample, rotX), dot(dir_sample, rotY)); - - vec2 uvcoords = uvcoordsvar.xy + dir_jittered * offset; - - if (uvcoords.x > 1.0 || uvcoords.x < 0.0 || uvcoords.y > 1.0 || uvcoords.y < 0.0) - continue; - - float depth_new = texture(depthbuffer, uvcoords).r; - if (depth_new != 1.0) { - vec3 pos_new = get_view_space_from_depth(uvcoords, viewvecs[0].xyz, viewvecs[1].xyz, depth_new); - vec3 dir = pos_new - position; - float len = length(dir); - float f = dot(dir, normal); - - /* use minor bias here to avoid self shadowing */ - if (f > 0.05 * len) - factor += f * 1.0 / (len * (1.0 + len * len * ssao_params.z)); - } - } - - factor /= ssao_sample_params.x; - - return clamp(factor * ssao_params.y, 0.0, 1.0); -} - -void main() -{ - float depth = texture(depthbuffer, uvcoordsvar.xy).r; - vec4 scene_col = texture(colorbuffer, uvcoordsvar.xy); - vec3 final_color = mix(scene_col.rgb, ssao_color.rgb, calculate_ssao_factor(depth)); - FragColor = vec4(final_color.rgb, scene_col.a); -} diff --git a/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl b/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl deleted file mode 100644 index 78241a798a2..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_frag.glsl +++ /dev/null @@ -1,19 +0,0 @@ -uniform vec2 ScaleU; -uniform sampler2D textureSource; - -in vec2 texCoord_interp; -out vec4 fragColor; - -void main() -{ - vec4 color = vec4(0.0); - color += texture(textureSource, texCoord_interp.st + vec2(-3.0 * ScaleU.x, -3.0 * ScaleU.y)) * 0.015625; - color += texture(textureSource, texCoord_interp.st + vec2(-2.0 * ScaleU.x, -2.0 * ScaleU.y)) * 0.09375; - color += texture(textureSource, texCoord_interp.st + vec2(-1.0 * ScaleU.x, -1.0 * ScaleU.y)) * 0.234375; - color += texture(textureSource, texCoord_interp.st + vec2(0.0, 0.0)) * 0.3125; - color += texture(textureSource, texCoord_interp.st + vec2(1.0 * ScaleU.x, 1.0 * ScaleU.y)) * 0.234375; - color += texture(textureSource, texCoord_interp.st + vec2(2.0 * ScaleU.x, 2.0 * ScaleU.y)) * 0.09375; - color += texture(textureSource, texCoord_interp.st + vec2(3.0 * ScaleU.x, 3.0 * ScaleU.y)) * 0.015625; - - fragColor = color; -} diff --git a/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl b/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl deleted file mode 100644 index fca39852c2a..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl +++ /dev/null @@ -1,14 +0,0 @@ - -out vec2 texCoord_interp; - -void main() -{ - const vec4 vert[3] = vec4[3]( - vec3(-1.0, -1.0, 0.0, 0.0), - vec3( 3.0, -1.0, 2.0, 0.0), - vec3(-1.0, 3.0, 0.0, 2.0) - ); - - gl_Position = vec4(vert[gl_VertexID].xy, 0.0, 1.0); - texCoord_interp = vert[gl_VertexID].zw; -} diff --git a/source/blender/gpu/shaders/gpu_shader_vertex.glsl b/source/blender/gpu/shaders/gpu_shader_vertex.glsl deleted file mode 100644 index e297c242044..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_vertex.glsl +++ /dev/null @@ -1,112 +0,0 @@ - -uniform mat4 ModelViewMatrix; -uniform mat4 ProjectionMatrix; -uniform mat3 NormalMatrix; - -#ifdef USE_OPENSUBDIV -in vec3 normal; -in vec4 position; - -out block { - VertexData v; -} outpt; -#endif - -out vec3 varposition; -out vec3 varnormal; - -#ifdef CLIP_WORKAROUND -varying float gl_ClipDistance[6]; -#endif - - -/* Color, keep in sync with: gpu_shader_vertex_world.glsl */ - -float srgb_to_linearrgb(float c) -{ - if (c < 0.04045) - return (c < 0.0) ? 0.0 : c * (1.0 / 12.92); - else - return pow((c + 0.055) * (1.0 / 1.055), 2.4); -} - -void srgb_to_linearrgb(vec3 col_from, out vec3 col_to) -{ - col_to.r = srgb_to_linearrgb(col_from.r); - col_to.g = srgb_to_linearrgb(col_from.g); - col_to.b = srgb_to_linearrgb(col_from.b); -} - -void srgb_to_linearrgb(vec4 col_from, out vec4 col_to) -{ - col_to.r = srgb_to_linearrgb(col_from.r); - col_to.g = srgb_to_linearrgb(col_from.g); - col_to.b = srgb_to_linearrgb(col_from.b); - col_to.a = col_from.a; -} - -bool is_srgb(int info) -{ - return (info == 1)? true: false; -} - -void set_var_from_attr(float attr, int info, out float var) -{ - var = attr; -} - -void set_var_from_attr(vec2 attr, int info, out vec2 var) -{ - var = attr; -} - -void set_var_from_attr(vec3 attr, int info, out vec3 var) -{ - if (is_srgb(info)) { - srgb_to_linearrgb(attr, var); - } - else { - var = attr; - } -} - -void set_var_from_attr(vec4 attr, int info, out vec4 var) -{ - if (is_srgb(info)) { - srgb_to_linearrgb(attr, var); - } - else { - var = attr; - } -} - -/* end color code */ - - -void main() -{ -#ifndef USE_OPENSUBDIV - vec4 position = gl_Vertex; - vec3 normal = gl_Normal; -#endif - - vec4 co = ModelViewMatrix * position; - - varposition = co.xyz; - varnormal = normalize(NormalMatrix * normal); - gl_Position = ProjectionMatrix * co; - -#ifdef CLIP_WORKAROUND - int i; - for (i = 0; i < 6; i++) - gl_ClipDistance[i] = dot(co, gl_ClipPlane[i]); -#elif !defined(GPU_ATI) - // Setting gl_ClipVertex is necessary to get glClipPlane working on NVIDIA - // graphic cards, while on ATI it can cause a software fallback. - gl_ClipVertex = co; -#endif - -#ifdef USE_OPENSUBDIV - outpt.v.position = co; - outpt.v.normal = varnormal; -#endif diff --git a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl b/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl deleted file mode 100644 index 6f97ef8abef..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_vertex_world.glsl +++ /dev/null @@ -1,75 +0,0 @@ - -out vec3 varposition; -out vec3 varnormal; - -/* Color, keep in sync with: gpu_shader_vertex.glsl */ - -float srgb_to_linearrgb(float c) -{ - if (c < 0.04045) - return (c < 0.0) ? 0.0 : c * (1.0 / 12.92); - else - return pow((c + 0.055) * (1.0 / 1.055), 2.4); -} - -void srgb_to_linearrgb(vec3 col_from, out vec3 col_to) -{ - col_to.r = srgb_to_linearrgb(col_from.r); - col_to.g = srgb_to_linearrgb(col_from.g); - col_to.b = srgb_to_linearrgb(col_from.b); -} - -void srgb_to_linearrgb(vec4 col_from, out vec4 col_to) -{ - col_to.r = srgb_to_linearrgb(col_from.r); - col_to.g = srgb_to_linearrgb(col_from.g); - col_to.b = srgb_to_linearrgb(col_from.b); - col_to.a = col_from.a; -} - -bool is_srgb(int info) -{ - return (info == 1)? true: false; -} - -void set_var_from_attr(float attr, int info, out float var) -{ - var = attr; -} - -void set_var_from_attr(vec2 attr, int info, out vec2 var) -{ - var = attr; -} - -void set_var_from_attr(vec3 attr, int info, out vec3 var) -{ - if (is_srgb(info)) { - srgb_to_linearrgb(attr, var); - } - else { - var = attr; - } -} - -void set_var_from_attr(vec4 attr, int info, out vec4 var) -{ - if (is_srgb(info)) { - srgb_to_linearrgb(attr, var); - } - else { - var = attr; - } -} - -/* end color code */ - - -void main() -{ - /* position does not need to be transformed, we already have it */ - gl_Position = gl_Vertex; - - varposition = gl_Vertex.xyz; - - varnormal = normalize(-varposition); diff --git a/source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl b/source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl deleted file mode 100644 index 6aad94bbf59..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_vsm_store_frag.glsl +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This fragment shader was initially found at http://fabiensanglard.net/shadowmappingVSM/index.php - */ - -in vec4 v_position; -out vec4 fragColor; - -void main() -{ - float depth = v_position.z / v_position.w; - depth = depth * 0.5 + 0.5; - - float moment1 = depth; - float moment2 = depth * depth; - - // Adjusting moments using partial derivative - float dx = dFdx(depth); - float dy = dFdy(depth); - moment2 += 0.25 * (dx * dx + dy * dy); - - fragColor = vec4(moment1, moment2, 0.0, 0.0); - // TODO: write to a 2-component target --^ -} diff --git a/source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl b/source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl deleted file mode 100644 index def835156f7..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_vsm_store_vert.glsl +++ /dev/null @@ -1,10 +0,0 @@ - -uniform mat4 ModelViewProjectionMatrix; - -out vec4 v_position; - -void main() -{ - gl_Position = ModelViewProjectionMatrix * gl_Vertex; - v_position = gl_Position; -} |