- Home /
Question by
Muxeu · Feb 16, 2013 at 03:28 PM ·
shadervertexvertexshader
Getting model bounds in vertex shader
Is there a way to get the bounds of the model in the vertex shader? Or just calculate max/min vertex.xyz ?
for example i want to change color of model depending on current fragment height (in model space)
uniform float max_y = 0;
v2f vert (appdata_full v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord.xy;
if(v.vertex.y > max_y) max_y = v.vertex.y;
o.height = v.vertex.y / max_y;
return o;
}
but max_y always zero. If i set height in code - all works fine.
Comment