First commit
This commit is contained in:
70
shaders/old/tonemap.shader
Executable file
70
shaders/old/tonemap.shader
Executable file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Kepler - Core
|
||||
* Copyright (c) 2010 kaj dijkstra STUDIOS
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Author: Kaj Dijksta
|
||||
*/
|
||||
|
||||
attribute vec3 position;
|
||||
attribute vec2 uv;
|
||||
|
||||
uniform mat4 viewProjection;
|
||||
|
||||
varying vec2 v_textureCoord;
|
||||
|
||||
void main(void) {
|
||||
|
||||
v_textureCoord = uv;
|
||||
gl_Position = viewProjection * vec4(position, 1.0);
|
||||
|
||||
}
|
||||
|
||||
// #keplerEngine - Split
|
||||
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D colorSampler;
|
||||
uniform float exposure;
|
||||
|
||||
varying vec2 v_textureCoord;
|
||||
|
||||
vec3 HDR_ACES(const vec3 x) {
|
||||
// Narkowicz 2015, "ACES Filmic Tone Mapping Curve"
|
||||
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 (x * (a * x + b)) / (x * (c * x + d) + e);
|
||||
}
|
||||
|
||||
vec3 tonemap(const vec3 x) {
|
||||
return HDR_ACES(x);
|
||||
}
|
||||
|
||||
float linearToSRGB(float c) {
|
||||
return (c <= 0.0031308) ? c * 12.92 : (pow(abs(c), 1.0 / 2.4) * 1.055) - 0.055;
|
||||
}
|
||||
|
||||
vec3 linearToSRGB(vec3 c) {
|
||||
return vec3(linearToSRGB(c.r), linearToSRGB(c.g), linearToSRGB(c.b));
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 pbr = texture2D( colorSampler, v_textureCoord ).rgb;
|
||||
gl_FragColor = vec4( pbr , 1.0 );
|
||||
//pbr.rgb *= exposure;
|
||||
|
||||
//if(v_textureCoord.x < 0.5) {
|
||||
// gl_FragColor = vec4( linearToSRGB( tonemap(pbr) ), 1.0 );
|
||||
//} else {
|
||||
// gl_FragColor = vec4(
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user