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

Author Topic: Failed to compile fragment shader  (Read 3765 times)

0 Members and 1 Guest are viewing this topic.

kaB00M

  • Full Member
  • ***
  • Posts: 101
    • View Profile
    • Caffeware
    • Email
Failed to compile fragment shader
« on: August 27, 2012, 01:00:16 pm »
Im getting this error:

Quote
Failed to compile fragment shader:
Sytax error: 'texture' parse error

texture framebuffer
float offset

effect
{
        vec2 offx = vec2(offset, 0.0);
        vec2 offy = vec2(0.0, offset);

        vec4 c0 = framebuffer(_in);
        vec4 c1 = framebuffer(_in - offy);
        vec4 c2 = framebuffer(_in + offy);
        vec4 c3 = framebuffer(_in - offx);
        vec4 c4 = framebuffer(_in + offx);

        _out = c0 * 0.2 + c1 * 0.2 + c2 * 0.2 + c3 * 0.2 + c4 * 0.2;
}
 

This worked fine in 1.6  ???
Thank you



eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Failed to compile fragment shader
« Reply #1 on: August 27, 2012, 01:11:25 pm »
Well SFML 1.6 isn't SFML 2, but I don't have that much knowledge on shaders, but you could take a look at the shader example that comes with SFML 2.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kaB00M

  • Full Member
  • ***
  • Posts: 101
    • View Profile
    • Caffeware
    • Email
Re: Failed to compile fragment shader
« Reply #2 on: August 27, 2012, 06:28:47 pm »
This one works, as an example!

uniform sampler2D texture;
uniform float blur_radius;

void main()
{
vec2 offx = vec2(blur_radius, 0.0);
vec2 offy = vec2(0.0, blur_radius);

vec4 pixel = texture2D(texture, gl_TexCoord[0].xy) * 4.0 +
                 texture2D(texture, gl_TexCoord[0].xy - offx) * 2.0 +
                 texture2D(texture, gl_TexCoord[0].xy + offx) * 2.0 +
                 texture2D(texture, gl_TexCoord[0].xy - offy) * 2.0 +
                 texture2D(texture, gl_TexCoord[0].xy + offy) * 2.0 +
                 texture2D(texture, gl_TexCoord[0].xy - offx - offy) * 1.0 +
                 texture2D(texture, gl_TexCoord[0].xy - offx + offy) * 1.0 +
                 texture2D(texture, gl_TexCoord[0].xy + offx - offy) * 1.0 +
                 texture2D(texture, gl_TexCoord[0].xy + offx + offy) * 1.0;

gl_FragColor = gl_Color * (pixel / 16.0);
}
 

Thank you once again.



Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Failed to compile fragment shader
« Reply #3 on: August 27, 2012, 08:25:37 pm »
SFML 2 uses pure GLSL syntax (as stated in the doc), there's no more syntactic shortcut.
Laurent Gomila - SFML developer