Calculate the focus factor z in the post shader
This commit is contained in:
parent
f275aef0b0
commit
8a48b59c0b
|
@ -11,9 +11,11 @@ uniform uint windowHeight;
|
||||||
uniform float time;
|
uniform float time;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float dx = 1.0/windowWidth;
|
vec2 dx = vec2(1,0) * 1.0/windowWidth;
|
||||||
float dy = 1.0/windowHeight;
|
vec2 dy = vec2(0,1) * 1.0/windowHeight;
|
||||||
|
|
||||||
vec2 UV = gl_FragCoord.xy / vec2(windowWidth, windowHeight);
|
vec2 UV = gl_FragCoord.xy / vec2(windowWidth, windowHeight);
|
||||||
color_out = texture(framebuffer, UV);
|
|
||||||
|
float z = pow(texture(depthbuffer, UV).r , 0x800);
|
||||||
|
z = abs(z*2-1)*1.2;
|
||||||
|
color_out = vec4(vec3(texture(depthbuffer, UV).r), 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#version 430 core
|
#version 430 core
|
||||||
|
|
||||||
in layout(location = 0) vec3 vertex;
|
in layout(location = 0) vec3 vertex;
|
||||||
out layout(location = 0) vec2 UV;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(vertex, 1.0);
|
gl_Position = vec4(vertex, 1.0);
|
||||||
UV = vertex.xy*0.5 + 0.5;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,9 +341,9 @@ void renderFrame(GLFWwindow* window, int windowWidth, int windowHeight) {
|
||||||
glDepthMask(GL_FALSE); // read only
|
glDepthMask(GL_FALSE); // read only
|
||||||
for (NodeDistShader a : transparent_nodes)
|
for (NodeDistShader a : transparent_nodes)
|
||||||
renderNode(a.node, a.s, nullptr, false);
|
renderNode(a.node, a.s, nullptr, false);
|
||||||
|
renderNode(hudNode, nullptr); // rootNode defined in scene.hpp
|
||||||
glDepthMask(GL_TRUE); // read write
|
glDepthMask(GL_TRUE); // read write
|
||||||
|
|
||||||
renderNode(hudNode, nullptr); // rootNode defined in scene.hpp
|
|
||||||
|
|
||||||
// render framebuffer to window
|
// render framebuffer to window
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
Loading…
Reference in New Issue