retuned horizontal blur
This commit is contained in:
parent
5937638895
commit
e4c5715b3f
1 changed files with 10 additions and 15 deletions
|
@ -8,21 +8,16 @@ float avg(float l, float c, float r) {
|
||||||
vec3 hblur() {
|
vec3 hblur() {
|
||||||
vec3 center = texture2D(gcolor, texcoord).rgb;
|
vec3 center = texture2D(gcolor, texcoord).rgb;
|
||||||
|
|
||||||
vec2 leftPos = texcoord - neighborOffset;
|
vec3 sum = vec3(0);
|
||||||
vec2 rightPos = texcoord + neighborOffset;
|
int count = 0;
|
||||||
|
for(int x = -2; x < 2; x++) {
|
||||||
vec3 left;
|
vec2 pos = texcoord - (neighborOffset * x);
|
||||||
if(leftPos.x >= 0)
|
if(pos.x >= 0 && pos.x < viewWidth) {
|
||||||
left = texture2D(gcolor, leftPos).rgb;
|
sum += texture2D(gcolor, pos).rgb;
|
||||||
else
|
count++;
|
||||||
left = center;
|
}
|
||||||
|
}
|
||||||
vec3 right;
|
|
||||||
if(rightPos.x >= 0)
|
return sum / count;
|
||||||
right = texture2D(gcolor, rightPos).rgb;
|
|
||||||
else
|
|
||||||
right = center;
|
|
||||||
|
|
||||||
return vec3(avg(left.r, center.r, right.r), avg(left.g, center.g, right.g), avg(left.b, center.b, right.b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue