diff options
| author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
|---|---|---|
| committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-11-06 15:12:42 -0500 |
| commit | eb84bb298d2b95aec7b2ae12cbf25ac64f25379a (patch) | |
| tree | efd616a157df06ab661c6d56651853431ac6b08b /VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers | |
| download | unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.gz unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.tar.bz2 unityprojects-eb84bb298d2b95aec7b2ae12cbf25ac64f25379a.zip | |
move to self host
Diffstat (limited to 'VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers')
2 files changed, 55 insertions, 0 deletions
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 +{ + /// <summary> + /// 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. + /// </summary> + [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<Vector3> nuvs = new List<Vector3>(); + 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"); + } + } + } + } + } +} diff --git a/VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs.meta b/VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs.meta new file mode 100644 index 00000000..d0eb1f29 --- /dev/null +++ b/VRCSDK3Worlds/Assets/MeshBaker/scripts/AssignToMeshCustomizers/CustomizerPutSliceIndexInUV0_z.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e5361140dc65f264fbaef9318fb07254 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |