-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
741f9a6
commit be11dba
Showing
3 changed files
with
37 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,42 @@ | ||
#ifdef GL_ES | ||
#ifdef GL_FRAGMENT_PRECISION_HIGH | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
#endif | ||
#version 300 es | ||
|
||
#if __VERSION__ == 300 | ||
#version 300 es | ||
in vec2 TexCoords; | ||
out vec4 FragColor; | ||
#else | ||
varying vec2 TexCoords; | ||
#endif | ||
precision highp float; | ||
|
||
in vec2 TexCoords; | ||
|
||
uniform sampler2D screen; | ||
uniform vec2 screenSize; | ||
uniform bool fast; | ||
uniform bool first; | ||
uniform float radius; | ||
|
||
out vec4 FragColor; | ||
|
||
void main() { | ||
float scaledRadius = radius * screenSize.y * 0.5; | ||
vec2 texOffset = 1.0 / screenSize; // gets size of single texel | ||
|
||
vec3 result = texture2D(screen, TexCoords).rgb; | ||
vec3 result = texture(screen, TexCoords).rgb; | ||
scaledRadius *= radius * 10.0 / ((radius * 10.0 + 1.0) * (radius * 10.0 + 1.0) - 1.0); | ||
float weight = 1.0; | ||
float weightSum = weight; | ||
if (first) { | ||
for (int i = 1; float(i) < scaledRadius; i++) { | ||
weight -= 1.0 / scaledRadius; | ||
weightSum += weight * 2.0; | ||
result += texture2D(screen, TexCoords + vec2(texOffset.x * float(i), 0.0)).rgb * weight; | ||
result += texture2D(screen, TexCoords - vec2(texOffset.x * float(i), 0.0)).rgb * weight; | ||
result += texture(screen, TexCoords + vec2(texOffset.x * float(i), 0.0)).rgb * weight; | ||
result += texture(screen, TexCoords - vec2(texOffset.x * float(i), 0.0)).rgb * weight; | ||
} | ||
} else { | ||
} | ||
else { | ||
for (int i = 1; float(i) < scaledRadius; i++) { | ||
weight -= 1.0 / scaledRadius; | ||
weightSum += weight * 2.0; | ||
result += texture2D(screen, TexCoords + vec2(0.0, texOffset.y * float(i))).rgb * weight; | ||
result += texture2D(screen, TexCoords - vec2(0.0, texOffset.y * float(i))).rgb * weight; | ||
result += texture(screen, TexCoords + vec2(0.0, texOffset.y * float(i))).rgb * weight; | ||
result += texture(screen, TexCoords - vec2(0.0, texOffset.y * float(i))).rgb * weight; | ||
} | ||
} | ||
result /= weightSum; | ||
|
||
#if __VERSION__ == 300 | ||
|
||
FragColor = vec4(result, 1.0); | ||
#else | ||
gl_FragColor = vec4(result, 1.0); | ||
#endif | ||
} |
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