Jump to content

Spawner Mask for Terrain Alphamap


Lacota

Recommended Posts

In Gaia 2021 Pro for Unity is there a spawner Mask Type that allows me to reference a Terrain alphamap? I am importing my heightmap and splatmaps. I haven't found any documentation on this but it doesn't help that Unity has half a dozen different words for splatmap.

Link to comment
Share on other sites

Hi @Lacota, yes there is, it is called "Terrain Texture":
image.png

Note that this links to TEXTURE SPAWN RULES and not to terrain layers - this was done to avoid issues with terrain layers not being added to the terrain (yet), terrain layers being in different orders, terrain layers being renamed at a later point, terrain layers being swapped out, etc.
In short, linking to spawn rules instead of layers was more reliable. If the layer you want to use in the mask does not exist as a spawn rule, you can make a dummy spawn rule to get the selection in that "Texture Rule" dropdown.

Link to comment
Share on other sites

Does the Texture Spawn Rule reference the terrain alphamap? I've loaded my values into the alphamap but they don't seem to be reflected in my texture spawner. Not sure how I associate a specific spawn rule with a channel in the alpha map. Unity allows you to define multiple channels but references first and second splatmaps each with 4 (rgba) normalized values. Was thinking I would use one to define biomes and the other to define features within biomes.

Link to comment
Share on other sites

The regular use case for the texture masks in Gaia is "to spawn things where a certain texture is being rendered on the terrain". For example: You create a texture spawner to render sand, grass and a rock texture on the terrain. Then in another spawner, you use the texture mask to spawn trees where the grass texture is being displayed.
The association between the spawn rule that creates the texture on the terrain and the texture mask is done via the resource settings of the texture spawn rule. Here is an example of the grass texture mask being displayed in visualization:

image.png

Gaia "knows" where the texture of the Grass spawn rule is being rendered on the terrain by looking into the resource settings of the grass spawn rule....

image.png

...and then looking for the texture files configured in there on the terrain layer prototypes on the terrain....

image.png

It therefore knows that on this terrain, the grass spawn rule maps to the Index 1 or green channel on the 1st alphamap. On a different terrain the grass terrain layer might be on a different index / channel, but it would still work regardless because Gaia would find it this way.
 

Quote

I've loaded my values into the alphamap but they don't seem to be reflected in my texture spawner. 

If you have a filled alphamap on the terrain that was not created through gaia spawn rules already, you would need to create dummy texture spawn rules whose resource settings match the terrain layer setup on the terrain. Then you should be able to select those "fake" spawn rules in the texture mask and they should find the correct index / color channel on the alphamap through the process above, even though you never spawned them before.

If you imported the alphamap contents as a regular texture file in unity, you could also consider using an image mask in Gaia and filtering by color channel.

image.png

Link to comment
Share on other sites

So there is no direct way to reference the Unity Terrain Alphamap. I would imagine something like the image mask above (Alphamap Mask) but instead of selecting a color channel you would enter an index. Does Gaia use the Terrain Alphamap for anything? Also, I can get the visualization to work for Biomes but it doesn't show for spawners. Is there some global setting I'm missing?

Link to comment
Share on other sites

1 hour ago, Lacota said:

So there is no direct way to reference the Unity Terrain Alphamap. I would imagine something like the image mask above (Alphamap Mask) but instead of selecting a color channel you would enter an index.

This is something we had in earlier unity versions, but this creates issues if the order of the terrain layer prototypes changes between terrains, or the user added terrain layer prototypes per hand etc. which is why we switched to reference spawn rules instead.
 

1 hour ago, Lacota said:

Does Gaia use the Terrain Alphamap for anything?

Yes, it queries the information for the terrain texture mask from the alphamap as described in detail above. When spawning terrain textures it writes to the alphamap so that the texture that is being spawned is displayed in the desired spot. 

1 hour ago, Lacota said:

Also, I can get the visualization to work for Biomes but it doesn't show for spawners. Is there some global setting I'm missing?

Hmm, the visualization should be identical from a technical perspective. What might be the issue is that one of the masks on the spawner prevents the visualization from being drawn. Try to deactivate all masks within the spawner to see if one mask is so restrictive that it does not leave any valid area anymore.
Also please note that if the spawner is part of a biome, the biome mask will also be taken into account when visualizing. So it could be a combination of both the masks used in the biome controller & the spawner that does not leave any valid area remaining for a spawn.

Link to comment
Share on other sites

Gaia is likely overwriting my alphamaps then. So back to my original workflow; I am bringing in the heightmap and splatmaps from an external source. Heightmaps are fine. But I should be creating image masks from my splatmaps instead of writing them directly to the alphamaps. I'm not sure how to do this in code but I'll give it a try and see how far we get. 

The spawners are working it's just the spawner visualizer that isn't rendering. But will try what you recommend.

Link to comment
Share on other sites

Just to make sure there is no misunderstanding:

  • Please note that the intended use case of the alphamaps in the unity terrain system is to store texture distribution information for splatmap texturing / rendering (drawing multiple textures across the terrain in varying strength).
  • The default unity terrain shader in all render pipelines will use the information stored in the alphamap for rendering the terrain textures on the terrain.
  • Any tool that is applying texturing to the terrain, such as Gaia or the vanilla terrain inspector, will overwrite the alphamaps, this is intentional and how the alphamaps are meant to be used for feeding texturing information into the terrain shader.
  • You can use the alphamaps to store other information such as biome borders, or a mask for tree positions etc. but you would lose your ability to display textures on the terrain then - unless you are using an alternative terrain shader, or you are ok with the textures being displayed only in the same locations as stored in the color channels of the alphamap.

I was not sure if this this was clearly expressed in my posts or not and was worried this might be lost in translation.

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
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...