Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: GLSL beginner needs help!  (Read 3213 times)

0 Members and 1 Guest are viewing this topic.

ief015

  • Newbie
  • *
  • Posts: 7
    • View Profile
GLSL beginner needs help!
« on: December 08, 2010, 10:57:40 pm »
Image here!

I'm a beginner with GLSL, and if you look at the image above, I'm having some issues. D:

The glow looks like it's working just fine, except the strange diagonal tear and strange blocks appearing.

I have two RenderImages, one that renders the shader/glow, and one on top of that one with the points without shading.

The shader RenderImage first uses a shader that "stretches" the pixels horizontally, then it uses a second shader that does the same thing, except horizontally.

Horizontal shader:
Code: [Select]

//HORIZONTAL GLOW

uniform float fadedelta;
/*
//Fading Delta:
float fadedelta = 0f;
for (float i = 0f; i < 10f * glowMul; i++)
fadedelta += (1f - (i / (10f * glowMul)));
fadedelta = 1f / (1f + 2f * fadedelta);
*/

uniform sampler2D img;
uniform float width;
uniform float g; //glow multiplier (glowMul)

void main() {
vec2 step = vec2(1. / width, 0.);
vec4 clr = texture2D(img, gl_TexCoord[0].st);

vec4 c = clr * fadedelta;

float threshold = 10. * g;
for(float i = 0.; i < threshold; i++) {
vec4 c_inc;

c_inc = texture2D(img, gl_TexCoord[0].st + step * i);
c += c_inc * (1. - (fadedelta * i)) * fadedelta;

c_inc = texture2D(img, gl_TexCoord[0].st - step * i);
c += c_inc * (1. - (fadedelta * i)) * fadedelta;
}
gl_FragColor = c * g;
}


Vertical shader:
Code: [Select]

//VERTICAL GLOW

uniform float fadedelta;
/*
//Fading Delta:
float fadedelta = 0f;
for (float i = 0f; i < 10f * glowMul; i++)
fadedelta += (1f - (i / (10f * glowMul)));
fadedelta = 1f / (1f + 2f * fadedelta);
*/

uniform sampler2D img;
uniform float height;
uniform float g; //glow multiplier (glowMul)

void main() {
vec2 step = vec2(0., 1. / height);
vec4 clr = texture2D(img, gl_TexCoord[0].st);

vec4 c = clr * fadedelta;

float threshold = 10. * g;
for(float i = 0.; i < threshold; i++) {
vec4 c_inc;

c_inc = texture2D(img, gl_TexCoord[0].st + step * i);
c += c_inc * (1. - (fadedelta * i)) * fadedelta;

c_inc = texture2D(img, gl_TexCoord[0].st - step * i);
c += c_inc * (1. - (fadedelta * i)) * fadedelta;
}
gl_FragColor = c * g;
}


Thanks for any help. :3

Also if it helps, I'm using C# and the latest build of the SFML 2 .NET binding.
I can post the application source if I need to.

EDIT:

I think I got it