- Home /
Custom Shader: Using Normal, Diffuse, Gloss, and Specular Maps
I've attempted at making a Shader
that utilizes Normal
, Diffuse
, Gloss
, and Specular
maps. I'm not receiving any compiler errors, however my object is appearing completely black which isn't correct. There are a couple of different colors, some parts that are shiny, etc. so it's definitely not displaying correctly.
The texture files are all .tga
files (Not sure if that matters). I haven't changed the Tiling or Offset fields from the defaults in the Editor. Also, the textures are set in the Editor.
Can anyone point out what I'm doing wrong here? If you need any more information please let me know, not 100% on what is needed for this one. My code seems fairly similar to others that I'm coming across which is why I can't find the issue.
Here is what I came up with.
Shader "Custom/Test" {
Properties {
_DiffuseTex ("Diffuse", 2D) = "white" {}
_SpecularTex ("Specular", 2D) = "white" {}
_NormalTex ("Normal", 2D) = "bump" {}
_GlossTex ("Gloss", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _DiffuseTex;
sampler2D _SpecularTex;
sampler2D _NormalTex;
sampler2D _GlossTex;
struct Input {
float2 uv_DiffuseTex;
float2 uv_SpecularTex;
float2 uv_NormalTex;
float2 uv_GlossTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 diff = tex2D (_DiffuseTex, IN.uv_DiffuseTex);
o.Albedo = diff.rgb;
o.Alpha = diff.a;
o.Specular = (tex2D (_SpecularTex, IN.uv_SpecularTex)).g;
o.Gloss = (tex2D(_GlossTex, IN.uv_GlossTex)).r;
o.Normal = UnpackNormal(tex2D(_NormalTex, IN.uv_NormalTex));
}
ENDCG
}
FallBack "Diffuse"
}
@tanoshimi I've changed Lambert
to BlinnPhong
thank you for that - didn't know the difference. As far as I can tell it didn't change anything, not sure if it was supposed to. I'm not sure what you mean by packing them into the same texture - is that something the artist who generated the .tga files would have to do?
Your answer
Follow this Question
Related Questions
Specular & alpha mapping 1 Answer
Problem of color in custom vertex shader 0 Answers
Outlined Specular shader? 0 Answers
Cartoon specular, regular diffuse, fresnel reflective? 1 Answer