I’m trying to make a shader that will print the eye’s texture of a character over it’s skin texture, my problem is that the eye’s texture has a white border around it and I don’t know what is causing it. Also the shader receives an rgb value that it will add to the grey areas of the eye to tint it (commented area). I’ve never tried programming shaders before and I don’t really understand how they work.
Here’s the code so far:
Shader "Custom/EyeShaderTest" {
Properties {
_SkinTex ("Skin", 2D) = "white" {}
_EyeTex ("Eye", 2D) = "white" {}
_EyeColor ("EyeColor", Color) = (.34 , .85, .92, 1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
sampler2D _SkinTex;
sampler2D _EyeTex;
half4 _EyeColor;
struct Input {
float2 uv_SkinTex;
float2 uv_EyeTex;
};
float3 overlayColor(float3 colorA, float4 colorB){
return (colorA * (1 - colorB.a)) + (colorB.rgb * colorB.a);
}
void surf (Input IN, inout SurfaceOutput o) {
half4 skin = tex2D (_SkinTex, IN.uv_SkinTex);
half4 eye = tex2D (_EyeTex, IN.uv_EyeTex);
//if( (0.2 < eye.g && eye.g < 0.8) ){
// eye.rgb = (_EyeColor.rgb * eye.rgb)*2;
//}
float3 mix = overlayColor(skin.rgb, eye);
o.Albedo = mix;
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}
guess my overlayColor function isn’t working as intended.
This is my eye texture:
[36796-screen+shot+2014-12-09+at+6.22.44+pm.png|36796]
This is the desired result :
[36797-screen+shot+2014-12-09+at+6.22.38+pm.png|36797]
And this is the result I’m getting: