I've been making 2D games in Unity for a long time, well before the sprite tools Unity added in 4.something, and for years I've been using this shader to handle 2D characters, but I'm finding it doesn't work properly with Unity's built-in sprites. Code (csharp): Shader "My Shaders/AlphaSelfIllum" { Properties { _Color ("Tint", Color) = (0.25,0.25,0.25,1) _MainTex ("Color (RGB) Alpha (A)", 2D) = "white" {} } Category { Tags {"Queue"="Transparent"} ZWrite Off Blend SrcAlpha OneMinusSrcAlpha SubShader { Pass { GLSLPROGRAM varying mediump vec2 uv; varying mediump vec4 color; #ifdef VERTEX uniform mediump vec4 _Color; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; uv = gl_MultiTexCoord0.xy; color = vec4(_Color.rgb * 4., _Color.a); } #endif #ifdef FRAGMENT uniform lowp sampler2D _MainTex; void main() { gl_FragColor = color * texture2D(_MainTex, uv); } #endif ENDGLSL } } SubShader { Pass { SetTexture [_MainTex] { constantColor [_Color] combine texture * constant quad, texture * constant } } } } } Basically it's a self-illuminated alpha shader, with a key twist - the tint color is "quadded" for lack of a better term so that the texture looks normal when the tint is set to (0.25,0.25,0.25) instead of 1.0. Why? So I can brighten the texture above normal, which is super useful for flashing players/enemies sprites to indicate something (taking damage, being selected, etc). So on to my question - anyone have a guess as to why this shader doesn't work with sprite renderers on an iOS device? I'm evaluating whether to try using Unity's built-in sprite features for a future 2D game, and discovered while testing that my trusty old shader looks/functions as expected in the editor when applied to a sprite, but when built to an iOS device it comes out solid white instead.
Where in this shader is the sprite assigned from the atlas? I can't see how it would work without it.
Probably easier just to take the latest sprite shader sources and add tint code there: http://unity3d.com/unity/download/archive
Ah, didn't know where to find the source for the built in shaders, thanks for that. Regarding not assigning from the atlas - that doesn't seem to be the issue, as my old shader doesn't behave correctly regardless of whether a unity-made atlas is used or not. Still a bit of a mystery why it works in the editor but not on the device. At any rate, simply modifying the default sprite shader worked just fine.