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
1
Question by Slin · Jun 27, 2010 at 11:08 AM · errorshadertexturematerial

Error: Material doesnt have texture property.

I am trying to change my materials textures and am getting the following error (and a similar one for _LightMap):

Material doesn't have a texture property '_MainTex4'
UnityEngine.Material:SetTexture(String, Texture)
UnityEngine.Material:SetTexture(String, Texture)
tile_container:Change_Tile() (at Assets\Scripts\tile_container.js:94)
tile_container:tile_container$Change_Tile$(Object, Object[])
System.MulticastDelegate:invoke_object_object_object[](Object, Object[])
Boo.Lang.Runtime.RuntimeServices:Dispatch(Object, String, Type[], Object[], DispatcherFactory)
Boo.Lang.Runtime.RuntimeServices:Dispatch(Object, String, Object[], DispatcherFactory)
Boo.Lang.Runtime.RuntimeServices:Invoke(Object, String, Object[])
UnityScript.Lang.UnityRuntimeServices:Invoke(Object, String, Object[], Type)
SaveLoad:Load_Map() (at Assets\Scripts\SaveLoad.js:151)

I just cant figure out why. The shader looks like this:

Shader "World Multi Texturing" { Properties { _MainTex0 ("Base 0 (RGB)", 2D) = "white" {} _MainTex1 ("Base 1 (RGB)", 2D) = "white" {} _MainTex2 ("Base 2 (RGB)", 2D) = "white" {} _MainTex3 ("Base 3 (RGB)", 2D) = "white" {} _MainTex4 ("Base 4 (RGB)", 2D) = "white" {}

     _BlendTex ("Blend (RGB)", 2D) = "black" {}

     _LightMap ("Light (RGB)", 2D) = "white" {}
 }

 SubShader
 {
     Pass
     {
         Lighting On

         CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag

             #include "UnityCG.cginc"

             uniform sampler2D _MainTex0;
             uniform sampler2D _MainTex1;
             uniform sampler2D _MainTex2;
             uniform sampler2D _MainTex3;
             uniform sampler2D _MainTex4;
             uniform sampler2D _BlendTex;
             uniform sampler2D _LightMap;

             struct v2f
             {
                 float4 position : POSITION;
                 float3 normal : COLOR;
                 float2 texblend : TEXCOORD0;
                 float2 texcoord : TEXCOORD1;
             }; 

             v2f vert(appdata_base In)
             {
                 v2f Out;

                 Out.position = mul(glstate.matrix.mvp, In.vertex);
                 Out.normal = mul(_Object2World, float4(In.normal, 0.0f)).xyz;

                 Out.texblend = (mul(_Object2World, In.vertex).xz+4.0f)/256.0f;
                 Out.texcoord = In.texcoord.xy;

                 return Out;
             }

             half4 frag(v2f In) : COLOR
             {
                 float4 color0 = tex2D(_MainTex0, In.texcoord);
                 float4 color1 = tex2D(_MainTex1, In.texcoord);
                 float4 color2 = tex2D(_MainTex2, In.texcoord);
                 float4 color3 = tex2D(_MainTex3, In.texcoord);
                 float4 color4 = tex2D(_MainTex4, In.texcoord);

                 float4 blend = tex2D(_BlendTex, In.texblend);
                 float4 light = tex2D(_LightMap, In.texblend);

                 float4 color = lerp(color0, color1, blend.r);
                 color = lerp(color, color2, blend.g);
                 color = lerp(color, color3, blend.b);
                 color = lerp(color, color4, blend.a);

                 In.normal = normalize(In.normal);
                 float diffuse = 0.5;
                 diffuse += saturate(dot(normalize(float3(1.0f, 1.0f, 1.0f)), In.normal));

                 return half4(color.rgb*light.rgb*diffuse, 1.0);
             }
         ENDCG
     }
 }

 FallBack "Diffuse"

}

There are no textures assigned, before I do so within the script like this:

tile_script.instance.renderer.materials[0].SetTexture("_MainTex4", tiletex4);

The textures are created like this:

var imagebytes : byte[] = File.ReadAllBytes(filepath);
tiletex4.LoadImage(imagebytes);

Is there a maximum texture limit other than the one of my hardware? Please help me to fix this if you can :) Thanks.

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

· Add your reply
  • Sort: 
avatar image
1

Answer by JonManatee · Jul 02, 2010 at 06:49 AM

Limits are also imposed by shader profiles, although I don't know if that specifically is your problem, it does answer your last question. See: http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter01.html

See specifically the statement in the section about profiles that:

For example, a given fragment profile may limit you to no more than four texture accesses per fragment.

and also see:

http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter10.html

for in-depth info on profiles

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 Slin · Jul 07, 2010 at 12:40 PM 0
Share

Thanks for your answer, I will try to compile for shadermodel 3.0 ins$$anonymous$$d, as that would mean a higher profile with an endless number of texture fetches, right? I just wonder why the script and not the shader is complaining. And why it works fine, while still throwing those errors.

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

No one has followed this question yet.

Related Questions

Multiple materials on same object 0 Answers

Texture2D to Texture3D 2 Answers

Tracing in Unity3D 2 Answers

What is wrong with my shader? 1 Answer

How can I prevent lights overlapping in intensity? 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