Skip to content

This is a project in which I created rendering and full interaction with sdf primitives. Using Python, GLSL, Imgui, glfw, pyopengl.

License

Notifications You must be signed in to change notification settings

EmberNoGlow/SDF-Model-Editor-Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

85 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SDF Model Editor (Demo)

A lightweight editor for creating and manipulating Signed Distance Field (SDF) primitives using Python, GLSL, and OpenGL.

Python 3.11 GLSL 330 Imgui 2.0.0 GLFW 2.1.0 MIT License GitHub Issues GitHub Stars


🌟 Overview

This project is a work-in-progress editor for designing 3D models using Signed Distance Fields (SDFs). Built with Python, GLSL, ImGui, GLFW, and PyOpenGL, it allows real-time rendering and interaction with SDF primitives.

While the current version is a demo with limited functionality, it serves as a foundation for a more powerful tool. The goal? To simplify 3D modeling by combining primitives into stylized characters or objectsβ€”no sculpting required!

I’m happy with the result, but there’s so much more to build!


πŸ“Œ Screenshots

Screenshot 1 Screenshot 2 Screenshot 2
Screenshot 3 Screenshot 4 Screenshot 2

⚠️ Current Status

This is an early-stage prototype with known bugs and missing features. Check the Roadmap for planned improvements.

Known Issues

  • Redo/Undo bugs
  • Small bugs

Your feedback and contributions are welcome! Open an issue or submit a PR.


πŸš€ Features

βœ… Real-time SDF rendering (GLSL shaders)

βœ… Cycles Additional rendering mode - Realistic Ray Tracing algorithm

βœ… Smooth logic operations (substract, intersect, union, etc.)

βœ… Multi-primitive composition (spheres, boxes, cones, etc.)

βœ… ImGui-based UI for intuitive controls

βœ… Save & Load functions (using tkinter)


🎯 Roadmap

Current Progress

  • 🐜 Fix Undo/Redo bugs
  • γ€½ Found and Fix bugs
  • ⏱ Optimize
  • 🧷 Integrate marching cubes written in Rust for export into 3D format (example, obj)
  • πŸ“ Creating a gizmo - Preparation

Core Functionality (MVP Goals)

  • Free movement of the camera in 3d space - Done!
  • Translation operations for primitives - rotation, scale, and position - can be changed in real time in the inspector.
  • Save/Load projects (JSON or custom format)
  • Undo/Redo support
  • Export to 3D formats (OBJ, GLTF) via voxelization/marching cubes
  • Gizmo-based manipulation (drag, rotate, scale primitives)
  • Add AABB - optimization
  • Write Docs!

User Experience (Future Improvements)

  • Themes & customization
  • Localization (i18n)
  • Performance optimizations

πŸ’ž Contributing

Contributions are highly encouraged! Here’s how you can help:

  1. Report bugs β†’ Open an issue.
  2. Suggest features β†’ Share your ideas in Discussions.
  3. Submit code β†’ Fork the repo and create a Pull Request.

Note: This project is a learning experience - expect refactoring and experimentation!


πŸ’‘ The Story Behind This Project

Inspiration

It all started with this article on SDF-based modeling. The idea of creating stylized 3D characters with just 10-20 primitives was too exciting to ignore!

The Journey

  • Phase 1: Built an MVP using AI tools (ChatGPT, Copilot, Cursor).
  • Phase 2: Hit limitations - free chat limits, code complexity, and bugs.
  • Phase 3: Spent 2 months refactoring, learning, and improving.

AI isn’t a magic solutionβ€”it’s a tool. The real work is in understanding and refining the code.

Lessons Learned

βœ” AI accelerates prototyping but requires deep debugging.

βœ” Refactoring is part of the processβ€”embrace it!

βœ” Small steps lead to big resultsβ€”this is just the beginning.


πŸ”— Resources


πŸ“œ License

This project is licensed under the MIT License – see LICENSE for details.


πŸ™Œ Acknowledgments

  • Inigo Quilez for SDF research.
  • AI tools (ChatGPT, Copilot, Cursor) for assistance.
  • Open-source community for inspiration and libraries.

πŸš€ Ready to Try It?

Download compiled

Compiled executables for windows can be found in releases

NOTE: I don't have the ability to compile a linux app yet.

Clone and run main.py

git clone https://github.com/EmberNoGlow/SDF-Model-Editor-Demo.git
cd SDF-Model-Editor-Demo
python -m venv .venv
.venv/Scripts/Activate.ps1
pip install -r requirements.txt
python main.py

NOTE: To install the imgui package you will need a c++ compiler. My advice is to use mingw - if you only need a compiler for this task. Build Tools will do for this task too, but it weighs more.

Compilation

  1. First, install pyinstaller.
pip install pyinstaller
  1. Compile into one file
pyinstaller --onefile --name sdfeditor --windowed --add-binary ".venv\Lib\site-packages\glfw\glfw3.dll;." main.py

NOTE: You should make sure that you have a virtual environment named .venv created and glfw installed (it is added to requirements). If there is none or the path is incorrect, specify the correct path to the glfw3.dll file located in the virtual environment in the \Lib\site-packages\glfw folder!

  1. Move the compiled file to a separate folder and drag the shaders folder to this directory. You should get it like this:

root directory
β”œβ”€β”€ shaders
β”‚    β”œβ”€β”€ fragment
β”‚    β”‚    β”œβ”€β”€ cycles.glsl
β”‚    β”‚    └── template.glsl
β”‚    β”‚
β”‚    β”œβ”€β”€ sdf_library.glsl
β”‚    └── vertex_shader.glsl
β”‚
β”œβ”€β”€ glfw3.dll
└── sdfeditor.exe


Final Thoughts

This project is a testament to experimentation - imperfect, evolving, but full of potential. Whether you’re here to learn, contribute, or build, I’m excited to see where it goes next!

Let’s create something amazing together. πŸš€


Support

Your support helps development! Help by leaving a review, reporting an error, suggesting an idea in Discussions, creating a Pull Request, or just star ⭐ the repository!.

Follow me

Dev.toBlue SkyGitHub