Aug
4
2016

Shader error: cannot map expression to vertex shader instruction

Had a strange looking error today:

Shader error in 'Custom/WhatAFineShader': cannot map expression to vertex shader instruction set at line 60 (on d3d9)

Turns out it was just that the function which was called inside vertex shader, was below the vertex shader,
so just moved it above the v2f vert (appdata v) and it works..

*Actually it was more complicated:
This one gives error: (maybe because noise is reserved word)

v2f vert (appdata v)
{
v2f o;
float var = noise(float2(0,0));
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex+var);
return o;
}

float noise(float2 xy)
{
return 0;
}

This one doesn’t

float noise(float2 xy)
{
return 0;
}

v2f vert (appdata v)
{
v2f o;
float var = noise(float2(0,0));
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex+var);
return o;
}

Leave a comment

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.