I trying rewrite (port to Love2D) simple shadow shaders from tutorials but none of them work.
My last try is with this tutorial https://ostindiegames.wordpress.com/201 ... ow-system/ and too not work. I do not know what is wrong. My experience is poor with shaders but i can write little stuff.
So my code looks that:
Code: Select all
uniform sampler2D TextureSampler;
uniform sampler2D StencilSampler;
vec4 effect( vec4 color, Image texture, vec2 texCoord, vec2 scrCoord)
{
vec4 oldColor = Texel(StencilSampler, texCoord);
vec2 newCoords = vec2(texCoord.x + (.5 - texCoord.x)*.5, texCoord.y + (.5 - texCoord.y)*.5);
vec4 newColor = Texel(StencilSampler, newCoords);
if (newColor.r == 0)
{
oldColor = newColor;
}
newCoords = vec2(texCoord.x + (.5 - texCoord.x)*.85, texCoord.y + (.5 - texCoord.y)*.85);
newColor = Texel(StencilSampler, newCoords);
if (newColor.r == 0)
{
oldColor = newColor;
}
return color*oldColor;
}