I am in need of a Diffuse + Detail + Specular + Normal Shader. See i have a some material files i am wanting to bring over from a different engine in mtl format. While I don’t mind recreating the material I just lack the shader needed.
I did find one on the forums, but it was rather old (2.x) and unity 4 did not like it.
Shader "Diffuse Detail Specular Normal" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Detail ("Detail (RGB)", 2D) = "gray" {}
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
_SpecMap ("Spec map (RGB)", 2D) = "white" {}
_BumpMap ("Bumpmap (RGB)", 2D) = "bump" {}
}
Category {
Blend AppSrcAdd AppDstAdd
Fog { Color [_AddFog] }
// ------------------------------------------------------------------
// ARB fragment program
SubShader {
// Ambient pass
Pass {
Name "BASE"
Tags {"LightMode" = "PixelOrNone"}
Blend AppSrcAdd AppDstAdd
Color [_PPLAmbient]
SetTexture [_MainTex] {constantColor [_Color] Combine texture * primary DOUBLE, texture * constant}
SetTexture [_Detail] {combine previous * texture DOUBLE, previous}
}
// Vertex lights
Pass {
Name "BASE"
Tags {"LightMode" = "Vertex"}
Material {
Diffuse [_Color]
Emission [_PPLAmbient]
}
Lighting On
SetTexture [_MainTex] {constantColor [_PPLAmbent] Combine texture * primary DOUBLE, texture * primary}
SetTexture [_Detail] { combine previous * texture DOUBLE, previous }
}
// 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"
struct v2f {
V2F_POS_FOG;
LIGHTING_COORDS
float3 uvK; // xy = main map, z = specular K
float2 uv; // detail map
float4 uv2; // bumpmap UV, specmap UV
float3 viewDirT;
float3 lightDirT;
};
uniform float4 _MainTex_ST,_Detail_ST, _BumpMap_ST, _SpecMap_ST;
uniform float _Shininess;
v2f vert (appdata_tan v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.uvK.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uvK.z = _Shininess * 128;
o.uv.xy =TRANSFORM_TEX(v.texcoord, _Detail);
o.uv2.xy = TRANSFORM_TEX(v.texcoord, _BumpMap);
o.uv2.zw = TRANSFORM_TEX(v.texcoord, _SpecMap);
TANGENT_SPACE_ROTATION;
o.lightDirT = mul( rotation, ObjSpaceLightDir( v.vertex ) );
o.viewDirT = mul( rotation, ObjSpaceViewDir( v.vertex ) );
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
uniform sampler2D _BumpMap;
uniform sampler2D _MainTex;
uniform sampler2D _Detail;
uniform sampler2D _SpecMap;
uniform float4 _LightColor0;
// Calculates Blinn-Phong (specular) lighting model
inline half4 SpecularColorLight( half3 lightDir, half3 viewDir, half3 normal, half4 color, half4 specColor, float specK, half atten )
{
#ifndef USING_DIRECTIONAL_LIGHT
lightDir = normalize(lightDir);
#endif
viewDir = normalize(viewDir);
half3 h = normalize( lightDir + viewDir );
half diffuse = dot( normal, lightDir );
float nh = saturate( dot( h, normal ) );
float spec = pow( nh, specK ) * color.a;
half4 c;
c.rgb = (color.rgb * _ModelLightColor0.rgb * diffuse + _LightColor0.rgb * specColor.rgb * spec) * (atten * 2);
c.a = _LightColor0.a * specColor.a * spec * atten; // specular passes by default put highlights to overbright
return c;
}
half4 frag (v2f i) : COLOR
{
half4 texcol = tex2D( _MainTex, i.uvK.xy );
texcol.rgb *= tex2D(_Detail,i.uv).rgb*2;
half4 speccol = tex2D( _SpecMap, i.uv2.zw );
float3 normal = tex2D(_BumpMap, i.uv2.xy).xyz * 2.0 - 1.0;
half4 c = SpecularColorLight( i.lightDirT, i.viewDirT, normal, texcol, speccol, i.uvK.z, LIGHT_ATTENUATION(i) );
return c;
}
ENDCG
}
}
}
FallBack "Diffuse"
}
any help would great.