• 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 elkree · Sep 06, 2012 at 11:08 AM · androidvertex shader

vertex shader android problem

Hi, i'm developing a net ripple using vertex shader

it works under windows and the editor but at android device (galaxy nexus) using opengl es 2.0 it calls at fallback

the cg program is really simple, it uses the sinc function and an attenuation like 1/t^2 where t >= 1

any one know if there is any incompatibility?

thanks

here the code:

 CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
 
         #include "UnityCG.cginc"
 
         float4 _Color;
         sampler2D _MainTex;
 
         struct input {
             float4 vertex : POSITION;
             float4 texcoord : TEXCOORD0;
             float4 color : COLOR;
         };
         
         struct v2f {
             float4  pos : SV_POSITION;
             float2  uv : TEXCOORD0;
         };
 
         float4 _MainTex_ST;
         float4 planeDimensions;
         float  time;
         float4 center;
         float  atenuation;
         float use;

         float3 CalcTranslation(float3 currentPos, float timeStamp, float3 center, float atenuation, float attenuationColor){
             float3 result = (0,0,0);
             float r = 0;
             float x = center[0]-currentPos[0];
             float y = center[1]-currentPos[1];
             float z = center[2]-currentPos[2];
             int index = 2;
             if(planeDimensions[0]==1)
                 r = r+x*x;
             else
                 index = 0;
             if(planeDimensions[1]==1)
                 r = r+y*y;
             else
                 index = 1;
             if(planeDimensions[2]==1)
                 r = r+z*z;
             else
                 index = 2;
                 
             r = sqrt(r);
             if(r <= 1) r = 1;
             float timeAttenuation = 1;
             if(timeStamp > 1)
                 timeAttenuation = 1/timeStamp;
             timeAttenuation = timeAttenuation*timeAttenuation;
                 
             if(index == 0)
                 result[0] = - timeAttenuation * attenuationColor * atenuation * sin(19*(r + timeStamp))/r;
             else if(index == 1)
                 result[1] = - timeAttenuation * attenuationColor * atenuation * sin(19*(r + timeStamp))/r;
             else
                 result[2] = - timeAttenuation * attenuationColor * atenuation * sin(19*(r + timeStamp))/r;
     
             return result;
         }
         
         v2f vert (input v)
         {
 
             v2f o;
             float3 finalPos, translation, center3;
             finalPos[0] = v.vertex[0];
             finalPos[1] = v.vertex[1];
             finalPos[2] = v.vertex[2];
             if(use>0.5f){
                 center3[0] = center[0];
                 center3[1] = center[1];
                 center3[2] = center[2];
                 
                 float mean = (v.color[0]+v.color[1]+v.color[2])/3;
                 
                 translation = CalcTranslation(finalPos, time, center3, atenuation, mean);
                 finalPos = finalPos+translation;
             }
             o.pos = mul(UNITY_MATRIX_MVP, float4(finalPos,v.vertex[3]));
             
             o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
             return o;
         }
         half4 frag (v2f i) : COLOR
         {
             half4 texcol = tex2D (_MainTex, i.uv);
             return texcol * _Color;
         }
     ENDCG
Comment
Add comment · Show 2
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 elkree · Sep 07, 2012 at 07:37 AM 0
Share

my own solution is to draw the nets using opengl calls and move them when i want... the cost is not too hight but is so ugly to do at cpu and not at gpu...

avatar image pfialho · Sep 14, 2012 at 09:38 PM 0
Share

having the same problem. $$anonymous$$e is with a slightly modified version of the unify's skin shader (for better performance), which looks as expected in cheaper androids, but on the galaxy nexus looks darker, ie directional light is represented with less intensity.

i've only seen this in galaxy nexus, maybe someone should fill a bug report..

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.

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

8 People are following this question.

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

Related Questions

conditional vertex texture fetch / texture lookups in vertex shader 0 Answers

Touch to move 3 Answers

GUI Button doesn't Work on Android 2 Answers

Vertex Color: Trying to export 3D Max model with Vertex Colors into Unity. 0 Answers

Android Button Screen 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