Labsco
MubarakHAlketbi logo

Game Asset Generator

β˜… 146

from MubarakHAlketbi

Generate 2D and 3D game assets using AI models hosted on Hugging Face Spaces.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup

Project owner will look into this repository soon, expect an update in JUNE 2026

Game Asset Generator using MCP and Hugging Face Spaces

This project is an innovative tool that simplifies game asset creation by leveraging AI-powered generation. Whether you're a game developer seeking rapid prototypes or an AI enthusiast exploring generative models, this tool enables you to create 2D and 3D game assets from text prompts effortlessly. It integrates AI models from Hugging Face Spacesβ€”powered by "gokaygokay/Flux-2D-Game-Assets-LoRA", "gokaygokay/Flux-Game-Assets-LoRA-v2", and one of three 3D model generation spaces (InstantMesh, Hunyuan3D-2, or Hunyuan3D-2mini-Turbo, which you must duplicate to your account)β€”and uses the Model Context Protocol (MCP) for seamless interaction with AI assistants like Claude Desktop.



Table of Contents

  1. Project Overview
  2. Features
  3. How It Works
  4. Prerequisites
  5. Installation
  6. Usage
  7. Configuration
  8. File Management
  9. MCP Integration
  10. Troubleshooting
  11. Advanced
  12. Contributing
  13. License

Project Overview

The Game Asset Generator (version 0.3.0) harnesses AI to streamline the creation of game assets. It supports generating 2D assets (e.g., pixel art sprites) and 3D assets (e.g., OBJ and GLB models) from text prompts, integrating with Hugging Face Spaces and the Model Context Protocol (MCP). This release introduces support for multiple 3D model generation spacesβ€”InstantMesh, Hunyuan3D-2, and Hunyuan3D-2mini-Turboβ€”offering flexibility and enhanced performance. Built with Node.js and the MCP TypeScript SDK (v1.7.0), it provides a robust, cross-platform solution for asset generation.


Features

  • 2D Asset Generation: Create pixel art, sprites, or other 2D assets from text prompts (e.g., "pixel art sword").
  • 3D Asset Generation: Generate 3D models (OBJ and GLB formats) from text descriptions, with automatic image-to-model conversion.
  • Multiple 3D Model Spaces: Supports InstantMesh, Hunyuan3D-2, and Hunyuan3D-2mini-Turbo for varied 3D generation workflows.
  • MCP Integration: Seamlessly interact with the tool via MCP-compatible clients like Claude Desktop.
  • File Management: Automatically saves and organizes assets in a local assets directory with resource URIs (e.g., asset://{type}/{id}).
  • Robust Input Validation: Uses Zod for secure and reliable input processing.
  • Multi-Client Support: Handles multiple simultaneous connections via SSE transport.
  • Secure Remote Access: Optional HTTPS support for safe remote communication.
  • Extensible Backend: Modular design for easy integration of new models or features.
  • Cross-Platform: Compatible with Windows, macOS, and Linux using Node.js.
  • Configurable 3D Generation: Customize parameters like inference steps, guidance scale, and turbo mode via environment variables.

How It Works

The Game Asset Generator transforms text prompts into game-ready assets through an automated pipeline:

  1. User Input: Submit a text prompt (e.g., "pixel art sword" or "isometric 3D castle").
  2. MCP Server: Routes the prompt to the appropriate tool (generate_2d_asset or generate_3d_asset).
  3. AI Model Interaction:
    • 2D Assets: Utilizes the Hugging Face Inference API with "gokaygokay/Flux-2D-Game-Assets-LoRA" (50 steps).
    • 3D Assets:
      • Generates an initial image using "gokaygokay/Flux-Game-Assets-LoRA-v2" (30 steps).
      • Converts the image to a 3D model using one of:
        • InstantMesh: Multi-step process (/preprocess, /generate_mvs, /make3d).
        • Hunyuan3D-2: Single-step process (/generation_all).
        • Hunyuan3D-2mini-Turbo: Single-step process (/generation_all) with configurable turbo modes.
  4. File Output: Saves assets (PNG for 2D, OBJ/GLB for 3D) in the assets directory.
  5. Response: Returns resource URIs (e.g., asset://3d_model/filename.glb) for immediate use.

Workflow Diagram

User Prompt β†’ MCP Server β†’ AI Model(s) β†’ Local File β†’ Resource URI Response

Prompts are automatically enhanced with "high detailed, complete object, not cut off, white solid background" for optimal quality.


File Management

  • Storage Location: Assets are saved in ./assets within the working directory.
  • Naming Convention: Files use a prefix, tool name, timestamp, and unique ID (e.g., 2d_asset_generate_2d_asset_1698765432_abcd1234.png).
  • Customization: Set a custom directory:
    node src/index.js /path/to/custom/directory
  • Resource Access: Use MCP URIs (e.g., asset://2d_asset/filename.png) to list or read assets.

MCP Integration

The Model Context Protocol (MCP) enables this tool to serve AI clients securely:

  • Tools: generate_2d_asset, generate_3d_asset.
  • Resources: Managed via asset:// URIs.
  • Prompts: generate_2d_sprite, generate_3d_model.
  • Compatibility: Works with Claude Desktop and other MCP clients.

Advanced

API Endpoints and Integration

  • 2D Asset Generation: Uses "gokaygokay/Flux-2D-Game-Assets-LoRA" (50 steps).
  • 3D Asset Image Generation: Uses "gokaygokay/Flux-Game-Assets-LoRA-v2" (30 steps).
  • 3D Model Conversion:
    • InstantMesh: Multi-step (/check_input_image, /preprocess, /generate_mvs, /make3d).
    • Hunyuan3D-2: Single-step (/generation_all).
    • Hunyuan3D-2mini-Turbo: Single-step (/generation_all) with turbo modes.

Versioning

  • Current Version: 0.3.0 (Added Hunyuan3D-2mini-Turbo support).
  • MCP SDK Version: 1.7.0.
  • Format: MAJOR.MINOR.PATCH (SemVer).

Backend Architecture

  • Core File: src/index.js.
  • Dependencies: See package.json.
  • Security: Zod validation, path traversal prevention, HTTPS support, rate limiting.
  • Performance: Async processing, retry with backoff, GPU quota handling.