Skip to content

VRSL DMX: Creating Custom DMX Shaders

AcChosen edited this page Jan 27, 2023 · 23 revisions

CG Includes & Properties

VRSLDMX.cginc

VRSL DMX is intended to be used more like a data protocol rather than a discrete set of shaders and tools. As such, any shader property can be controlled by DMX, whether it's lighting, vertex transforms, screen space, etc. If it's a shader property, it can be controlled by VRSL. This page discusses what you need to add to your custom shaders to enable VRSL DMX functionality.

VRSL DMX works similarly to audiolink in that there is a single CGINC file that you need to include to start creating DMX-compatible world shaders. The file is called VRSLDMX.cginc and you can use it with this strip of code:

#include "Packages/com.acchosen.vr-stage-lighting/Runtime/Shaders/VRSLDMX.cginc"

This file contains a few instanced defined properties, standard defined properties, and some functions needed to read DMX from the grid node. Once you have this file in, there are some properties you may want to define first before you get started writing.

The Main Properties

These two are the two properties most important:

  • _DMXChannel ("Starting DMX Channel", Int) = 1

    • The _DMXChannel instanced property is where you'll set the starting DMX Channel for your DMX shader. DMX Channels start reading from 1, so 1 is the default.
  • [NoScaleOffset] _DMXGridRenderTexture("DMX Grid Render Texture (To Control Lights)", 2D) = "white" {}

    • The _DMXGridRenderTexture is where the DMX Grid render texture will actually go. You can find the render textures in: Packages/com.acchosen.vr-stage-lighting/Runtime/Textures/RTs. There you can find the horizontal, vertical, and legacy versions of the textures. I recommend using the DMXRTViewer-Interpolated-Color+Intensity prefixed render textures as those are the slighting smoothed versions of the RAW render texture counterparts.

These two properties are required for all world-based DMX shaders (for now).

The Extra Properties

Here are some extra properties that are not required but are still highly recommended to have in your shader to enable standard features:

  • [Toggle] _EnableDMX ("Enable Stream DMX/DMX Control", Int) = 0
    • A simple instanced int toggle property that can be used to enable/disable DMX functionality at runtime. This toggle can be controlled by the VRSL DMX Udon Script.
  • [NoScaleOffset] _DMXGridStrobeTimer("DMX Grid Strobe Texture (To Control Strobing)", 2D) = "white" {}
    • The render texture property that enables the strobing functionality of VRSL DMX. If you want to enable the strobing function, this texture is required. You can find them in the same render texture folder as the standard DMX render textures and they have the prefix DMXRTViewer-StrobeTimings-.
  • [Toggle] _NineUniverseMode ("Extended Universe Mode", Int) = 0
    • An instanced toggle for nine/extended universe mode. This toggle is required for your shader to be used in extended universe mode. This toggle can be controlled by the VRSL Control Panel.
  • [Toggle] _EnableVerticalMode ("Enable Vertical Mode", Int) = 0
    • An instanced toggle for vertical mode. This toggle is required for your shader to be used in vertical mode. This toggle can be controlled by the VRSL Control Panel.
  • [Toggle] _EnableCompatibilityMode ("Enable Compatibility Mode", Int) = 0
    • An instanced toggle for legacy mode. This toggle is required for your shader to be used in legacy mode. This toggle can be controlled by the VRSL Control Panel.
  • [Toggle] _EnableStrobe ("Enable Strobe", Int) = 0
    • An instanced toggle for strobe functionality. Use this property if you want to have an instanced toggle for the strobing feature. This toggle can be controlled by the VRSL DMX Udon Script.
  • [HDR] _Emission ("Base DMX Emission Color", Color) = (1,1,1,1)
    • An instanced base emission color. Multiple your DMX color output by this to change the shader's base starting color. This color can be controlled by the VRSL DMX Udon Script.
  • _GlobalIntensity ("Global Intensity", Range(0,1)) = 1
    • An instanced 0-1 float value intended to control the base intensity of your DMX color output. This value can be controlled by the VRSL DMX Udon Script.
  • _FinalIntensity ("Final Intensity", Range(0,1)) = 1
    • An instanced 0-1 float value intended to control the base intensity of your DMX color output. This value can be controlled by the VRSL DMX Udon Script.

The DMX Functions