Skip to content

Vision Effects

Jasmine Mai edited this page Aug 31, 2020 · 9 revisions

Vision Effects

There are three types of vision effects: renderer effects, material effects, and skybox effects. However, they all live under the same enum: VisionEffects. The difference between them is the type of controller that controls the effects. Renderer effects are applied to the camera. Material Effects are applied to environment objects in the scene and controlled by the MaterialController.cs script on the object. All Material Effects scripts inherit from MaterialEffect.cs. An example of material effects is UV, since the amount of UV emitted is different on a per-object basis. Skybox effects are applied to the skybox material and are controlled by the SkyboxController.cs script. All Skybox Effects scripts inherit from SkyboxEffect.cs. Similarly, Renderer effects are controlled by RendererController.cs, and inherit from RendererEffect.cs. An example of a renderer effect is colorblindness, as it effects the entire rendered screen.
If there are several of the same type of effects, they are applied in the order set in inspector list of effects on the AnimalVision.cs script.

Checklist for creating new vision effects can be found here.

Material Effects

Sparkle

Turns on and off sparkle and changes intensity based on the number of

Parameters

  • Sparkle Intensity: amount of sparkle on the object

Usage

  1. Add Sparkle to vision effects of the AnimalVision.cs scripts on the Animal prefab(s) that you want the UV effect for.
  2. On the object that you want to apply the UV effect, make sure you have attached a MaterialController.cs script.
  3. Attach a SparkleShaderIntensity.cs script. In another script, make sure you set the current intensity by using IncrementSparkle and DecreaseSparkle functions and calling them when the intensity needs to be updated.

UV

The UV false color effect is a per-object effect. It takes the original color of a material and creates a new false color by getting rid of the old color's red channel, swapping the green channel value into the red channel, swapping the blue channel into the green channel, and inputting the UV amount (adjustable per object) into the new color's blue channel. UV.cs will go through the game object recursively and change all of the materials to UV false coloring. If it finds a UV.cs script on a child object, it will use the parameters on the child's UV.cs script instead for the child object's renderer. If your material uses a texture, it will go through the texture pixel-by-pixel, generate a texture that has the false-color effect applied, and switch out the texture for the newly generated texture.

A note on shaders: Shaders use various property names internally for the settings that you can set in the inspector. For the regular URP Unity materials, the property name for the base color and base texture is _BaseColor and _BaseTexture respectively. UV.cs uses these shader property names and shader property colors to find the proper texture and color to change. If you are using another shader, this might not be the property name for the base color and base texture. If that is the case, you should modify the Shader Base Color and Shader Base Texture properties in the inspector to the appropriate names.

Parameters

  • UV Amount: amount of UV emitted by this object
  • Shader Base Color: the shader property name of the color that you want to be modified
  • Shader Base Texture: the shader property name of the texture that you want to be modified. May not apply if your material does not use a texture.

Usage

  1. Add UV to vision effects of the AnimalVision.cs scripts on the Animal prefab(s) that you want the UV effect for.
  2. On the object that you want to apply the UV effect, make sure you have attached a MaterialController.cs script.
  3. Attach a UV.cs script and adjust the parameters. If you wish to have specific parameters for a child object, attach a UV.cs script on the child object. These parameters will be used for the child object in place of the parameters set on the parent.

Material Swap

In the inspector, you can link what materials a material should swap to given an animal. MaterialSwap.cs will go through the game object recursively to find any instances of a material and swap it for the appropriate material given an animal type. If the material is not listed in the inspector, it will switch back to the original material. Note: material swap tends to be pretty performance heavy on the Quest

Parameters

  • Material Groups: a list of associated materials. Each list item comprises of:
    • originalMaterial: the original material
    • MaterialsToSwap: A list of MaterialAnimal objects containing the materials that should be swapped in place of the original material when a certain animal is switched to.

Usage

  1. Add MaterialSwap to vision effects of the AnimalVision.cs scripts on the Animal prefab(s) that you want the material swap effect applied for.
  2. On the object that you want to apply the MaterialSwap effect, make sure you have attached a MaterialController.cs script. Then, attach a MaterialSwap.cs script and link the materials and animals.

Renderer Effects

Generic Blit Effect

Blits are the core functionality of renderer effects. In essence, a blit is when an image is copied into a new location while an effect is applied to it. Blits allow one to apply effects to an image. In our case, we use blits to modify the result of a camera's output. BlitEffect.cs is a script that allows for the easy creation of a blit renderer effect without writing a new script.

Usage

  1. Make sure you have the RendererManager prefab in your scene.
  2. Keep the Renderer Controller component, but delete any other effect componenents you don't wish to use.
  3. Add the BlitEffect.cs script as a component to the RendererManager.
  4. In the Effect dropdown, select the effect name you want this blit effect to be associated with.
  5. Under Effect Name, input a name for this effect (this step is optional, but helps with clarity).
  6. Open the Settings dropdown. This is where the main blit settings are.
  7. Event determines when the blit effect is applied. For most effects, After Rendering Transparents is a safe bet. This will allow your effect to be applied everything in the scene, including the skybox.
  8. Blit Material is the most important setting. Set it to any material using an Image Effect Shader. During rendering, the camera's output will be passed to the shader as the Main Texture (_MainTex).
  9. Blit Material Pass is irrelevant for basic blit effects. Set it to 0.
  10. Keep Destination set to color.
  11. Texture ID is irrelevant for basic blit effects.

Colorblind

Uses a material with the Anivision/Colorblind shader to apply a colorblind effect as a renderer effect. The type of colorblindness can be adjusted.

Usage

  1. Add Colorblindness on the Animal prefab(s) that has colorblindness. Select the type of colorblindness that the animal has. (If you select Custom as the type, enter a custom color shift matrix).
  2. Make sure you have the RendererManager prefab in your scene.
  3. Keep the Renderer Controller component, but delete any other effect componenents you don't wish to use.
  4. Add the ColorblindEffect.cs script as a component to the RendererManager.
  5. Set Colorblind Material to any material using the Anivision/Colorblind shader.

Skybox Effects

Skybox Swap

Swaps the skybox material for another material given a certain animal.

Usage

  1. Make sure you have the SkyboxManager prefab in your scene.
  2. Add the SkyboxSwap.cs script to the SkyboxManager prefab. Link the animals and skybox materials you want swapped through the inspector.