Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygon offset of node overlays causes Z-issues with outline and other nodes #15821

Closed
kno10 opened this issue Feb 22, 2025 · 8 comments · Fixed by #15867
Closed

Polygon offset of node overlays causes Z-issues with outline and other nodes #15821

kno10 opened this issue Feb 22, 2025 · 8 comments · Fixed by #15867
Labels
Bug Issues that were confirmed to be a bug @ Client rendering Regression Something that used to work no longer does
Milestone

Comments

@kno10
Copy link
Contributor

kno10 commented Feb 22, 2025

Luanti version

Luanti 5.12.0-dev-166e02955 (Linux)
Using LuaJIT 2.1.1737090214 (OpenResty)
Built by GCC 14.2
Running on Linux/6.11.6 x86_64
BUILD_TYPE=Release
RUN_IN_PLACE=0
USE_CURL=1
USE_GETTEXT=1
USE_SOUND=1
STATIC_SHAREDIR="/usr/local/share/luanti"
STATIC_LOCALEDIR="/usr/local/share/locale"

Operating system and version

Linux

GPU model

Intel

Active renderer

4.6 / opengl / X11

Summary

Note how barely visible the node outline is in this screenshot:

Image

On nodes with no overlays, the line is much more visible.

This is a regression from #15634

For an additional issue with the new overlay approach and "flat" nodes such as carpets and snow, see also #15674

Steps to reproduce

Find a node with overlay textures as the examples #15632.
Observe the selection outline indicating the node you are pointing at.

@kno10 kno10 added the Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible label Feb 22, 2025
@appgurueu appgurueu added Bug Issues that were confirmed to be a bug @ Client rendering and removed Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible labels Feb 22, 2025
@appgurueu
Copy link
Contributor

Can reproduce:

Screenshot from 2025-02-22 22-03-25

If the fix for #15632 is to stay for now, we could probably fix this by just extruding the box a slight bit further for such nodes.

@sfan5 sfan5 added the Regression Something that used to work no longer does label Feb 23, 2025
@kno10
Copy link
Contributor Author

kno10 commented Feb 25, 2025

@sfan5 How about doing the opposite - if there is an overlay, move back the background instead of moving the overlay in front?
I.e., in

if (layer == 1) {
material.PolygonOffsetSlopeScale = -1;
material.PolygonOffsetDepthBias = -1;
}

does it work to use layer == 0 and +1 instead of -1?

@sfan5
Copy link
Collaborator

sfan5 commented Feb 25, 2025

Good idea. I'll try it this evening.

@sfan5 sfan5 changed the title Overlay Z regression on node outlines Node outline barely visible when overlays used Feb 25, 2025
@sfan5
Copy link
Collaborator

sfan5 commented Feb 26, 2025

Just doing that has the same problem but in a different situation (rails layer 0 fights grass layer 1):
Image

The closest I can think of for a solution is:

  • if two layers, move layer 0 away from camera
  • if one layer, don't do anything

It would solve the situation from above, but still cause the same problem if you put an overlay-using raillike on an overlay-using node surface.

@sfan5 sfan5 added this to the 5.12.0 milestone Feb 26, 2025
@ryvnf
Copy link
Contributor

ryvnf commented Feb 26, 2025

This seems to be a bigger issue. I found that it does not matter what height you use.

See my comment in the other issue: #15674 (comment)

@sfan5 sfan5 changed the title Node outline barely visible when overlays used Polygon offset of node overlays causes Z-issues with outline and other nodes Feb 26, 2025
@sfan5
Copy link
Collaborator

sfan5 commented Feb 26, 2025

Also before anyone suggests it: yes, we are drawing the overlays after the base layer. this is working correctly.

@sfan5
Copy link
Collaborator

sfan5 commented Mar 5, 2025

The closest I can think of for a solution is:

* if two layers, move layer 0 _away_ from camera

* if one layer, don't do anything

I implemented this here 1487a2b but it doesn't work and I don't know why.
Rails and everything are fine now but now the grass is z-fighting was if the z-bias was not working at all.

Edit: lol nvm, I forgot to edit the operator==.

@sfan5 sfan5 linked a pull request Mar 6, 2025 that will close this issue
@SmallJoker
Copy link
Member

I don't know whether it's exactly the same issue with water, but a similar Z-fighting issue can be reproduced by placing a castle_gates:stonebrick_gate_slot into water. This node is larger than 1x1x1. The main part is rendered properly but not such that is located outside the {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5} extent:

stonebrick in water

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Client rendering Regression Something that used to work no longer does
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants