Camera and Transparency

Is there by any chance an easy way to detect if an object is blocking a certain actor from sight and rendering it partly transparent so you can see the actor through it? I guess if not, I’d have to shoot a ray out of the camera and calculate all the collisions etc.


shooting rays is your best bet. thought in this special case i would prefer a collision segment instead of a collision ray. panda can calculate the collisions for you, but you have to set up the collision system.

I figured that would be the case, but what about in the instance of something like a small barrel in front of the actor? If the ray hit that it would become transparent, but it would not necessarily cover the whole character. Is there an efficient way of determining if the whole actor is covered or is it just a matter of shooting several rays?

the way i’d approach this is to have a list of transparent objects. when it comes time to render, you render all the non-transparent objects, take the list of transparent objects (culled, of course), sort it by each objects half-space distance from the cameras near plane, then render them.

this way, if there are no transparent objects in the frustum, you don’t have to do any work.

by writing the non-transparent objects to the depth buffer, you’ll get the proper occlusion with the transparent objects behind them, and by rendering the transparent objects back to front you get the correct transparency. also keep in mind with transparent objects, you want to render the back faces first, then the front faces.