Calculate the focus factor z in the post shader

This commit is contained in:
Peder Bergebakken Sundt 2019-04-01 13:05:12 +02:00
parent f275aef0b0
commit 8a48b59c0b
3 changed files with 7 additions and 7 deletions

View File

@ -11,9 +11,11 @@ uniform uint windowHeight;
uniform float time;
void main() {
float dx = 1.0/windowWidth;
float dy = 1.0/windowHeight;
vec2 dx = vec2(1,0) * 1.0/windowWidth;
vec2 dy = vec2(0,1) * 1.0/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);
}

View File

@ -1,9 +1,7 @@
#version 430 core
in layout(location = 0) vec3 vertex;
out layout(location = 0) vec2 UV;
void main() {
gl_Position = vec4(vertex, 1.0);
UV = vertex.xy*0.5 + 0.5;
}

View File

@ -341,9 +341,9 @@ void renderFrame(GLFWwindow* window, int windowWidth, int windowHeight) {
glDepthMask(GL_FALSE); // read only
for (NodeDistShader a : transparent_nodes)
renderNode(a.node, a.s, nullptr, false);
renderNode(hudNode, nullptr); // rootNode defined in scene.hpp
glDepthMask(GL_TRUE); // read write
renderNode(hudNode, nullptr); // rootNode defined in scene.hpp
// render framebuffer to window
glBindFramebuffer(GL_FRAMEBUFFER, 0);