A worked example, rendered from real sample data. Sign in to run the tool on your own input.
mainColor:vec4 = (1,0.42,0.21,1)
scrollSpeed:float = 0.5 [0,4] "Texture scroll rate"
noiseTex:sampler2D
worldMatrix:mat4
resolution:vec2
intensity:float = 1 [0,8]Properties
{
_MainColor ("Main Color", Color) = (1, 0.42, 0.21, 1)
_ScrollSpeed ("Texture scroll rate", Range(0, 4)) = 0.5
_NoiseTex ("Noise Tex", 2D) = "white" {}
_Resolution ("Resolution", Vector) = (0, 0, 0, 0)
_Intensity ("Intensity", Range(0, 8)) = 1
}
CBUFFER_START(UnityPerMaterial)
float4 _MainColor;
float _ScrollSpeed;
float4x4 _WorldMatrix;
float2 _Resolution;
float _Intensity;
CBUFFER_END
TEXTURE2D(_NoiseTex);
SAMPLER(sampler_NoiseTex);
static readonly MaterialPropertyBlock Block = new MaterialPropertyBlock();
static readonly int MainColorId = Shader.PropertyToID("_MainColor");
static readonly int ScrollSpeedId = Shader.PropertyToID("_ScrollSpeed");
static readonly int NoiseTexId = Shader.PropertyToID("_NoiseTex");
static readonly int WorldMatrixId = Shader.PropertyToID("_WorldMatrix");
static readonly int ResolutionId = Shader.PropertyToID("_Resolution");
static readonly int IntensityId = Shader.PropertyToID("_Intensity");
Block.SetColor(MainColorId, mainColor);
Block.SetFloat(ScrollSpeedId, scrollSpeed);
Block.SetTexture(NoiseTexId, noiseTex);
Block.SetMatrix(WorldMatrixId, worldMatrix);
Block.SetVector(ResolutionId, resolution);
Block.SetFloat(IntensityId, intensity);
renderer.SetPropertyBlock(Block);
std140 uniform block layout — 112 bytes (16 padding)
name type offset size align pad
mainColor vec4 0 16 16 0
scrollSpeed float 16 4 4 0
noiseTex sampler2D — — — — (texture, bound separately)
worldMatrix mat4 32 64
…
Generate GLSL/HLSL uniform declarations from parameter descriptions. Part of the DevTools Surf developer suite. Browse more tools in the Game Dev collection.