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 bpears · Jan 04, 2014 at 06:27 AM · errorshadermaterialwiki

Vertex Fragment Shaders are BROKEN?

Hello, I am trying this shader below from http://en.wikibooks.org/wiki/Cg_Programming/Unity/Billboards

and I keep getting error:

Material doesn't have a texture property '_MainTex'.

Along with these errors:

 Unsupported: Cg  shader for billboards
 Unsupported: Cg  shader for billboards
  done. [Time: 84.483981 ms]
 Unsupported: Cg  shader for billboards
 Shader error in 'Cg  shader for billboards': FindCgParams failed (compiling for flash) at line 7
  
 (Filename: wikibillboard Line: 7)
 
 Shader error in 'Cg  shader for billboards': Vertex program 'vert': unknown input channel 'tex' at line 7
  
 (Filename: wikibillboard Line: 7)
 
 Shader error in 'Cg  shader for billboards': Shader program had errors at line 8
  
 (Filename: wikibillboard Line: 8)
 




Anyone see any problems with this shader? I can't get it working. I'm trying to learn how it works, but hard when doesn't work from the start! :(

 Shader "Cg  shader for billboards" {
    Properties {
       _MainTex ("Texture Image", 2D) = "white" {}
    }
    SubShader {
       Pass {   
          CGPROGRAM
  
          #pragma vertex vert  
          #pragma fragment frag 
  
          // User-specified uniforms            
          uniform sampler2D _MainTex;        
  
          struct vertexInput {
             float4 vertex : POSITION;
             float4 tex : TEXCOORD0;
          };
          struct vertexOutput {
             float4 pos : SV_POSITION;
             float4 tex : TEXCOORD0;
          };
  
          vertexOutput vert(vertexInput input) 
          {
             vertexOutput output;
  
             output.pos = mul(UNITY_MATRIX_P, 
               mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
               - float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
  
             output.tex = input.tex;
  
             return output;
          }
  
          float4 frag(vertexOutput input) : COLOR
          {
             return tex2D(_MainTex, float2(input.tex.xy));   
          }
  
          ENDCG
       }
    }
 }




EDIT: I tested a sort of similar shader in the docs(the one called "Chess") and get the same type of errors: http://docs.unity3d.com/Documentation/Components/SL-VertexFragmentShaderExamples.html

It appears it doesnt understand texcoord0 in the "Chess" shader, which makes me think it doesnt understand TEXCOORD0 in the wiki shader. So, why is this?...

EDIT2: Did more testing. The problem is definately having to do with texture coordinates used in a struct, or possibly vertex positions. I tried just about all the shaders on the documentation, and none with texture coordinates work. If I use the "ChessOpt" shader, which has no texture coordinate structs, it works great, but the normal Chess shader, does not. I'm starting to think this might be a problem worth bringing to UT attention.

Comment
Add comment · Show 3
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 04, 2014 at 10:55 AM 0
Share

Do you build for flash here? At least it looks like due to the error message. The flash export had tons of restrictions and Unity abandoned the flash support as you can read here. They just keep up the premium support while in the 4.x cycle and after that it's finally dead.

Try a different target platform

avatar image Bunny83 · Jan 04, 2014 at 11:20 AM 0
Share

You don't get what i'm saying. What is your selected target platform in the build settings? Unity behaves very differently depending on the target platform. $$anonymous$$ake sure you selected your desired platform. Unity usually reimports all assets on a platform change since a lot assets are treated differently on other platforms.

avatar image bpears · Jan 04, 2014 at 11:29 AM 0
Share

I understood, it is on PC standalone. I just meant to also say, I didn't try to build for flash, either.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by bpears · Jan 04, 2014 at 11:02 AM

No, I didn't build, I don't know why it says that.

However, I am finding that that wiki page with the code was edited, to include TEXCOORD0 in the vertexInput struct. So I think maybe Unity did upgrade or change something in Unity 4, and so Unity 3.5 does not support updated code or documentation to have TEXCOORD0 set up like that, for some reason. Can only use it in the Output struct(for 3.5). So need to keep an eye out and calculate the input/output by hand.

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
avatar image
0

Answer by pointcache · Jan 04, 2014 at 08:09 AM

Yes that's the thing with those wiki shaders some of them don't work because shaderlab is updating from time to time. I don't know shader lang so good to be able to fix that, but it's probably something with changed syntax.

Comment
Add comment · Show 1 · 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 bpears · Jan 04, 2014 at 08:26 AM 0
Share

I'm using Unity 3 AT$$anonymous$$, but it should be fine. I know surface shader syntax, and write those, and I understand what this shader is doing for the most part, but I don't get why it isn't compiling.

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

19 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

Related Questions

Why does this material not turn invisible? 2 Answers

Material doesn't have a texture property '_MainTex' UnityEditor.DockArea:OnGUI() 2 Answers

Errors with shaders/materials on newer iOS devices 1 Answer

Material/Shader issue 0 Answers

Material doesn't have a color property '_Color' 4 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