Allegro.cc Forums » Programming Questions » Why some Shaders don't work !

 Why some Shaders don't work !
 SilverTES Member #16,572 October 2016 #SelectExpand 1---[Vertex_Shader] 2void main(void) 3{ 4 gl_Position = ftransform(); 5 gl_TexCoord[0] = gl_MultiTexCoord0; 6} 7 8---[Pixel_Shader] 9uniform sampler2D al_tex; // 0 10uniform vec2 center; // Mouse position 11uniform float time; // effect elapsed time 12uniform vec3 shockParams; // 10.0, 0.8, 0.1 13void main() 14{ 15 vec2 uv = gl_TexCoord[0].xy; 16 vec2 texCoord = uv; 17 float distance = distance(uv, center); 18 if ( (distance <= (time + shockParams.z)) && 19 (distance >= (time - shockParams.z)) ) 20 { 21 float diff = (distance - time); 22 float powDiff = 1.0 - pow(abs(diff*shockParams.x), 23 shockParams.y); 24 float diffTime = diff * powDiff; 25 vec2 diffUV = normalize(uv - center); 26 texCoord = uv + (diffUV * diffTime); 27 } 28 gl_FragColor = texture2D(al_tex, texCoord); 29} Effect : It's just a simple shockwave effect but don't work!but this one work fine : #SelectExpand 1---[Vertex_Shader] 2I use "al_get_default_shader_source(ALLEGRO_SHADER_GLSL, ALLEGRO_VERTEX_SHADER)" 3 4---[Pixel_Shader] 5uniform sampler2D al_tex; 6uniform float radius; 7varying vec2 varying_texcoord; 8 9void main () 10{ 11 vec2 pos = mod(gl_FragCoord.xy, vec2(40.0)) - vec2(20.0); 12 float dist_squared = dot(pos, pos); 13 vec4 tmp = texture2D(al_tex, varying_texcoord); 14 15 if (dist_squared < radius && (tmp.r>0 || tmp.g>0 || tmp.b>0) ) 16 gl_FragColor = vec4(.0+tmp.r, .0+tmp.g, .0+tmp.b, 1.0); 17 else 18 gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); 19} Effect : tile of filled circles with settable radius ! why
 Edgar Reynaldo Major Reynaldo May 2007 Check your return values.
 SilverTES Member #16,572 October 2016 I don't have any errors.
 Edgar Reynaldo Major Reynaldo May 2007 All your shaders compiled and bound without error?
 SilverTES Member #16,572 October 2016 Yes I checked them, step by step.
 Edgar Reynaldo Major Reynaldo May 2007 I don't understand shaders very well, so I can't help much. Perhaps the error is in the way you're using your shaders? Have you set the correct drawing targets? Did you bind the shaders and then use them right afterwards?
 SilverTES Member #16,572 October 2016 I do exactly the same method with the Two Shaders above ( Shockwave & Tile circle).One works the other not.Unfortunately, It's really really hard to find some shader's tutorials using with Allegro 5.The examples are not really explicative. I have to guess when I read.
 Edgar Reynaldo Major Reynaldo May 2007 Try and post code if you can. Create the smallest example possible to demonstrate that one shader works and the other doesn't.