Marnix
September 17, 2011, 11:22am
1
Is it possible to set your uv tiling on mirror repeat? I do know that OpenGL supports it and DirectX does so too.
So, instead of just repeating the texture, the texture needs to be flipped instead of just repeated.
http://www.opengl.org/registry/specs/ARB/texture_mirrored_repeat.txt
No it is not possible to change the UV to mirror mode. However if your UVs is set to repeat, you can easily achieve the same effect by writing a custom shader.
I have implemented a simple diffuse shader that does the trick:
Shader "Custom/DiffuseUVMirrowShader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
float4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
float2 t = frac(IN.uv_MainTex*0.5)*2.0;
float2 length = {1.0,1.0};
float2 mirrorTexCoords = length-abs(t-length);
half4 c = tex2D(_MainTex, mirrorTexCoords) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "VertexLit"
}