Jump to content

Enhance Collision Mask Layer


mohdanis
 Share

Recommended Posts

Hi,

Happy New Year!

 

On the spawner, I can use the Collision Mask with "Layer Game Object". Can I get similar functionality with Unity Tags? Use case:

I want to use Unity ProBuilder to create a polyshape. The polyshape will mark out a biome through a Collision Mask and a Unity Tag can be used by the Mask to get the corresponding polyshape object. Note that this is the same behavior as for "Layer GameObject" under "Respected Collisions" of the Collision Mask but applied for Tags.

 

Other enhancements:

- An option to select disabled gameobjects for Collision Mask.

- Directly specify list of game objects

- Strength falloff at the boundary of the collision mask so there's blending with other biomes

- Not sure if I can specify the resolution of the generated Collision Mask (so far looks fine to me)

 

I believe the above can be accomplished with Image Masks just that this feels a bit more straightforward since everything sits in Unity (e.g. I don't need to go into an image editor to tweak the image mask, load it back into Unity and check what it looks like)

Link to comment
Share on other sites

Hi, happy new year to you as well!

You might have noticed already, but there is a "Radius Tag" selection in the collision mask that let's you render a radius around an object with a certain tag. Depending on what you want to do with your poly shape, that might be good enough if you can tag each "vertex" of your poly shape so that it renders a radius around it. But it might not be precise enough.

Here is an example where I tagged those cubes (which act as my "vertices"):

image.png

And the resulting shape in the collision mask:

image.png

Generally speaking those are very good suggestions, what we currently have with the layer is not flexible enough if you only want X objects from a certain layer, also you do not always want to "sacrifice" a layer just for Gaia collision detection or your objects need to be on a different layer for other technical reasons.
What makes it a bit more difficult to support this over layers is that when capturing the shapes of the object we use an unity camera as well. This can be done easily (and safely without changing the scene data) when just rendering a certain layer for the mask. As soon as we start with rendering certain tags or a list of Game Objects only, we might need to change the scene data during the collision mask capture (e.g. hide all objects with different tags) which we want to avoid as this could destroy the scene if anything goes wrong and we run into an unforeseen error. But we might be able to find a way around this, and there were also requests for having "native" polygon shaped masks or being able to draw a mask directly in unity which might solve the same problems in a different way.

Link to comment
Share on other sites

Oh yeah thanks! Will take a look at the radius thingie. But yeah.. polygon shaped masks will be great. If it's too much work you can look at hooking it up with the Spline functionality on Gena so as to incentivize folks to get Gena too!

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

@Peter I guess one option could be bypassing the camera rendering entirely and just you have a texture that's stretched across the entire terrain. Now your 2d spline is basically a polygon (or just project the spline on the xz-plane to get the polygon) and you can look at doing an in/out test at each pixel on the texture to see if it's inside the polygon. It might be a tiny bit slow but I doubt it's going to matter. It can also be trivially multithreaded since you can have the in/out test run independently. 

 

If there's concern on large terrains with precision loss,just calculate an axis aligned bounding box across the spline and stretch the texture across the box.

Link to comment
Share on other sites

  • 3 weeks later...
On 1/23/2022 at 9:02 AM, mohdanis said:

@Peter I guess one option could be bypassing the camera rendering entirely and just you have a texture that's stretched across the entire terrain. Now your 2d spline is basically a polygon (or just project the spline on the xz-plane to get the polygon) and you can look at doing an in/out test at each pixel on the texture to see if it's inside the polygon. It might be a tiny bit slow but I doubt it's going to matter. It can also be trivially multithreaded since you can have the in/out test run independently. 

 

If there's concern on large terrains with precision loss,just calculate an axis aligned bounding box across the spline and stretch the texture across the box.

So good news! I managed to do the above using a 4096x4096 Alpha-only texture and geometry3Sharp library (it came with another package.. it might be free since it's on github too). So now i just generate my own image mask. Hope to see a good solution for this on the Gaia/Gena 2022 cycle. Vegetation Studio Pro seems to have a good solution for this (no stampers support though).

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Tell a friend

    Love Unity 3D World & Game Creation Tools - Canopy - Procedural Worlds? Tell a friend!
  • Interesting Articles

    1. 8

      Errors from Gaia 2021 after updating to Unity 2021.3.2 LTS

    2. 7

      Problems with latest Gaia Update

    3. 7

      Problems with latest Gaia Update

    4. 0

      Ambient sounds issues

    5. 7

      Scene Optimizer

×
×
  • Create New...