Urho3D/bin/CoreData/Shaders/GLSL/Tonemap.glsl
2015-01-18 21:31:13 +08:00

41 lines
1.1 KiB
GLSL

#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#include "ScreenPos.glsl"
#include "PostProcess.glsl"
varying vec2 vScreenPos;
#ifdef COMPILEPS
uniform float cTonemapExposureBias;
uniform float cTonemapMaxWhite;
#endif
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vScreenPos = GetScreenPosPreDiv(gl_Position);
}
void PS()
{
#ifdef REINHARDEQ3
vec3 color = ReinhardEq3Tonemap(max(texture2D(sDiffMap, vScreenPos).rgb * cTonemapExposureBias, 0.0));
gl_FragColor = vec4(color, 1.0);
#endif
#ifdef REINHARDEQ4
vec3 color = ReinhardEq4Tonemap(max(texture2D(sDiffMap, vScreenPos).rgb * cTonemapExposureBias, 0.0), cTonemapMaxWhite);
gl_FragColor = vec4(color, 1.0);
#endif
#ifdef UNCHARTED2
vec3 color = Uncharted2Tonemap(max(texture2D(sDiffMap, vScreenPos).rgb * cTonemapExposureBias, 0.0)) /
Uncharted2Tonemap(vec3(cTonemapMaxWhite, cTonemapMaxWhite, cTonemapMaxWhite));
gl_FragColor = vec4(color, 1.0);
#endif
}