S
SuperSaabrio
Guest
So I thought I was finally understanding shaders after I manage to make a basic color flash shader, but it seems I really do not.
I want to make a shader that sets every alpha value of a pixel above the half way point of the sprite to 0. Yes I know I can use draw sprite part, but the functionality isn't whats important, it's the fact that if I can understand how to do this then I can make a shader that fits my end goal.
I was under the impression that the main function loops once for every pixel on the screen and that v_vTexcoord was the x,y position within the sprite. I already tried
main()
{
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
if (v_vTexcoord.y > 0.5)
{
gl_FragColor.a = 0.0;
}
}
but that didn't work, so I obviously lack an understanding of how fragment shader actually works.
I want to make a shader that sets every alpha value of a pixel above the half way point of the sprite to 0. Yes I know I can use draw sprite part, but the functionality isn't whats important, it's the fact that if I can understand how to do this then I can make a shader that fits my end goal.
I was under the impression that the main function loops once for every pixel on the screen and that v_vTexcoord was the x,y position within the sprite. I already tried
main()
{
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
if (v_vTexcoord.y > 0.5)
{
gl_FragColor.a = 0.0;
}
}
but that didn't work, so I obviously lack an understanding of how fragment shader actually works.