Skip to content

Instantly share code, notes, and snippets.

@bitinn
Created May 1, 2018 13:16
Show Gist options
  • Save bitinn/de567d7922b519c988e0700c416cd9ae to your computer and use it in GitHub Desktop.
Save bitinn/de567d7922b519c988e0700c416cd9ae to your computer and use it in GitHub Desktop.
shader debug
Shader "Leocities/Tileable"
{
Properties
{
_BaseColorMask("BaseColor Mask", 2D) = "white" {}
_NormalMetallicRoughness("Normal Metallic Roughness", 2D) = "black" {}
[Toggle]_UseDecal("Use Decal", Range( 0 , 1)) = 1
[Toggle]_UseDecalNormal("Use Decal Normal", Range( 0 , 1)) = 1
_DecalBackgroundColor("Decal Background Color", Color) = (0,0,0,0)
_DecalForegroundColor("Decal Foreground Color", Color) = (1,1,1,0)
[HideInInspector] _texcoord2( "", 2D ) = "white" {}
[HideInInspector] _texcoord( "", 2D ) = "white" {}
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IgnoreProjector" = "True" }
Cull Back
CGPROGRAM
#pragma target 3.5
#pragma multi_compile_instancing
#pragma only_renderers d3d9 d3d11 glcore metal
#pragma surface surf Standard keepalpha addshadow fullforwardshadows exclude_path:forward novertexlights nolightmap nodirlightmap nofog nometa noforwardadd
struct Input
{
float2 uv2_texcoord2;
float2 uv_texcoord;
};
uniform sampler2D _NormalMetallicRoughness;
uniform sampler2D _BaseColorMask;
UNITY_INSTANCING_BUFFER_START(LeocitiesTileable)
UNITY_DEFINE_INSTANCED_PROP(fixed, _UseDecalNormal)
#define _UseDecalNormal_arr LeocitiesTileable
UNITY_DEFINE_INSTANCED_PROP(fixed4, _DecalBackgroundColor)
#define _DecalBackgroundColor_arr LeocitiesTileable
UNITY_DEFINE_INSTANCED_PROP(fixed4, _DecalForegroundColor)
#define _DecalForegroundColor_arr LeocitiesTileable
UNITY_DEFINE_INSTANCED_PROP(fixed, _UseDecal)
#define _UseDecal_arr LeocitiesTileable
UNITY_INSTANCING_BUFFER_END(LeocitiesTileable)
void surf( Input i , inout SurfaceOutputStandard o )
{
float2 uv2_TexCoord58 = i.uv2_texcoord2 * float2( 1,1 ) + float2( 0,0 );
float4 tex2DNode65 = tex2D( _NormalMetallicRoughness, uv2_TexCoord58 );
fixed _UseDecalNormal_Instance = UNITY_ACCESS_INSTANCED_PROP(_UseDecalNormal_arr, _UseDecalNormal);
float lerpResult76 = lerp( 0.5 , tex2DNode65.g , _UseDecalNormal_Instance);
float lerpResult77 = lerp( 0.5 , tex2DNode65.a , _UseDecalNormal_Instance);
float4 appendResult55 = (float4(1 , lerpResult76 , 1 , lerpResult77));
o.Normal = UnpackNormal( appendResult55 );
float2 uv_TexCoord46 = i.uv_texcoord * float2( 1,1 ) + float2( 0,0 );
fixed4 _DecalBackgroundColor_Instance = UNITY_ACCESS_INSTANCED_PROP(_DecalBackgroundColor_arr, _DecalBackgroundColor);
fixed4 _DecalForegroundColor_Instance = UNITY_ACCESS_INSTANCED_PROP(_DecalForegroundColor_arr, _DecalForegroundColor);
fixed _UseDecal_Instance = UNITY_ACCESS_INSTANCED_PROP(_UseDecal_arr, _UseDecal);
float lerpResult67 = lerp( 0 , tex2D( _BaseColorMask, uv2_TexCoord58 ).a , _UseDecal_Instance);
float3 lerpResult80 = lerp( (_DecalBackgroundColor_Instance).rgb , (_DecalForegroundColor_Instance).rgb , lerpResult67);
float3 lerpResult101 = lerp( (tex2D( _BaseColorMask, uv_TexCoord46 )).rgb , lerpResult80 , lerpResult67);
o.Albedo = lerpResult101;
float4 tex2DNode47 = tex2D( _NormalMetallicRoughness, uv_TexCoord46 );
o.Metallic = tex2DNode47.b;
o.Smoothness = ( 1.0 - tex2DNode47.r );
o.Alpha = 1;
}
ENDCG
}
Fallback "Unlit/Color"
CustomEditor "ASEMaterialInspector"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment