Textures gets overlap while zooming out in panda3d world

Hello,
Actually am new here and with Panda3D,
Am working on a project that draws a surface, and sometimes there will be a surface on another surface (like if you draw a garden and there is a pool on it).

So, My problem is: After drawing this surface, when am zooming out the two surfaces gets overlap like in the image below.

Does anyone have an idea how to avoid that?

First of all, welcome to the community! I hope that you’ll find your time here to be positive! :slight_smile:

As to the issue that you’re encountering, I believe you’re seeing an effect called “Z-Fighting”. In essence, the two surfaces are so close together that the measure of which is closer to the camera–and thus which should be drawn over the other–becomes unreliable, causing regions from each to be drawn.

One solution is to apply a “depth offset” to the NodePath of one of the objects: a value that slightly alters the measure of the NodePath’s distance from the camera, thus allowing it to be “separated” from other NodePaths that are at much the same distance.

This does require you to know which objects should be rendered over which, of course.

For details on setting a depth-offset, see this entry in the API.

1 Like

OMG, Thank you so much you really helped me a lot. it’s worked perfectly right now.
Just a question how to find the best value of the two-parameter (bias, priority), am just not sure how to find them, in the code below I used and it’s worked fine

            if isinstance(polygon_2d_part, Field):
                self.polygon_model.setDepthOffset(2) # This is the main surface
            else:
                self.polygon_model.setDepthOffset(4) # This will appear above the main surface
1 Like

It’s my pleasure. :slight_smile:

If I recall correctly, the first parameter has values such that a value of 1 should separate two surfaces that are in exactly the same place. However, the camera’s distance from the surfaces in question may affect this, so some experimentation may be called for.

The section parameter, the priority, should I think only be called for if you want to a call to “setDepthOffset” to override the effect of one or more other depth-offsets that are further up the scene-graph. (That is, that are applied to NodePaths that are parents, or parents of parents, etc., of the NodePath on which you’re calling “setDepthOffset”.)

1 Like

One last question, sorry for bothering you :smiley:
Why after I made a setDepthOffset this happened with the render pipeline? and it is fine without it?

You’re not bothering me. :slight_smile:

However, if you’re referring to the advanced rendering system called “RenderPipeline”, then I’m afraid that I don’t use it myself, and don’t know its behaviour. :/

That said, it looks as though your texture may simply be tiled too many times over your surface–as though your texture is repeated a great many times over the model.

Why this might be depends on how you’ve produced the model in question, and perhaps whether you’re using “RenderPipeline”, if it has some effect that might impact this.

1 Like