ToyEngine/Demo/Engine/Shaders/skybox.frag

33 lines
668 B
GLSL
Raw Normal View History

2023-04-16 17:12:29 +08:00
#version 450 core
out vec4 FragColor;
in vec3 WorldPos;
uniform samplerCube environmentMap;
uniform float exposure = 1;
vec3 ACESToneMapping(vec3 color)
{
const float A = 2.51;
const float B = 0.03;
const float C = 2.43;
const float D = 0.59;
const float E = 0.14;
return (color * (A * color + B)) / (color * (C * color + D) + E);
}
void main()
{
vec3 color = texture(environmentMap, WorldPos).rgb;
// HDR tonemap
//envColor = envColor / (envColor + vec3(1.0));
color *= exposure;
color = ACESToneMapping(color);
// gamma correct
color = pow(color, vec3(1.0/2.2));
FragColor = vec4(color, 1.0);
}