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

Doesn't work with Unity's Terrain #1

Closed
zwcloud opened this issue Jun 4, 2020 · 3 comments
Closed

Doesn't work with Unity's Terrain #1

zwcloud opened this issue Jun 4, 2020 · 3 comments

Comments

@zwcloud
Copy link

zwcloud commented Jun 4, 2020

image

using Unity 2019.3.9f1 URP 7.3.1

@Anatta336
Copy link
Owner

Hello, thanks for the report.

It looks like the problem is that it doesn't recognise Unity's Terrain as being a mesh that it can project against. This issue is reproducible, the decal projection system completely doesn't work with Unity's Terrain.

I think it would be a lot of work to get this type of decal system to work in a satisfactory way with Unity's Terrain. Although we cannot directly access the meshes generated by Terrain, we could still build a decal mesh by looking up height data from the Terrain. The bigger problem is that the Terrain swaps between different resolution meshes as the camera moves. To avoid visually clipping through the terrain, the generated decal mesh would need to also swap between matching meshes under the exact same conditions.

That would be possible to do, but it feels to me like something that would better be done by a dedicated Terrain-based system, or a decal system that does the projection at render-time and so doesn't need to access mesh data at all.

@Anatta336 Anatta336 changed the title Doesn't work: Cannot project mesh until the decal is placed close to a static mesh in the scene. Doesn't work with Unity's Terrain Jun 5, 2020
@zwcloud
Copy link
Author

zwcloud commented Jun 5, 2020

It looks like the problem is that it doesn't recognise Unity's Terrain as being a mesh that it can project against.

That's a terrain-like mesh, not a Unity terrain: MeshB.zip

I have also tried regular meshes like sphere, plane and box, it doesn't work either.

@Anatta336
Copy link
Owner

Aha, okay. By default the decal looks for nearby meshes that are on objects flagged as "static" (the checkbox on top-right of the inspector when the mesh's object is selected.) If the meshes you're testing with aren't static then the decal will normally not try to project against them.

If you want a decal to project against non-static mesh objects you can untick "All static meshes" on the Decal Mesh and add whatever MeshFilters you wish to the "Target meshes" list.

Here is a decal projecting against the example mesh, with the mesh itself still being non-static:
projectedOnMeshB

Hopefully that helps.

@zwcloud zwcloud closed this as completed Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants