For a school project we are trying to get shadows + lighting to work in a 2d game.
I created a method with pixel blitting (SDL) but it doesnt use a GPU so it is slow.
What it does:
render the scene>
create a full screen overlay with RGB(0,0,0)
for each light: add alpha value to overlay
blend overlay ALPHA with scene
this gives me shadows like:
problem: it is pretty slow (8ms to create lightmap + render @ 1024*768)
Now i’m trying to do this with OPENGL but i can’t get it to work.
What i’m trying to do at the moment:
fill screen with black, alpha at 0.
disable color buffer
render lights to alpha channel
render scene, blending with the current alpha values
actually someone made a tutorial for this doing exactly what i’m doing without opengl but i can’t get some things to work:
filling the screen with black and resetting the alpha channel works
filling the alpha channel with the lights: doesnt work, what should i use as parameters for glblendfunc ?
rendering the scene: haven’t tried it
I guess there are more people that have done shadowing like this or maybe some people who know of a better method.
Someone knows what i’m doing wrong?