74 lines
2.5 KiB
Plaintext
74 lines
2.5 KiB
Plaintext
Shader "Custom/Minecraft/Standard Animated Cutout"
|
|
{
|
|
Properties
|
|
{
|
|
[NoScaleOffset]_DiffuseArray("Transparent Albedo (RGBA)", 2DArray) = "" {}
|
|
_Color("Tint Color", Color) = (1, 1, 1, 1)
|
|
_Cutoff ("Alpha Cutoff", Range(0, 1)) = 0.5
|
|
[NoScaleOffset]_MetallicArray("Metallic", 2DArray) = "" {}
|
|
_Glossiness("Smoothness", Range(0, 1)) = 0.5
|
|
[NoScaleOffset]_EmissionArray("Emission Map", 2DArray) = "" {}
|
|
_Brightness("Brightness", Float) = 1.0
|
|
|
|
_FlipbookFPS("Flipbook FPS", Integer) = 30
|
|
_FlipbookFrames("Flipbook Frames", Integer) = 30
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags { "RenderType" = "TransparentCutout" }
|
|
LOD 200
|
|
|
|
CGPROGRAM
|
|
#pragma surface surf Standard fullforwardshadows alpha:auto alphatest:_Cutoff addshadow
|
|
#pragma target 3.0
|
|
|
|
UNITY_DECLARE_TEX2DARRAY(_DiffuseArray);
|
|
fixed4 _Color;
|
|
UNITY_DECLARE_TEX2DARRAY(_MetallicArray);
|
|
half _Glossiness;
|
|
UNITY_DECLARE_TEX2DARRAY(_EmissionArray);
|
|
half _Brightness;
|
|
|
|
int _FlipbookFPS;
|
|
int _FlipbookFrames;
|
|
|
|
struct Input
|
|
{
|
|
float2 uv_DiffuseArray;
|
|
};
|
|
|
|
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
|
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
|
// #pragma instancing_options assumeuniformscaling
|
|
UNITY_INSTANCING_BUFFER_START(Props)
|
|
// put more per-instance properties here
|
|
UNITY_INSTANCING_BUFFER_END(Props)
|
|
|
|
void surf(Input IN, inout SurfaceOutputStandard o)
|
|
{
|
|
// Common UV for all texture arrays
|
|
float frame = fmod(floor(_Time.y * _FlipbookFPS), _FlipbookFrames); // Cyclic frame value
|
|
float3 uvw = float3(IN.uv_DiffuseArray, frame);
|
|
|
|
// Albedo with alpha
|
|
float4 diff = UNITY_SAMPLE_TEX2DARRAY(_DiffuseArray, uvw) * _Color;
|
|
o.Albedo = diff.rgb;
|
|
o.Alpha = diff.a;
|
|
|
|
// Sample Metallic and smoothness (R = Metallic, A = Smoothness) plus slider variable
|
|
float4 metalGloss = UNITY_SAMPLE_TEX2DARRAY(_MetallicArray, uvw);
|
|
o.Metallic = metalGloss.r;
|
|
o.Smoothness = metalGloss.a * _Glossiness;
|
|
|
|
// Emission
|
|
float4 emission = UNITY_SAMPLE_TEX2DARRAY(_EmissionArray, uvw);
|
|
o.Emission = emission.rgb * _Brightness;
|
|
}
|
|
|
|
ENDCG
|
|
}
|
|
|
|
FallBack "Standard"
|
|
}
|