- Home /
Unity 3.1 shader upgrade issue with Blend AppSrcAdd AppDstAdd
I'm currently migrating a project from Unity iPhone 1.7 to Unity 3.1 and I'm having some issues with the shader below.
Shader "iPhone/Reflection/SphereMapped" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.7
_MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}
_Sphere ("Reflection SphereMap", 2D) = "white" { TexGen SphereMap }
}
SubShader {
Pass {
Blend AppSrcAdd AppDstAdd
Tags {"Queue"="Geometry" "LightMode"="Always"}
Material {
Diffuse[_Color]
Ambient(1,1,1,1)
Shininess[_Shininess]
Specular[_SpecColor]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
combine texture * primary QUAD, texture * primary
}
SetTexture [_Sphere] {
combine texture * primary
}
}
}
Fallback off
}
Every time I import the shader into Unity 3.1, Unity comments out the Blend command with this message.
/ Upgrade NOTE: commented out, possibly part of old style per-pixel lighting: Blend AppSrcAdd AppDstAdd /
This is causing the shader to basically ignore the first SetTexture command and is only displaying the result of the second SetTexture command.
Does anyone have any ideas on why this would be happening, or if this is just a bug I've stumbled across?
Answer by Jessy · Nov 23, 2010 at 03:47 AM
Blend AppSrcAdd AppDstAdd has been deprecated for Unity 3.0, but it's useless in your shader anyway. That blend mode was only used with multiple passes, so if it ever did anything, then that was a bug. All your shader does is multiply the spheremap by light, as you describe. Also, SeparateSpecular is useless on iOS. I'm making you an updated shader presently.
Edit: Here's a shader. It's kind of a rough draft, in that I didn't really know where you wanted Double, Quad, etc., or how you wanted to influence the reflections with texture alpha. You should be able to modify it with your own multipliers as you like.
Shader "iPhone/Reflection/SphereMapped" {
Properties { _Color ("Main Color", Color) = (1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1) _Shininess ("Shininess", Range (0.03, 1)) = 0.7 _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} _Sphere ("Reflection SphereMap", 2D) = "white" {TexGen SphereMap} }
Category { Lighting On Material { Diffuse[_Color] Ambient(1,1,1) Shininess[_Shininess] Specular[_SpecColor] }
// iPhone 3GS and later
SubShader {Pass {
SetTexture[_Sphere]
SetTexture[_MainTex] {Combine previous * texture alpha}
SetTexture[_MainTex] {Combine previous + texture}
SetTexture[_] {Combine previous * primary Double}
} }
// pre-3GS devices, including the September 2009 8GB iPod touch
SubShader {
Pass {
SetTexture[_Sphere] {Combine texture * primary Double}
}
Pass {
Blend One SrcAlpha
SetTexture[_MainTex] {Combine texture * primary Double, texture}
}
}
}
}
Thanks Jessy! I couldn't find any Unity 3 specific information about the mobile shader pipeline in the docs. Is there any available?
Not that I know of. I think all the iOS-specific ShaderLab stuff I know, I learned on my own, or by people telling me about issues here or on the forum. I've asked UT to include more iOS information in the docs, using the Bug Reporter app, but they haven't done it, as far as I know. :-(
Your answer
Follow this Question
Related Questions
Shading with cube maps on iPhone 3GS for Unity 3 beta 1 Answer
Unity 5 upgrade broke lightmapped shader 1 Answer
Problem with upgrading project to untiy 3. 1 Answer
clipping shader for OpenGL quad 0 Answers
GLSL shader adding UV offset 1 Answer