-
Notifications
You must be signed in to change notification settings - Fork 99
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
Normal artifact along region boundaries #185
Comments
Exploring more, here is the call stack
The problem is visible in get_height. This code can be pasted into fragment and look at the artifact on the inside of the bowl next to the mountain:
Height is not read smoothly across the region boundaries in fragment. It screws up normals when they take the difference in heights across the boundaries, which also screws up the autoshader. Height seems to be read smoothly across region boundaries in vertex Some of my thoughts are:
Stakira suggested:
Attempting 2. above, I used a normal method using only 3 lookups, center plus two perpendicular offsets:
Current 4-lookup method, 3-lookup method, 3-lookup method conditional with reverse if near region boundary (red). So far the third reduces the issue the most. In real world use this is much better and will be incorporated until we can find a better solution. Current vs 3-lookup conditional: Autoshader |
Partial workaround added in 990e7c0 |
This might be a solution. https://discord.com/channels/691957978680786944/1065519581013229578/1225045276759294053
|
this should branch the additional vertex reads correctly. |
@FishOfTheNorthStar Responding to #348 (comment) and above. I appreciate your ideas. You and @Xtarsia both seem to have solutions that address the normal artifact, and I am excited about optimizing the shader further. I have a running list of ideas in #26.
I also want to do all lookups per vertex and remove all fragment lookups. I was able to have it working fine on LOD0, but it didn't look good LOD1+, and not on the transitions. Did you solve this? I've had this theory that removing all fragment lookups and removing all lods might be more performant than fragment lookups with lods.
Regarding the pictures above, I see the artifact is gone, great. However, the normals elsewhere in the background are noticeably softer in the fixed version than before.
@Xtarsia suggested something similar. I'm not excited about throwing away 1-2m of data. I'm not sure which is the best solution yet. The ideas about using TextureGather and other things sound interesting. The more optimal the shader, the more features we can add to it.
Migrating is the least of my concerns. I've been upgrading people seamlessly since my second release. What is the concern is making changes that will require the user to move their objects around or resculpt/texture. The questions are:
I look forward to seeing what you come up with. One thing I will ask on PRs is no arcane variable names like below. I need understandable code, variables with full name instead of vgh, zro, frv, etc so I and others can have a chance at understanding it.
|
@Xtarsia your solution in #185 (comment) and #185 (comment) works well where there are regions, however it turns into a grid where there aren't any and using noise. Do you have a fix for this? |
Edit: this was a total failure. |
This fixes 99% this is fixed with this:
this line edit: corner noise still an issue, related to the direction of the offset height reads. though probably better to fix corner world noise blending. (all tested on a fresh project with 4.2.1.stable with 0.9.1 beta release) |
Yes, just a small adjustable amount to avoid hard lines. With these shader updates, I don't see an artifact anywhere, even on the edge of the world. However, I do see it costs about 5-10% of performance. 🤔 Also strangely, this eliminates the artifact:
But this makes it worse:
I don't understand why. I tried several other variations and all produced the same result, only sending get_height directly into v_heights allowed it to work. There is a get_height(UV2) call earlier in vertex() for VERTEX that I was trying to use, but I couldn't reuse the lookup. I also couldn't set v_heights before and set VERTEX off of it. So there's a redundant lookup, but I'm confused as to why I can't reuse the data. |
branching for vertex normals to fix TokisanGames#185 caused performance loss. so make that branch as big as possible without visual loss..
Branching for vertex normals to fix TokisanGames#185 caused performance loss. so make that branch as big as possible without visual loss..
Branching for vertex normals to fix TokisanGames#185 caused performance loss. so make that branch as big as possible without visual loss..
Branching for vertex normals to fix TokisanGames#185 caused performance loss. so make that branch as big as possible without visual loss..
Branching for vertex normals to fix #185 caused performance loss. so make that branch as big as possible without visual loss..
Excellent work by @Xtarsia finally fixed this long standing bug in #353. @FishOfTheNorthStar and @Xtarsia Let's keep talking about shader optimizations in #26 and other places. I'm very interested in the idea of removing all fragment lookups and boosting speed. In the meantime, we have an improved terrain today! Also Fish, you might want to join my discord where we talk a lot about development. |
This artifact appears on regions borders. Along a region border make multiple heights at 40, 20, 0, -40 then start smoothing them together and it will appear. The thickness of this artifact appears to be 2 vertices, and is offset. So on X it goes from 0.5 to -1.5.
The artifact is in the normals. It occurs in the fragment() normal calculation. It has to do with using texture() with filter_linear, as it linearly blends the edge of the height map in it's normal calculation. If we switch to filter_nearest or texelfetch() it does resolve, however the normals are blocky.
Possible solutions:
Testing notes:
I tried clamping to the region so it wouldn't sample across boundaries and just average, that reduced the size but didn't help
The text was updated successfully, but these errors were encountered: