How to create audio reactive shaders / materials

Shaders are a complex topic and require a good understanding of the math and techniques involved, so that won’t be covered here.

Writing shaders through code can be especially challenging, so when starting out it’s recommended to use a node-based tool if available.

The shaders for the example materials included with the SDK have been created using the Amplify Shader Editor (ASE), a node-based shader creation tool available on the Unity Asset Store. They also have a Tutorial series on YouTube targeted at beginners.

Any shader, whether it’s been created through code or a node-based tool, can be made to react to the audio that is playing, as long it uses one or more of the properties listed below.

To receive the audio analysis data sent by a Audio Reactive Material component in a shader, it needs to have the correct properties defined.

The Audio Reactive Material components control the following shader / material properties:

  • _BeatIntensity (“Beat Intensity”, Float): A value between 0 and 1 that fades out after a beat is detected.
  • _BeatOffset (“Beat Offset”, Float): A cumulative value which can be used to animate materials over time. Each frame (Beat Intensity * Time.deltaTime) is added.
  • _EnergyLevel (“Energy Level”, Int): The current energy level represented as an Integer. 1 (Low), 2 (Normal), 3(High)
  • _RenderTextureInfo (“RenderTextureInfo”, Vector3): A vector containing information about the Render Texture currently being rendered to (X = Width, Y = Height and Z = Aspect Ratio (Width / Height)), which can be used to control scaling in the shader. This property is ONLY set when using the Audio Reactive Material Renderer component!

All Audio Reactive Material components will check which properties are used by a material, so not all of the properties listed here need to be used in every audio reactive shader.

The 3 colors from the active Lighting Color Scheme are available in all shaders through the following Global Color properties:

  • PrimaryLightingColor
  • SecondaryLightingColor
  • TertiaryLightingColor
  • sdk_how_to_create_audio_reactive_shaders.txt
  • Last modified: 2019/10/11 19:20
  • by 123