Making geomtery translucent when very close to camera

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.