- Home /
Flip cubemap image from within the shader.
Hi all,
I am a bit stumped on this one and wondered if anyone could point me in the right direction. I have 360 degree stereoscopic images which I am using a cube map shader to display on spheres in my scene.
Everything was working fine in Unity 4 until I upgraded to 5 which caused my cubemap image to be flipped. I cannot change it via the Tiling or Offset settings so I am wondering if you can flip images directly in the shader?
Here is the code:
Shader "Environment Map" {
Properties {
_Cube ("Cubemap", CUBE) = "" {}
}
SubShader {
Cull front
Pass {
CGPROGRAM
struct v2f {
float4 position_clip: SV_POSITION;
float3 position_local: TEXCOORD0;
};
#pragma vertex main_vertex
v2f main_vertex(float4 position: position) {
v2f v2f;
v2f.position_clip = mul(UNITY_MATRIX_MVP, position);
v2f.position_local = position;
return v2f;
}
#pragma fragment main_fragment
samplerCUBE _Cube;
half4 main_fragment(v2f v2f): COLOR {
return texCUBE(_Cube, v2f.position_local);
}
ENDCG
}
}
}
Any help much appreciated.
Answer by mattratcliffe · Aug 13, 2015 at 01:49 PM
It looks like this was caused by a corrupt project, or some project setting that I had flicked. When I pulled it into a fresh project the shader stopped working properly altogether. Definitely something different in the way this shader works between 4 and 5 that warrants a bit more investigation.