colorblending?

I want a model (a plane) to be complete transparent and only visible where shadow is casted on it.

I experimented some time with colorblendattrib but i dont realy understand how the colorblendattrib works and how to use it, also couldnt find infos/examples on the forum about how to use the colorblenattrib. With following code im actually close to the look i want, but close is not enough ;D (i found this code with trial and error, trying al the constants listed in the api under colorblendattrib)

shadowplane.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MLessEqual))

This works when the color of the light, which casts the shadows is completly white, but if the light has a color, this color is also visible/drawn. Is there a way to define a color, lets say (0.1,0.1,0.1) and make the model only visible if the color of it is below that defined color? How?

Another problem is, i want the shadow not to be complete black, but halftransparent instead, but alpha/transparency seems not to work when i use the colorblenattrib, how to work around that?

Or is there a simpler way to have shadows in an augmented reality application???

Thanks for looking ;D

edit: i found a solution to one of the issues, with following code i was able to do a half-transparent overlay (found it somewher on the forums):

shadowplane.setColor(1,1,1,0.7)
shadowplane.setTransparency(True)
shadowplane.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOne)) 

but this does not seem to work with the MLessEqual-mode…so im still looking for a methode to overlay just the dark colors and make them halftransparent

noone familiar with the colorblendattrib??? Or is my question to complicated?

Im especialy interested about the make(mode, opperand a, operand b,color) methode in the colorblend class. I dont realy understand what exactly are these different opperands (a+b) for and what does the fourth (color) variable do? Can someone please tellme more?

mhhh … my last AR-project was before the automated shadows so i had to use custom shaders for it, so i also hardcoded this “overlay-effect” into the shader. But now with the automated shadows and the autoshader i have to find another way… it seems im very close to the effect i want to archieve, but not using the right combination of opperands, but with trial and error, this is realy hard to find out…

Thanks again for looking!

i expereimented further and another idea came to my mind: how about applying a treshold like filter to the “shadowplane” to get rid of the light-color and after that doing the colorblend? I tryed:

shadowplane.setAttrib(LightRampAttrib.makeSingleThreshold(0, 1))

This “scales” the colors as expected, but doesnt get rid of the light-color, so i guess i have to desaturate the colorplane completly first. But how can i desaturate that plane? This also seems to be overkil for this task, but if its doing the job…

Using only white light for the shadowlight is the only way to get the effect im after, but this limits me in doing some nice lightning effects…so this is not realy an option for me… but if i can’t find another way, i have to go this route…

Im realy burning out on this problem… David where are you :wink:

Hmm, I suspect what you’re asking for can’t be done with the fixed-function ColorBlendAttrib. You might have to write a custom shader to achieve it.

David

Thank you for your reply david, but can i write a custom shader and use it together with the autoshader? Because i need the autoshader for the shadows… Or do i have to also do the shadows on my own in this customshader?

No, once you write a custom shader, you have to write the shader completely. You can’t combine the shader with any other state, including the autoshader.

But one trick you can use is to dump out the shader text generated by the autoshader (I forget the command to do this right off the top of my head, but I bet you can find it with a forum search). Then you can use that shader as a starting point for your custom shader.

David

Hello again!
I found the command to get the generated shader text, but its descibed here (discourse.panda3d.org/viewtopic.php?t=6753): this doesnt seems to work with 1.7 because of the shadows…

so any other ideas to do this overlay-effect?

Atm im using the ColorBlendAttrib.MLessEqual and white light for the shadows which works (the not shadowed part of the plane is invisible), but the shadow isnt halftransparent but completly black, what can i do?..live with it?

discourse.panda3d.org/viewtopic … highlight=

Thanks for that hint Anon, must have overlooked that…