Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Murcho · Nov 23, 2010 at 03:12 AM · shaderupgradeopengl

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?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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

}

}

Comment
Add comment · Show 2 · Share
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 Murcho · Nov 23, 2010 at 04:05 AM 0
Share

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

avatar image Jessy · Nov 23, 2010 at 04:46 AM 0
Share

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

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

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


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