Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 LyveIG · Feb 20, 2015 at 01:49 AM · shadercgglslgles

Cg Language incompatibility Desktop VS GLSL Android

Hi there,

today I came across a bug in one of my shaders. The following line caused the problem, but only on Android Mobile device:

 float3 side = step(3.0f, foo.xyz) * 3.0f;

The fix for this was the following:

 float3 side = step(float3(3,3,3), foo.xyz) * float3(3,3,3);

In the Unity3D Editor, even when GLES 2.0 emulation is enabled, the result is what I've expected. Each component of "side" contains 0 or 3 for each component of "foo" that is >= 3.

On mobile, each component of side contains 0 or 3 if foo.x is >= 3.

I do not get any "implicit truncation of vector type" warning in the log and also no warnings at all for any shader language in the shader properties.

I have searched the language specifications and found out that GLSL isn't capable to convert a single component float value to a vector type implicitly, or at least it isn't documented or I didn't find it.

But Cg is, which would mean that the generated code for HLSL/GLSL is wrong, but why only on mobile? According to the Cg spec, the first code portion should be okay, the first parameter of step() should be widened to be a float3 and the last multiplication should become a float3, too.

So who is wrong here? Did I misunderstand something, is there a bug in Cg or in Unity3D? Should I file a bug report with an example project?

Best,

Nils

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Shader problem with alpha blend and zwrite iOS 1 Answer

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

Sizeof float in cg shader 1 Answer

shaderlab: Matrix-vector multiplication in fragment shader on iOS not working? 0 Answers

No acceptable conversion when converting cg shader to glsl 0 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