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

Author Topic: SFML.Net, Failed to compile Fragement Shader error(#60)  (Read 4518 times)

0 Members and 1 Guest are viewing this topic.

Raptor2277

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
SFML.Net, Failed to compile Fragement Shader error(#60)
« on: August 26, 2015, 06:01:05 pm »
It runs fine on my computer and some of my friends' computers. But when I try it on others, I get this error.

Failed to compile fragment shader:
Fragment shader failed to compile with the following erros:
ERROR: error(#60) Unknown char: ""
ERROR: error(#273) 1 compilation erros. No code generated

Thnks in advance.

Raptor2277

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #1 on: August 26, 2015, 06:36:35 pm »
Here is the shader.

uniform vec2 lightPos;
uniform vec3 lightColor;
uniform float screenHeight;

uniform sampler2D texture;

void main()
{   
   lightPos.y = screenHeight - lightPos.y;
   float length = length(lightPos - gl_FragCoord.xy);
   float attenuation = 1.0 / (length/10) + .2;

   vec4 color2 = vec4(lightColor, 1) * attenuation;
   
   vec4 color = texture2D(texture,gl_TexCoord[0].st);

   if(color == vec4(0,0,0,1))
      gl_FragColor = color;
   else
      gl_FragColor = color2;

}

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #2 on: August 26, 2015, 07:15:41 pm »
Are you sure that shaders are available in the computers that have a problem?
What does
sf::Shader::isAvailable()
return?

You should always test for shader support with sf::Shader::isAvailable() before trying to use shaders and then either tell the user that shader support is required and exit or fall back to running without shaders.

Raptor2277

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #3 on: August 26, 2015, 10:47:39 pm »
It is.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #4 on: August 26, 2015, 10:57:05 pm »
It is.
Which question does this answer?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Ztormi

  • Jr. Member
  • **
  • Posts: 71
  • Web developer by day. Game developer by night.
    • View Profile
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #5 on: August 26, 2015, 11:25:29 pm »
Reminds me of a situation at work some time ago. I had copypasted a piece of Javascript from some website and ran into a syntax error on an empty line  :o

Turned out there was a nonprintable character which Visual Studio and web debugger didn't recognize and I just wasted an hour or two wondering what the heck can be wrong with an empty line of code...

Raptor2277

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #6 on: August 27, 2015, 04:17:35 am »
The computer supports shaders because I've had in not compile once because one didn't support shaders. It gave an error before it even began compiling.

I've also tried some debugging like reading the file and outputting it to cmd before trying to create the shader class. It reads fine and prints the contents of the txt file fine.

Raptor2277

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: SFML.Net, Failed to compile Fragement Shader error(#60)
« Reply #7 on: August 28, 2015, 05:21:48 pm »
I have made it work.

It turns out that it might be an encoding problem. What I did is create a new text document on the computer that I'm trying to make it work on and copy the contents of the shader there. Then I "save as" replacing the original shader. It loads fine with no errors.

The problem is I don't know anything about encoding. If someone could point me in the right direction how to write and safe shaders in a way that it will work on all platforms.

Thank you all for your help.

 

anything