Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by DaveA · Jan 27, 2011 at 07:32 AM · shadertexturemeshcoordinatesgenerate

Best way to generate texture coordinates?

I'm generating some meshes at runtime (actually reading from a file), which may or may not have texture coords. I assign the Transparent/Specular map to the objects. In some cases I get this on my console:

Shader wants texture coordinates, but the mesh doesn't have them UnityEditor.DockArea:OnGUI() Shader wants secondary texture coordinates, but the mesh doesn't have any UnityEditor.DockArea:OnGUI()

So, do I have to generate texture coordinates?, and secondary ones (???) Is there any facility for this in Unity, if not, any good resources on how to generate these? Thanks

Comment
Add comment · Show 1
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 Glurth · Feb 08, 2015 at 07:14 PM 0
Share

you only NEED to to assign UV coordinates for shaders that actually USE them. I suspect that Shaders that do not take a texture will not generate this error. I'd bet it's because there are so many different ways one can choose to map textures to a shape, that there is no default function for this (like there is for say.. RecomputeNormals) ooo... http://wiki.unity3d.com/index.php/Scripts/General... check out the section "mesh helpers"

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jan 27, 2011 at 08:58 AM

The example shown at Mesh.uv does exactly what you want. You may need to assign .uv2 too.

ps. Read more Unity Script Reference ;)

Comment
Add comment · Show 5 · 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 Bunny83 · Jan 27, 2011 at 09:06 AM 0
Share

Just to be clear on that: Doing what they did in the example will just add UVs to your mesh but they won't fit any unwrap you might have done for those meshes. As long as you don't use textures or when it's not important that they don't fit on the triangles, you'll be fine

avatar image DaveA · Jan 27, 2011 at 09:15 AM 0
Share

Ah I should have been more precise (and that script reference has been my daily bible this past year or more!). I would like to generate something of a default projection, such that any given face will have one 'tile' stretched across it (any direction, but not distorted). Or even better, if all faces had the same sized tile. Like if I'm importing a building with a brick texture, that those bricks would tile across all faces where uv's are undefined. I imagine this would entail a) getting the extents (bounds) of each face, b) (optional) deter$$anonymous$$e tile size, c) generate uv per vertex, (more..)

avatar image DaveA · Jan 27, 2011 at 09:17 AM 0
Share

probably aligning to either local or world x/z plane, or first segment on the face.

avatar image Bunny83 · Jan 27, 2011 at 03:27 PM 0
Share

hmm you talk about buildings with simple geometry? If your faces are always quads (2 triangles) you could calculate the uvs according to the position of the vertices on the face-plane, but when you have unorderd triangles it's getting difficult. As long as your building is aligned to the 3 axis (parallel to the axis) you could try what you've just mentioned. $$anonymous$$inda project the geometry onto your texture to get the uvs ;)

avatar image DaveA · Jan 29, 2011 at 07:34 PM 0
Share

Yeah, that's what I was thinking. Simple case of a unit cube aligned to world axes, trivial. Same cube, rotated, there must be a simple transform I could use to get those UV's. On a non-unit cube, I'd be scaling the UV's according to the size of the bounding square in the plane of the triangle. I was hoping there was some handy utility for this, but if it needs to be written, by golly, that's what I'll do (I actually did something similar years ago for an Unreal Editor exporter)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to texture an irregular (hexagon) shape (mesh) ? 1 Answer

How do you dynamically tile sub-portions of a plane? 1 Answer

MODEL TURNS BLACK AFTER APPLYING TEXTURE PLS HELP 3 Answers

Applying Tileable Texture to Imported Mesh 1 Answer

My mesh didn’t appear in Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges