This repository is mostly just a sample for inspiration. For specialized functionality like this you should play with the render script and shaders. I’ve actually already experimented with exactly what you’re describing to create some sort of fog-of-war that hides shadowed objects.
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D tex0;
uniform lowp sampler2D tex1;
uniform lowp vec4 tint0;
uniform lowp vec4 tint1;
void main()
{
vec4 tint0_pm = vec4(tint0.xyz * tint0.w, tint0.w);
vec4 tint1_pm = vec4(tint1.xyz * tint1.w, tint1.w);
vec4 color0 = texture2D(tex0, var_texcoord0.xy) * tint0_pm;
vec4 color1 = texture2D(tex1, var_texcoord0.xy) * tint1_pm;
if (color0.a > 0.1 && color1.a < 0.5)
{
discard;
}
gl_FragColor = color0;
}
Here I’m drawing the shadow-clipped sprites together with the lights, and discard pixels where the lights texture (color1
) has alpha less than 0.5
, which in this case is slightly above the ambient light alpha of my game.