Now im just trying to fugure out how to work with angles, and so on. Each shadow is a one separate Sprite, so I need it to soften somehow. I fond a solution to make alpha all borders from center to edges, through the center axis. But still cant figure out how to make this thing, I cant do anything until I have no debug stuff, Im just doing, but I cant check myself, I didnt expect how to make anything so hard without debug ...
Well, at first sight I don't understand the logic behind your math!
Assuming you use a Bitmap as a way to apply your shader, then your textureCoord will vary from (0,0):top-left corner to (1,1): bottom-right corner (if the texture used with your bitmap is power of two sized). Your lightCoord is predivided by world width and height, so I assume your shading bitmap is applied all over your world too, right ?
Nope my Shading bitmap is relative to world positioned Shape, drawed by code. Ive attached my shadows lib, you to understand how Im producing shadows, code is simple ang clear.
Ok, I understand better. Since your shadow is just a black/translucent shape, you don't need texture coordinates at all. I think it would be easier to use actual world coordinates in the shader. Just convert vertex position to world position in vertex shader thanks to world matrix (SYS_WORLD) and pass it as a varying to the fragment shader.
Then supply your light source position as world position directly (no need to divide by world size).
From there it should be more straightforward to compute shading.
Ok, I understand better. Since your shadow is just a black/translucent shape, you don't need texture coordinates at all. I think it would be easier to use actual world coordinates in the shader. Just convert vertex position to world position in vertex shader thanks to world matrix (SYS_WORLD) and pass it as a varying to the fragment shader.
Then supply your light source position as world position directly (no need to divide by world size).
From there it should be more straightforward to compute shading.
Did solved, with some issues, give a feedback later ...
Comments
Assuming you use a Bitmap as a way to apply your shader, then your textureCoord will vary from (0,0):top-left corner to (1,1): bottom-right corner (if the texture used with your bitmap is power of two sized).
Your lightCoord is predivided by world width and height, so I assume your shading bitmap is applied all over your world too, right ?
But then I don't get what
Here's what I would have computed:
And I dont know how to find light direction ...
Then supply your light source position as world position directly (no need to divide by world size).
From there it should be more straightforward to compute shading.