[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] lighting challenge



âHi,

I played around with it a bit, but I'm not sure exactly what the problem is, nor do I have time to figure out exactly what you're trying to do about it.

I didn't run through your implementations in detail, but I did notice that you're copying surface(s) in every one. I bet this eats a lot of time.

Certainly, the blits will too. As you observed, a GPU is great for this sort of thing. If you haven't used PyOpenGL before, it might not be as hard as you think to get simple blitting function correct. Actually, I think there are already several projects on PyGame.org that provide it. In any case, GPUs exist to draw things. They're very good at it. It is wise to take them up on the offer.

Lastly, a correct-ish blitting function to use (assuming no SSS or radiosity) in pseudocode:
result = 0
for all surfaces:
ÂÂÂ light_at_surface = light intensity * product_of_alphas_between_light_and_surface
ÂÂÂ result += light_at_surface * surface_reflectance * product_of_surface_alphas_between_surface_and_eye
I bet that can be factored into a 1-pass-per-surface algorithm.

Ianâ