Implement HDR and gamma correction in post shader pass
This commit is contained in:
parent
7060c08217
commit
250c108e97
|
@ -5,7 +5,7 @@ Collapsed=0
|
||||||
|
|
||||||
[Window][Terrain Controls]
|
[Window][Terrain Controls]
|
||||||
Pos=0,19
|
Pos=0,19
|
||||||
Size=1498,94
|
Size=1280,94
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
|
@ -19,17 +19,17 @@ Collapsed=0
|
||||||
|
|
||||||
[Window][TerraVisor]
|
[Window][TerraVisor]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=1498,720
|
Size=1280,720
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Scene Window]
|
[Window][Scene Window]
|
||||||
Pos=0,115
|
Pos=0,115
|
||||||
Size=1498,605
|
Size=1280,605
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,19 Size=1498,701 Split=Y Selected=0x9F2D9299
|
DockSpace ID=0x6F42A598 Window=0xE80F322C Pos=0,19 Size=1280,701 Split=Y Selected=0x9F2D9299
|
||||||
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=1280,94 Selected=0xF69494A7
|
DockNode ID=0x00000001 Parent=0x6F42A598 SizeRef=1280,94 Selected=0xF69494A7
|
||||||
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=1280,605 CentralNode=1 Selected=0x9F2D9299
|
DockNode ID=0x00000002 Parent=0x6F42A598 SizeRef=1280,605 CentralNode=1 Selected=0x9F2D9299
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#version 430
|
#version 430
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D diffuse_tex;
|
layout(binding = 0) uniform sampler2D diffuse_tex;
|
||||||
layout(location = 1) uniform float time;
|
layout(location = 1) uniform float time;
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@ in VertexData
|
||||||
vec3 nw; //world-space normal vector
|
vec3 nw; //world-space normal vector
|
||||||
} inData; //block is named 'inData'
|
} inData; //block is named 'inData'
|
||||||
|
|
||||||
out vec4 fragcolor; //the output color for this fragment
|
out vec4 frag_color; //the output color for this fragment
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +56,6 @@ void main(void)
|
||||||
// vec4 specular_term = atten*ks*Ls*pow(max(0.0, dot(rw, vw)), shininess);
|
// vec4 specular_term = atten*ks*Ls*pow(max(0.0, dot(rw, vw)), shininess);
|
||||||
|
|
||||||
// fragcolor = ambient_term + diffuse_term + specular_term;
|
// fragcolor = ambient_term + diffuse_term + specular_term;
|
||||||
fragcolor = vec4(0.0, 0.0, 1.0, 1.0);
|
frag_color = vec4(0.45f, 0.82f, 0.52f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
#version 330 core
|
#version 430
|
||||||
out vec4 FragColor;
|
precision highp float;
|
||||||
|
|
||||||
in vec2 TexCoord;
|
out vec4 frag_color;
|
||||||
|
|
||||||
uniform sampler2D screenTexture;
|
in vec2 tex_coords;
|
||||||
|
|
||||||
|
uniform sampler2D screen_texture;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = texture(screenTexture, TexCoord);
|
vec3 hdr_color = texture(screen_texture, tex_coords).rgb;
|
||||||
//FragColor = vec4(vec3(1.0 - texture(screenTexture, TexCoord)), 1.0);
|
vec3 tone_mapped_color = hdr_color / (hdr_color + vec3(1.0));
|
||||||
|
tone_mapped_color = pow(tone_mapped_color, vec3(1.0/2.2));
|
||||||
|
|
||||||
|
frag_color = vec4(tone_mapped_color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#version 330 core
|
#version 430
|
||||||
layout(location = 0) in vec3 pos_attrib; //this variable holds the position of mesh vertices
|
layout(location = 0) in vec3 pos_attrib; //this variable holds the position of mesh vertices
|
||||||
layout(location = 1) in vec2 tex_coord_attrib;
|
layout(location = 1) in vec2 tex_coord_attrib;
|
||||||
layout(location = 2) in vec3 normal_attrib;
|
layout(location = 2) in vec3 normal_attrib;
|
||||||
|
|
||||||
out vec2 TexCoord;
|
out vec2 tex_coords;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(pos_attrib.xy, 0.0, 1.0);
|
gl_Position = vec4(pos_attrib.xy, 0.0, 1.0);
|
||||||
TexCoord = tex_coord_attrib;
|
tex_coords = tex_coord_attrib;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ void FBO::Init(int width, int height) {
|
||||||
// Generate the color texture
|
// Generate the color texture
|
||||||
glGenTextures(1, &color_texture_id_);
|
glGenTextures(1, &color_texture_id_);
|
||||||
glBindTexture(GL_TEXTURE_2D, color_texture_id_);
|
glBindTexture(GL_TEXTURE_2D, color_texture_id_);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, nullptr);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
|
@ -153,7 +153,6 @@ void Scene::Display(GLFWwindow* window) {
|
||||||
|
|
||||||
fbo_.Unbind();
|
fbo_.Unbind();
|
||||||
|
|
||||||
// post_fbo_ currently renders with a nasty artifact. Need to fix
|
|
||||||
post_fbo_.Bind();
|
post_fbo_.Bind();
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue