Making geomtery translucent when very close to camera

Several MORPGS like FFXI and WoW have the feature of making objects that are very close to the camera (usually the player model) become translucent when very close such as when the player is surrounded by obstacles resulting in the camera view snapping very close to the player to avoid obstruction. Is there a way to achieve this behavior in Panda3D as well since the default would be to have everything clipped and thus such objects would disappear completely. Maybe by rendering a second camera view with the near clip range set very close to the camera and ending at the near plane of the main camera view then fractionally (25% perhaps) alpha merge that texture over the rendered scene of the main camera (resulting in anything close to the camera that would clip normally to appear faded over the main scene instead)? This would effectively halve the frame rate so maybe there’s some other way to achieve the same?

Hi. I can think of several ways that could be achieved.
The idea is some close GeomNodes are applied a color scale like so: (1,1,1,0.5). Some games seem to change the alpha scale as the camera gets closer.
In this case you need to make that you indeed have separate geoms, otherwise a whole building could become transparent and you don’t want that.
Now how to actually find out if objects are close or not. You can use ordinary collision detection and attach a sphere to the camera and when colliding with something use CollisionHandlerEvent to set the color scale of the objects you are colliding with to (1,1,1,0.5) or something else.
You could also create a perspective lense and assign it to the camera, set the far value quite low and use the isInView() method of th lens to find out if objects are in it’s “view”. There is example code somewhere for this.

This would require you to have more geoms, which can become a problem.

Another approach which I haven’t gotten the time to try is to use projected textures. You would project a alpha texture to everything but your ground (terrain). The texture would look something like this:

The black would have no effect, but the gray (or alpha) spot would make things semitransparent in the middle. So you could attach it to your camera and enjoy.

If the second method would work, I’d personally prefer it over the first as you wouldn’t need to split your meshes into parts in your modeller so very big meshes wouldn’t get hidden at once.

I think this game uses a similar approach:
youtube.com/watch?v=jultTIabt9o

Someone used a similar trick here for a fog effect: [RR with animated fog (no shaders))
You’ll just need to change the texture and multitexturing mode to cause things inside the circle transparent.

Anyway, there might be other ways to do this.

My first thought was to render two scenes with different clip settings: one normal for the scene, the other with only close range (latter scene’s far clip is first scene’s near clip) and overlay the latter scene over the first with fractional alpha. I worry about the frame rate doing it that way but it would be better than mucking with all the geometry in the workflow process.

I tried to do something like this, but I must be missing something. How do I make the projected texture cast a transparent hole?

I’ve made a texture with the hole and tried to project it as MModulate but that gave no effect. Any tips or code snippets would be much welcome.