pygame-ce
pygame-ce copied to clipboard
Add pygame.transform.bloom function
I implemented the bloom algorithm to add it to pygame.transform.
I also added documentation and stubs.
I think this is the best implementation. This is the steps, if someone needs them to review:
- Create a bright pass filter surface
- Iterate the source surface and keep only the pixels with the luminance within the threshold
- Run either the box or blur algorithm
- On the lines where the blurred color is applied, also blit it to the original surface with additive blend
Please tell me if there are any C improvements, structure improvements or performance improvements.
I see no reason not to merge this, but I think this might be more flexible as three separate operations: Threshold, blur, and blit. At least, I think this could be more useful as a function that computes the bloom overlay with a black or transparent background.
I see no reason not to merge this, but I think this might be more flexible as three separate operations: Threshold, blur, and blit. At least, I think this could be more useful as a function that computes the bloom overlay with a black or transparent background.
Maybe it would be more flexible but not more performant as the blit is implemented within the blur using only 2 loops. I'd like for @itzpr3d4t0r to have a word about what you mentioned. I can always modify it as requested.
To add to what I just said, what i think would be best is to keep bloom as a function and maybe add the luminance filter as another function that can reuse the same code this pull request is using.
My main criticism is that the input parameters are quite loosely defined right now in the documentation with no expected ranges, and not much description of what they effect in the output.
you have a point. I'll improve the documentation and explain what each argument does