[orx-fx] Fix GLES compatibility for FrameBlur and MipBloom
This commit is contained in:
@@ -19,11 +19,7 @@ void main() {
|
||||
for (int x = -w; x <= w; ++x) {
|
||||
float lw = exp( float(-(x*x)) / (2.0 * sigma * sigma) ) ;
|
||||
vec2 tc = v_texCoord0 + float(x) * blurDirection * s;// * spread;
|
||||
#ifndef OR_WEBGL2
|
||||
sum += textureLod(tex0, tc, float(sourceLevel)) * lw;
|
||||
#else
|
||||
sum += texture(tex0, tc);
|
||||
#endif
|
||||
sum += texture(tex0, tc) * lw;
|
||||
weight += lw;
|
||||
}
|
||||
o_color = (sum / weight) * gain;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
out vec4 o_output;
|
||||
in vec2 v_texCoord0;
|
||||
uniform sampler2D tex0;
|
||||
highp out vec4 o_output;
|
||||
highp in vec2 v_texCoord0;
|
||||
uniform highp sampler2D tex0;
|
||||
|
||||
|
||||
// -- based on https://github.com/excess-demogroup/even-laster-engine/blob/a451a89f6bd6d3c6017d5890b92d9f72823bc742/src/shaders/bloom.fra
|
||||
@@ -11,9 +11,9 @@ void main()
|
||||
vec4 offsets = vec4(-diagonalOffsets.xy, +diagonalOffsets.xy) / vec2(textureSize(tex0, 0)).xyxy;
|
||||
float diagonalWeight = 0.2085034734347498;
|
||||
|
||||
o_output = textureLod(tex0, v_texCoord0, 0.0) * centerWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.xy, 0.0) * diagonalWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.wx, 0.0) * diagonalWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.zw, 0.0) * diagonalWeight +
|
||||
textureLod(tex0, v_texCoord0 + offsets.yz, 0.0) * diagonalWeight;
|
||||
o_output = texture(tex0, v_texCoord0) * centerWeight +
|
||||
texture(tex0, v_texCoord0 + offsets.xy) * diagonalWeight +
|
||||
texture(tex0, v_texCoord0 + offsets.wx) * diagonalWeight +
|
||||
texture(tex0, v_texCoord0 + offsets.zw) * diagonalWeight +
|
||||
texture(tex0, v_texCoord0 + offsets.yz) * diagonalWeight;
|
||||
}
|
||||
@@ -6,7 +6,6 @@ float nrand(vec2 n) {
|
||||
uniform float noiseSeed;
|
||||
uniform float shape;
|
||||
uniform float gain;
|
||||
|
||||
uniform float noiseGain;
|
||||
|
||||
in vec2 v_texCoord0;
|
||||
@@ -28,7 +27,7 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 2.0 - 1.0) / vec2(textureSize(tex0, 0));
|
||||
sum += textureLod(tex0, pos + rnd * noiseGain, 0.0) * weight;
|
||||
sum += texture(tex0, pos + rnd * noiseGain) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
@@ -36,7 +35,7 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 2.0 - 1.0) / vec2(textureSize(tex0, 0));
|
||||
sum += textureLod(tex1, pos + rnd * noiseGain, 0.0) * weight;
|
||||
sum += texture(tex1, pos + rnd * noiseGain, 0.0) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
@@ -44,7 +43,7 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 2.0 - 1.0) / vec2(textureSize(tex0, 0));
|
||||
sum += textureLod(tex2, pos + rnd * noiseGain, 0.0) * weight;
|
||||
sum += texture(tex2, pos + rnd * noiseGain) * weight;
|
||||
total += weight;
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 3.0 - 1.0) / vec2(textureSize(tex0, 0));
|
||||
sum += textureLod(tex3, pos + rnd * noiseGain, 0.0) * weight;
|
||||
sum += texture(tex3, pos + rnd * noiseGain) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
@@ -61,7 +60,7 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 3.0 - 1.0) / vec2(textureSize(tex0, 0));
|
||||
sum += textureLod(tex4, pos + rnd * noiseGain, 0.0) * weight;
|
||||
sum += texture(tex4, pos + rnd * noiseGain) * weight;
|
||||
total += weight;
|
||||
}
|
||||
{
|
||||
@@ -69,7 +68,7 @@ vec4 sampleBloom(vec2 pos, float shape) {
|
||||
vec2 rnd = vec2(nrand(3.0 + 0.0 + pos.xy + noiseSeed),
|
||||
nrand(5.0 + 0.0 + pos.yx - noiseSeed));
|
||||
rnd = (rnd * 3.0 - 1.0) / vec2(textureSize(tex0, 0));
|
||||
sum += textureLod(tex5, pos + rnd * noiseGain, 0.0) * weight;
|
||||
sum += texture(tex5, pos + rnd * noiseGain) * weight;
|
||||
total += weight;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,24 +6,20 @@ uniform float sigma;
|
||||
uniform float spread;
|
||||
uniform float gain;
|
||||
|
||||
|
||||
out vec4 o_color;
|
||||
void main() {
|
||||
|
||||
vec2 s = vec2(textureSize(tex0, 0).xy);
|
||||
s = vec2(1.0/s.x, 1.0/s.y);
|
||||
|
||||
vec2 s = vec2(textureSize(tex0, 0).xy);
|
||||
s = vec2(1.0 / s.x, 1.0 / s.y);
|
||||
int w = window;
|
||||
|
||||
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
float weight = 0.0;
|
||||
for (int y = -w; y<= w; ++y) {
|
||||
for (int x = -w; x<= w; ++x) {
|
||||
float lw = exp(-float(x*x+y*y) / (2.0 * sigma * sigma));
|
||||
sum+=texture(tex0, v_texCoord0 + vec2(x, y) * s * spread) * lw;
|
||||
weight+=lw;
|
||||
for (int y = -w; y <= w; ++y) {
|
||||
for (int x = -w; x <= w; ++x) {
|
||||
float lw = exp(-float(x * x + y * y) / (2.0 * sigma * sigma));
|
||||
sum += texture(tex0, v_texCoord0 + vec2(x, y) * s * 1.0) * lw;
|
||||
weight += lw;
|
||||
}
|
||||
}
|
||||
|
||||
o_color = (sum / weight) * gain;
|
||||
}
|
||||
Reference in New Issue
Block a user