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 PEOWIfjpwoiqjf · Jul 05, 2012 at 04:24 PM · shaderfloatcgglsl

Sizeof float in cg shader

I'm trying to write a shader for unity using cg, and I'd like to know what accuracy my floats have, but I can't figure out how to use the sizeof command. When I attempt to use it, I get the error:

 Shader error in 'Relativity/ColorShift': GLSL vertex shader: ERROR: 0:433: 'sizeof' : Reserved word.  at line 218

218 is the line that says "CGPROGRAM".

Can anyone tell me if there's either a standard size using the arbvp1/arbfp1 profile for a float or how to use the sizeof command?

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

Answer by ScroodgeM · Jul 14, 2012 at 12:29 PM

unity3d shader perfomance

float: high precision floating point. Generally 32 bits, just like float type in regular programming languages.

msdn about float

Type float

Approximate range -3.4 × 10^38 to +3.4 × 10^38

Precision 7 digits

Comment
Add comment · Show 6 · 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 PEOWIfjpwoiqjf · Jul 16, 2012 at 08:25 PM 0
Share

I need to know exactly what precision it is using, and also why I can't use so many standard cg functions. ( defining things as double has the same error as using float).

avatar image ScroodgeM · Jul 17, 2012 at 04:35 AM 0
Share

in float structure 1 bit used for sign, 8 bits for exponent and 23 bits for significand, so it's guaranteed 7 decimal digits are stored.

which cg function can't u use? unity3d supports S$$anonymous$$3.0 and almost all functions are works ok.

would you like describe which error do you got? may be somebody here have a solution or another way to arrive you target 8)

avatar image PEOWIfjpwoiqjf · Jul 20, 2012 at 01:23 PM 0
Share

The error I get is in the original question.

avatar image ScroodgeM · Jul 20, 2012 at 04:30 PM 0
Share

you got this error in working model or while debugging?

i mean do you need 'sizeof' in running release version of shader?

avatar image PEOWIfjpwoiqjf · Aug 01, 2012 at 03:08 PM 0
Share

It's more that there's a ton of functions that are supposed to be supported and unity has specific errors for, but there seems to be no way to use them. Ideally I would be able to use sizeof in the shader.

I would like to be able to use the double data type as well which is supposed to be possible, but this also has a similar error ( simply 'double' ins$$anonymous$$d of 'sizeof')

Show more comments

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I make my own shader include file (.cginc or .glslinc)? 2 Answers

How can I get GLSL shaders to work in Unity? 0 Answers

Can a CG shader fail to work on hardware? 1 Answer

shader inverse(float4x4) function 2 Answers

Can sampler2DArray be used? 2 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