I'm not good with shaders.
Can someone tell me how I would take the skin shader below (from the wiki) and make the specular map be a separate texture instead of getting it from the alpha of the MainTex?
I'm loading textures from the user's hard drive and since Unity can't load a DDS or anything with an actual alpha channel (unless I use an asset pack but user's can't make those) I need to use a separate texture as the spec map.
Thanks in advance!
Shader "Skin/Bumped Specular" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_BumpMap ("Bump (RGB)", 2D) = "white" {}
_RimTex ("Rim ramp (GRB) Fresnel ramp (A)", 2D) = " grey" {}
_WrapTex ("Wrap ramp (RGBA)", 2D) = "grey" {}
}
// ------------------------------------------------------------------
// Fragment program
SubShader {
Blend AppSrcAdd AppDstAdd
Fog { Color [_AddFog] }
TexCount 4
UsePass "Skin/Specular/BASE"
// Pixel lights
Pass {
Name "PPL"
Tags { "LightMode" = "Pixel" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "skinhelpers.cginc"
struct v2f {
V2F_POS_FOG;
LIGHTING_COORDS
float3 uvK; // xy = UV, z = specular K
float3 viewDirT;
float3 lightDirT;
float2 bumpUV;
};
uniform float _Shininess;
uniform float4 _MainTex_ST, _BumpMap_ST;
v2f vert (appdata_tan v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.uvK.z = _Shininess * 128;
o.uvK.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
o.bumpUV = TRANSFORM_TEX(v.texcoord, _BumpMap);
TANGENT_SPACE_ROTATION;
o.lightDirT = normalize (mul (rotation, ObjSpaceLightDir( v.vertex )));
o.viewDirT = normalize (mul (rotation, ObjSpaceViewDir( v.vertex )));
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
uniform sampler2D _MainTex;
uniform sampler2D _BumpMap;
float4 frag (v2f i) : COLOR
{
half4 texcol = tex2D( _MainTex, i.uvK.xy );
float3 normalT = normalize (tex2D (_BumpMap, i.bumpUV).rgb * 2 - 1);
return SpecularLightWrap(i.lightDirT, i.viewDirT, normalT, texcol, i.uvK.z, LIGHT_ATTENUATION(i));
}
ENDCG
}
}
Fallback "Skin/Specular", 0
}