Skip to main content

VRCGraphics

Udon has access to a variety of Unity's graphics functions.

Types

VRCShader

Overarching class for global shader setters. See functions documented below for more.

VRCGraphics

Exposes a subset of Unity’s built-in `Graphics` class. See documented functions for more.

Exposed Functions

VRCGraphics.Blit()

Copies source texture into destination RenderTexture with a shader. Note that we do not allow you to supply a null destination.

See Graphics.Blit.

Minimap Example

The version of the SDK installed by the Creator Companion includes an example scene that provides a performant Minimap as an example use of Graphics.Blit. You can open it from the Unity Menu Bar under VRChat SDK > Samples > Minimap. This example uses the Udon Graph, it's also available as an UdonSharp example.

index-aecb84d-minimap-example.png

Meta Quest Exceptions

VRCGraphics.Blit will not work on the Quest GPU unless you:

Add ZTest Always to the shader OR Turn off the depth on the target RenderTexture.

Failing to do so will cause the operation to fail.

VRCGraphics.DrawMeshInstanced()

Draw the same mesh multiple times using GPU instancing.

See Graphics.DrawMeshInstanced.

VRCShader.PropertyToID()

Use PropertyToID to get an ID based on a shader property name. Call this function only once during initialization, the ID can be reused and will not change, even between different materials and shaders.

Note that the property name must be prefixed with “_Udon”, or be the literal string “_AudioTexture” in order to be used with VRCShader.SetGlobal, however, will still return the ID regardless of this.

See Shader.PropertyToID.

VRCShader.SetGlobal()

Use the ID acquired with PropertyToID as a key and specify a value of the correct type. The value will be available in all shaders in the world (including ones on avatars!) under the name passed into PropertyToID.

Available variants:

  • VRCShader.SetGlobalColor()
  • VRCShader.SetGlobalFloat()
  • VRCShader.SetGlobalFloatArray()
  • VRCShader.SetGlobalInteger() still sets the value as float for now, due to a Unity bug
  • VRCShader.SetGlobalMatrix()
  • VRCShader.SetGlobalMatrixArray()
  • VRCShader.SetGlobalTexture()
  • VRCShader.SetGlobalVector()
  • VRCShader.SetGlobalVectorArray()