- Home /
Question by
chirpywiz711 · Dec 30, 2018 at 08:08 PM ·
scripting problemshadershaderlabtoon shader
Standard Shader Features in Custom Surface Shader
I would like to use a Toon Ramp shader with the features of the Standard Surface shader (roughness setup), and I tried to use the standard shader code, but all it was was a bunch of #pragmas, and it didn't seem to work out.
This is my code
Shader "Chirpy/Regular" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Texture", 2D) = "white" {}
_BumpMap("Normalmap", 2D) = "bump" {}
_Ramp("Shading Ramp", 2D) = "gray" {}
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
_SpecGlossMap("Smoothness Map", 2D) = "white" {}
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
_MetallicGlossMap("Metallic Map", 2D) = "white" {}
_Cube("Reflection Cubemap", Cube) = "_Skybox" {}
_Parallax("Height Scale", Range(0.005, 0.08)) = 0.02
_ParallaxMap("Height Map", 2D) = "black" {}
_OcclusionStrength("Occlusion Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion Map", 2D) = "white" {}
_EmissionColor("Emission Color", Color) = (0,0,0)
_EmissionMap("Emission Map", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
_DetailNormalMapScale("Scale", Float) = 1.0
_DetailNormalMap("Normal Map", 2D) = "bump" {}
}
SubShader{
Tags { "RenderType" = "Opaque" }
//Added Double sided normal support
Cull off
CGPROGRAM
#pragma surface surf Ramp
#pragma target 3.5
#pragma glsl
sampler2D _Ramp;
half4 LightingRamp(SurfaceOutput s, half3 lightDir, half atten) {
half d = (dot(s.Normal, lightDir)*0.5 + 0.5) * atten;
half3 ramp = tex2D(_Ramp, float2(d,d)).rgb;
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
c.a = s.Alpha;
return c;
}
fixed4 _Color;
half _Metallic;
half _Glossiness;
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float3 worldRefl;
INTERNAL_DATA
};
sampler2D _MainTex;
sampler2D _BumpMap;
samplerCUBE _Cube;
void surf(Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 c = tex * _Color;
o.Albedo = c.rgb-(c.rgb*_Metallic);
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
float3 worldRefl = WorldReflectionVector(IN, o.Normal);
fixed4 reflcol = texCUBE(_Cube, worldRefl);
reflcol *= tex.a;
o.Emission = reflcol.rgb * (_Metallic/2, _Metallic/2, _Metallic/2);
o.Alpha = c.a;
}
ENDCG
}
Fallback "Diffuse Bumped"
}
Comment