-
Notifications
You must be signed in to change notification settings - Fork 1
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.
Turns on and off sparkle and changes intensity based on the number of
-
Sparkle Intensity
: amount of sparkle on the object
- Add
Sparkle
to vision effects of theAnimalVision.cs
scripts on the Animal prefab(s) that you want the UV effect for. - On the object that you want to apply the UV effect, make sure you have attached a
MaterialController.cs
script. - Attach a
SparkleShaderIntensity.cs
script. In another script, make sure you set the current intensity by usingIncrementSparkle
andDecreaseSparkle
functions and calling them when the intensity needs to be updated.
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.
-
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.
- Add
UV
to vision effects of theAnimalVision.cs
scripts on the Animal prefab(s) that you want the UV effect for. - On the object that you want to apply the UV effect, make sure you have attached a
MaterialController.cs
script. - Attach a
UV.cs
script and adjust the parameters. If you wish to have specific parameters for a child object, attach aUV.cs
script on the child object. These parameters will be used for the child object in place of the parameters set on the parent.
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
-
Material Groups
: a list of associated materials. Each list item comprises of:-
originalMaterial
: the original material -
MaterialsToSwap
: A list ofMaterialAnimal
objects containing the materials that should be swapped in place of the original material when a certain animal is switched to.
-
- Add
MaterialSwap
to vision effects of theAnimalVision.cs
scripts on the Animal prefab(s) that you want the material swap effect applied for. - On the object that you want to apply the MaterialSwap effect, make sure you have attached a
MaterialController.cs
script. Then, attach aMaterialSwap.cs
script and link the materials and animals.
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.
- Make sure you have the
RendererManager
prefab in your scene. - Keep the
Renderer Controller
component, but delete any other effect componenents you don't wish to use. - Add the
BlitEffect.cs
script as a component to theRendererManager
. - In the
Effect
dropdown, select the effect name you want this blit effect to be associated with. - Under
Effect Name
, input a name for this effect (this step is optional, but helps with clarity). - Open the
Settings
dropdown. This is where the main blit settings are. -
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. -
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). -
Blit Material Pass
is irrelevant for basic blit effects. Set it to 0. - Keep
Destination
set to color. -
Texture ID
is irrelevant for basic blit effects.
Uses a material with the Anivision/Colorblind
shader to apply a colorblind effect as a renderer effect. The type of colorblindness can be adjusted.
- Add
Colorblindness
on the Animal prefab(s) that has colorblindness. Select the type of colorblindness that the animal has. (If you selectCustom
as the type, enter a custom color shift matrix). - Make sure you have the
RendererManager
prefab in your scene. - Keep the
Renderer Controller
component, but delete any other effect componenents you don't wish to use. - Add the
ColorblindEffect.cs
script as a component to theRendererManager
. - Set
Colorblind Material
to any material using theAnivision/Colorblind
shader.
Swaps the skybox material for another material given a certain animal.
- Make sure you have the
SkyboxManager
prefab in your scene. - Add the
SkyboxSwap.cs
script to theSkyboxManager
prefab. Link the animals and skybox materials you want swapped through the inspector.