• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Fragment Shader Compile Error

G

GenesisPig

Guest
Hello:

I'm trying to make a simple outline shader for sprites. However, when I compile, I get a strange error:

Fragment Shader: shd_outline at line 9 : ''

This is the "void main()" command that appears anytime you make a new shader. I noticed that the "main" is not highlighted red like it is expected to be. Furthermore, the main appears to be nonfunctional even when I create a new shader. These problems persist between different project files as well.

Has the main become obsolete or something? Does anyone know a workaround?

Heres my fragment shader code:

//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float pixelH;
uniform pixelW;

void main() // <- Where the error is
{
vec2 offsetx;
offsetx.x = pixelW;
vec2 offsety;
offset.y = pixelH;

float alpha = texture2D( gm_BaseTexture, v_vTexcoord ).a;
alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord + offsetx).a;
alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord - offsetx).a;
alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord + offsety).a;
alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord - offsety).a;

gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor.a = alpha;
}
 
G

GenesisPig

Guest
I appeared to have some errors in my code, but now I get a new error:

Fragment Shader: shd_outline at line 21 : '

Code:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float pixelW;
uniform float pixelH;

void main()

{
    vec2 offsetx;
    offsetx.x = pixelW;
    vec2 offsety;
    offsety.y = pixelH;
   
    float alpha = texture2D( gm_BaseTexture, v_vTexcoord ).a;
   
    alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord + offsetx).a;
    alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord - offsetx).a;
    alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord - offsety).a;
    alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord + offsety).a;
   
    gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
    gl_FragColor.a = alpha;
}
This is the "alpha += ceil(texture2D( gm_BaseTexture, v_vTexcoord - offsety).a;" line
 
Top