Hey guys ![]()
Ok so I really need you peoples help. I’ve been using my googling capabilities to the fullest but I haven’t found a good solution to my problem yet (or at least one I can understand). For the game I’m working on we need a shader which can do something similiar to the Multiply function in Photoshop, with the option to change transparency on the ‘detail’ texture. We want to have a creature which can have it’s normal texture, and when it gets sicker we want to raise the transparency on the detail texture to gradually make it appear sicker and sicker. We are using 2d Toolkit and will use this shader on animated sprites if that makes any difference. So what we need in our shader is a _MainTex for the regular texture, a _DetailTex for the texture we want to “Multiply” with the regular and some way to adjust transparency on the _DetailTex (however, this is not our main concern here, just getting Multiply to work would be great). Here’s an example picture of what we want:
http://imageshack.us/photo/my-images/834/multiplyexample.jpg/
Here’s what we got so far. I thought the lerp function would do the ‘multiplying’ for us by it’s use of _DetailMap _DiffuseMap, however with this code it seems we are only taking the mask from the _MainTex and then putting _DetailTex in that mask.
We are really in a jam about this and any help at all is greatly appreciated ![]()
Shader "Custom/DiffuseDetailCuttoff"
{
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_DetailTex ("Detail Texture", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_DetailTiling ("Detail Tiling", Float) = 1.0
_DetailFade ("Defail Fade", Range(0, 1)) = 1.0
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
sampler2D _DetailTex;
float _DetailTiling;
float _DetailFade;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 DiffuseMap = tex2D(_MainTex, IN.uv_MainTex) * _Color;
fixed4 DetailMap = tex2D(_DetailTex, IN.uv_MainTex * _DetailTiling);
o.Albedo = lerp(DiffuseMap.rgb, DetailMap.rgb, _DetailFade);
o.Alpha = DiffuseMap.a;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
