Hi folks,
I have no idea what Im doing with shaders or tools like strumpy for that matter (And believe me Ive tried) and I have created a character that Im working on setting up as a 3rd person Player Character in Unity, that I need a specific type of shader for.
So
I was wondering if anyone has or can make me a Unity Shader that supports Diffuse maps, Normal maps, Spec maps, Emmision maps and Alpha channels/cutoff that I can please pilfer?
Cheers.
SW
Replies
alpha cutoff references the main texture alpha, emission is packed in the normal map alpha
Shader "Custom/PC_ASlphaEmissive" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_EmissionLM ("Emission (Lightmapper)", Float) = 0
_EAmount ("Emission Amount", Float) = 0
_EColor ("Emission Color", Color) = (1,1,1,1)
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 400
CGPROGRAM
#pragma surface surf BlinnPhong alphatest:_Cutoff
#pragma exclude_renderers flash
sampler2D _MainTex;
sampler2D _BumpMap;
fixed4 _Color;
half _Shininess;
float _EAmount;
fixed4 _EColor;
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = tex * _Color;
o.Emission = tex.rgb * tex2D(_BumpMap, IN.uv_BumpMap).a * _EAmount * _EColor;
o.Gloss = tex.a;
o.Alpha = tex.a * _Color.a;
o.Specular = _Shininess;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG
}
FallBack "Transparent/Cutout/VertexLit"
}
This is good, but ideally I need slots to place my specmap and emmisive map in too.
Edit: Also placing a texture into the Alpha channel of the Normal map, does not seem to make any difference.
Thanks.
SW
That's good to know. I guess we need at least one more texture lookup.
Shader "Custom/PC_ASlphaEmissive" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_EmissionRange("_EmissionRange", Range(0,10) ) = 0.91
_Emission("_Emission", 2D) = "black" {}
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 400
CGPROGRAM
#pragma surface surf BlinnPhong alphatest:_Cutoff
#pragma exclude_renderers flash
sampler2D _MainTex;
sampler2D _BumpMap;
fixed4 _Color;
half _Shininess;
float _EmissionRange;
sampler2D _Emission;
half3 Emission;
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float2 uv_Emission;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = tex * _Color;
o.Emission = 0.0;
o.Gloss = tex.a;
o.Alpha = tex.a * _Color.a;
o.Specular = _Shininess;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
float4 Tex2D2=tex2D(_Emission,(IN.uv_Emission.xyxy).xy);
float4 Multiply2=_EmissionRange.xxxx * Tex2D2;
o.Emission = Multiply2;
}
ENDCG
}
FallBack "Transparent/Cutout/VertexLit"
}