I need to do some green screen processing, but I also need to apply the bloom effect before that. I have my camera set up to render a solid color for the background (which will later be used for the green screen), but, as far as I understand, since bloom is a full screen effect, the background color is also consider it for the process, which creates various undesired side effects, for example, red objects have some yellowish inner glow.
I think, I could solve these issues, if I could turn green pixels black after they are sampled and before the effect is applied. I peered inside the code, but I don’t fully understand how it works. It seems, it samples the screen and then somehow it applies the effect, but I haven’t been able to figure out how. I suppose the samples are stored in some kind of texture, but it is not clear to me how and where.
Could anyone please explain how could I achieve this?
If you’re going fully custom, bloom typically has a “threshold” pass that it performs on the scene first.
IE, a ultra simplified version of that would be:
Sample color on pixel
If color on pixel is less bright than BRIGHTNESS_THRESHOLD, discard (set to black) color
If you added in your chroma key check after 2), and discarded any green, then your bloom texture would effectively do what you wanted it to. Check out shadertoy.com and search “chroma key” for some examples, and look at (typically older) bloom effects that have dedicated threshold passes.
That’s exactly what I’m trying to do. The problems is that I don’t know where to plug that piece of code. It is clear to me that it is sampling the screen, but I don’t understand where and how it updates the pixels.
It will depend on the bloom effect, there is no set pass to put it as all blooms are different, even within blooms, it could differ (ie. for a mobile-optimization, I combine thresholding into the first downsampling pass at the start with my bloom, if that’s not checked, it’s a separate pass). I would know where to put it in the bloom that I write for PRISM, but can’t speak to others. Your best bet is to play around with some simpler post-processing shaders to see how they work (shadertoy is a good place to start) and gradually build an understanding.
Emission Maps might be able to work for this if the shaders are set up properly for them, though I have no experience with 3d so I’m not sure how well it would work there