- Home /
The question is answered, right answer was accepted
How to set float or float4 UV in Mesh.
Hello. I'm trying to create a shader that supports an outline. My approach is to assign barycentric coordinates to each triangle of a face. These are 3 dimensional.
I know Unity's UVs support float3 or float4. Is there a way that I can pass that to the Mesh? If not, do I have to create my own Mesh-like data structure that communicates directly with the shader?
Thanks!
Answer by maxmet · Jan 05, 2018 at 12:18 PM
Ok, progress. https://docs.unity3d.com/ScriptReference/Mesh-uv.html misled me into thinking that 2D UVs were the only option with meshes.
I've found https://docs.unity3d.com/ScriptReference/Mesh.SetUVs.html now, which suggests that isn't the case! Will post here again if I have trouble using it.
Hope it helps someone who was confused by the documentation page too.
But what does your shader look like? I'm having trouble getting my shader to use float3 for the uv coords, getting a compile error "cannot implicitly convert 'const float2' to 'float3'" in the generated shader code.
Your comment is out of the scope of this question. Please ask a seperate question and include your not working code.