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 ?
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)
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.
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?