PDA

View Full Version : Tricky Blending Q 4 U



pocketmoon
10-30-2002, 03:31 AM
folks,

I'm trying to implement a stencil shadow type thing but without using a stencil buffer. Please dont ask why http://www.opengl.org/discussion_boards/ubb/smile.gif

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.

AdrianD
10-30-2002, 06:25 AM
Originally posted by pocketmoon:
[...]

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 ?


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)

pocketmoon
10-30-2002, 06:39 AM
What about RGB - are they clamped to 0..1 or -1..1 ?

cass
10-30-2002, 06:49 AM
It sounds like what you want is "signed blending", but I don't know of any implementations that support it.

Cass

pocketmoon
10-30-2002, 07:09 AM
Thanks Cass, I'll stick to the two passes then.

fresh
10-30-2002, 09:18 AM
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.

pocketmoon
10-30-2002, 11:12 AM
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

mattc
10-30-2002, 05:35 PM
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?

pocketmoon
10-31-2002, 12:52 AM
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.