generated from raccoon/vrchat-project-template
New standard shader with flipbook animation
This commit is contained in:
73
Assets/dbl-world/shaders/minecraft/StandardSurf.shader
Normal file
73
Assets/dbl-world/shaders/minecraft/StandardSurf.shader
Normal file
@@ -0,0 +1,73 @@
|
||||
Shader "Custom/StandardSurf"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
_MainTex("Albedo (RGBA)", 2D) = "white" {}
|
||||
_Glossiness("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic("Metallic", Range(0,1)) = 0.0
|
||||
|
||||
[NoScaleOffset]_DiffuseArray("Transparent Albedo (RGBA)", 2DArray) = "" {}
|
||||
_FlipbookFPS("Flipbook FPS", Integer) = 30
|
||||
_FlipbookFrames("Flipbook Frames", Integer) = 30
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
|
||||
LOD 200
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Back
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard fullforwardshadows alpha:fade
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
UNITY_DECLARE_TEX2DARRAY(_DiffuseArray);
|
||||
|
||||
int _FlipbookFPS;
|
||||
int _FlipbookFrames;
|
||||
|
||||
sampler2D _MainTex;
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
// 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_MainTex, frame);
|
||||
|
||||
float4 diff = UNITY_SAMPLE_TEX2DARRAY(_DiffuseArray, uvw) * _Color;
|
||||
o.Albedo = diff.rgb;
|
||||
o.Alpha = diff.a;
|
||||
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
// o.Alpha = c.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
FallBack "Standard"
|
||||
}
|
||||
Reference in New Issue
Block a user