I have written a skin shader with soft highlights but I am having a problem adding a spec map.
I want to add a universal spec map that isn’t based on the model’s UV map.
Heres a picture showing you what I’m trying to do.

this is using hard lighting but you should still get the point. I want to use a spec map or any map to add noise the lighting.
here’s the shader code"
Shader"custome/Skin"
{
properties
{
_MainTex(“Texture”, 2D) = “white” {}
_Smap(“SpecMap”, 2D) = “white” {}
_Shininess (“Specularity”,range(0.005,2.5))= 0.05
_MatCap (“MatCap (RGB)”, 2D) = “white” {}
_CapPower(“matPower”,range(1.2,1.7))= 1.4
_Normals (“Normal”, 2D)=“white” {}
_NorRange (“Dephs”,range(0.95,8))= 3
}
SubShader
{
Pass{
Tags{“LightMode” = “ForwardBase”}
CGPROGRAM
#pragma vertex vertsA
#pragma fragment fragsA
#pragma target 3.0
#pragma only_renderers d3d9 debug
uniform half4 _Color;
uniform half _Shininess;
uniform half4 _LightColor0;
uniform sampler2D _MainTex;
uniform half4 _MainTex_ST;
uniform sampler2D _Normals;
uniform half4 _Normals_ST;
uniform half _NorRange;
uniform half _CapPower;
uniform sampler2D _Smap;
uniform half4 _Smap_ST;
uniform sampler2D _MatCap;
uniform float2 matcapUV;
half4x4 _Object2World;
half4x4 _World2Object;
half4 _WorldSpaceLightPos0;
half3 _WorldSpaceCameraPos;
//input structs
struct VertInput1 { // vertex imput info
half4 vertex : POSITION;
half3 normal : NORMAL;
half4 texcoord : TEXCOORD0;
half4 tangent : TANGENT;
};
//output structs
struct VertOutput1 { // vertex output info
half4 pos : SV_POSITION;
half4 colur: COLOR;
half4 sktex : TEXCOORD0;
half4 lightDir : TEXCOORD1;
half3 posNormal : TEXCOORD2;
half3 tans : TEXCOORD3;
half3 binoms : TEXCOORD4;
half3 cameraView :TEXCOORD5;
half4 spTex : TEXCOORD6;
float2 cap : TEXCOORD7;
};
// vertex
VertOutput1 vertsA(VertInput1 g)
{
VertOutput1 h;
//matcap
half2 capCoord;
capCoord.x = dot(UNITY_MATRIX_IT_MV[0].xyz,g.normal);
capCoord.y = dot(UNITY_MATRIX_IT_MV[1].xyz,g.normal);
h.cap = capCoord * 0.5 + 0.5;
// direction variables
h.posNormal = normalize(mul(half4(g.normal,0.0),_World2Object).xyz);
h.tans = normalize( mul(_Object2World, g.tangent).xyz);
h.binoms = normalize(cross(h.posNormal,h.tans)* g.tangent.w);
half4 posMain = mul(_Object2World, g.vertex);
h.pos = mul(UNITY_MATRIX_MVP, g.vertex);
h.sktex = g.texcoord;
h.cameraView = normalize (_WorldSpaceCameraPos.xyz -posMain.xyz); //tweakable
//multilight and light physics
half3 facetolite= _WorldSpaceLightPos0.xyz -posMain.xyz;
half distance = length(facetolite);
h.lightDir = half4(normalize(lerp(_WorldSpaceLightPos0.xyz,facetolite,_WorldSpaceLightPos0.w)),
lerp(1.0,(1.0/(distance*distance)),_WorldSpaceLightPos0.w));
return h;
}
// fragment
half4 fragsA(VertOutput1 i) : COLOR
{
//maps
half4 sktexf = tex2D(_MainTex, i.sktex.xy + (_MainTex_ST.xy * _MainTex_ST.zw));
half4 tans = tex2D(_Normals, i.sktex.xy + (_Normals_ST.xy * _Normals_ST.zw));
half4 spTex = tex2D(_Smap, i.sktex.xy + (_Smap_ST.xy *_Smap_ST.zw));
//normals
half3 localCoords = half3(2.0 * tans.ag - half2(1.0,1.0),_NorRange);
half3x3 local2WorldTranspose = float3x3( i.tans, i.binoms, i.posNormal);
half3 normalDirection = normalize(mul(localCoords, local2WorldTranspose));
//matcap
fixed4 mc = tex2D(_MatCap,i.cap);
//lambert lighting calc
half3 SNdotL= saturate( dot( normalDirection,i.lightDir.xyz));
half3 thelighting = i.lightDir.w * _LightColor0.xyz 2 SNdotL;
//Specularity calc
half3 theshine = i.lightDir.w * 0.8spTex.rgb(0.4max( 0.0,dot(0.7normalDirection,0.7* i.lightDir.xyz)))
- pow(max(0.0, dot(reflect(-i.lightDir.xyz, normalDirection),i.cameraView )),_Shininess);
//spec highlights messy code
half3 thehigh = i.lightDir.w * max( 0.0,dot(normalDirection, i.lightDir.xyz))
*pow(max(0.0, dot(reflect(-i.lightDir.xyz, normalDirection),i.cameraView )),15);
half3 thebrightness = theshine+(0.1*thehigh);
//combine the lights
half3 lights = (mc*_CapPower)(thelighting)+(thebrightness);//(theshine0.6);// + (2*UNITY_LIGHTMODEL_AMBIENT.xyz);
//final lighting
return half4 (sktexf.rgb*lights,1.0);
}
ENDCG
}