How Do You Guys Handle Depth Clarity When Using Elevation Tricks in Babylon.js?

Hey everyone,

I’ve been spending time with some 3D scenes lately, and I noticed something odd when objects are arranged close together—especially when they sit on or near the same horizontal plane. From certain camera angles, especially top-down or diagonal, the meshes start to visually collapse into one another. They don’t literally overlap, but they feel like they do because there’s not enough visual separation. It’s like the Z-depth alone isn’t enough to communicate layers clearly, especially without heavy shadows or transparency tricks.

To make things more readable, I started experimenting with depth cues. Playing around with the lighting direction helped a bit—just shifting where shadows fell made the forms feel more distinct. I also tried subtle differences in roughness and reflectivity between surfaces, hoping that would separate them more visually. That kind of worked, but it also started to pull me away from the visual style I wanted. Changing materials just to get clarity started to feel like I was compromising more than solving.

Then I looked at zOffset and depthPrePass options inside Babylon.js. They gave some control, but I still had the same issue when many similar elements were spread out on a plane. Even with zOffset, at certain angles, the visual depth just felt “flat.” It’s like I was missing one more cue to really help my eye understand what’s closer and what’s further.

I started thinking more about elevation at that point. In the 3D world, elevation typically refers to how high something sits along the Y-axis relative to the base ground or origin plane. This might sound simple, but in web-based environments, it can play a huge role in visual clarity. I recently came across the idea of a real-time elevation tracker, often used in mapping tools to monitor height changes dynamically. I wasn’t using elevation in the same way, but the concept gave me the idea to try adding just a little Y-axis offset to some of my elements—like giving them a small lift above the rest.

That tiny tweak actually made a difference. Just by raising a mesh slightly—by 0.01 or 0.02 units—it felt more visually present in the scene. I didn’t need to mess with shadows or lighting too much. It’s like that small nudge in elevation added a physicality that told my brain, “hey, this is on top.” I was inspired by that elevation idea in a positive way, and I started applying it more intentionally. But I quickly saw the limits—do it too much and things float, and sometimes raycasting starts acting up because hits don’t register where you’d expect.

Now I’m trying to figure out when to apply this elevation offset and how to keep it subtle. Should I only use it for certain object types, like interactive elements or indicators? Or maybe adjust the amount dynamically based on the camera distance? I thought about tying it into the camera angle—so elevation offset increases as the view flattens—but I’m not sure how to avoid weird side effects like z-fighting or jitter.

Has anyone here used elevation for visual clarity in this way? What do you use to separate geometry visually, especially when everything sits on the same plane? I’m curious how others approach this, especially if you’re trying to keep things clean and readable without overloading the scene with post-process tricks or changing your whole material system. Would love to hear any approaches that worked for you.

1 Like

This is a deep topic at the intersection of technical and artistic solutions that @PatrickRyan could probably talk about for miles!

@anihawo, do you have any screen captures you can share with us? I am not sure I am imagining what you are describing correctly and think that a couple of pictures would go a long way. Depending on the overall distance from camera and view angle, there could be a few things done to enhance the feeling of space in a scene. Atmospheric fog is the easiest solution since it’s built into the engine.

If you are artificially moving the position of your meshes based on distance from camera. I can see it causing problems like the raycasting you mentioned. I would love to see what you are doing because I am sure I am not visualizing your scene as you have built it.