6
$\begingroup$

Is there a way to prevent z-fighting of planar instances generated using Geometry Nodes?

Random distance doesn't space my planes far enough apart from each other.

Maybe there is a way to implement Poisson Disc distribution for the Z axis?

Or maybe there is a way to space instances equally on the Z axis?

The black spots are the result of planes z-fighting:

Here is the node setup, which I modified from an answer by Hulifier:

Geometry Nodes setup for billboard particle style instances

This area is probably the place to pay the most attention to:

Nodes that determine height

$\endgroup$
3
  • $\begingroup$ "Or maybe there is a way to space instances equally on the Z axis?" - yes there is, sort the points on Z, then use Map Range to map their sorted index to a range of Z values (I think 0..0.7 in your case) $\endgroup$ Commented Jun 6, 2022 at 20:32
  • $\begingroup$ Thanks! Since we're dealing with points, and a random order is okay, is there an easy way to sort by vert index number? Maybe using ID? $\endgroup$
    – Mentalist
    Commented Jun 6, 2022 at 22:24
  • $\begingroup$ @MarkusvonBroady I've figured out how to sort by point index along Z. Index node > Math (Multiply) > Combine XYZ (Z) > Set Position [Offset input]. Next I'll try it out with the whole node setup. Your hint about sorting helped me know what to search for and what to try. :-) $\endgroup$
    – Mentalist
    Commented Jun 7, 2022 at 2:09

2 Answers 2

5
$\begingroup$

What worked for me was to add spacing to each point, using the points' indices to target them - and then summing that with the random spacing that already existed. This way they are still staggered, but now include some minimum in-between padding.

Geometry Nodes - random spacing plus index spacing

The idea is that if you have two planes that are really really close together, even if you double/triple/etc the scale on Z, it may not affect those particular close neighbors enough to cure their z-fighting. But using the Index node it is possible to specify equidistant spacing. However we don't need to lose the desirable randomness - we can add the random and equidistant values together to get the best of both.

Problem solved:

Note that it doesn't take much spacing of the indices to eliminate the z-fighting. In my case a value of 0.0001 was enough.

Reminder: The Clip Start and Clip End also contribute to the appearance of z-fighting, and the clip settings are separate for the Viewport and the Camera. A broader start-to-end range is more likely to cause z-fighting, while a narrower one is less likely to.

$\endgroup$
4
$\begingroup$

I don't completely understand what you are trying to achieve, but simple random value seems to help:

enter image description here

Else than that this seems to be a problem of z-buffer precision so no matter what you do if you have too many planes in the same region, some of them are going to get too close at some point no matter how you try to fit them, so the way I see it, you need to adjust viewport/camera clipping values to match the scene better or move the planes further apart.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .