I am doing simple shadow-casting using simple ‘vector-position-color’ polygons…
The idea is having a few vertices at the base of the shadow-casting sprite, and moving the other few vertices around (based on the lights source) to create dynamic shadow… Simple stuff…
Now, when I draw these vertices, the coordinates I assign them have (0,0) as the CENTER of the screen, and a value of 1 represents the furthest edges of the screen… So its like we are talking ratios from the center of the screen, rather than game units, or pixels from the top left.
The problem is slightly compounded by the fact that my game scrolls…
Should I just do a little calculation to get a screen ratio from my object coordinates?
Or is there a view-matrix trick I can do, to align these 2 coordinate systems?..
I’m not sure exactly if you want orthographic projection, but if you want the origin of the viewport to be the centre and the edges to be 1s it would be:
@LithiumToast@raizam Thank you very much guys I am sure this must be what I was looking for. I’ll get back to it when my election buzz wears off…
EDIT:
I am right to ‘subtract’ these shadow polygons from the light-source, right? Like using blend states normally, I can just draw these using the blend-state I want?