• 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 Kajos · May 01, 2013 at 05:20 PM · shader

Shader not finding properties

I have the following shader, see below.

For some reason the Unity Editor gives error messages that it can't find any of the properties. How can I fix these errors? I tried restarting my computer as suggested for these errors in other posts, to no avail.

Example:

Material doesn't have a texture property '_BumpMap'

UnityEditor.DockArea:OnGUI() However sometimes I get the following error, I take it is caused by the for loop.

Shader error in 'Voxels/VoxelizeShader': Program 'frag', Temporary register limit of 32 exceeded; 69 registers needed to compile program at line 13

 Shader "Voxels/VoxelizeShader" {
     Properties {
         _MainTex("Base (RGB)", 2D) = "white" {}
         _BumpMap("Bumpmap", 2D) = "bump" {}
         _StepSize("Raycast Step Size", Float) = 0.1
         _VoxelTex("Empty VoxelTex", 3D) = "white" {}
     }
     SubShader {
         Pass {
             Cull Back
             Lighting On
             
             CGPROGRAM
             #pragma exclude_renderers d3d11 xbox360 gles
             #pragma vertex vert
             #pragma fragment frag
             #pragma target 3.0
             #include "UnityCG.cginc"
             
             struct a2v
             {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float4 texcoord : TEXCOORD0;
                 float4 tangent : TANGENT;
     
             }; 
                 
             struct v2f { 
                 float4 pos : SV_POSITION;
                 float2 uv : TEXCOORD0;
                 float3 vertex;
                 float3 normal;
                 float3 lightDir;
             };
             
             uniform sampler3D _VoxelTex;
             uniform sampler2D _MainTex;
             uniform float4 _MainTex_ST;
             uniform sampler2D _BumpMap;
             uniform float4 _BumpMap_ST;
             uniform uniform float4 _LightColor0; 
             
             uniform float _VoxelRaycasting;
             uniform float _StepSize;
             
              
             v2f vert( a2v v ) {
                 v2f o;
                 o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                 o.vertex = v.vertex;
                 o.normal = v.normal;
                 TANGENT_SPACE_ROTATION;
                 o.uv = v.texcoord;
                 
                 // lighting from single directional light + ambient
                 o.lightDir = mul(rotation, ObjSpaceLightDir(v.vertex));
                 return o;
             }
             
             float4 getVoxel(float3 vposition) {
                 float4 color = tex3D(_VoxelTex, vposition);
                 return color;
             }
             
             bool showVoxels(float3 vposition) {
                 if (getVoxel(vposition).a > 0.5) 
                     return true;
                 else
                     return false;
             }
             
             void frag(v2f IN, out float4 finalColor : COLOR) {
                 if (_VoxelRaycasting > 0.5 && showVoxels(IN.vertex)) {
                 
                     finalColor = tex2D(_MainTex, TRANSFORM_TEX(IN.uv.xy, _MainTex));  
                     float3 n =  UnpackNormal(tex2D (_BumpMap, TRANSFORM_TEX (IN.uv.xy, _BumpMap))); 
              
                     float3 lightColor = UNITY_LIGHTMODEL_AMBIENT.xyz;
              
                     float lengthSq = dot(IN.lightDir, IN.lightDir);
                     float atten = 1.0 / (1.0 + lengthSq * unity_LightAtten[0].z);
                     
                     float diff = saturate (dot (n, normalize(IN.lightDir)));   
                     lightColor += _LightColor0.rgb * (diff * atten);
                     finalColor.rgb = lightColor * finalColor.rgb * 2;
                     
                 } else {
 //                
 //                    float random = fract(sin(gl_FragCoord.x * 12.9898 + gl_FragCoord.y * 78.233) * 43758.5453);
                     float actStepSize = _StepSize;
                     
                     float4 rayStart = mul(_World2Object, float4(_WorldSpaceCameraPos, 1));
                     
                     float3 dir = IN.vertex - rayStart;
                     float startLength = length(dir);
                     
                     float3 deltaDir = normalize(dir) * actStepSize;
                     float deltaDirLen = length(deltaDir);
                     
                     float3 voxelCoord = rayStart;
                     float4 colorAcum;
                     float intensity;
                     float lengthAcum = 0.0;
                  
                     bool solved = false;
                     
                     int loopSize = 160;
                     for(int i = 0; i < loopSize; i++) {
                         colorAcum = getVoxel(voxelCoord);
                         if (colorAcum.a < 0.5) {
                             solved = true;
                             break;
                         }
                         voxelCoord += deltaDir;
                         lengthAcum += deltaDirLen;
                     }
                     if (solved) {
                         finalColor = colorAcum;
                     } else {
                         discard;
                     }
                 } 
             }
             
             ENDCG
             
             SetTexture [_MainTex] {
                 Combine texture * primary DOUBLE, texture * primary
             }
             SetTexture [_Bumpmap]
             SetTexture [_VoxelTex]
             
         }
     }
             
     Fallback "VertexLit"
 }
 
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
0
Best Answer

Answer by Jessy · May 01, 2013 at 05:30 PM

The "Material doesn't have a texture property" spams are useless lies and have been reported as bugs years ago. They just appear whenever you have any other errors.

Optimize your code, or you'll have to use #pragma profileoption, and plan on not being able to count on other people running your app.

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.

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

13 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

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

Custom shader behaves differently on WebGL deployment (correct) and editor view (incorrect) 1 Answer

shader for light replacement blending, instead of additive blending? 0 Answers

Only render stencil mask when behind maskable object 0 Answers

Raycasting in script suddenly stopped working 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