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 temptest123 · Jan 13, 2013 at 09:51 PM · cgmatrixfragmentglslgles

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

I want to calculate screenspace normals and therefore try to performa a matrix-vector multiplication in the fragment shader. It works in the editor, but outputs pink on iOS.

this is my test fragment shader:

 half4 frag( v2f i ) : COLOR
 {
     return float4(0,1,0,0);
     //return mul(UNITY_MATRIX_MVP, float4(0,1,0,0));
 }

outputs as expected green. but when comment the first line and uncomment the second line instead, the shader fails. Xcode shows me the following output:

 Fragment Shader:
 precision mediump float;
 
 #define SHADER_API_GLES 1
 #define tex2D texture2D
 
 #define gl_ModelViewProjectionMatrix glstate_matrix_mvp
 uniform mat4 glstate_matrix_mvp;
 
 void main ()
 {
   mediump vec4 tmpvar_1;
   tmpvar_1 = (gl_ModelViewProjectionMatrix * vec4(0.00000, 1.00000, 0.00000, 0.00000));
   gl_FragData[0] = tmpvar_1;
 }
 
 Unsupported: MyShader


is this line the problem?

 #define SHADER_API_GLES 1

http://http.developer.nvidia.com/Cg/mul.html states that

 mul is supported in all profiles except the fp20, ps_1_1, ps_1_2, and ps_1_3 fragment profiles.

I'm not sure how that translates to GLES profiles, but I assume this could be the problem? how do I target GLES2 instead?

Comment
Add comment · Show 8
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 whydoidoit · Jan 13, 2013 at 09:56 PM 0
Share

You should probably be doing that multiplication in the vertex shader and then interpolating it into the fragment (at least that's what I normally do).

avatar image temptest123 · Jan 13, 2013 at 10:02 PM 0
Share

if i could move it to the vertex shader of course I would. But that's not always possible. This question is targeted at problems that explicitely require a matrix vector multiplication in the fragment shader.

avatar image whydoidoit · Jan 13, 2013 at 10:06 PM 0
Share

Have you tried:

 #pragma target 2.0 
avatar image temptest123 · Jan 13, 2013 at 10:14 PM 0
Share

yes I tried this and the result is the same, also it still results in #define SHADER_API_GLES 1. The same for #pragma target 3.0. This pragma doesn't seem to affect GLES

avatar image whydoidoit · Jan 13, 2013 at 10:17 PM 0
Share

Damn, that's annoying :S Hmmm - from threads I've read it looks like you can set GLES 2.0 - now I look I can't work out how...

Show more comments

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

9 People are following this question.

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

Related Questions

shader inverse(float4x4) function 2 Answers

'discard' keyword cg error 1 Answer

Cg Language incompatibility Desktop VS GLSL Android 0 Answers

No acceptable conversion when converting cg shader to glsl 0 Answers

Depth map from a second camera at a light position 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