• 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 bricevdm · Dec 25, 2009 at 12:11 PM · iphonecustom-shader

"Combine" fixed function error

Hello everyone and merry Xmas :)

I've been looking into Shaderlab these days to build some shader for an iPhone project of ours. The aim here was to build one for static geometry, a classic "lightmap diffuse 2". However I wanted to use the extra alpha channel of the lightmap to store another light channel, to make it blink and/or gameplay related.

No big trouble, it seems i can use this combine function as explained in the doc: combine src1 * src2 + src3 (http://unity3d.com/support/documentation/Components/SL-SetTexture.html)

SubShader { Pass { Color [_Color] Fog {}

     BindChannels {
     Bind "Vertex", vertex
     Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
     Bind "texcoord", texcoord1 // main uses 1st uv
     }

         AlphaTest Greater [_Cutoff]

     SetTexture [_LightMap] {
         constantColor (1,1,1,1)
         combine previous * texture + texture
         , constant}
             SetTexture [_MainTex] { 
         combine previous * texture}
 }

pretty simple: ((color alpha of lightmap) + lightmap.rgb) diffuse

But I have this weird error, both on target and in the editor it renders out black/nothing and outputs this:

Shader 'g0 lm * d': no subshaders can run on this graphics card with no other "classic red" error

if I use this combine instead: //combine previous lerp(texture) texture

it works just fine (even tough it's not visually accurate), which makes me think it might be a bug.

Please note that I define a constant color to avoid the alpha of the lightmap beeing used for alpha testing (i know it's weirdly unefficient, I'll avoid that in the game :) )

That's about it, any thought?

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
1
Best Answer

Answer by Ree · Dec 27, 2009 at 06:22 AM

From the error you got it sounds like the iPhone doesn't support src1*src2+src3. Assuming that you're trying to do this within Unity iPhone editor. The example of video cards in the ShaderLab reference say that ATI Rage (which appear quite similar in specs to the pre-3GS iPhones; as it only has two stages as well) does not support src1*src2+src3 || src1*src2+-src3 || src1*src2-src3. I suppose you could try running this Shader within Unity 2.6 to see if it works. If it does, chances are the iPhone doesn't allow for this blending method.

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 bricevdm · Dec 27, 2009 at 03:37 PM 0
Share

Hello, thanks for your answer :)

I'm using a mac $$anonymous$$i which use a GeForce 9400$$anonymous$$ and an iTouch 3GS. I found where the problem lies tough: I installed Unity 2.6 on the same machine and the shader shows up perfectly (I was using 1.5.1f2). I'm stuck for my iPhone project, but now we know this is probably a software issue.

So this seems to be a version bug, hopefully the merge with the 2.x editor will fix that...

avatar image Aras ♦♦ · Jan 10, 2010 at 06:35 AM 0
Share

Unity iPhone defaults to "iPhone" graphics emulation. So if iPhone does not support a*b+c combiner, then it won't show that.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

What shader blending modes don't work on iOS? 1 Answer

Toon Shader for the iPhone 1 Answer

What, exactly, in a shader, stops batching from happening? 2 Answers

Why do Zwrite, Ztest, and Colormask simplifications not optimize shader performance? 3 Answers

WHAT licence for Iphone DEV 2 Answers


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