hotte
08-06-2004, 07:00 AM
I've got a scene with colour and depth values coming in from an external renderer. I'm using DrawPixels to get them into the frame buffer and I store the result in a buffer region for later redrawing as I move some models through the scene.
So far that's all good.
Now, I'd like to add an effect where everything in my background above a certain target depth is translucent. Models should be visible through the translucent stuff, but not through each other or the background where it's below the target depth. Also, models above the translucent stuff should appear solid.
I'm having trouble finding an effective solution that satisfies all the criteria.
The big problem is combining alpha-blending and depth test. I tried setting alpha values based on the depths (alpha=0 below target, alpha=1 above)and drawing my models with glBlendFunc(GL_ONE, GL_DST_ALPHA);
But that doesn't handle the case where the models overlap each other or if they appear completely in front of the translucent areas. It needs to take into account the depth of the model as well as the background...
Any suggestions? If there's sample code that would be ideal.
So far that's all good.
Now, I'd like to add an effect where everything in my background above a certain target depth is translucent. Models should be visible through the translucent stuff, but not through each other or the background where it's below the target depth. Also, models above the translucent stuff should appear solid.
I'm having trouble finding an effective solution that satisfies all the criteria.
The big problem is combining alpha-blending and depth test. I tried setting alpha values based on the depths (alpha=0 below target, alpha=1 above)and drawing my models with glBlendFunc(GL_ONE, GL_DST_ALPHA);
But that doesn't handle the case where the models overlap each other or if they appear completely in front of the translucent areas. It needs to take into account the depth of the model as well as the background...
Any suggestions? If there's sample code that would be ideal.