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 124c41 · May 27, 2014 at 12:34 AM · shader

Shaders: Constant register limit exceeded - what does it mean?

Hello,

I already used Google, tried the search function and also scanned the documents provided by Nvidia, but this keeps me puzzled:

I'm working on a shader that, besides some other stuff, has a secondary texture used for detailing. The texture slot is used for a perlin noise sample, which is called three times with different texture coordinates, then summed up to create a basic fBm. It looks like this:

 float subtex = (tex2D(_SubTex, i.tex.xy * _SubTex_ST.xy + _SubTex_ST.zw ).x - .5 )*SUB_TEX_WEIGHT;
 float subtex2 = (tex2D(_SubTex, i.tex.xy * _SubTex_ST.xy * 2 + _SubTex_ST.zw * 2 ).x - .5)*SUB_TEX_WEIGHT;
 float subtex3 = (tex2D(_SubTex, i.tex.xy * _SubTex_ST.xy * 4 + _SubTex_ST.zw * 4 ).x - .5 )*SUB_TEX_WEIGHT;

but, when I sum up like this:

 subtex += subtex2*.5 + subtex3*.25;

I get an error: Constant register limit exceeded; more than 32 constant registers needed to compiled program at line 38

same is for

 subtex2 += subtex3*.5;
 subtex += subtex2*.5;

or any other variation of this kind. But when I create a new float like this:

 float subtexSum = subtex + subtex2*.5 + subtex3*.25;

there is no problem.

I don't get it. What is the problem with the first and second variant, and why is it working in the final version? Or, what operations are utilizing constant registers and what don't? Any clarification on this topic would be welcome. Thank you!

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

2 Replies

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

Answer by ilya_ca · Jul 26, 2014 at 10:13 AM

Try using #pragma glsl

Adding the above pragma in my case fixed the error.

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 124c41 · Aug 04, 2014 at 12:41 PM 0
Share

I'm still not sure why it behaves that way, but this at least fixed it. Thank you.

avatar image
1

Answer by tanoshimi · Jul 26, 2014 at 12:01 PM

To see how registers are being used, you can view the compiled shader file that Unity creates.

To fix the problem, try adding #pragma target 3.0

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 124c41 · Aug 04, 2014 at 12:42 PM 0
Share

I'm allready using target 3.0, but thank you.

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

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

Related Questions

Additional blending when using properties rather than hard-coded values for colors 0 Answers

How to render a Cube using Shaders? 0 Answers

Multipass Surface Shader (or equivalent)? 2 Answers

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

Parse error: Syntax Error in compiled shader, Unity 4.3.1 [free] 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