PixelForge Unity Plugin Guide

Unity Integration

Import PixelForge 3D assets directly into your Unity project using the glTFast package. Works with Unity 2021+ and handles GLB files, PBR materials, and LOD groups automatically.

1

Install glTFast

PixelForge assets are exported as GLB files — Unity's built-in glTFast package handles the import. Add it via Unity Package Manager:

// Window → Package Manager → + → Add from Git URL com.atteneder.gltfast
Unity 2023.2+ includes glTFast by default — no install needed. For older versions, install via Window → Package Manager → Add package from git URL... and paste com.atteneder.gltfast.
2

Add the PixelForge Import Script

Create PixelForgeImporter.cs in your project (e.g. Assets/Scripts/PixelForgeImporter.cs):

using System; using System.Collections; using UnityEngine; using GLTFast; using GLTFast.Loading; public class PixelForgeImporter : MonoBehaviour { [SerializeField] private string modelUrl; [SerializeField] private Material[] customMaterials; private GltfAsset gltfAsset; public void LoadModel(string url, Action<GameObject> onComplete) { var downloader = new HttpRemoteDownloader(); var gltf = new GltfImport(downloader); StartCoroutine(LoadAsync(gltf, url, onComplete)); } private IEnumerator LoadAsync(GltfImport gltf, string url, Action<GameObject> onComplete) { var task = gltf.LoadAsync(url); yield return new WaitUntil(() => task.IsCompleted); if (gltf.Success) { GameObject root = new GameObject("PixelForge_Asset"); gltf.InstantiateOn(root.transform); var renderers = root.GetComponentsInChildren<Renderer>(); for (int i = 0; i < renderers.Length && i < customMaterials?.Length; i++) { renderers[i].material = customMaterials[i]; } onComplete?.Invoke(root); } else { Debug.LogError($"PixelForge import failed: {gltf.Error}"); } } public void LoadFromAssetId(int assetId, string apiBaseUrl, Action<GameObject> onComplete) { StartCoroutine(FetchModelUrlAndLoad(assetId, apiBaseUrl, onComplete)); } private IEnumerator FetchModelUrlAndLoad(int assetId, string apiBaseUrl, Action<GameObject> onComplete) { var url = $"{apiBaseUrl}/api/assets/" + assetId + "/export/glb"; var www = new UnityEngine.Networking.UnityWebRequest.Get(url); yield return www.SendWebRequest(); if (www.result == UnityEngine.Networking.UnityWebRequest.Result.Success) { var json = www.downloadHandler.text; var data = JsonUtility.FromJson<ExportResponse>(json); if (data != null && !string.IsNullOrEmpty(data.url)) { LoadModel(data.url, onComplete); } } else { Debug.LogError($"Failed to get asset URL: {www.error}"); } } [Serializable] public class ExportResponse { public string url; public string filename; } }
3

Auto-Setup LOD Groups

PixelForge generates three LOD variants. Wire up LOD groups for optimized rendering at any distance:

Hi High — Full detail (use for close-ups and hero objects) Culling: 0–50m
Med Medium — ~50% polygon reduction Culling: 50–150m
Low Low — ~20% original polycount Culling: 150m+

Add the LODGroupSetup.cs component to your imported prefab to automatically generate LOD renderers and assign transition thresholds.

4

PBR Material Mapping

PixelForge exports four PBR texture channels. Map them in Unity's Standard Shader:

Channel Unity Property Usage
AlbedoAlbedo (Base Color)Base color and opacity
NormalNormal MapSurface detail and curvature
MetallicMetallic + SmoothnessSet Metallic = texture R, Smoothness = texture A
RoughnessStandard (Greyscale)Set Smoothness = texture G
Tip: Leave Metallic at 1.0 and Roughness at 0.0 in the Standard Shader when using packed Metallic+Roughness textures. Assign the texture to the Metallic slot — Unity unpacks automatically.
5

API Quick Reference

Query your PixelForge app directly from Unity:

EndpointMethodDescription
/api/assets/generatePOSTSubmit a generation job with { "prompt": "..." }
/api/assets/:id/statusGETPoll until status: "ready"
/api/assets/:id/export/glbGETGet GLB download URL
/api/assets/:id/export/fbxGETGet FBX download URL (requires live Tripo key)