This commit is contained in:
unknown
2026-04-16 18:19:23 +05:00
parent 6c3f72385e
commit 087db550f1
43 changed files with 1676 additions and 58 deletions

View File

@@ -0,0 +1,55 @@
Shader "Blocks/VoxelLit"
{
Properties
{
_MainTexArray ("Texture Array", 2DArray) = "" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.0
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Standard surface shader с кастомным vertex для передачи texIndex
#pragma surface surf Standard fullforwardshadows vertex:vert
#pragma target 3.5
#pragma require 2darray
UNITY_DECLARE_TEX2DARRAY(_MainTexArray);
struct Input
{
float2 uv_MainTexArray; // стандартный UV (0-1 по грани)
float texIndex; // индекс слоя в Texture2DArray
};
half _Glossiness;
half _Metallic;
// Vertex-функция: читаем texIndex из канала UV1 (mesh.uv2)
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
o.uv_MainTexArray = v.texcoord.xy;
o.texIndex = v.texcoord1.x; // UV1.x = индекс текстуры
}
void surf(Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = UNITY_SAMPLE_TEX2DARRAY(
_MainTexArray,
float3(IN.uv_MainTexArray, IN.texIndex)
);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}