Hello!
In my top-down game I want to objects have shadows as from source at infinite distance.
This is a table if anyone wonders. Shadows like these is all I need. I made them using a pass with this code:
float4 worldVert = mul(_Object2World, i.vertex);
if (worldVert.y - floor(worldVert.y) < 0.5) {
i.vertex.x += 0.4;
i.vertex.y = lerp(i.vertex.y - 0.2, i.vertex.y + 0.2, worldVert.x - floor(worldVert.x));
}
All objects are aligned to grid on integer coordinates like [2,3], so this shader moves the top part and leaves the bottom in place. The problem is that some sprites take up exactly one unit, so the shader can’t move top part, or it is a bit bigger than one unit and then it all goes wrong for obvious reasons.
Also I have some connected tiles like this:
So it would be great, if the shadows could match up/be continuous.
Is there an easy way to make shadows with small performance impact, that doesn’t rely on coordinates like mine? Thanks for answers.