forked from minetest/minetest
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds configurable light exposure control and bloom effect (light bleeding) with client-side settings.
- Loading branch information
Showing
16 changed files
with
422 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#define rendered texture0 | ||
|
||
uniform sampler2D rendered; | ||
uniform vec2 texelSize0; | ||
uniform mediump float bloomRadius = 3.0; | ||
|
||
#ifdef GL_ES | ||
varying mediump vec2 varTexCoord; | ||
#else | ||
centroid varying vec2 varTexCoord; | ||
#endif | ||
|
||
void main(void) | ||
{ | ||
// kernel distance and linear size | ||
mediump float n = 2. * bloomRadius + 1.; | ||
|
||
vec2 uv = varTexCoord.st - vec2(bloomRadius * texelSize0.x, 0.); | ||
vec4 color = vec4(0.); | ||
mediump float sum = 0.; | ||
for (mediump float i = 0.; i < n; i++) { | ||
mediump float weight = pow(1. - (abs(i / bloomRadius - 1.)), 1.3); | ||
color += texture2D(rendered, uv).rgba * weight; | ||
sum += weight; | ||
uv += vec2(texelSize0.x, 0.); | ||
} | ||
color /= sum; | ||
gl_FragColor = vec4(color.rgb, 1.0); // force full alpha to avoid holes in the image. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifdef GL_ES | ||
varying mediump vec2 varTexCoord; | ||
#else | ||
centroid varying vec2 varTexCoord; | ||
#endif | ||
|
||
void main(void) | ||
{ | ||
varTexCoord.st = inTexCoord0.st; | ||
gl_Position = inVertexPosition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#define rendered texture0 | ||
|
||
uniform sampler2D rendered; | ||
uniform vec2 texelSize0; | ||
uniform mediump float bloomRadius = 3.0; | ||
|
||
#ifdef GL_ES | ||
varying mediump vec2 varTexCoord; | ||
#else | ||
centroid varying vec2 varTexCoord; | ||
#endif | ||
|
||
void main(void) | ||
{ | ||
// kernel distance and linear size | ||
mediump float n = 2. * bloomRadius + 1.; | ||
|
||
vec2 uv = varTexCoord.st - vec2(0., bloomRadius * texelSize0.y); | ||
vec4 color = vec4(0.); | ||
mediump float sum = 0.; | ||
for (mediump float i = 0.; i < n; i++) { | ||
mediump float weight = pow(1. - (abs(i / bloomRadius - 1.)), 1.3); | ||
color += texture2D(rendered, uv).rgba * weight; | ||
sum += weight; | ||
uv += vec2(0., texelSize0.y); | ||
} | ||
color /= sum; | ||
gl_FragColor = vec4(color.rgb, 1.0); // force full alpha to avoid holes in the image. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifdef GL_ES | ||
varying mediump vec2 varTexCoord; | ||
#else | ||
centroid varying vec2 varTexCoord; | ||
#endif | ||
|
||
void main(void) | ||
{ | ||
varTexCoord.st = inTexCoord0.st; | ||
gl_Position = inVertexPosition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#define rendered texture0 | ||
|
||
uniform sampler2D rendered; | ||
uniform mediump float exposureFactor = 2.5; | ||
uniform float bloomLuminanceThreshold = 1.0; | ||
|
||
#ifdef GL_ES | ||
varying mediump vec2 varTexCoord; | ||
#else | ||
centroid varying vec2 varTexCoord; | ||
#endif | ||
|
||
|
||
void main(void) | ||
{ | ||
vec2 uv = varTexCoord.st; | ||
vec4 color = texture2D(rendered, uv).rgba; | ||
// translate to linear colorspace (approximate) | ||
color.rgb = pow(color.rgb, vec3(2.2)) * exposureFactor; | ||
gl_FragColor = vec4(color.rgb, 1.0); // force full alpha to avoid holes in the image. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifdef GL_ES | ||
varying mediump vec2 varTexCoord; | ||
#else | ||
centroid varying vec2 varTexCoord; | ||
#endif | ||
|
||
void main(void) | ||
{ | ||
varTexCoord.st = inTexCoord0.st; | ||
gl_Position = inVertexPosition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.