• 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
Question by Catlard · Mar 05, 2013 at 02:38 PM · shadergraphicsdrawing

Shader wants texture coordinates, but the mesh doesn't have them

Hey!

So, I'm working with a shader that I'm using with a mesh that I've generated in a script, using the graphics class, and the Graphics.DrawMesh() function. My trouble is that the shader I'm using is continually spitting out this message:

"Shader wants texture coordinates, but the mesh doesn't have them".

The shader doesn't seem to be malfunctioning -- I'm just using it to display a flat color. But What I'd like is to have the shader stop crowding my console with this message. The shader code is below -- what do I have to change to stop the shader from "wanting texture coordinates"? It doesn't seem to need them...let me know if there's something else you need in order to figure out the problem.

 Shader "Sprite/Vertex Colored" {
 Properties {
     _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
 }
 
 Category {
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
     ZWrite Off
     Blend SrcAlpha OneMinusSrcAlpha 
     SubShader {
         Material {
             Diffuse [_Color]
         }
         Pass {
             ColorMaterial AmbientAndDiffuse
             Lighting Off
             Cull Off
         SetTexture [_MainTex] {
             Combine texture * primary, texture * primary
         }
         SetTexture [_MainTex] {
             constantColor [_Color]
             Combine previous * constant DOUBLE, previous * constant
         }  
         }
     } 
 }
 }
Comment

People who like this

0 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 Graham-Dunnett ♦♦ · Mar 10, 2013 at 03:46 PM 0
Share

So, when you create the mesh, create some texture coordinates. Your shader uses a texture, so Unity is telling you the mesh should provide texture coords.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by nsxdavid · Mar 10, 2013 at 05:02 PM

Your shader is not just displaying a flat color, it's trying to use a texture (i.e. _MainTex). So the model must contain texture coordinates, which are added in the 3D application that authored the model, or some external app, via UV Mapping.

Comment
Catlard

People who like this

1 Show 2 · 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 Fattie · Mar 10, 2013 at 05:05 PM 0
Share

indeed. TBC, if you are building the mesh programatically you must of course create and set the UVs.

http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html

http://docs.unity3d.com/Documentation/ScriptReference/Mesh-uv.html

the arcana of this is endlessly discussed on here!

avatar image Catlard · Mar 13, 2013 at 08:31 PM 0
Share

Hey guys! Thanks heaps. David, my old friend, you're right -- I just forgot. I am using a single white pixel as my texture to get a flat color effect. As far as creating and setting UVs, I actually would prefer not to do this, if it's going to save me memory. Because the drawing class I'm using this for needs to be maximally speedy. How would you recommend removing the need for UVs from this shader, then, Fattie? Is that even possible?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

14 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

Related Questions

Shader wants texture coordinates... 1 Answer

Color dithering/quantizing 1 Answer

How to make vector monitor graphics in Unity? 3 Answers

Screen Space warping 1 Answer

Can I read/write to the Stencil buffer in a pixel shader? 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