aagocs
April 14, 2015, 2:15pm
1
Hello we’re using a custom matcap shader, but in Unity 5, the texture is displayed very weird.
Shader "MatCap/Vertex/Textured Lit Flat Shaded"
{
Properties
{
_Color ("Color", Color) = (0,0,0,1)
_MatCap ("MatCap (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
//Cull Off
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MatCap;
float4 _Color;
struct Input
{
float2 matcapUV;
};
void vert (inout appdata_full v, out Input o)
{
o.matcapUV = float2(dot(UNITY_MATRIX_IT_MV[0].xyz,v.normal),dot(UNITY_MATRIX_IT_MV[1].xyz,v.normal)) * 0.5 + 0.5;
}
void surf (Input IN, inout SurfaceOutput o)
{
half4 mc = tex2D(_MatCap, IN.matcapUV);
o.Albedo = ((mc * 2.0) *_Color);
}
ENDCG
}
}
Any idea?
2068076–134914–MatCap_Lit.shader (887 Bytes)
larku
April 14, 2015, 2:18pm
2
Hey I too had issues with the matcap shaders (and my customised versions of) after upgrading to Unity 5. I contacted the dev and he fixed them VERY quickly and uploaded new versions to the Asset Store.
Have you tried using the latest version from the Asset Store? If you are using the latest contact the dev, he’ll most likely fix it quick.
aagocs
April 14, 2015, 2:21pm
3
larku:
Hey I too had issues with the matcap shaders (and my customised versions of) after upgrading to Unity 5. I contacted the dev and he fixed them VERY quickly and uploaded new versions to the Asset Store.
Have you tried using the latest version from the Asset Store? If you are using the latest contact the dev, he’ll most likely fix it quick.
Thanks for the quick reply. This is a custom made shader, not from the free pack on the asset store.
larku
April 14, 2015, 2:25pm
4
Oh sorry, I thought it was one you modified from the pack from the asset store! Oops.
Edit: perhaps still worth looking at that free pack since it may shed some light on what needs to change for Unity 5.
I think you need to normalize. Haven’t fully tested, but something like this:
o.matcapUV = float2(dot(normalize(UNITY_MATRIX_IT_MV[0].xyz),v.normal ),dot(normalize(UNITY_MATRIX_IT_MV[1].xyz),v.normal )) * 0.5 + 0.5;
Unity5 stopped auto compensating for scale on the CPU. Which is good for non-uniform scale and performance, but it means you may need to normalize in the shader where you didn’t before, especially with scaled object.