### Install UnitySplats from Git URL Source: https://github.com/arloopa/unitysplats/blob/main/README.md After installing Unity.WebP, install UnitySplats using this Git URL. This installs the repository's current default branch. ```text https://github.com/arloopa/UnitySplats.git ``` -------------------------------- ### Install from Git URL with automatic Unity.WebP resolution - manifest.json Source: https://github.com/arloopa/unitysplats/blob/main/README.md Add the OpenUPM scoped registry for the com.netpyoung scope and the UnitySplats Git URL to the target project's Packages/manifest.json. Unity then installs Unity.WebP automatically when it resolves UnitySplats. ```json { "scopedRegistries": [ { "name": "OpenUPM", "url": "https://package.openupm.com", "scopes": [ "com.netpyoung" ] } ], "dependencies": { "com.arloopa.unitysplats": "https://github.com/arloopa/UnitySplats.git" } } ``` -------------------------------- ### Install Unity.WebP from Git URL Source: https://github.com/arloopa/unitysplats/blob/main/README.md Install Unity.WebP first because Unity Package Manager cannot resolve one Git package as a transitive dependency of another Git package. Use this URL in the Package Manager's 'Install package from git URL...' option. ```text https://github.com/netpyoung/unity.webp.git?path=unity_project/Assets/unity.webp#0.3.22 ``` -------------------------------- ### Asynchronous Upload Usage Example Source: https://github.com/arloopa/unitysplats Example of asynchronous upload with progress-visible rendering. CreateResource is normally called via GsplatResourceManager; UploadDataAsync yields per batch. ```csharp // Asynchronous upload with progress-visible rendering: var resource = asset.CreateResource(); // normally via GsplatResourceManager Task upload = asset.UploadDataAsync(resource); // yields per batch (await Task.Yield()) ``` -------------------------------- ### Install both Git dependencies from manifest.json Source: https://github.com/arloopa/unitysplats/blob/main/README.md Add both direct dependencies to the target project's Packages/manifest.json. Keep the project's other dependencies in the same object. ```json { "dependencies": { "com.netpyoung.webp": "https://github.com/netpyoung/unity.webp.git?path=unity_project/Assets/unity.webp#0.3.22", "com.arloopa.unitysplats": "https://github.com/arloopa/UnitySplats.git" } } ``` -------------------------------- ### LoadUnpackedSog usage example from disk Source: https://github.com/arloopa/unitysplats Loads an unpacked SOG directory from disk by reading meta.json and resolving file references with File.ReadAllBytes. ```csharp // Unpacked SOG directory on disk: string meta = File.ReadAllText(Path.Combine(sogDir, "meta.json")); GsplatAsset asset = GsplatRuntimeLoader.LoadUnpackedSog(meta, fileName => File.ReadAllBytes(Path.Combine(sogDir, fileName)), CompressionMode.Spark); ``` -------------------------------- ### Load(Stream) usage example with UnityWebRequest Source: https://github.com/arloopa/unitysplats Shows loading a .spz file from a URL using UnityWebRequest and assigning the resulting asset to a renderer. Requires the UnityEngine.Networking namespace. ```csharp using UnityEngine.Networking; var request = UnityWebRequest.Get("https://example.com/model.spz"); yield return request.SendWebRequest(); if (request.result == UnityWebRequest.Result.Success) { GsplatAsset asset = GsplatRuntimeLoader.Load(request.downloadHandler.data, GsplatFileFormat.Spz, CompressionMode.Spark); renderer.GsplatAsset = asset; } ``` -------------------------------- ### LoadFile usage example Source: https://github.com/arloopa/unitysplats Loads a PLY file with Spark compression and assigns it to a renderer. Auto coordinates resolve to RUB for PLY. ```csharp using Gsplat; GsplatAsset asset = GsplatRuntimeLoader.LoadFile( "/storage/emulated/0/Download/scene.ply", CompressionMode.Spark); // Auto coordinates: RUB for PLY renderer.GsplatAsset = asset; ``` -------------------------------- ### GsplatResourceManager usage example Source: https://github.com/arloopa/unitysplats Shows two renderers sharing one asset receive the same GsplatResource. Release twice; a third call would warn: "Trying to release a GPU resource that is not cached." ```csharp // Two renderers sharing one asset receive the same GsplatResource: GsplatResource a = GsplatResourceManager.Get(asset); GsplatResource b = GsplatResourceManager.Get(asset); // same instance, RefCount == 2 GsplatResourceManager.Release(asset); GsplatResourceManager.Release(asset); // third call would warn: "Trying to release a GPU resource that is not cached." ``` -------------------------------- ### GsplatRenderer.ActiveSplatCount Source: https://github.com/arloopa/unitysplats/blob/main/README.md Gets the number of active splats after setting ranges. ```APIDOC ## GsplatRenderer.ActiveSplatCount ### Description Gets the number of active splats after setting ranges. ### Method Property ### Endpoint GsplatRenderer.ActiveSplatCount ### Returns - **uint** - The configured active splat count. ### Usage Example ```csharp uint configured = renderer.ActiveSplatCount; ``` ``` -------------------------------- ### GsplatRenderer.ResidentActiveSplatCount Source: https://github.com/arloopa/unitysplats/blob/main/README.md Gets the number of resident active splats after setting ranges. ```APIDOC ## GsplatRenderer.ResidentActiveSplatCount ### Description Gets the number of resident active splats after setting ranges. ### Method Property ### Endpoint GsplatRenderer.ResidentActiveSplatCount ### Returns - **uint** - The resident active splat count. ### Usage Example ```csharp uint resident = renderer.ResidentActiveSplatCount; ``` ``` -------------------------------- ### GsplatResourceManager class definition Source: https://github.com/arloopa/unitysplats Static reference-counted cache keyed by GsplatAsset. Get increments the count and returns the cached resource, calling asset.CreateResource() on first use. Release decrements; at zero it disposes the resource and removes the entry. ```csharp public static class GsplatResourceManager { public static GsplatResource Get(GsplatAsset asset) public static void Release(GsplatAsset asset) } ``` -------------------------------- ### Load runtime GsplatAsset and assign to renderer Source: https://github.com/arloopa/unitysplats/blob/main/README.md Loads a splat asset from a filesystem path using GsplatRuntimeLoader.LoadFile with CompressionMode.Spark, assigns it to a GsplatRenderer component, and cleans up by nulling the asset reference and destroying the asset when no longer used. Must run on the main thread. ```csharp using Gsplat; GsplatAsset asset = GsplatRuntimeLoader.LoadFile( absolutePath, CompressionMode.Spark); GsplatRenderer renderer = GetComponent(); renderer.GsplatAsset = asset; // When the renderer no longer uses the runtime asset: renderer.GsplatAsset = null; Destroy(asset); ``` -------------------------------- ### FormatFromPath method signature Source: https://github.com/arloopa/unitysplats Returns the format parsed from the file extension. Throws ArgumentException if path is null or whitespace. ```csharp public static GsplatFileFormat FormatFromPath(string path) ``` -------------------------------- ### GsplatRuntimeLoader.LoadFile Source: https://github.com/arloopa/unitysplats/blob/main/README.md Loads a splat asset from a filesystem path into an in-memory GsplatAsset. Must be called on the main thread. ```APIDOC ## GsplatRuntimeLoader.LoadFile ### Description Loads a splat asset from a filesystem path into an in-memory GsplatAsset. Must be called on the main thread. ### Method LoadFile ### Endpoint GsplatRuntimeLoader.LoadFile(absolutePath, CompressionMode) ### Parameters #### Arguments - **absolutePath** (string) - Required - The filesystem path to the splat file. - **CompressionMode** (CompressionMode) - Required - The compression mode to use (e.g., Spark). ### Returns - **GsplatAsset** - The loaded in-memory splat asset. ### Usage Example ```csharp using Gsplat; GsplatAsset asset = GsplatRuntimeLoader.LoadFile( absolutePath, CompressionMode.Spark); ``` ``` -------------------------------- ### Load(byte[], string extensionOrFormat) Source: https://github.com/arloopa/unitysplats Loads a Gaussian-splat file from a byte array, deriving the format from a string extension or format name. Must be called on Unity's main thread. ```APIDOC ## Load(byte[], string extensionOrFormat) ### Description Loads a Gaussian-splat file from a byte array, deriving the format from a string extension or format name. Must be called on Unity's main thread. ### Method Load ### Signature ```csharp public static GsplatAsset Load( byte[] bytes, string extensionOrFormat, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` ### Parameters - `bytes` (byte[]) - Required - Complete encoded file bytes - `extensionOrFormat` (string) - Required - Format hint; may be `"ply"`, `".ply"`, `"sog"`, `"spz"`, `"glb"`, or `"auto"` (case-insensitive) - `compression` (CompressionMode) - Optional - Asset representation (default: `CompressionMode.Spark`) - `sourceCoordinates` (SourceCoordinates) - Optional - Source coordinate frame (default: `SourceCoordinates.Unspecified`) - `progress` (ProgressCallback) - Optional - Progress callback (default: `null`) ### Returns - `GsplatAsset` - The created asset ### Exceptions - `ArgumentNullException` - if `bytes` is `null` ``` -------------------------------- ### Abstract and virtual methods for depth and order Source: https://github.com/arloopa/unitysplats Defines the public API for setting up material property blocks, computing depth keys, and initializing order. The virtual ComputeDepth overload delegates to the abstract one using resource.UploadedCount. InitOrder rebuilds the sequential source-ID order, applies cutouts, and optionally recomputes bounds via the UPDATE_BOUNDS keyword. ```csharp public abstract void SetupMaterialPropertyBlock(MaterialPropertyBlock propertyBlock, GsplatResource resource); public abstract void ComputeDepth(CommandBuffer cmd, Matrix4x4 matrixMv, ISorterResource sorterResource, GsplatResource resource); public virtual void ComputeDepth(CommandBuffer cmd, Matrix4x4 matrixMv, uint activeCount, ISorterResource sorterResource, GsplatResource resource) => ComputeDepth(cmd, matrixMv, sorterResource, resource); public abstract void InitOrder(ISorterResource sorterResource, GsplatResource resource, bool updateBounds); ``` -------------------------------- ### GsplatRuntimeLoader.Load(byte[], ...) Source: https://github.com/arloopa/unitysplats/blob/main/README.md Loads a splat asset from a byte array. Use this for URI-based sources (e.g., HTTP, Android StreamingAssets) after reading with UnityWebRequest. ```APIDOC ## GsplatRuntimeLoader.Load(byte[], ...) ### Description Loads a splat asset from a byte array. Use this for URI-based sources (e.g., HTTP, Android StreamingAssets) after reading with UnityWebRequest. ### Method Load ### Endpoint GsplatRuntimeLoader.Load(byte[], ...) ### Parameters #### Arguments - **byte[]** (byte[]) - Required - The raw splat data. - **...** (params) - Optional - Additional parameters as needed. ### Returns - **GsplatAsset** - The loaded in-memory splat asset. ### Usage Example ```csharp // Example not provided in source. ``` ``` -------------------------------- ### Load(byte[]) method signature Source: https://github.com/arloopa/unitysplats Loads a splat from complete encoded file bytes. Format defaults to Auto, which sniffs the magic. Throws ArgumentNullException if bytes is null. ```csharp public static GsplatAsset Load( byte[] bytes, GsplatFileFormat format = GsplatFileFormat.Auto, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` -------------------------------- ### GsplatAsset.LoadFromPly Source: https://github.com/arloopa/unitysplats Reads a binary little-endian PLY file and populates the asset. Default source coordinates are RUF (already-Unity) on this abstract contract; subclasses that self-load default differently. ```APIDOC ## LoadFromPly ### Description Reads a binary little-endian PLY file and populates the asset. Default source coordinates are RUF (already-Unity) on this abstract contract; subclasses that self-load default differently. ### Method LoadFromPly ### Signature ```csharp public abstract void LoadFromPly(string plyPath, ProgressCallback progressCallback = null, SourceCoordinates sourceCoordinates = SourceCoordinates.RUF); ``` ### Parameters - `plyPath` (string) - Required - Path to the PLY file. - `progressCallback` (ProgressCallback) - Optional - Callback for progress reporting. - `sourceCoordinates` (SourceCoordinates) - Optional - Source coordinate system; default is `RUF`. ``` -------------------------------- ### LoadFile Source: https://github.com/arloopa/unitysplats Loads a Gaussian-splat file from a filesystem path and returns a GsplatAsset. Must be called on Unity's main thread. ```APIDOC ## LoadFile ### Description Loads a Gaussian-splat file from a filesystem path and returns a GsplatAsset. Must be called on Unity's main thread. ### Method LoadFile ### Signature ```csharp public static GsplatAsset LoadFile( string path, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` ### Parameters - `path` (string) - Required - Absolute filesystem path to the splat file - `compression` (CompressionMode) - Optional - Asset representation: `Spark` or `Uncompressed` (default: `CompressionMode.Spark`) - `sourceCoordinates` (SourceCoordinates) - Optional - Source frame; `Unspecified` resolves to `LUF` for GLB, `RUB` otherwise (default: `SourceCoordinates.Unspecified`) - `progress` (ProgressCallback) - Optional - Progress callback `(string info, float progress)` (default: `null`) ### Returns - `GsplatAsset` - The created asset; `asset.name` is set to `Path.GetFileNameWithoutExtension(path)` ### Exceptions - `ArgumentException` - if `path` is null/whitespace - All exceptions listed for `Load(Stream, ...)` (including `NotSupportedException` for unknown extensions and `InvalidDataException` for unrecognized streams) ### Request Example ```csharp using Gsplat; GsplatAsset asset = GsplatRuntimeLoader.LoadFile( "/storage/emulated/0/Download/scene.ply", CompressionMode.Spark); // Auto coordinates: RUB for PLY renderer.GsplatAsset = asset; ``` ``` -------------------------------- ### Load(Stream) method signature Source: https://github.com/arloopa/unitysplats Loads a Gaussian splat asset from a stream. The stream must be readable; non-seekable or positioned streams are copied to a MemoryStream. Throws ArgumentNullException, ArgumentException, InvalidDataException, NotSupportedException, or decode/validation exceptions. On failure, the partially built asset is destroyed. ```csharp public static GsplatAsset Load( Stream stream, GsplatFileFormat format = GsplatFileFormat.Auto, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` -------------------------------- ### LoadFile method signature Source: https://github.com/arloopa/unitysplats Loads a splat file from an absolute path. Returns a GsplatAsset with name set to the file name without extension. Throws ArgumentException for null/whitespace path and all exceptions from Load(Stream, ...). ```csharp public static GsplatAsset LoadFile( string path, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` -------------------------------- ### Protected abstract upload helpers and shader property IDs Source: https://github.com/arloopa/unitysplats Protected abstract methods for asynchronous and synchronous data upload, plus static readonly shader property IDs for bounds, cutouts, and cutout count. The m_kernelInitOrder field is used for the init order kernel. ```csharp protected abstract Task _UploadDataAsync(GsplatResource resource, CancellationToken cancellationToken); protected abstract void _UploadData(GsplatResource resource); protected int m_kernelInitOrder; static readonly protected int k_boundsBuffer = Shader.PropertyToID("_BoundsBuffer"); static readonly protected int k_cutoutsBuffer = Shader.PropertyToID("_CutoutsBuffer"); static readonly protected int k_cutoutsCount = Shader.PropertyToID("_CutoutsCount"); ``` -------------------------------- ### Load(byte[]) Source: https://github.com/arloopa/unitysplats Loads a Gaussian-splat file from a byte array and returns a GsplatAsset. Must be called on Unity's main thread. ```APIDOC ## Load(byte[]) ### Description Loads a Gaussian-splat file from a byte array and returns a GsplatAsset. Must be called on Unity's main thread. ### Method Load ### Signature ```csharp public static GsplatAsset Load( byte[] bytes, GsplatFileFormat format = GsplatFileFormat.Auto, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` ### Parameters - `bytes` (byte[]) - Required - Complete encoded file bytes - `format` (GsplatFileFormat) - Optional - Format hint; `Auto` sniffs the magic (default: `GsplatFileFormat.Auto`) - `compression` (CompressionMode) - Optional - Asset representation (default: `CompressionMode.Spark`) - `sourceCoordinates` (SourceCoordinates) - Optional - Source coordinate frame (default: `SourceCoordinates.Unspecified`) - `progress` (ProgressCallback) - Optional - Progress callback (default: `null`) ### Returns - `GsplatAsset` - The created asset ### Exceptions - `ArgumentNullException` - if `bytes` is `null` ``` -------------------------------- ### GsplatRuntimeLoader.Load(Stream, ...) Source: https://github.com/arloopa/unitysplats/blob/main/README.md Loads a splat asset from a stream. Use for other input forms. ```APIDOC ## GsplatRuntimeLoader.Load(Stream, ...) ### Description Loads a splat asset from a stream. Use for other input forms. ### Method Load ### Endpoint GsplatRuntimeLoader.Load(Stream, ...) ### Parameters #### Arguments - **Stream** (Stream) - Required - The stream containing splat data. - **...** (params) - Optional - Additional parameters as needed. ### Returns - **GsplatAsset** - The loaded in-memory splat asset. ### Usage Example ```csharp // Example not provided in source. ``` ``` -------------------------------- ### GsplatAsset.CreateResource Source: https://github.com/arloopa/unitysplats Returns the matching GPU resource (GsplatResourceUncompressed or GsplatResourceSpark). ```APIDOC ## CreateResource ### Description Returns the matching GPU resource (`GsplatResourceUncompressed` or `GsplatResourceSpark`). ### Method CreateResource ### Signature ```csharp public abstract GsplatResource CreateResource(); ``` ``` -------------------------------- ### Load(byte[], string) method signature Source: https://github.com/arloopa/unitysplats Loads a splat from bytes, deriving the format from a string extension or format name. Accepts "ply", ".ply", "sog", "spz", "glb", or "auto" (case-insensitive). ```csharp public static GsplatAsset Load( byte[] bytes, string extensionOrFormat, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` -------------------------------- ### Awaiting async upload with disposal fault handling Source: https://github.com/arloopa/unitysplats Shows the recommended pattern for awaiting an async upload. The await is safe because the task faults with OperationCanceledException if the resource is disposed mid-upload. ```csharp if (!resource.Uploaded) await asset.UploadDataAsync(resource); // safe to await; faults on disposal ``` -------------------------------- ### GsplatRuntimeLoader.LoadUnpackedSog(...) Source: https://github.com/arloopa/unitysplats/blob/main/README.md Loads a splat asset from an unpacked SOG format. Use for other input forms. ```APIDOC ## GsplatRuntimeLoader.LoadUnpackedSog(...) ### Description Loads a splat asset from an unpacked SOG format. Use for other input forms. ### Method LoadUnpackedSog ### Endpoint GsplatRuntimeLoader.LoadUnpackedSog(...) ### Parameters #### Arguments - **...** (params) - Required - Parameters for the unpacked SOG input. ### Returns - **GsplatAsset** - The loaded in-memory splat asset. ### Usage Example ```csharp // Example not provided in source. ``` ``` -------------------------------- ### LoadUnpackedSog method signature Source: https://github.com/arloopa/unitysplats Loads an unpacked SOG meta.json with a caller-provided file resolver. The resolver must return the bytes for a referenced filename. Throws exceptions from the underlying reader. ```csharp /// Loads an unpacked SOG meta.json with a caller-provided file resolver. public static GsplatAsset LoadUnpackedSog( string metadata, Func resolveFile, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` -------------------------------- ### GsplatRenderer.GsplatAsset Source: https://github.com/arloopa/unitysplats/blob/main/README.md Property to assign or retrieve the GsplatAsset to render. Must be set on the main thread. ```APIDOC ## GsplatRenderer.GsplatAsset ### Description Property to assign or retrieve the GsplatAsset to render. Must be set on the main thread. ### Method Property ### Endpoint GsplatRenderer.GsplatAsset ### Parameters #### Property Value - **GsplatAsset** (GsplatAsset) - Required - The asset to render. Set to null to clear. ### Usage Example ```csharp GsplatRenderer renderer = GetComponent(); renderer.GsplatAsset = asset; // When the renderer no longer uses the runtime asset: renderer.GsplatAsset = null; Destroy(asset); ``` ``` -------------------------------- ### FormatFromPath Source: https://github.com/arloopa/unitysplats Determines the GsplatFileFormat from a file path by its extension. Throws an exception for invalid paths. ```APIDOC ## FormatFromPath ### Description Determines the GsplatFileFormat from a file path by its extension. Throws an exception for invalid paths. ### Method FormatFromPath ### Signature ```csharp public static GsplatFileFormat FormatFromPath(string path) ``` ### Parameters - **path** (string) - Required - The file path to inspect. ### Returns Returns `ParseFormat(Path.GetExtension(path))`. Throws `ArgumentException` if `path` is null/whitespace. ``` -------------------------------- ### ParseFormat method signature Source: https://github.com/arloopa/unitysplats Parses format strings like "auto", "ply", "sog", "spz", "glb" (case-insensitive, leading dots ignored). Empty/null returns Auto. Throws NotSupportedException for other values. ```csharp public static GsplatFileFormat ParseFormat(string extensionOrFormat) ``` -------------------------------- ### GsplatAssetUncompressed.InitOrder Source: https://github.com/arloopa/unitysplats Initializes the sorting order for the splat rendering. ```APIDOC ## InitOrder ### Description Initializes the sorting order for the splat rendering. ### Method InitOrder ### Signature `public override void InitOrder(ISorterResource sorterResource, GsplatResource resource, bool updateBounds)` ### Parameters - **sorterResource** (ISorterResource) - Required - The sorter resource. - **resource** (GsplatResource) - Required - The GPU resource. - **updateBounds** (bool) - Required - Whether to update bounds. ``` -------------------------------- ### Set active source ranges on GsplatRenderer Source: https://github.com/arloopa/unitysplats/blob/main/README.md Selects an exact union of source-splat ranges using GsplatRenderer.SetActiveRanges with half-open [Offset, Offset + Count) semantics. Ranges are normalized when overlapping or touching. Updates Unity GPU buffers and must run on the main thread; compute cutouts are bypassed while explicit ranges are enabled. ```csharp renderer.SetActiveRanges(new[] { new GsplatActiveRange(offset: 1000, count: 500), new GsplatActiveRange(offset: 3000, count: 250) }); uint configured = renderer.ActiveSplatCount; uint resident = renderer.ResidentActiveSplatCount; renderer.ClearActiveRanges(); ``` -------------------------------- ### GsplatAssetUncompressed.SetupMaterialPropertyBlock Source: https://github.com/arloopa/unitysplats Binds the splat data buffers or textures to a material property block for rendering. ```APIDOC ## SetupMaterialPropertyBlock ### Description Binds the splat data buffers or textures to a material property block for rendering. ### Method SetupMaterialPropertyBlock ### Signature `public override void SetupMaterialPropertyBlock(MaterialPropertyBlock propertyBlock, GsplatResource resource)` ### Parameters - **propertyBlock** (MaterialPropertyBlock) - Required - The property block to bind data to. - **resource** (GsplatResource) - Required - The GPU resource containing the splat data. ### Remarks - Binds `_PositionBuffer`, `_ScaleBuffer`, `_RotationBuffer`, `_ColorBuffer`, and (when `SHBands > 0`) `_SHBuffer`. - On the texture path, binds `_PositionTexture`, `_ScaleTexture`, `_RotationTexture`, `_ColorTexture`, `_GsplatTextureWidth`, and `_SHTexture`/`_SHTextureWidth`. ``` -------------------------------- ### GsplatAsset Properties Source: https://github.com/arloopa/unitysplats Properties for the abstract GsplatAsset class. Compression is abstract; GsplatMaterial returns the material for the compression mode; Materials returns the five SH-band-indexed variant materials. ```csharp public abstract CompressionMode Compression { get; } public GsplatMaterial GsplatMaterial => GsplatSettings.Instance.Materials[(int)Compression]; public Material[] Materials => GsplatMaterial.Materials[SHBands]; ``` -------------------------------- ### GsplatResource abstract class definition Source: https://github.com/arloopa/unitysplats Base class for all GPU resources in the gsplat asset system. Tracks upload state, async upload task, and disposal. BeginDispose() cancels in-flight async uploads via an internal CancellationTokenSource, causing OperationCanceledException. ```csharp public abstract class GsplatResource { public bool Uploaded; public uint UploadedCount; public Task UploadTask { get; private set; } = Task.CompletedTask; public bool Disposed { get; private set; } protected bool BeginDispose(); public abstract void Dispose(); } ``` -------------------------------- ### ResolveCoordinates method signature Source: https://github.com/arloopa/unitysplats Returns sourceCoordinates unchanged unless Unspecified, in which case returns LUF for Glb format and RUB for all others. ```csharp public static SourceCoordinates ResolveCoordinates( GsplatFileFormat format, SourceCoordinates sourceCoordinates) ``` -------------------------------- ### UploadData and UploadDataAsync Source: https://github.com/arloopa/unitysplats Synchronous and asynchronous upload methods. UploadData sets Uploaded and UploadedCount; UploadDataAsync throws ArgumentNullException on null resource and ObjectDisposedException on disposed resource, and faults with OperationCanceledException if disposed mid-upload. ```csharp public void UploadData(GsplatResource resource) { if (resource.Uploaded) return; _UploadData(resource); resource.Uploaded = true; resource.UploadedCount = SplatCount; } public Task UploadDataAsync(GsplatResource resource) { if (resource == null) throw new ArgumentNullException(nameof(resource)); if (resource.Disposed) throw new ObjectDisposedException(resource.GetType().Name); if (resource.Uploaded) return resource.UploadTask; var cancellationToken = resource.BeginAsyncUpload(); resource.Uploaded = true; Task task; try { task = _UploadDataAsync(resource, cancellationToken); } catch (Exception exception) { task = Task.FromException(exception); } resource.OwnUploadTask(task); return task; } ``` -------------------------------- ### Buffer Helper Signatures Source: https://github.com/arloopa/unitysplats Buffer helper methods for cutouts and bounds. UpdateCutoutsBuffer creates or reuses a structured GraphicsBuffer and binds it; UpdateBoundsBuffer fills the buffer with sortable encoding and binds _BoundsBuffer. ```csharp public GraphicsBuffer UpdateCutoutsBuffer(GraphicsBuffer cutoutsBuffer, GsplatCutout.ShaderData[] cutoutsData) public void UpdateBoundsBuffer(GraphicsBuffer BoundsBuffer) ``` -------------------------------- ### GsplatAsset.LoadFromPlyBytes Source: https://github.com/arloopa/unitysplats Loads PLY data from a byte array. The base implementation throws NotSupportedException; overridden by GsplatAssetUncompressed and GsplatAssetSpark. ```APIDOC ## LoadFromPlyBytes ### Description Loads PLY data from a byte array. The base implementation throws `NotSupportedException`; overridden by `GsplatAssetUncompressed` and `GsplatAssetSpark`. ### Method LoadFromPlyBytes ### Signature ```csharp public virtual void LoadFromPlyBytes(byte[] plyBytes, ProgressCallback progressCallback = null, SourceCoordinates sourceCoordinates = SourceCoordinates.RUF) => throw new NotSupportedException($"{GetType().Name} does not support loading PLY from bytes."); ``` ### Parameters - `plyBytes` (byte[]) - Required - The PLY data as a byte array. - `progressCallback` (ProgressCallback) - Optional - Callback for progress reporting. - `sourceCoordinates` (SourceCoordinates) - Optional - Source coordinate system; default is `RUF`. ``` -------------------------------- ### LoadUnpackedSog Source: https://github.com/arloopa/unitysplats Loads an unpacked SOG meta.json with a caller-provided file resolver. Useful for loading SOG assets from disk or remote sources. ```APIDOC ## LoadUnpackedSog ### Description Loads an unpacked SOG `meta.json` with a caller-provided file resolver. Useful for loading SOG assets from disk or remote sources. ### Method LoadUnpackedSog ### Signature ```csharp public static GsplatAsset LoadUnpackedSog( string metadata, Func resolveFile, CompressionMode compression = CompressionMode.Spark, SourceCoordinates sourceCoordinates = SourceCoordinates.Unspecified, ProgressCallback progress = null) ``` ### Parameters - **metadata** (string) - Required - The unpacked SOG `meta.json` text - **resolveFile** (Func) - Required - Resolves a referenced filename to its bytes (e.g., reads from disk or `UnityWebRequest`) - **compression** (CompressionMode) - Optional (default: `Spark`) - Asset representation - **sourceCoordinates** (SourceCoordinates) - Optional (default: `Unspecified`) - Source frame - **progress** (ProgressCallback) - Optional (default: `null`) - Progress callback ### Request Example ```csharp // Unpacked SOG directory on disk: string meta = File.ReadAllText(Path.Combine(sogDir, "meta.json")); GsplatAsset asset = GsplatRuntimeLoader.LoadUnpackedSog(meta, fileName => File.ReadAllBytes(Path.Combine(sogDir, fileName)), CompressionMode.Spark); ``` ``` -------------------------------- ### GsplatAssetUncompressed.LoadFromPlyBytes Source: https://github.com/arloopa/unitysplats Loads splat data from raw PLY bytes, throwing an exception if the byte array is null or empty. ```APIDOC ## LoadFromPlyBytes ### Description Loads splat data from raw PLY bytes, throwing an exception if the byte array is null or empty. ### Method LoadFromPlyBytes ### Signature `public override void LoadFromPlyBytes(byte[] plyBytes, ...)` ### Parameters - **plyBytes** (byte[]) - Required - The PLY file content as a byte array. - Additional parameters may be present (ellipsis). ### Exceptions - `ArgumentException` if `plyBytes` is null or empty. ``` -------------------------------- ### GsplatAssetUncompressed.CreateResource Source: https://github.com/arloopa/unitysplats Creates a new uncompressed GPU resource for the splat data. ```APIDOC ## CreateResource ### Description Creates a new uncompressed GPU resource for the splat data. ### Method CreateResource ### Signature `public override GsplatResource CreateResource()` ### Parameters None ### Returns - **GsplatResource** - A new `GsplatResourceUncompressed` instance with the current `SplatCount` and `SHBands`. ``` -------------------------------- ### GsplatAssetUncompressed.LoadFromPly Source: https://github.com/arloopa/unitysplats Loads splat data from a PLY file, throwing an exception for files larger than 2 GiB. ```APIDOC ## LoadFromPly ### Description Loads splat data from a PLY file, throwing an exception for files larger than 2 GiB. ### Method LoadFromPly ### Signature `public override void LoadFromPly(string plyPath, ProgressCallback progressCallback = null, SourceCoordinates sourceCoordinates = SourceCoordinates.RUF)` ### Parameters - **plyPath** (string) - Required - Path to the PLY file. - **progressCallback** (ProgressCallback) - Optional - Callback for progress reporting. - **sourceCoordinates** (SourceCoordinates) - Optional - Coordinate system of the source (default: RUF). ### Exceptions - `NotSupportedException` if the file size is >= 2 GiB. ``` -------------------------------- ### GsplatRenderer.SetActiveRanges Source: https://github.com/arloopa/unitysplats/blob/main/README.md Selects an exact union of source-splat ranges without creating another asset. Ranges use half-open [Offset, Offset + Count) semantics and are normalized when they overlap or touch. Must run on the main thread. ```APIDOC ## GsplatRenderer.SetActiveRanges ### Description Selects an exact union of source-splat ranges without creating another asset. Ranges use half-open [Offset, Offset + Count) semantics and are normalized when they overlap or touch. Must run on the main thread. ### Method SetActiveRanges ### Endpoint GsplatRenderer.SetActiveRanges(GsplatActiveRange[]) ### Parameters #### Arguments - **ranges** (GsplatActiveRange[]) - Required - Array of active ranges. ### Usage Example ```csharp renderer.SetActiveRanges(new[] { new GsplatActiveRange(offset: 1000, count: 500), new GsplatActiveRange(offset: 3000, count: 250) }); ``` ``` -------------------------------- ### GsplatAsset.UpdateCutoutsBuffer Source: https://github.com/arloopa/unitysplats Creates (or reuses) a structured GraphicsBuffer of GsplatCutout.ShaderDataSize stride, uploads cutoutsData, and binds it plus _CutoutsCount to GsplatMaterial.InitOrderShader kernel m_kernelInitOrder. ```APIDOC ## UpdateCutoutsBuffer ### Description Creates (or reuses, when `count` matches) a structured `GraphicsBuffer` of `GsplatCutout.ShaderDataSize` stride, uploads `cutoutsData`, and binds it plus `_CutoutsCount` to `GsplatMaterial.InitOrderShader` kernel `m_kernelInitOrder`. ### Method UpdateCutoutsBuffer ### Signature ```csharp public GraphicsBuffer UpdateCutoutsBuffer(GraphicsBuffer cutoutsBuffer, GsplatCutout.ShaderData[] cutoutsData) ``` ### Parameters - `cutoutsBuffer` (GraphicsBuffer) - Required - The buffer to update or reuse. - `cutoutsData` (GsplatCutout.ShaderData[]) - Required - The cutout data to upload. ``` -------------------------------- ### ParseFormat Source: https://github.com/arloopa/unitysplats Parses a string into a GsplatFileFormat. Accepts 'auto', 'ply', 'sog', 'spz', 'glb' (case and leading dots ignored). ```APIDOC ## ParseFormat ### Description Parses a string into a GsplatFileFormat. Accepts 'auto', 'ply', 'sog', 'spz', 'glb' (case and leading dots ignored). ### Method ParseFormat ### Signature ```csharp public static GsplatFileFormat ParseFormat(string extensionOrFormat) ``` ### Parameters - **extensionOrFormat** (string) - Required - The extension or format string to parse. ### Returns Parses `"auto"`, `"ply"`, `"sog"`, `"spz"`, `"glb"` (leading dots and case ignored). Empty/null input returns `GsplatFileFormat.Auto`. Throws `NotSupportedException` for any other value: > `Unsupported Gaussian-splat format '{extensionOrFormat}'. Expected PLY, SOG, SPZ, or GLB.` ``` -------------------------------- ### PlyHeaderInfo Constructor Source: https://github.com/arloopa/unitysplats Parses the ASCII PLY header from a stream to extract vertex count, property counts, and byte offsets for position, color, SH, opacity, scale, and rotation properties. This constructor is part of the GsplatAsset class and is used by format readers. ```APIDOC ## [CONSTRUCTOR] PlyHeaderInfo(Stream fs) ### Description Parses the ASCII PLY header from the stream to populate the PlyHeaderInfo fields. ### Method Constructor ### Endpoint PlyHeaderInfo(Stream fs) ### Parameters #### Constructor Parameters - **fs** (Stream) - Required - The stream containing the PLY header to parse. ### Response #### Success Response - **VertexCount** (uint) - Number of vertices parsed from the `element vertex N` line. - **PropertyCount** (int) - Count of `vertex` element properties. - **SHPropertyCount** (int) - Count of `f_rest_*` properties. - **PositionOffset** (int) - Byte-property index of `x`, or -1 if absent. - **ColorOffset** (int) - Byte-property index of `f_dc_0`, or -1 if absent. - **SHOffset** (int) - Byte-property index of `f_rest_0`, or -1 if absent. - **OpacityOffset** (int) - Byte-property index of `opacity`, or -1 if absent. - **ScaleOffset** (int) - Byte-property index of `scale_0`, or -1 if absent. - **RotationOffset** (int) - Byte-property index of `rot_0`, or -1 if absent. ``` -------------------------------- ### GsplatAsset Members Source: https://github.com/arloopa/unitysplats Abstract and virtual members of GsplatAsset. Allocate allocates managed CPU arrays; LoadFromPly reads binary little-endian PLY with default sourceCoordinates RUF; LoadFromDecoded populates from GsplatDecodedData and calls Validate(); LoadFromPlyBytes throws NotSupportedException by default; CreateResource returns the matching GPU resource. ```csharp public abstract void Allocate(); public abstract void LoadFromPly(string plyPath, ProgressCallback progressCallback = null, SourceCoordinates sourceCoordinates = SourceCoordinates.RUF); public abstract void LoadFromDecoded(GsplatDecodedData data, ProgressCallback progressCallback = null); public virtual void LoadFromPlyBytes(byte[] plyBytes, ProgressCallback progressCallback = null, SourceCoordinates sourceCoordinates = SourceCoordinates.RUF) => throw new NotSupportedException($"{GetType().Name} does not support loading PLY from bytes."); public abstract GsplatResource CreateResource(); ``` -------------------------------- ### GsplatResourceUncompressed class definition Source: https://github.com/arloopa/unitysplats Concrete resource for uncompressed splat data. Constructor with splatCount == 0 allocates nothing. When GsplatUtils.UseVertexDataTextures is set, allocates R32G32B32A32_SFloat textures; otherwise allocates GraphicsBuffers with 16-byte float4 elements. SHBuffer has SHBandsToCoefficientCount(shBands) * splatCount elements when shBands > 0. Dispose() releases all buffers and destroys textures; it is idempotent. ```csharp public class GsplatResourceUncompressed : GsplatResource { public GraphicsBuffer PositionBuffer { get; private set; } public GraphicsBuffer ScaleBuffer { get; private set; } public GraphicsBuffer RotationBuffer { get; private set; } public GraphicsBuffer ColorBuffer { get; private set; } public GraphicsBuffer SHBuffer { get; private set; } public Texture2D PositionTexture { get; private set; } public Texture2D ScaleTexture { get; private set; } public Texture2D RotationTexture { get; private set; } public Texture2D ColorTexture { get; private set; } public Texture2D SHTexture { get; private set; } public bool UsesVertexTextures { get; } public GsplatResourceUncompressed(uint splatCount, byte shBands) } ``` -------------------------------- ### GsplatAsset.UploadDataAsync Source: https://github.com/arloopa/unitysplats Asynchronously uploads data to the given resource. Returns the asset's upload Task (which becomes resource.UploadTask). Throws ArgumentNullException on null resource and ObjectDisposedException on disposed resource. ```APIDOC ## UploadDataAsync ### Description Asynchronously uploads data to the given resource. Returns the asset's upload `Task` (which becomes `resource.UploadTask`). Throws `ArgumentNullException` on a `null` resource and `ObjectDisposedException` on a disposed resource. The task faults with `OperationCanceledException` when the resource is disposed mid-upload. ### Method UploadDataAsync ### Signature ```csharp public Task UploadDataAsync(GsplatResource resource) { if (resource == null) throw new ArgumentNullException(nameof(resource)); if (resource.Disposed) throw new ObjectDisposedException(resource.GetType().Name); if (resource.Uploaded) return resource.UploadTask; var cancellationToken = resource.BeginAsyncUpload(); resource.Uploaded = true; Task task; try { task = _UploadDataAsync(resource, cancellationToken); } catch (Exception exception) { task = Task.FromException(exception); } resource.OwnUploadTask(task); return task; } ``` ### Parameters - `resource` (GsplatResource) - Required - The resource to upload data to. ### Example ```csharp // Asynchronous upload with progress-visible rendering: var resource = asset.CreateResource(); // normally via GsplatResourceManager Task upload = asset.UploadDataAsync(resource); // yields per batch (await Task.Yield()) ``` ``` -------------------------------- ### GsplatAsset.Allocate Source: https://github.com/arloopa/unitysplats Allocates managed CPU arrays sized from SplatCount and SHBands. ```APIDOC ## Allocate ### Description Allocates managed CPU arrays sized from `SplatCount`/`SHBands`. ### Method Allocate ### Signature ```csharp public abstract void Allocate(); ``` ``` -------------------------------- ### GsplatFileFormat enum Source: https://github.com/arloopa/unitysplats Defines the Gaussian-splat container formats supported by GsplatRuntimeLoader. Auto detects from stream magic bytes; Ply, Sog, Spz, and Glb are explicit formats. ```csharp /// The Gaussian-splat containers understood by . public enum GsplatFileFormat { Auto, Ply, Sog, Spz, Glb } ``` -------------------------------- ### ResolveCoordinates Source: https://github.com/arloopa/unitysplats Resolves source coordinates based on the file format. Returns the provided coordinates unless unspecified, in which case it applies format-specific defaults. ```APIDOC ## ResolveCoordinates ### Description Resolves source coordinates based on the file format. Returns the provided coordinates unless unspecified, in which case it applies format-specific defaults. ### Method ResolveCoordinates ### Signature ```csharp public static SourceCoordinates ResolveCoordinates( GsplatFileFormat format, SourceCoordinates sourceCoordinates) ``` ### Parameters - **format** (GsplatFileFormat) - Required - The file format. - **sourceCoordinates** (SourceCoordinates) - Required - The source coordinates to resolve. ### Returns Returns `sourceCoordinates` unchanged unless it is `Unspecified`, in which case it returns `SourceCoordinates.LUF` for `GsplatFileFormat.Glb` and `SourceCoordinates.RUB` for all other formats. ``` -------------------------------- ### GsplatRenderer.ClearActiveRanges Source: https://github.com/arloopa/unitysplats/blob/main/README.md Clears all active ranges, restoring default behavior. Must run on the main thread. ```APIDOC ## GsplatRenderer.ClearActiveRanges ### Description Clears all active ranges, restoring default behavior. Must run on the main thread. ### Method ClearActiveRanges ### Endpoint GsplatRenderer.ClearActiveRanges() ### Usage Example ```csharp renderer.ClearActiveRanges(); ``` ``` -------------------------------- ### GsplatAsset.LoadFromDecoded Source: https://github.com/arloopa/unitysplats Populates the asset from the canonical GsplatDecodedData representation. Calls data.Validate() first. ```APIDOC ## LoadFromDecoded ### Description Populates the asset from the canonical `GsplatDecodedData` representation. Calls `data.Validate()` first. ### Method LoadFromDecoded ### Signature ```csharp public abstract void LoadFromDecoded(GsplatDecodedData data, ProgressCallback progressCallback = null); ``` ### Parameters - `data` (GsplatDecodedData) - Required - The decoded data to load. - `progressCallback` (ProgressCallback) - Optional - Callback for progress reporting. ``` -------------------------------- ### GsplatAssetUncompressed.ComputeDepth Source: https://github.com/arloopa/unitysplats Computes depth values for sorting, with two overloads as defined on the base class. ```APIDOC ## ComputeDepth ### Description Computes depth values for sorting, with two overloads as defined on the base class. ### Method ComputeDepth ### Signatures - `public override void ComputeDepth(...)` (abstract 5-arg) - `public override void ComputeDepth(...)` (virtual 6-arg) ### Parameters Refer to the base class documentation for parameter details. ``` -------------------------------- ### GsplatAssetUncompressed.Allocate Source: https://github.com/arloopa/unitysplats Allocates the CPU arrays for positions, colors, scales, rotations, and optionally SH coefficients based on the splat count and SH bands. ```APIDOC ## Allocate ### Description Allocates the CPU arrays for positions, colors, scales, rotations, and optionally SH coefficients based on the splat count and SH bands. ### Method Allocate ### Signature `public override void Allocate()` ### Parameters None ### Returns void ### Remarks - Allocates `Positions`, `Colors`, `Scales`, `Rotations` of length `SplatCount`. - Allocates `SHs` of length `SplatCount * SHBandsToCoefficientCount(SHBands)` when `SHBands > 0`. ```