• 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 undead-steve · Sep 23, 2013 at 04:50 PM · shaderosxdeformation

Vertex texture fetch on OSX / IOS

I've got a vertex animation shader which runs fine under force GL mode on my PC:

 Shader "FX/VertexAnimationAlpha" {
     Properties {
         _MainTex("Texture (RGB)", 2D) = "white" {} 
         _AnimTex ("Vertex Animation (RGBA)", 2D) = "white" {}
         _Tint("Color", Color) = (1,1,1,1)
         _Softness("Fresnel", Float) = 0
         _TexW("texture Width", Float) = 512
         _TexH("Texture Height", Float) = 32
         _Scale("Scale", Float) = 1
         _KeyTime("Key Time", Float) = 1
         
     }
 SubShader {
 
         Pass {   
             CGPROGRAM
             #pragma target 3.0
             #pragma glsl
             #include "UnityCG.cginc"
             #pragma vertex vert  
             #pragma fragment frag 
         
         
             uniform sampler2D _MainTex;
             uniform sampler2D _AnimTex;       
             uniform fixed _KeyTime;
             uniform float _TexW;
             uniform float _TexH;
             uniform float _Scale;
             uniform fixed _Softness;
             half4 _Tint;
 
             
         
             struct vertexInput {
                 float4 vertex     :     POSITION;
                 float4 tex         :     TEXCOORD0;
                 float4 tex2     :     TEXCOORD1;
                 float4 normal    :    NORMAL;
             };
     
             struct vertexOutput {
                 float4 pos         :     SV_POSITION;
                 half4 vertColor    : COLOR;
                 half4 uv_map     : TEXCOORD0;
             };
             
             vertexOutput vert(vertexInput input) 
             {                  
                 vertexOutput output;                
                 half4 animLine = input.tex2;
                 animLine.y =   (_KeyTime / _TexH) + 1 / (2 * _TexH);
                 float4 raw_offset = tex2Dlod(_AnimTex, half4(animLine.xy,0, .5));
                 float4 vtx_offset = (2 * raw_offset) - float4(1);
                 vtx_offset.xyz *= _Scale * raw_offset.w;
                 float4 vtx = input.vertex + vtx_offset;
                 
                 half3 osvd = normalize(ObjSpaceViewDir (input.vertex));
                 half3 osn = normalize(input.normal.xyz);
                 if (_Softness < 0)
                     {                
                     output.vertColor =  pow(1 - dot(osvd, osn), -1 * _Softness);
                     }
                 else
                     {
                     output.vertColor =  pow(dot(osvd, osn),  _Softness);
                     }
                 output.uv_map =  mul(UNITY_MATRIX_TEXTURE0, input.tex);
                 vtx.w = input.vertex.w;
                 output.pos =  mul(UNITY_MATRIX_MVP, vtx);
                 return output;
             } 
             
             half4 frag(vertexOutput input) : COLOR
             {   
                 return _Tint * input.vertColor * tex2D(_MainTex, input.uv_map.xy);
             }
         
         ENDCG
         }
             
     } 
     FallBack "Diffuse"
 }
 

However it's behaving wierdly when testing OSX. On OSX the meshs still deforms - but I it appears to be deforming differently. It's hard to tell exactly because the OSX version looks quite odd: it seems as if the shader is drawing black polys (like a clear pass but in the main render) which are z-fighting with the the main mesh.

Any hints on what might be going wrong here? It's puzzling to say the least, and there's not much here on the site except for discussions of vtf and iOS5 - I was hoping to get this working for the re-enabled vtf in ios7 but I need to get past this OSX business first.

Comment
Add comment · Show 1
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 thebarryman · Oct 08, 2014 at 06:16 PM 0
Share
  • to this. $$anonymous$$y vertex animation shader works on PC and iPad, but not two different $$anonymous$$ac computers I've tested on...

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

16 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

Related Questions

Sprite Deform Diffuse Shader 0 Answers

Snow deformation 1 Answer

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

Performance on mobile: Shader Vs Mesh deformation 1 Answer

Deformation shader 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