Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL: Pixel-wise comparison

Started by strivingJuno Aug 16, 2010 at 9:17 AM 3 replies 1.8k views
Original Post
strivingJuno
strivingJuno
Hi everybody,

When rendering into the color buffer, is it possible to draw the pixels dependent on the existing content of the color buffer?

What I need is the following rendering logic: When drawing a pixel, draw it only if it is "brighter" than the existing one. (Let's be given a definition of a measure that allows a comparison of pixel intensities, for instance the eucledian norm of the rgb vector).

glLogicOp is not what I need, am I right?

Or do I have to apply custom shader programs?

Thanks for any suggestion and help.

[Edited by - strivingJuno on August 17, 2010 7:28:55 PM]
strivingJuno
strivingJuno
Common guys! There is a beer waiting for the one providing me with the correct answers :)
twistedjoe
twistedjoe
Well it's possible to keep copy of buffer and use them to create some special FX, but without a shader, will it be possible to do per pixel operation on both buffer?? I don't know.....

twistedjoe
twistedjoe
by the way, if you do it outside of the fragment shader, am not an expert, but am pretty sure it will take a LOT of resources since per pixel operation usually are. Since the fragment shader already do operation on each pixel, if you do it outside of this shader, you have two loop instead of one.....


Like I said am not an expert and it's a bit blurry in my head.....but am pretty sure the best thing you should do here is to make a custom shader that take the old color as one of it's parameter
Krohm
Krohm
Quote:
Original post by strivingJuno
When rendering into the color buffer, is it possible to draw the pixels dependent on the existing content of the color buffer?
Only for some simple operations, there's for example blendfunc MAX. The dependancies must be expressed as blendfuncs, as such they're completely enumerated by {src factor, dst factor, blendop}.
Quote:
Original post by strivingJuno
What I need is the following rendering logic: When drawing a pixel, draw it only if it is "brighter" than the existing one. (Let's be given a definition of a measure that allows a comparison of pixel intensities, for instance the eucledian norm of the rgb vector).
You don't really want to use this way. Take a look at the color weights in NTSC for example.
Quote:
Original post by strivingJuno
glLogicOp is not what I need, am I right?
I don't see how this could help you. I would be interested in knowing if it works at all. As it seems to provide bit-ops, I expect this to give you software fallback.
Quote:
Original post by strivingJuno
Or do I have to apply custom shader programs?
Very likely, as you need at least to provide the "brightness" logic. Ping-ponging rendertargets is also necessary as the shader needs varying, dynamic branching on a per pixel basis on the data to merge.

Previously "Krohm"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.