[Solved] Is there a way to get the color underneath the current pixel in a fragment program?

Hullo again! It’s been a while.

So, pretty new to the whole shaders thing I was wondering how I go about getting the color of the pixel underneath the current pixel I’m processing in a fragment program. If I can’t, is there any other similar solutions where I can basically write my own blend modes?

Thanks.

1 Like

You can render the scene once to the off-screen buffer, so called “render target”, and then use it as a texture for other shaders - therefore, what’s rendered next - can get a pixel “underneath” - so from a render target of what’s already drawn on the scene.

This is a basic approach for semi-transparency, color grading, post process effects, so you can learn basics, e.g. here:

This even uses the same approach (render the scene first to a render target, then use it to draw the final scene result (here drawing even two - scene + a separate light map) - and I think this video (which is mine :sweat_smile: ) explains it well:

3 Likes

Oh, that’s neat! I think I’ve read your post on Shaders before (and it’s how I figured out how to write fragment programs and stuff in the first place, so very big thanks), but I don’t think I’ve really ever done post-processing like that before.

I’ll probably have further questions as I figure things out, but we’ll get to that when we get to that. Thank you very much :sparkles:

1 Like

Nevermind, I achieved exactly what I set out to perform.

Did a little test with a white circle using difference blending. The World goes brrrrrr

Thanks for all the help! :sparkles:

2 Likes