mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 04:30:09 -05:00
Copied changes from old HDR branch to new one.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout (location = 0) out vec4 finalColor;
|
||||
|
||||
uniform int pass;
|
||||
uniform sampler2DMS filterImage;
|
||||
uniform sampler2D filterFirstPass;
|
||||
|
||||
// Gaussian Weights from OpenGL SuperBible 7 ed.
|
||||
const float weights[] = float[](0.0024499299678342,
|
||||
0.0043538453346397,
|
||||
0.0073599963704157,
|
||||
0.0118349786570722,
|
||||
0.0181026699707781,
|
||||
0.0263392293891488,
|
||||
0.0364543006660986,
|
||||
0.0479932050577658,
|
||||
0.0601029809166942,
|
||||
0.0715974486241365,
|
||||
0.0811305381519717,
|
||||
0.0874493212267511,
|
||||
0.0896631113333857,
|
||||
0.0874493212267511,
|
||||
0.0811305381519717,
|
||||
0.0715974486241365,
|
||||
0.0601029809166942,
|
||||
0.0479932050577658,
|
||||
0.0364543006660986,
|
||||
0.0263392293891488,
|
||||
0.0181026699707781,
|
||||
0.0118349786570722,
|
||||
0.0073599963704157,
|
||||
0.0043538453346397,
|
||||
0.0024499299678342);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = vec4(0.0);
|
||||
// Transpose the image so the filter can be applied on X and Y
|
||||
ivec2 P = ivec2(gl_FragCoord.yx) - ivec2(0, weights.length() >> 1);
|
||||
|
||||
for (int i = 0; i < weights.length(); i++)
|
||||
{
|
||||
if (pass == 1)
|
||||
color += vec4(texelFetch(filterImage, P + ivec2(0, i), 0).rgb, 1.0) * weights[i];
|
||||
else if (pass == 2)
|
||||
color += vec4(texelFetch(filterFirstPass, P + ivec2(0, i), 0).rgb, 1.0) * weights[i];
|
||||
}
|
||||
|
||||
finalColor = vec4(color.rgb, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
void main(void)
|
||||
{
|
||||
const vec4 vertices[] = vec4[](vec4(-1.0, -1.0, 0.5, 1.0),
|
||||
vec4( 1.0, -1.0, 0.5, 1.0),
|
||||
vec4(-1.0, 1.0, 0.5, 1.0),
|
||||
vec4( 1.0, 1.0, 0.5, 1.0));
|
||||
|
||||
gl_Position = vertices[gl_VertexID];
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout (location = 0) out vec4 finalColor;
|
||||
|
||||
uniform float bloomOrigFactor;
|
||||
uniform float bloomNewFactor;
|
||||
uniform sampler2D renderedImage;
|
||||
uniform sampler2D bloomImage;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
color += texelFetch(renderedImage, ivec2(gl_FragCoord.xy), 0) * bloomOrigFactor;
|
||||
float alpha = color.a;
|
||||
color += texelFetch(bloomImage, ivec2(gl_FragCoord.xy), 0) * bloomNewFactor;
|
||||
|
||||
finalColor = vec4(color.rgb, alpha);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
void main(void)
|
||||
{
|
||||
const vec4 vertices[] = vec4[](vec4(-1.0, -1.0, 0.5, 1.0),
|
||||
vec4( 1.0, -1.0, 0.5, 1.0),
|
||||
vec4(-1.0, 1.0, 0.5, 1.0),
|
||||
vec4( 1.0, 1.0, 0.5, 1.0));
|
||||
|
||||
gl_Position = vertices[gl_VertexID];
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout (location = 0) out vec4 finalColor;
|
||||
|
||||
uniform int bufferWidth;
|
||||
uniform int bufferHeight;
|
||||
uniform sampler2D hdrTexture;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
float fH = float(bufferHeight);
|
||||
float fW = float(bufferWidth);
|
||||
|
||||
float sum = 0.f;
|
||||
for (int i = 0; i < bufferHeight; ++i) {
|
||||
for (int j = 0; j < bufferWidth; ++j) {
|
||||
vec2 texCoord = vec2(float(i) / fH, float(j) / fW);
|
||||
vec4 tmpColor = texture(hdrTexture, texCoord);
|
||||
float lum = dot(tmpColor.xyz, vec3(0.2126f, 0.7152f, 0.0722f));
|
||||
sum += log(lum + 0.00001);
|
||||
}
|
||||
}
|
||||
|
||||
finalColor = vec4(vec3(exp(sum / (fH * fW))), 1.0);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
#include "hdr.glsl"
|
||||
|
||||
layout (location = 0) out vec4 finalColor;
|
||||
|
||||
uniform float backgroundConstant;
|
||||
uniform float backgroundExposure;
|
||||
uniform float blackoutFactor;
|
||||
uniform float gamma;
|
||||
uniform float maxWhite;
|
||||
uniform float aveLum;
|
||||
uniform int toneMapOperator;
|
||||
|
||||
uniform sampler2D deferredResultsTexture;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
vec4 adaptiveToneMap() {
|
||||
int i;
|
||||
float lum[25];
|
||||
vec2 tex_scale = vec2(1.0) / textureSize(deferredResultsTexture, 0);
|
||||
|
||||
for (i = 0; i < 25; i++)
|
||||
{
|
||||
vec2 tc = (gl_FragCoord.xy + 3.5 * vec2(i % 5 - 2, i / 5 - 2));
|
||||
vec3 col = texture(deferredResultsTexture, tc * tex_scale).rgb;
|
||||
lum[i] = dot(col, vec3(0.3, 0.59, 0.11));
|
||||
}
|
||||
|
||||
// Calculate weighted color of region
|
||||
vec3 vColor = texelFetch(deferredResultsTexture, ivec2(gl_FragCoord.xy), 0).rgb;
|
||||
|
||||
float kernelLuminance = (
|
||||
(1.0 * (lum[0] + lum[4] + lum[20] + lum[24])) +
|
||||
(4.0 * (lum[1] + lum[3] + lum[5] + lum[9] +
|
||||
lum[15] + lum[19] + lum[21] + lum[23])) +
|
||||
(7.0 * (lum[2] + lum[10] + lum[14] + lum[22])) +
|
||||
(16.0 * (lum[6] + lum[8] + lum[16] + lum[18])) +
|
||||
(26.0 * (lum[7] + lum[11] + lum[13] + lum[17])) +
|
||||
(41.0 * lum[12])
|
||||
) / 273.0;
|
||||
|
||||
// Compute the corresponding exposure
|
||||
float exposure = sqrt(8.0 / (kernelLuminance + 0.25));
|
||||
|
||||
// Apply the exposure to this texel
|
||||
vec4 fColor;
|
||||
fColor.rgb = 1.0 - exp2(-vColor * exposure);
|
||||
fColor.a = 1.0f;
|
||||
|
||||
return fColor;
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 color = vec4(0.0);
|
||||
color = texture(deferredResultsTexture, texCoord);
|
||||
//color = texelFetch(deferredResultsTexture, ivec2(gl_FragCoord.xy), 0);
|
||||
color.a *= blackoutFactor;
|
||||
|
||||
if (toneMapOperator == EXPONENTIAL) {
|
||||
vec3 tColor = exponentialToneMapping(color.rgb, backgroundExposure, gamma);
|
||||
finalColor = vec4(tColor, color.a);
|
||||
} else if (toneMapOperator == LINEAR) {
|
||||
vec3 tColor = linearToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == SIMPLE_REINHARD) {
|
||||
vec3 tColor = simpleReinhardToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == LUM_BASED_REINHARD) {
|
||||
vec3 tColor = lumaBasedReinhardToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == WHITE_PRESERVING) {
|
||||
vec3 tColor = whitePreservingLumaBasedReinhardToneMapping(color.rgb, backgroundExposure, maxWhite);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == ROM_BIN_DA_HOUSE) {
|
||||
vec3 tColor = RomBinDaHouseToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == FILMIC) {
|
||||
vec3 tColor = filmicToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == UNCHARTED) {
|
||||
vec3 tColor = Uncharted2ToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == COSTA) {
|
||||
vec3 tColor = jToneMapping(color.rgb, backgroundExposure);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == ADAPTIVE) {
|
||||
vec3 tColor = vec3(adaptiveToneMap());
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
} else if (toneMapOperator == GLOBAL) {
|
||||
vec3 tColor = globalToneMappingOperatorRTR(color.rgb, backgroundExposure, maxWhite, aveLum);
|
||||
finalColor = vec4(gammaCorrection(tColor, gamma), color.a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
out vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
texCoord = 0.5 + position.xy * 0.5;
|
||||
gl_Position = position;
|
||||
}
|
||||
@@ -28,11 +28,29 @@
|
||||
layout(location = 0) out vec4 _out_color_;
|
||||
layout(location = 1) out vec4 gPosition;
|
||||
layout(location = 2) out vec4 gNormal;
|
||||
layout(location = 3) out vec4 filterBuffer;
|
||||
|
||||
void main() {
|
||||
Fragment f = getFragment();
|
||||
_out_color_ = f.color;
|
||||
gPosition = f.gPosition;
|
||||
gNormal = f.gNormal;
|
||||
|
||||
bool automaticBloom = false;
|
||||
if (automaticBloom) {
|
||||
// Extract luminance
|
||||
float Y = dot(f.color.rgb, vec3(0.299, 0.587, 0.144));
|
||||
|
||||
// Apply Bloom on the bloom threshold range values
|
||||
//vec4 bColor = f.color * 4.0 * smoothstep(bloom_thresh_min, bloom_thresh_max, Y);
|
||||
//filterBuffer = bColor
|
||||
filterBuffer = vec4(f.filterFlag);
|
||||
} else {
|
||||
if (f.filterFlag == 1)
|
||||
filterBuffer = f.color;
|
||||
else
|
||||
filterBuffer = vec4(0);
|
||||
}
|
||||
|
||||
gl_FragDepth = normalizeFloat(f.depth);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user