Colorize main-color of the iPhone/lightmap/reflective shader doesnt work...


the "Penelope"-iPhone-Tutorial for example is using the "iPhone/lightmap/reflective"-shader. (object-example in penelope: "polySurface973").

I would like to make the same reflection for the iphone and use this shader. But im wondering, while im changing the "Main-Color"-property in the inspector, nothing changes. What are the requirements for the three different textures using this reflective shader? I have to colorize the material...

Its a pity thats no iphone-shader declaration like for the standard unity shaders.

Thanks for your time, yosh

I'm sorry. This terrible website did not contact me about you having commented. Now it's a month later, and only now, via the RSS feed sending out your question again, due to it being unanswered, do I see these comments. I'm posting this in a new answer in hopes that it makes the website work better. Ug! >8-O

Everything you mentioned is doable, but the more textures you want to use, the more passes you're going to need, because the iPhone's GPU isn't very good. Here is an option that would work in one pass. It doesn't require a mask for the "main color", because it uses the vertex colors for that. If you don't want colorization in a certain area, then use white. It also uses the vertex colors' alpha channel as a reflectivity mask.

So, this is probably the fastest method to achieve everything you mentioned, but it does require that vertex colors will work for your application. That should be the case if you have hard edges or are just using smooth gradients. Let me know if this is not sufficient, and I'll give you something more appropriate. However, do be very clear, and don't ask for things you don't need. Every little bit counts, on the iPhone. The more you can get away with, with vertex colors, instead of textures, the better you can do in terms of batching, as long as your meshes have few enough vertices.

Shader "iPhone/Vertex Lightmap + Masked Spheremap" {

    _MainTex ("Main Texture (RGB)", 2D) = ""
    _Spheremap ("Spheremap (RGB)", 2D) = "" {TexGen SphereMap}

SubShader {Pass
    // ShaderLab doesn't provide a way that I know of
    // to not screw up the SphereMap with BindChannels.
    ColorMaterial Ambient  Lighting Off

    SetTexture[_MainTex] {Combine primary * texture}
    SetTexture[_Spheremap] {Combine texture Lerp(primary) previous}


Shaders that work on the iPhone can currently only use fixed function ShaderLab commands; no Cg or GLSL. As such, the shaders are extremely simple, and ShaderLab is pretty well-documented, so I don't think they warrant explanations. I'd rather have the developers work on something that we shouldn't be worrying about ourselves.

In addition, this shader in particular isn't put together very well. The Main Color property actually does nothing whatsoever. Give me the requirements for what you need, and I'll write it for you, though.