Tricky Blending Q 4 U

folks,

I’m trying to implement a stencil shadow type thing but without using a stencil buffer. Please dont ask why

I have it all working, using the alpha component to hold the ‘shadow count’ but I have to do this is two passes (using Carmacks Reverse) :

Increment (additive blend) for back faces
Decrement (subtractive blend) for front faces

The value blended is just a constant 1/256.

I would like to do this in one pass, setting the blend value negative depending on my fragment facing. I have complete control over the blended constant in a frag prog (but this has to be in the range [0…1]?)

Is this possible, perhaps using register combiners ? I haven’t delved into RC’s but I read that there is an input modified which will expand the alpha range [0…1] to [-1…1] (expand_normal_nv) but is the Reg Combiner output clamped to [0…1] before blending takes place ?

cheers

R.

Originally posted by pocketmoon:
[b][…]

Is this possible, perhaps using register combiners ? I haven’t delved into RC’s but I read that there is an input modified which will expand the alpha range [0…1] to [-1…1] (expand_normal_nv) but is the Reg Combiner output clamped to [0…1] before blending takes place ?
[/b]

every RC output is clamped before it is blended with the framebuffer.

here is some idea:
maybe you could use the minmax-functionality to recognazie the negative/positive values ?
(ie. x<128 negative and >128 positive)

What about RGB - are they clamped to 0…1 or -1…1 ?

It sounds like what you want is “signed blending”, but I don’t know of any implementations that support it.

Cass

Thanks Cass, I’ll stick to the two passes then.

You could do it in one pass if you split your shadow volume into front and back facing polygon batches. Draw the front facing polygons with additive blending, and the back facing ones with subtractive blending.

How about rendering the scene to a pbuffer?Then you could do all the signed blending you like.

Yes I could batch’em. I’ll see what works out faster.

Originally posted by fresh:
How about rendering the scene to a pbuffer?Then you could do all the signed blending you like.

If I use a floatin point pbuffer I cant blend. Can I do signed blend in a standard pbuffer ?

Rob

unless my memory’s totally off, there is a blending function string with a name like “GL_BLEND_ADD_SIGNED”… not at home machine now, could easily be wrong about the exact name? probably part of an arb/ext gl blending extension?

GL_ADD_SIGNED ? Part of the tex env combine extension - it allows signed blending a+b-0.5 but not with any destination values.

What I would need is src+dest-0.5 which isn’t available.