# Greased line visual glitch at large scale

**URL:** <https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320>\
**Category:** Bugs\
**Tags:** greasedline\
**Created:** [July 1, 2025, 2:22pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320 "2025-07-01T14:22:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [July 1, 2025, 2:22pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/1 "2025-07-01T14:22:31Z")

</div>

Hey there,

I am making large scale orbit meshes and I want to use greased lines as thick lines are really cool 👌

I am having some artifacts when making the orbits very large:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/9/4996632cc7e4aa54f2029467cb84d7db796c2316.png)

And this does not happen with regular lines (toggle L49 in the following PG for comparison):

> **[Babylon.js Playground](https://playground.babylonjs.com/#6HWY5R%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

Is it a fundamental limitation of greased lines or am I missing some tricks to make it work?

Pinging @roland as you are the greased line lord around here ^^

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 1, 2025, 3:44pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/2 "2025-07-01T15:44:41Z")

</div>

cc @roland

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [July 1, 2025, 11:25pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/3 "2025-07-01T23:25:05Z")

</div>

I think it’s a floating point precision issue as the orbital ranges you have vary from 0.0001 to 100000, which would cause rendering glitches scene wide. ~~It probably explains why planets aren’t showing at those scales either, but when 100000 is changed to 1000 everything works (planets and greased line orbits).~~ I see now the planet positions exceed `camera.maxZ` so that’s why they don’t show at those extreme ranges, but I still think you’re hitting a hardware floating point precision limit.

You might need to consider scaling everything down and/or [implementing floating origin](https://doc.babylonjs.com/features/featuresDeepDive/scene/floating_origin) and/or breaking geometry up into tiles.

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [July 2, 2025, 7:01am UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/4 "2025-07-02T07:01:43Z")

</div>

Thanks for investigating! I am making a 1:1 scale space game so those precision issues are often a challenge ^^ What I don’t get is why the simple lines work while the greased lines are glitchy: I would expect the lines to have the same issues.

Even if the scale is large, space is mostly empty so z-fighting is not an issue for the orbit lines, so I still have hope!

This PG already has the camera at the origin so floating origin will not improve the precision further unfortunately 😕 Breaking the geometry into tiles might be the solution if I can’t fix greased lines yes

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [July 2, 2025, 7:34am UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/5 "2025-07-02T07:34:36Z")

</div>

Just guessing but greased lines use triangles whereas lineset does not, but I get your point.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 18, 2025, 10:59am UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/6 "2025-07-18T10:59:34Z")

</div>

> [@CrashMaster](#):
>
> Pinging @roland as you are the greased line lord around here ^^

Hello! Thanks 😃

Guys, sorry for the late reply I’m quite busy these days…

So, @inteja is absolutely right. It’s all about loosing the correct vertex positions due to precision loss in the vertex shader. `float32`s has only 23 bits mantisa so every value beyond 10^7 gets only 1 unit precision at the end.

The solution would be the `floating origin` approach proposed by @inteja and if I can recall it correctly, you already posted some question about this technique.

> [@CrashMaster](#):
>
> This PG already has the camera at the origin so floating origin will not improve the precision further unfortunately

The problem is the vertex positions are too far from the camera origin. You could rescale the positions and/or use a separate dybamically positioned camera for the orbit lines.

Surely it will introduce complexity to your code but unfortunately I can’t come up with any other solution.

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [July 18, 2025, 2:31pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/7 "2025-07-18T14:31:33Z")

</div>

Thanks for the answer ^^

> [@roland](#):
>
> It’s all about loosing the correct vertex positions due to precision loss in the vertex shader. `float32`s has only 23 bits mantisa so every value beyond 10^7 gets only 1 unit precision at the end.

Yeah I was afraid you would say that 😕 Looks like the thin lines work fine only because the float imprecision is not as visible.

However, it worked in the past: [Fix #140 by BarthPaleologue · Pull Request #147 · BarthPaleologue/CosmosJourneyer · GitHub](https://github.com/BarthPaleologue/CosmosJourneyer/pull/147) (see the screenshot in the PR), so there must be more than a precision issue 🤔

I used Babylon 7.21.4 at the time so there might have been a regression since then. I will try to narrow the version range a bit so it’s more useful 😉

> [@roland](#):
>
> The problem is the vertex positions are too far from the camera origin. You could rescale the positions and/or use a separate dybamically positioned camera for the orbit lines.

Unfortunately that’s not really possible if I am making a 1:1 scale solar system, the camera might be around some planet and should still be able to see the orbit lines of planets far away.

For now, I will keep things simple and stick to thin lines

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [July 18, 2025, 2:57pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/8 "2025-07-18T14:57:53Z")

</div>

So I have been doing some `git bisect` and narrowed the version regression range.

This dep upgrade broke the greased line for me: [upgrade deps · BarthPaleologue/CosmosJourneyer@8c42d47 · GitHub](https://github.com/BarthPaleologue/CosmosJourneyer/commit/8c42d4727a75d582c6f6f9efdf574ce810eed39f)

So there must have been something between 7.49.0 and 7.54.3

Here is a PG that proves that it worked in 7.49.0: [https://playground.babylonjs.com/?version=7.49.0#6HWY5R#8](https://playground.babylonjs.com/?version=7.49.0#6HWY5R#8) @roland

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 20, 2025, 12:55pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/9 "2025-07-20T12:55:44Z")

</div>

The issue was introduced here:

> <https://github.com/BabylonJS/Babylon.js/pull/16186/commits>
>
> https://forum.babylonjs.com/t/visual-glitch-when-crossing-a-greasedline/56538
> 
> …
> \#FJRQ8N#171
> \#FJRQ8N#172

It fixed the issue with rendering lines really close to the camera. Unfortunately, it also unleashed the bug you sensed in the Force. 😞 Sorry about that, my fellow Jedi.

I’ll be off on a brief retreat to a distant system for the next 10 days, but once I return, I’ll face this bug head-on and bring balance to the PR.

Your vigilance has not gone unnoticed, thank you for reporting this disturbance in the codebase. The Dark Side respects such keen observation!

😎

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [July 21, 2025, 8:25pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/10 "2025-07-21T20:25:19Z")

</div>

> [@roland](#):
>
> It fixed the issue with rendering lines really close to the camera. Unfortunately, it also unleashed the bug you sensed in the Force. 😞 Sorry about that, my fellow Jedi.

Ah I can see how it’s not easy to have both at the same time, maybe we need to turn to the dark side ^^

> [@roland](#):
>
> I’ll be off on a brief retreat to a distant system for the next 10 days, but once I return, I’ll face this bug head-on and bring balance to the PR.

Take care 😉 it’s not urgent

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [August 6, 2025, 5:22pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/11 "2025-08-06T17:22:09Z")

</div>

Fix on the way:

> <https://github.com/BabylonJS/Babylon.js/pull/16978>
>
> Fixes this issue:
> https://forum.babylonjs.com/t/greased-line-visual-glitch-at-l…arge-scale/59320 
> 
> It might need a more elaborate solution in the future, but since this fixes the only reported issue so far, I wouldn't add more calculations to the shader. (calculate the the direction in world space and convert the resulting offset to clip space).

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 7, 2025, 3:01pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/12 "2025-08-07T15:01:32Z")

</div>

Merged 🙂

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [August 9, 2025, 5:04pm UTC](https://forum.babylonjs.com/t/greased-line-visual-glitch-at-large-scale/59320/13 "2025-08-09T17:04:25Z")

</div>

Thanks a lot! You are the best 👌
