From eb84bb298d2b95aec7b2ae12cbf25ac64f25379a Mon Sep 17 00:00:00 2001 From: tylermurphy534 Date: Sun, 6 Nov 2022 15:12:42 -0500 Subject: move to self host --- .../CustomizerPutSliceIndexInUV0_z.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs (limited to 'VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs') diff --git a/VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs b/VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs new file mode 100644 index 00000000..6a2fb77f --- /dev/null +++ b/VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using DigitalOpus.MB.Core; + +namespace DigitalOpus.MB.Core +{ + /// + /// This MeshAssignCustomizer alters the UV data as it is being assigned to the mesh. + /// It appends the Texture Array slice index in the UV.z channel. + /// + /// Shaders must be modified to read the slice index from the UV.z channel to use this. + /// + [CreateAssetMenu(fileName = "MeshAssignCustomizerPutSliceIdxInUV0_z", menuName = "Mesh Baker/Assign To Mesh Customizer/Put Slice Index In UV0.z", order = 1)] + public class CustomizerPutSliceIndexInUV0_z : MB_DefaultMeshAssignCustomizer + { + public override void meshAssign_UV0(int channel, MB_IMeshBakerSettings settings, MB2_TextureBakeResults textureBakeResults, Mesh mesh, Vector2[] uvs, float[] sliceIndexes) + { + if (textureBakeResults.resultType == MB2_TextureBakeResults.ResultType.atlas) + { + mesh.uv = uvs; + } + else + { + { + if (uvs.Length == sliceIndexes.Length) + { + List nuvs = new List(); + for (int i = 0; i < uvs.Length; i++) + { + nuvs.Add(new Vector3(uvs[i].x, uvs[i].y, sliceIndexes[i])); + } + + mesh.SetUVs(0, nuvs); + } + else + { + Debug.LogError("UV slice buffer was not the same size as the uv buffer"); + } + } + } + } + } +} -- cgit v1.2.3-freya