This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl
2016-05-26 18:53:09 +10:00

73 lines
1.8 KiB
GLSL

uniform vec2 invrendertargetdim;
//texture coordinates for framebuffer read
varying vec4 uvcoordsvar;
/* color texture coordinates, offset by a small amount */
varying vec2 color_uv1;
varying vec2 color_uv2;
varying vec2 depth_uv1;
varying vec2 depth_uv2;
varying vec2 depth_uv3;
varying vec2 depth_uv4;
//very simple shader for gull screen FX, just pass values on
void vert_generic()
{
uvcoordsvar = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}
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 = gl_MultiTexCoord0.xy + vec2(-1.5, -1.5) * invrendertargetdim;
color_uv2 = gl_MultiTexCoord0.xy + vec2(0.5, -1.5) * invrendertargetdim;
depth_uv1 = gl_MultiTexCoord0.xy + vec2(-1.5, -1.5) * invrendertargetdim;
depth_uv2 = gl_MultiTexCoord0.xy + vec2(-0.5, -1.5) * invrendertargetdim;
depth_uv3 = gl_MultiTexCoord0.xy + vec2(0.5, -1.5) * invrendertargetdim;
depth_uv4 = gl_MultiTexCoord0.xy + vec2(1.5, -1.5) * invrendertargetdim;
gl_Position = gl_Vertex;
}
void vert_dof_fourth_pass()
{
vec4 halfpixel = vec4(-0.5, 0.5, -0.5, 0.5);
uvcoordsvar = gl_MultiTexCoord0.xxyy +
halfpixel *
vec4(invrendertargetdim.x,
invrendertargetdim.x,
invrendertargetdim.y,
invrendertargetdim.y);
gl_Position = gl_Vertex;
}
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 = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}
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
}