--- title: Chord Demo for Minecraft Shaders emoji: 😻 colorFrom: blue colorTo: green sdk: gradio sdk_version: 5.49.1 app_file: app.py pinned: false python_version: 3.12 short_description: Chord with labPBR and RTX/VV texture output license: apache-2.0 thumbnail: >- https://cdn-uploads.huggingface.co/production/uploads/631654f076c93113fb159204/W2PASdJ8i4SqVTHixi2n_.png ---
A Gradio demo for **Chord**, a deep learning model that estimates PBR (Physically Based Rendering) materials from texture images. > This fork adds **Minecraft shader format exports** for both Java Edition (LabPBR 1.3) and Bedrock Edition (RTX & Vibrant Visuals). ## Features - **PBR Material Estimation**: Predicts basecolor, normal, roughness, and metalness maps from a single input image - **Minecraft Shader Export**: Outputs textures compatible with popular Minecraft shaders - **Height Map Derivation**: Generates height maps for Parallax Occlusion Mapping (POM) using Frankot-Chellappa integration - **AO Derivation**: Computes ambient occlusion from normal map divergence - **Advanced Material Properties**: Porosity, subsurface scattering (SSS), and emission extraction ## Note This generates _predictions_ and _estimations_ of the PBR output. You may need to modify the output to improve the appearance in various shaders. ## Installation ```bash # Clone the repository git clone https://huggingface.co/spaces/jasong/chord-minecraft-pbr cd chord-demo # Install dependencies (requires CUDA) pip install -r requirements.txt # Set up Hugging Face token for model download export HF_TOKEN=your_huggingface_token # Run the demo python app.py ``` Alternatively, place `chord_v1.safetensors` in the project root to skip the download. ## Output Formats ### LabPBR 1.3 (Java Edition) For shaders like Iris, OptiFine, Complementary, etc. | Texture | Channels | Description | |---------|----------|-------------| | **Albedo** | RGB | Basecolor texture | | **Specular (_s)** | R | Perceptual smoothness (`1 - sqrt(roughness)`) | | | G | F0/Metal ID (10=dielectric, 230-237=metals, 255=custom) | | | B | Porosity (0-64) or SSS (65-255) | | | A | Emission (1-254, where 0 and 255 = no emission) | | **Normal (_n)** | R | Normal X | | | G | Normal Y (DirectX, Y-down) | | | B | Ambient Occlusion | | | A | Height/POM (0.25=25% depth, 1.0=surface) | ### Bedrock For Minecraft Bedrock Edition with Vibrant Visuals, RTX, or BetterRTX. | Texture | Channels | Description | |---------|----------|-------------| | **Albedo** | RGB | Basecolor texture | | **Normal (_normal)** | RGB | DirectX normal map | | **MER (_mer)** | R | Metalness | | | G | Emissive level | | | B | Roughness | | **MERS (_mers)** | RGBA | MER + Alpha for SSS thickness | ## Settings Reference ### General - **Seamless/Tileable**: Enable for textures that should tile seamlessly ### AO & Height Derivation (LabPBR) - **AO Strength**: Contrast multiplier for ambient occlusion (default: 2.0) - **AO Blur**: Gaussian blur radius for AO smoothing (default: 5) - **Include Height Map**: Enable POM height derivation (disable for flat surfaces) ### Height Relief Balance Fine-tune the height map frequency response: - **Low Frequencies**: Large-scale height variations (default: 1.0) - **Mid Frequencies**: Medium surface features (default: 1.0) - **High Frequencies**: Fine surface detail (default: 1.0) - **Global Intensity**: Overall height strength, 0 = flat (default: 1.0) ### Porosity (LabPBR Blue 0-64) - **Compute Porosity**: Calculate from AO, smoothness, and F0 - **Normalize Porosity**: Normalize to full range before scaling ### Subsurface Scattering - **Compute SSS**: Calculate thickness from normal curvature - **Curvature Weight**: Contribution from surface curvature (default: 0.7) - **AO Weight**: Contribution from inverted AO (default: 0.3) - **SSS Blur**: Softness of SSS effect (default: 2) ### Emission - **Compute Emission**: Extract from bright basecolor regions - **Emission Threshold**: Luminance threshold (default: 0.85) - **Emission Knee**: Soft transition width (default: 0.1) - **Emission Bloom**: Optional blur for bloom effect (default: 0) ### Hardcoded Metals (LabPBR) Select predefined metal types for accurate F0 values: - None (Auto), Custom (255), Iron (230), Gold (231), Aluminum (232), Chrome (233), Copper (234), Lead (235), Platinum (236), Silver (237) ## Technical Notes ### Height Map for Minecraft POM The height map is scaled to [0.25, 1.0] where: - **Black (0.25)** = 25% block depth (deepest point) - **White (1.0)** = Surface level (no displacement) This follows Minecraft shader conventions where pure black represents 25% of a block's depth, not absolute zero. ### Frequency Filtering Height derivation uses FFT-based Frankot-Chellappa integration with configurable frequency band weighting: - Low frequencies: 0-20% of Nyquist - Mid frequencies: 20-50% of Nyquist - High frequencies: 50-100% of Nyquist Smooth hermite interpolation blends between bands. ## Credits This demo is based on the [original Chord demo](https://huggingface.co/spaces/ksangk/chord-demo) by Ubisoft La Forge. **Original Authors**: [Zhi Ying](https://orcid.org/0009-0008-8390-3366)\*, [Boxiang Rong](https://ribosome-rbx.github.io/)\*, [Jingyu Wang](https://ccetaw.github.io/), [Maoyuan Xu](https://ultraman-blazar.github.io/) **Paper**: "Chord: Chain of Rendering Decomposition for PBR Material Estimation from Generated Texture Images" --- This demo is not affiliated with or endorsed by Mojang, Microsoft, NVIDIA, Ubisoft or the original Chord project authors.