Git Product home page Git Product logo

Comments (4)

Zylann avatar Zylann commented on July 17, 2024

I think you're using the wrong SDF scale for your stamped SDF, and that's affecting the result. It's a unit sphere you scaled by 30, but you scaled its distance field by 500, which is 16 times too much. If you use the same scale 30, the issue is much less (if at all) noticeable:

image

Now I'm less sure about why the presence of a modifier affects it, but that might have to do with differences in gradient (one sphere is placed in an area that was already full of air so it's less prone to incorrect SDF, but the other one is placed in an area that has much closer distances so it matters more, especially since the added shape has zero-crossings in the same locations).

Here is how the SDF looks like initially (bright yellow=10, bright blue=-10):
before0

When you use scale 500, you get this:
after0
The right sphere doesnt end up looking bad because voxels above its surface can keep going with a "fast" gradients since there was no existing surface nearby (SDF keeps going beyond 10, the debug image doesn't show that). But the left sphere had one, so gradients go fast from the center of the sphere but suddenly have to "slow down" sharply above the surface since that's the closer values to the sphere that was originally there (the Add operation does a SDF union which uses the min operator). I suspect that discontinuity is causing the blockyness.

You'll even notice the same problem if you chain these two, without a modifier:

	voxel_tool.stamp_sdf(voxel_mesh_sdf, transform.translated(Vector3(50,0,0)), 0, 30)
	voxel_tool.stamp_sdf(voxel_mesh_sdf, transform.translated(Vector3(50,0,0)), 0, 500)

But if you use scale 30, you get this:
after0
Which is pretty much the result you expected.

from godot_voxel.

Piratux avatar Piratux commented on July 17, 2024

Yes, I'm aware that I'm using different scales (there are reasons why I'm doing this, but it's a bit out of scope for this issue) and why the issue happens.
Roughly speaking
With sdf scale = 1 values are:
A = [.., -2, -1, 0, 1, 2, ..]

With sdf scale = 1 values are:
B = [.., -20, -10, 0, 10, 20, ..]

Thus,
SDF_UNION(A, B) = MIN(A, B) = [.., -20, -10, 0, 1, 2, ..]
Which causes unwanted blocky look.

My main point with this report, is that, presence of modifier should not affect the result (after all, it's intended to be non-destructive preview of the mesh).

from godot_voxel.

Zylann avatar Zylann commented on July 17, 2024

Unfortunately this cannot be "fixed", the problem is you're expecting that using wrong SDF alongside correct SDF to behave correctly, which can't happen.

stamp_sdf is a destructive operation, and you're using Add, so what was there earlier will affect the result. Modifiers act like "local generator extensions", therefore they are only applied in non-edited areas, before edits. Once the area becomes edited, they are frozen on it, with your destructive edit being done on top. Even if that order was somehow reversed and the modifier was applied on top of everything, it would not solve your issue because min(a, b) == min(b, a).

from godot_voxel.

Piratux avatar Piratux commented on July 17, 2024

I should have mentioned in an initial issue, that I expected the sphere on the left to be smooth again, after moving VoxelModifier away as I thought it was applied last.

However, now knowing that modifiers are to be treated as part of terrain this behavior is to be expected.

So this is not an issue.

from godot_voxel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.