Give Page Feedback | API

Cell Visual Transition Controllers - Per Material Transitioner

The Per Material Transitioner performs transitions by setting a material property using Material.SetFloat method. Typically the property set will control some kind of transparency or cross fade effect, however this is not a strict requirement. It's possible the property will have nothing to do with transparency and/or cross fading.

This transitioner is primarily intended to be used with the Scriptable Render Pipeline and SRP Batcher, in setups where the SRP Batcher gains an advantage over other rendering techniques.

Read About The SRP Batcher

Creating A Per Material Transitioner Component

You can add this component by selecting a game object and then selecting from the Top Menu Bar:

Component -> Deep Space Labs -> -> SAM -> Visual Transition Controllers -> Per Material Transitioner

Adding A Per Material Transitioner Component From The Top Menu Bar GIF

or by selecting a game object and using the Add Component menu via its inspector:

Component -> Deep Space Labs -> -> SAM -> Visual Transition Controllers -> Per Material Transitioner

Adding A Per Material Transitioner Component From Add Component Menu GIF

Benefits

Using Material Property Blocks allows you to use the same Material across many different Game Objects while allowing for each Renderer component to use unique values. In terms of the SAM, this allows the transitioner to transition the visibility specific Asset Chunks while maintaining the visibility of other Asset Chunks, even when all of those Asset Chunks use the same Material.

Mat Prop Block Transitioner Vs Per Material Transitioner

These two Transitioners function in nearly the same way; the only difference between them is that the Per Material Transitioner uses Material.SetFloat to adjust the shader property while the Mat Prop Block Transitioner uses Material Property Blocks.

While this difference is subtle, the effects on your game can be huge depending on your setup.

The Per Material Transitioner is primarily intended to be used with the Scriptable Render Pipeline in situations where the SRP Batcher can take advantage of your Mesh/Material/Shader setup, which generally includes a small number of shaders/shader variants and a large number of unique materials or meshes.

The Mat Prop Block Transitioner, on the other hand, is great for situations where you are using GPU Instancing (i.e., drawing the same mesh repeatedly) or not using the Scriptable Render Pipeline.

We recommend testing with both transitioners to see which is more performant with your setup.

Read About Material Property Blocks

Use Shared Material

Normally the Transitioner will use the .material property of the Renderer to set the transition property. If you enable this option, it will use the .sharedMaterial property instead. While this will reduce the number of unique material instances created, it has the disadvantage that changing the transition property on the shared material will transition any Asset Chunks using the same material, which is usually undesirable.

For this reason, we recommend only enabling this option if you know what you are doing.

Do note that using the .material property also has a drawback. The material instance that is created when this property is accessed needs to be destroyed in one of two ways when the Asset Chunk using the material is destroyed:

1) By manually destroying the material using the Destroy method. This is best done in a custom Chunk Streamer, however option 2 is generally recommended rather than using this option.

2) By calling Resources.UnloadUnusedAssets. Fortunately, all of the default Chunk Streamers include settings that allow you to easily force this method to be called when destroying/unloading Asset Chunks. Just choose the Memory Freeing Strategy that you think is best and the Streamer will take care of the rest!

Multiple Materials Per Mesh

This Transitioner will call SetFloat for every Material on each Renderer, which is usually desired. However, if all Materials do not utilize the shader property or you do not want all of them to be transitioned, you will need to create a custom transitioner.

Use Unity Crossfade

Enabling this special option allows the transitioner to manipulate materials in the same way that Unity does when using its built-in LODGroup component, i.e., it enables LOD Crossfading for materials which are compatible with the LODGroup component.

Do note, however, when using this option, you will almost certainly need to set the Visual State Of Stored Assets When Active option to Invisible, for any LOD Groups that will be used with the transitioner. This setting can be found on each LOD Group specific tab on your Streamable Grid Assets.

Also note that it is necessary to assign all of the Materials that will be transitioned using the Transitioner explicitly, in order for certain shader keywords to be enabled. If you do not do this, the transitions will not work.

Finally, note that while this option should work with the SRP batcher, it is untested so if you run into any problems, please let us know!

Transition Settings

These settings allow you to control the amount of time transitions take as well as separate curves that control the lerping of the transition value while transitioning Asset Chunks from Invisible to Visible and Visible to Invisible.

--Special Note--
You can modify the transition time at runtime via the TransitionTime property.

Other Settings

Hover over the field labels in the inspector to view additional information about each setting.