HDR output buffer (WIP)

This commit is contained in:
2022-02-15 23:37:42 +08:00
parent a628fdb434
commit 326253a73b
5 changed files with 34 additions and 13 deletions

View File

@ -3,6 +3,7 @@
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
uniform mat4 mvp;
uniform mat4 lightspace;
uniform vec3 viewPos;
@ -33,7 +34,7 @@ void main() {
vec4 posView = view * pos4;
fragDepthView = posView.z;
gl_Position = projection * posView;
gl_Position = mvp * vec4(vert, 1);
fragPosWorld -= viewPos;
}

View File

@ -24,8 +24,6 @@ in vec2 fragPosScreen;
out vec4 outputColor;
const float gamma = 2.2;
const float ambient = 0.3, specularStrength = 0.08, specularShininess = 8;
const float fogDensity = .00003;
@ -64,12 +62,12 @@ void main() {
color += vec4(fragColor.rgb * light, 0.0f);
color.a = fragColor.a;
color.rgb = pow(color.rgb, vec3(1.0/gamma));
float z = gl_FragCoord.z / gl_FragCoord.w;
float fog = clamp(exp(-fogDensity * z * z), 0.2, 1);
//float z = gl_FragCoord.z / gl_FragCoord.w;
//float fog = clamp(exp(-fogDensity * z * z), 0.2, 1);
outputColor = mix(fogColor, color, fog);
//outputColor = mix(fogColor, color, fog);
outputColor = color;
}
void lightSun() {

View File

@ -1,10 +1,15 @@
#version 330
uniform sampler2D tex;
uniform float gamma, exposure;
in vec2 fragPosScreen;
out vec4 outputColor;
void main() {
outputColor = texture(tex, fragPosScreen);
vec4 texColor = texture(tex, fragPosScreen);
if (texColor.a < 1e-4)
discard;
outputColor = vec4(pow(texColor.rgb / exposure, vec3(1.0/gamma)), 1.0f);
}

View File

@ -43,7 +43,7 @@ void main() {
color += vec4(fragColor.rgb * light, 0.0f);
color.a = fragColor.a;
color.rgb = pow(color.rgb, vec3(1.0/gamma));
color.rgb = color.rgb;
float z = gl_FragCoord.z / gl_FragCoord.w;
float fog = clamp(exp(-fogDensity * z * z), 0.2, 1);