Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Madrayken · Aug 01, 2013 at 07:24 PM · shadergraphicsdrawingtexturecoord

Shader wants texture coordinates...

Hi folks,

I'm trying to create a shader that does a couple of things:

1) Uses vertex lights

2) Uses the vertex colours

3) Modifies these by another colour/vector (don't mind which)

4) DOES NOT USE TEXTURES

As such, I've managed to fumble my way through the various guides and things and come up with:

 Shader "Custom/MobileVertexLitVertexColouredAndBaseColoured" 
 {
     Properties 
     {
         _Color ("Main Color", Color) = (1,1,1,1)
     }
     
     SubShader 
     {
         Pass 
         {
             Material 
             {
             }
             ColorMaterial AmbientAndDiffuse
             Lighting On
             SetTexture [_MainColor] 
             {
                 Combine primary, primary
             }
             
             SetTexture [_MainColor] 
             {
                 constantColor [_Color]
                 Combine previous * constant DOUBLE, previous * constant
             } 
         }
     }
 }


Now, of course, I've got two lovely 'SetTexture' commands in there that I don't really want - I don't want textures! But, of course, those segments of the shader are also what allows that 'constantColor' to be used.

The shader works, but - understandably - complains about the fact that I have no UVs. Is there an alternative way to do what I require in some other (presumably poorly documented) pass, that doesn't require a UV set? I'd rather not kluge my way around the issue by creating a texture and a bunch of useless UVs.

Many thanks for any hints. I appreciate your time, and hope I've specified the question well and clearly enough to be useful.

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 Madrayken · Aug 02, 2013 at 10:08 PM 0
Share

Thanks for that. I'm trying to stay well away from all pixel-shaders for mobile performance reasons.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FuzzyLogic · Aug 02, 2013 at 06:32 PM

You can do it with a surface shader.

Tested code...

 Shader "Custom/MobileVertexLitVertexColouredAndBaseColoured" {
     Properties {
         _Color ("Main Color", Color) = (1,1,1,1)
     }
 
     SubShader {
         Tags {
             "RenderType" = "Opaque"
         }
        
         CGPROGRAM
         // the noforwardadd option makes it use vertex lights only + 1 directional per-pixel light
         #pragma surface surf BlinnPhong noforwardadd
        
         float4 _Color;
  
         struct Input {
             float4 color: Color; // Vertex color
         };
  
         void surf (Input IN, inout SurfaceOutput o) {
             o.Albedo = _Color.rgb + IN.color.rgb; // additive blend
         }
         ENDCG
     }
 //    FallBack "Diffuse" // disable during development
 }


The above shader does use one per-pixel light but if you really don't want it, you will need to do custom lighting.

Here's some surface shader examples from the unity reference.

Surface Shader Examples

Comment
Add comment · 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

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

15 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

Related Questions

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

Black Texture on Initial Load 1 Answer

Fake PS1 "jittery movement" effect in Unity? 1 Answer

Greyscale shading 0 Answers

Pixel snap for material made with Unlit Shader Graph? 1 Answer


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