Question About adding tint to a Relfective texture.

Hi guys,
I’m starting to get a grasp of the shader side of things but I was hoping someone could help me with this.
I managed to get this simple reflective shader together for an iPhone project, but I can’t seem to get the tint to have any effect.

Shader "My Shaders/UnlitReflective" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB)", 2D) = "white" {}
    _EnvMap ("EnvMap", 2D) = "black" { TexGen SphereMap } 
}

SubShader {

	// Base pass: Reflection
      Pass { 
         Name "REFLECT" 
         BindChannels { 
            Bind "Vertex", vertex 
            Bind "normal", normal 
         }          
         SetTexture [_EnvMap] { 
            combine texture 
         } 
      } 
	
	// Second pass: Base
	Pass {
		Name "BASE"
		BindChannels {
			Bind "Vertex", vertex
			Bind "texcoord", texcoord0 // main uses 1st uv
		}
		Blend One OneMinusDstColor
		Fog { Color (0,0,0,0) }
		SetTexture [_MainTex] { combine texture }
	}
}
}

Can anyone see why the tint might not be working here?

THanks
Pete

as far as I see you don’t use the color anywhere that you define on your second pass

Ahh, cool. Got it!

Shader "My Shaders/CustomBoard/Wheels" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB)", 2D) = "white" {}
    _EnvMap ("EnvMap", 2D) = "black" { TexGen SphereMap } 
}

SubShader {

	// Base pass: Reflection
      Pass { 
         Name "REFLECT" 
         BindChannels { 
            Bind "Vertex", vertex 
            Bind "normal", normal 
         }          
         SetTexture [_EnvMap] { 
            combine texture     
         } 
      } 
	
	// Second pass: Base
	Pass {
		Name "BASE"
		BindChannels {
			Bind "Vertex", vertex
			Bind "texcoord", texcoord0 // main uses 1st uv
		}
		Blend One OneMinusDstColor
		SetTexture [_MainTex] {constantColor [_Color] combine texture combine texture * constant}
	}
}
}

This works now :slight_smile:

Are you using a different version? That last line doesn’t compile. You need two passes in the fixed function pipeline, to get your exact results, but do you need the texture for anything else? If you can just adjust it in Photoshop, you can do this in one pass. (The adjustment is to duplicate the texture, invert it, and then multiply the inverted version with the original.)

SubShader {Pass { 
	BindChannels { 
		Bind "vertex", vertex
		Bind "texcoord", texcoord
		Bind "normal", normal 
	}          
	SetTexture[_MainTex] {constantColor [_Color] Combine texture * constant}
	SetTexture[_EnvMap] {Combine texture + previous} 
}}

Hmm, actually that last line does look a bit funny -

SetTexture [_MainTex] {constantColor [_Color] combine texture combine texture * constant}

I changed it to this -

SetTexture [_MainTex] {constantColor [_Color] combine texture combine texture * constant}

Not sure why it doesn’t compile for you. I have the second pass because I wanted to have a base texture, then a tinted reflection over that. I wanted to be able to change the tint on the fly.

Hey Jessy,
I just put your code in a shader and it works great. Weird, I thought you would have to separate reflection and base texture into passes. Tint still works fine in yours too :slight_smile:
Thanks
Pete