• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Oct 21, 2018 at 10:17 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by maxmet · Jan 05, 2018 at 12:13 PM · shadermeshinputuvvertex

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!

Comment
Comments Locked
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0
Best Answer

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.

Comment
Comments Locked · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image maxmet · Jan 05, 2018 at 12:33 PM 0
Share

It worked fine.

avatar image BassaForte · Oct 21, 2018 at 08:47 PM 0
Share

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.

avatar image Bunny83 BassaForte · Oct 21, 2018 at 10:16 PM 0
Share

Your comment is out of the scope of this question. Please ask a seperate question and include your not working code.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

133 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity shader vertex displace doesn't work 0 Answers

How does appdata_base work? 0 Answers

Any way to set the ZW part of a dynamic mesh's UVs? 0 Answers

Mesh breaks apart when using vertex displacement with shadergraph. 1 Answer

Do i need recalculate uv coordinate after modifying mesh vertices 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges