On 2015-07-05 19:49, Ian Mallett wrote:
Hi Ian The general idea was to find a way to simulate lights using pygame (using layers of pygame.Surfaces and the blend operators) for showing day/night or dark rooms. Maybe there are other, simpler or faster ways than what I did. I wanted to give people the possibility to contribute and experiment themselves to find an algorithm that gives some result. I had some fun trying different approaches and I thought maybe other can have fun too (without having to set up all the plumbing code in between). That said, if someone wants to contribute, fine, if not, its fine too. I know a bit openGL (through PyOpenGL) and I know about the projects about openGL on pygame.org and I know about the huge processing power todays graphic cards have. Still, I wonder what can be done with simple blitting in pygame. I wonder, how to organize it, make it efficient. I guess, this is also applicable to openGL code. And yet, I like this simplicity of blitting pygame.Surfaces. No offense, openGL is good and results look amazing. I probably will use it in future, but just not now. About your pseudo-code: I have been trying to write code according to your algorithm, but I don't understand it. At least not in terms of pygame.Surfaces. I think the product_of_alphas_between_light_and_surface and product_of_surface_alphas_between_surface_and_eye can be omitted to simplify. Then what is left is like: result = 0
for all surfaces:
ÂÂÂ light_at_surface = light
intensity
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ result += light_at_surface * surface_reflectanceBut even with that I'm not sure what to do about. Not sure how to translate that into blit operations. Here some questions: What is surface_reflectance exactly? A number? What range? What do you mean by 'for all surfaces' ? Why does it accumulate into one result? This result, is that a pygame.Surface? Or this would be per Pixel? The operators '+' and '*' are not the blit operation pygame.BLEND_ADDÂ and pygame.BLEND_MULT, are they? Maybe you could give me some clues so that maybe I'm able to write down code implementing this algorithm. Help appreciated. Thanks. ~DR0ID |