SirRamEsq / SmartShape2D

A 2D Terrain Tool for Godot
MIT License
1.27k stars 63 forks source link

Texture edge material overflows outside of the shape if the shape is thin #168

Open DinoMC opened 2 months ago

DinoMC commented 2 months ago

I have the following shape with edge material working fine, I set a texture + a corner texture for the edge : OK_shape_edge

But when the shape is thin or has sharp turns, the edge material will render outside of the shape, and also hide the edge from the opposite side :

shape_edge_overflow overflow_with_taper

This is my edge texture (zoomed, it's normally 16x32px) : edge_texture

I tried most settings but couldn't find any to fix this. Did I miss it or is it not possible?

mphe commented 2 months ago

Does this occur with Asset store or master version, or both?

limbonaut commented 2 months ago

As things stand now, the edge quads/meshes are not cropped to shape's boundaries if the specific shape part is too thin to accommodate the full-height edge. The height of the edge depends on the height of the texture. So what we see here is edges getting out of shape bounds, because generated quads are wider than the shape body itself. Is this a bug? IMO, more like a limitation of this model.

DinoMC commented 2 months ago

This is on the master version, haven't tried asset store.

I guess it makes sense. I was looking for a setting like "clip content" but even if it was there it would look wrong anyway, especially when the edge on both sides overlap. Maybe I can create a "thin ledge" texture and apply it to these areas.

(The reason I can't just set it manually or avoid these shape is because I'm using the smart shape as terrain for a digging game, so the player maybe dig the shape like this. Also experimenting with destroying thin ledges when they are created due to "lack of support" to get around this)

mphe commented 2 months ago

We would need a kind of spatial analysis to get the thickness of the shape at each position to fix this problem. This is IMO out of the scope of this plugin, especially since it will have quite a performance impact.

As a workaround you can make a variation of your texture that is a bit smaller and use texture overrides at the relevant positions.

Edit: Ah ok, overrides are not possible.

limbonaut commented 2 months ago

In a potential cropping solution, the edge's quad/edge height would be cropped to half of the available space. We'd probably crop the mesh/quads on both edges at a similar scale. I wouldn't mind, if someone implemented something like this. As an option, though, because it would probably cause editor slow-downs.