Hi! I wrote shader in CG, which is working on PC and MAC, but i have problem with iPhone and iPad. My shader receive some global variables and use some vertex variables. My vertex input struct is: Code (csharp): struct Input { float4 vertex : POSITION; float4 color : COLOR; float3 normal : NORMAL; float2 texcoord : TEXCOORD0; float2 texcoord1 : TEXCOORD1; }; I'm using normal, texcoords in my way, avoiding typical usage. Normals are used to set custom offset/resize of model (when its grow or disapear), texcoords to set graphics effects. Everything working without (i think) normal, because i think on iOS its clamped to -1;1 range. Someone have similar problem? Its possible iOS clamps normals? Other functionalities of shader works without part bounded up with normals. Maybe exists special flags for shader compiler? Sorry for my english. I will be glad for help.
I think it should be like the following- float4 _POSITION; float4 _COLOR; float3 _NORMAL; float2 uv_MyTexCoordName;//prefix of uv_ is UV Channel 1 float2 uv2_MyTexCoordName; //prefix of uv2_ is UV Channel 2
Hi, I've got a similar problem (and Lamont's explanation wasn't clear enough to help), and don't understand what's happening. I'm generating a mesh for a particles system, and I use normal (x component) to store the particle age in each vertex (and the y component is used to store particle luminosity.) Using this shader to see the normals Code (csharp): Shader "!Debug/Normals" { SubShader { Pass { Fog { Mode Off } CGPROGRAM #pragma vertex vert #pragma fragment frag // vertex input: position, normal struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; }; struct v2f { float4 pos : SV_POSITION; fixed4 color : COLOR; }; v2f vert (appdata v) { v2f o; o.pos = mul( UNITY_MATRIX_MVP, v.vertex ); o.color.xyz = v.normal * 0.5 + 0.5; o.color.w = 1.0; return o; } fixed4 frag (v2f i) : COLOR0 { return i.color; } ENDCG } } } young particle (smallest ones) are luminous, so they are displayed as green, and become pink (and bigger) while aging. the editor shows the expected result : while the iOS devices shows this : The normal values seems to be clamped or rounded. What am I missing ?
Yay ! Solution found here : http://forum.unity3d.com/threads/140557-How-to-stop-shader-compiler-applying-Normalize-to-normals