PDA

View Full Version : different GL states for each render target ?



shajder
02-25-2010, 02:05 PM
Hi all,

I would like to render to depth texture and color texture at the same time (MRT), problem is I would like to apply additive blending for color texture which means I need to disable Z writing, in result depth map is clear.

Now I found GL_EXT_draw_buffers2 extension which allows to allpy different blending states per each render target, is there possibility to do the same for depth states somehow ?

Thanks in advance,
Martin

ZbuffeR
02-25-2010, 02:13 PM
additive blending for color texture which means I need to disable Z writing
I don't understand.
Maybe you only need to disable depth test ?

shajder
02-25-2010, 10:58 PM
additive blending for color texture which means I need to disable Z writing
I don't understand.
Maybe you only need to disable depth test ?

I don't think so, what goona happen with my depth map if I disable z-test ? No, I need proper z values in depth map, I need z-test and z-write enabled for depth map render target and z-write disabled for color map render target. Is it possible ?

Alfonse Reinheart
02-26-2010, 12:33 AM
Why would you need to disable either when doing additive blending? Addition is commutative and associative; it doesn't matter what order you do it in.

Note that additive blending would be GL_ONE, GL_ONE for the blend function. Not GL_ALPHA, GL_ONE_MINUS_ALPHA.

shajder
02-26-2010, 03:29 AM
Why would you need to disable either when doing additive blending? Addition is commutative and associative; it doesn't matter what order you do it in.

Note that additive blending would be GL_ONE, GL_ONE for the blend function. Not GL_ALPHA, GL_ONE_MINUS_ALPHA.

I think you assumes I am drawing sorted geometry, it is not the case. I am drawing not sorted point sprites and I want each fragment to be added in my color map so I must set z-mask to 0 or disable z-test, both of it spoils my depth map. As far as I remember blending is performed after depth test so if incoming fragment doesn't pass it will not be added. Am I right ? At least my test says so.

ZbuffeR
02-26-2010, 05:10 AM
OK so do not disable depth test if you need it. What is the problem ?

shajder
02-26-2010, 05:27 AM
OK so do not disable depth test if you need it. What is the problem ?

I need it for depth map render target, for color map I need z-mask set to 0. I wondering is it possible to render it in one pass. I am getting some strange feeling I am repeating myself :|

ZbuffeR
02-26-2010, 06:48 AM
Ah at least it clicks !

So you want both depth test writing to depth buffer with only the nearest depth, AND AT THE SAME TIME no depth testing on the color buffer, as you have unsorted additive blended stuff.

Is that right ?

I am pretty sure that is not possible.
Do it in two passes.

shajder
02-26-2010, 08:16 AM
...
Is that right ?


yes, exactly



I am pretty sure that is not possible.
Do it in two passes.


I already did that in two passes, now I want to optimize it, thanks for your help anyway.

Martin