Reputation: 73
I am writing a shader and I would like to pass a vec3 along to the input. however everything I could find is always passing either a single float a vec4, texture or number range. Is it possible to send a vanilla vec3 along to a shader in unity?
Properties
{
offset ("formula Offset", Vector) = (0, 0, 0)
}
Doesn't seem to work as I hoped. To get it to compile I have been doing this:
Properties
{
offset ("formula Offset", Vector) = (0, 0, 0, 0)
}
// offset.xyz //Extract relevant data from vector
this just doesn't feel right. Is there a better way?
Upvotes: 6
Views: 19961
Reputation: 4888
Looks like when you mark a property as Vector it has to have 4 components. Even the documentation says: "Vector properties are displayed as four number fields."
This really isn't as bad as it looks, just set the last components to zero.
Note that annoyingly the matching variable is NOT "vector", it's "float4".
Full list:
https://stackoverflow.com/a/37749687/294884
Upvotes: 5