is there a simple reflection shader for iOS? even a hacky one?

Hi there,

I need to make an icy looking surface on iOS and I can’t seem to find a suitable shader that will give me a reflective look. I tried additively blending an image with spherical mapping but it just looks a bit weird.

I can’t seem to find any other examples of a simple reflective shader.

Any ideas?
Thanks
Pete

You can always use the good ol’-fashioned “duplicate and flip geometry” trick. Scaling by -1 on the y axis will do. Then use a transparent plane for the surface.

–Eric

If you mean reflective just supplying a reflective texture yourself, search forums, I posted on a while ago. Try searching for env mapping or environment or sphere mapping.

If you mean actually reflecting the environment then what eric suggests is a fast way to do it.

Thanks Guys,
I was looking for more of an overall reflective look so more like what hippocoder is talking about. Searched the forums a bit but it’s hard to find something that is relevant. I just seem to be coming up with loose ends. Is cube mapping the answer? Because the sphere mapping isn’t really working in my case.
Thanks
Pete

Hey guys, I ended up using this -
And it works great for what I need, but, it doesn’t seem to work with opengl es 1.1 does anyone know why that might be?
Thanks
P.

Shader "Relfective Vertex Mask" {
    Properties {
        _MainTex ("Reflection Texture", Cube) = "white" {TexGen CubeReflect}
   }   

Category {
	Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
	Blend One One
	Cull Off 
	Lighting Off 
	ZWrite Off

	SubShader {
		Pass {
			ColorMaterial AmbientAndDiffuse
			
			SetTexture [_MainTex2] {
				Combine primary
			}
			
			SetTexture [_MainTex] {
				combine texture * previous
			}
		}
	}
}
}

I’m not shader guru, but I think 1.1 do not support cube mapping. For 1.1 you can do it via crude scripting though, instead of sending to the GPU.

use sphere mapping instead for 1.1 (off the top of my head the code would look like):

Shader "Mobile/Spheremap"
{
	 Properties 
	 {
		_EnvMap ("EnvMap", 2D) = "black" { TexGen SphereMap }
	 }

	 SubShader 
	 {
	 	Lighting on
		Tags {"Queue" = "Geometry"}

		Pass 
		{ 	
			BindChannels 
			{ 
				Bind "Vertex", vertex 
				Bind "normal", normal 
			}
			Material
			{
				Diffuse [_Color]
				Ambient [_Color]
			}

			SetTexture [_EnvMap]
			{ 
				combine texture + primary 
			} 
		}
	} 
}

Untested, give it a quick spin.

Be sure to use a proper sphere map. Here’s one:

Thanks Hippocoder, that seems to be doing the job pretty cool.

I had to change : SetTexture [_MainTex] to SetTexture [_EnvMap]

Thanks for the help!

Ahh crap, spoke too soon.
For some reason the reflection looks textured on when i run it on the iPhone, it doesn’t move across the surface…
What am i doing wrong, any ideas?
This shader is driving me mad.
Pete

I remember that trick, evil genius used it. Great game. Oh so off topic :stuck_out_tongue:

I’d use that but my character is on an uneven ground and the reflective areas are in little sections so it wouldn’t really work.
Surely there must be a reflective look shader out there though, I must have seen unity games with them.

Looks Cool. Thanks. I Added main color to blend with reflection map. but where i can control the reflection amount. Little help would be great.