Fix missing shader in build

This commit is contained in:
Nikita Dugin
2026-04-07 17:30:17 +03:00
parent 1a466a5fc6
commit 11ab636608
6 changed files with 130 additions and 50 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 67e1b040a2dcc344dbf491999c0877ba
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,49 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &797018065588400165
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 74135865886311664}
- component: {fileID: 2927522923773808063}
m_Layer: 0
m_Name: VoxelWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &74135865886311664
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 797018065588400165}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2927522923773808063
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 797018065588400165}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62cd563780165844caddc098f92ff23f, type: 3}
m_Name:
m_EditorClassIdentifier: VoxelWorld.Runtime::InfiniteWorld.VoxelWorld.VoxelWorldGenerator
streamTarget: {fileID: 0}
config: {fileID: 11400000, guid: b8cf28a5522134b479c23f017234070c, type: 2}
_terrainShader: {fileID: 4800000, guid: ec80aebd8cb61f44cbfa6b7d5f087211, type: 3}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 91b5caa5457131b4f8c542529f4ad7c3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -41,7 +41,7 @@ namespace InfiniteWorld.VoxelWorld
internal sealed class VoxelWorldAtlas : IDisposable internal sealed class VoxelWorldAtlas : IDisposable
{ {
private const int FallbackTileSize = 32; private const int FallbackTileSize = 32;
private const string ShaderName = "Infinite World/VoxelWorld/TextureArrayUnlit"; // private const string ShaderName = "Infinite World/VoxelWorld/TextureArrayUnlit";
private static readonly VoxelSurfaceType[] SurfaceOrder = private static readonly VoxelSurfaceType[] SurfaceOrder =
{ {
@@ -76,7 +76,7 @@ namespace InfiniteWorld.VoxelWorld
return layerLookup[0][surfaceType]; return layerLookup[0][surfaceType];
} }
public static VoxelWorldAtlas CreateRuntimeAtlas(IReadOnlyList<VoxelBiomeProfile> biomeProfiles) public static VoxelWorldAtlas CreateRuntimeAtlas(IReadOnlyList<VoxelBiomeProfile> biomeProfiles, Shader terrainShader)
{ {
List<VoxelBiomeProfile> sourceBiomes = new List<VoxelBiomeProfile>(); List<VoxelBiomeProfile> sourceBiomes = new List<VoxelBiomeProfile>();
if (biomeProfiles != null) if (biomeProfiles != null)
@@ -134,11 +134,11 @@ namespace InfiniteWorld.VoxelWorld
textureArray.Apply(false, false); textureArray.Apply(false, false);
Shader shader = Shader.Find(ShaderName); Shader shader = terrainShader;
if (shader == null) if (shader == null)
{ {
shader = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Standard"); shader = Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Standard");
Debug.LogError($"Shader '{ShaderName}' was not found. Falling back to '{shader?.name ?? "<missing>"}', but voxel texture array sampling will not work until the shader asset is imported correctly."); Debug.LogError($"Shader was not found. Falling back to '{shader?.name ?? "<missing>"}', but voxel texture array sampling will not work until the shader asset is imported correctly.");
} }
Material material = new Material(shader) Material material = new Material(shader)
@@ -10,6 +10,7 @@ namespace InfiniteWorld.VoxelWorld
[Header("References")] [Header("References")]
[SerializeField] private Transform streamTarget; [SerializeField] private Transform streamTarget;
[SerializeField] private VoxelWorldConfig config; [SerializeField] private VoxelWorldConfig config;
[SerializeField] private Shader _terrainShader;
private readonly Dictionary<Vector2Int, ChunkRuntime> chunks = new Dictionary<Vector2Int, ChunkRuntime>(); private readonly Dictionary<Vector2Int, ChunkRuntime> chunks = new Dictionary<Vector2Int, ChunkRuntime>();
private readonly Dictionary<Vector2Int, RegionRuntime> regions = new Dictionary<Vector2Int, RegionRuntime>(); private readonly Dictionary<Vector2Int, RegionRuntime> regions = new Dictionary<Vector2Int, RegionRuntime>();
@@ -134,7 +135,7 @@ namespace InfiniteWorld.VoxelWorld
} }
atlas?.Dispose(); atlas?.Dispose();
atlas = VoxelWorldAtlas.CreateRuntimeAtlas(biomeProfiles); atlas = VoxelWorldAtlas.CreateRuntimeAtlas(biomeProfiles, _terrainShader);
atlasBiomeCount = atlas.BiomeCount; atlasBiomeCount = atlas.BiomeCount;
RefreshRegionMaterials(); RefreshRegionMaterials();
} }
@@ -383,56 +383,71 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1842209026 --- !u!1001 &6493552143235564167
GameObject: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1842209028}
- component: {fileID: 1842209027}
m_Layer: 0
m_Name: VoxelWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1842209027
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1842209026}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62cd563780165844caddc098f92ff23f, type: 3}
m_Name:
m_EditorClassIdentifier: VoxelWorld.Runtime::InfiniteWorld.VoxelWorld.VoxelWorldGenerator
streamTarget: {fileID: 1331065949}
config: {fileID: 11400000, guid: b8cf28a5522134b479c23f017234070c, type: 2}
--- !u!4 &1842209028
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1842209026}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_Modification:
m_LocalPosition: {x: 0, y: 0, z: 0} serializedVersion: 3
m_LocalScale: {x: 1, y: 1, z: 1} m_TransformParent: {fileID: 0}
m_ConstrainProportionsScale: 0 m_Modifications:
m_Children: [] - target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
m_Father: {fileID: 0} propertyPath: m_LocalPosition.x
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 74135865886311664, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 797018065588400165, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: m_Name
value: VoxelWorld
objectReference: {fileID: 0}
- target: {fileID: 2927522923773808063, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
propertyPath: streamTarget
value:
objectReference: {fileID: 1331065949}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 91b5caa5457131b4f8c542529f4ad7c3, type: 3}
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_Roots: m_Roots:
- {fileID: 1331065949} - {fileID: 1331065949}
- {fileID: 47249972} - {fileID: 47249972}
- {fileID: 1842209028} - {fileID: 6493552143235564167}