different GL states for each render target ?

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,

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 ?

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.

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 :expressionless:

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.

yes, exactly

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