x


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?

more ▼

asked Nov 23, 2010 at 03:12 AM

Murcho gravatar image

Murcho
2.9k 27 35 67

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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}
     } 
 }

}

}

more ▼

answered Nov 23, 2010 at 03:47 AM

Jessy gravatar image

Jessy
18.3k 208 178 296

Thanks Jessy! I couldn't find any Unity 3 specific information about the mobile shader pipeline in the docs. Is there any available?

Nov 23, 2010 at 04:05 AM Murcho

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. :-(

Nov 23, 2010 at 04:46 AM Jessy
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3151
x190
x164
x110

asked: Nov 23, 2010 at 03:12 AM

Seen: 1932 times

Last Updated: Nov 23, 2010 at 03:12 AM