sdforge 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sdforge-0.2.2/PKG-INFO +42 -0
- sdforge-0.2.2/README.md +17 -0
- sdforge-0.2.2/sdforge/__init__.py +17 -0
- sdforge-0.2.2/sdforge.egg-info/PKG-INFO +42 -0
- sdforge-0.2.2/sdforge.egg-info/SOURCES.txt +8 -0
- sdforge-0.2.2/sdforge.egg-info/requires.txt +1 -0
- sdforge-0.2.2/sdforge.egg-info/top_level.txt +1 -0
- sdforge-0.2.2/setup.py +24 -0
- sdforge-0.2.0/LICENSE +0 -21
- sdforge-0.2.0/MANIFEST.in +0 -1
- sdforge-0.2.0/PKG-INFO +0 -287
- sdforge-0.2.0/README.md +0 -248
- sdforge-0.2.0/examples/__init__.py +0 -0
- sdforge-0.2.0/examples/camera.py +0 -66
- sdforge-0.2.0/examples/debug.py +0 -56
- sdforge-0.2.0/examples/export.py +0 -32
- sdforge-0.2.0/examples/forge.py +0 -63
- sdforge-0.2.0/examples/group.py +0 -58
- sdforge-0.2.0/examples/light.py +0 -62
- sdforge-0.2.0/examples/material.py +0 -23
- sdforge-0.2.0/examples/noise.py +0 -57
- sdforge-0.2.0/examples/operations.py +0 -71
- sdforge-0.2.0/examples/params.py +0 -35
- sdforge-0.2.0/examples/primitives.py +0 -68
- sdforge-0.2.0/examples/render.py +0 -30
- sdforge-0.2.0/examples/saving.py +0 -79
- sdforge-0.2.0/examples/shaping.py +0 -70
- sdforge-0.2.0/examples/transforms.py +0 -125
- sdforge-0.2.0/sdforge/__init__.py +0 -30
- sdforge-0.2.0/sdforge/core.py +0 -340
- sdforge-0.2.0/sdforge/debug.py +0 -13
- sdforge-0.2.0/sdforge/export.py +0 -119
- sdforge-0.2.0/sdforge/glsl/camera.glsl +0 -25
- sdforge-0.2.0/sdforge/glsl/debug.glsl +0 -15
- sdforge-0.2.0/sdforge/glsl/light.glsl +0 -24
- sdforge-0.2.0/sdforge/glsl/noise.glsl +0 -50
- sdforge-0.2.0/sdforge/glsl/operations.glsl +0 -41
- sdforge-0.2.0/sdforge/glsl/primitives.glsl +0 -161
- sdforge-0.2.0/sdforge/glsl/raymarching.glsl +0 -23
- sdforge-0.2.0/sdforge/glsl/shaping.glsl +0 -23
- sdforge-0.2.0/sdforge/glsl/transforms.glsl +0 -106
- sdforge-0.2.0/sdforge/loader.py +0 -32
- sdforge-0.2.0/sdforge/mesh.py +0 -150
- sdforge-0.2.0/sdforge/render.py +0 -309
- sdforge-0.2.0/sdforge/utils.py +0 -8
- sdforge-0.2.0/sdforge.egg-info/PKG-INFO +0 -287
- sdforge-0.2.0/sdforge.egg-info/SOURCES.txt +0 -59
- sdforge-0.2.0/sdforge.egg-info/requires.txt +0 -15
- sdforge-0.2.0/sdforge.egg-info/top_level.txt +0 -3
- sdforge-0.2.0/setup.py +0 -42
- sdforge-0.2.0/tests/__init__.py +0 -0
- sdforge-0.2.0/tests/camera.py +0 -27
- sdforge-0.2.0/tests/conftest.py +0 -147
- sdforge-0.2.0/tests/debug.py +0 -64
- sdforge-0.2.0/tests/export.py +0 -47
- sdforge-0.2.0/tests/forge.py +0 -85
- sdforge-0.2.0/tests/group.py +0 -67
- sdforge-0.2.0/tests/light.py +0 -10
- sdforge-0.2.0/tests/material.py +0 -48
- sdforge-0.2.0/tests/noise.py +0 -50
- sdforge-0.2.0/tests/operations.py +0 -131
- sdforge-0.2.0/tests/params.py +0 -27
- sdforge-0.2.0/tests/primitives.py +0 -144
- sdforge-0.2.0/tests/render.py +0 -95
- sdforge-0.2.0/tests/saving.py +0 -78
- sdforge-0.2.0/tests/shaping.py +0 -58
- sdforge-0.2.0/tests/transforms.py +0 -124
- {sdforge-0.2.0 → sdforge-0.2.2}/sdforge.egg-info/dependency_links.txt +0 -0
- {sdforge-0.2.0 → sdforge-0.2.2}/setup.cfg +0 -0
sdforge-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sdforge
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Compatibility package for the renamed DistForge SDF modeling library.
|
|
5
|
+
Home-page: https://github.com/nassimberrada/distforge
|
|
6
|
+
Author: nassimberrada
|
|
7
|
+
Classifier: Development Status :: 7 - Inactive
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
14
|
+
Requires-Python: >=3.6
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: distforge>=1.0.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# sdforge has moved
|
|
27
|
+
|
|
28
|
+
The `sdforge` package has been renamed to **DistForge**.
|
|
29
|
+
|
|
30
|
+
Install the new package:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install -U distforge
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
New code should import from `distforge`:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from distforge import sphere, box
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This release remains available as a compatibility bridge for existing users.
|
sdforge-0.2.2/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# sdforge has moved
|
|
2
|
+
|
|
3
|
+
The `sdforge` package has been renamed to **DistForge**.
|
|
4
|
+
|
|
5
|
+
Install the new package:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install -U distforge
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
New code should import from `distforge`:
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from distforge import sphere, box
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This release remains available as a compatibility bridge for existing users.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Compatibility layer for the former ``sdforge`` import path.
|
|
2
|
+
|
|
3
|
+
The project was renamed to DistForge in version 1.0.0. New code should use
|
|
4
|
+
``distforge`` directly; this module keeps the old top-level and internal
|
|
5
|
+
import paths working while downstream projects migrate.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import importlib
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
from distforge import *
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
api = importlib.import_module("distforge.api")
|
|
15
|
+
sys.modules[f"{__name__}.api"] = api
|
|
16
|
+
|
|
17
|
+
del importlib, sys
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sdforge
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Compatibility package for the renamed DistForge SDF modeling library.
|
|
5
|
+
Home-page: https://github.com/nassimberrada/distforge
|
|
6
|
+
Author: nassimberrada
|
|
7
|
+
Classifier: Development Status :: 7 - Inactive
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
14
|
+
Requires-Python: >=3.6
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: distforge>=1.0.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# sdforge has moved
|
|
27
|
+
|
|
28
|
+
The `sdforge` package has been renamed to **DistForge**.
|
|
29
|
+
|
|
30
|
+
Install the new package:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install -U distforge
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
New code should import from `distforge`:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from distforge import sphere, box
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This release remains available as a compatibility bridge for existing users.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
distforge>=1.0.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sdforge
|
sdforge-0.2.2/setup.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from setuptools import find_packages, setup
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="sdforge",
|
|
6
|
+
version="0.2.2",
|
|
7
|
+
author="nassimberrada",
|
|
8
|
+
description="Compatibility package for the renamed DistForge SDF modeling library.",
|
|
9
|
+
long_description=open("README.md").read(),
|
|
10
|
+
long_description_content_type="text/markdown",
|
|
11
|
+
url="https://github.com/nassimberrada/distforge",
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
install_requires=["distforge>=1.0.0"],
|
|
14
|
+
classifiers=[
|
|
15
|
+
"Development Status :: 7 - Inactive",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: Multimedia :: Graphics :: 3D Modeling",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
22
|
+
],
|
|
23
|
+
python_requires=">=3.6",
|
|
24
|
+
)
|
sdforge-0.2.0/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 nassimberrada
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
sdforge-0.2.0/MANIFEST.in
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
recursive-include sdforge/glsl *.glsl
|
sdforge-0.2.0/PKG-INFO
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: sdforge
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: A Python library for SDF modeling with real-time GLSL rendering and mesh export.
|
|
5
|
-
Home-page: https://github.com/nassimberrada/sdforge
|
|
6
|
-
Author: nassimberrada
|
|
7
|
-
Classifier: Development Status :: 4 - Beta
|
|
8
|
-
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: Intended Audience :: Science/Research
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
|
|
13
|
-
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
14
|
-
Requires-Python: >=3.6
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Requires-Dist: numpy
|
|
18
|
-
Requires-Dist: scikit-image>=0.17
|
|
19
|
-
Requires-Dist: watchdog
|
|
20
|
-
Requires-Dist: moderngl
|
|
21
|
-
Requires-Dist: glfw
|
|
22
|
-
Provides-Extra: ui
|
|
23
|
-
Requires-Dist: imgui[glfw]>=2.0.0; extra == "ui"
|
|
24
|
-
Provides-Extra: export
|
|
25
|
-
Requires-Dist: pygltflib; extra == "export"
|
|
26
|
-
Provides-Extra: full
|
|
27
|
-
Requires-Dist: imgui[glfw]>=2.0.0; extra == "full"
|
|
28
|
-
Requires-Dist: pygltflib; extra == "full"
|
|
29
|
-
Dynamic: author
|
|
30
|
-
Dynamic: classifier
|
|
31
|
-
Dynamic: description
|
|
32
|
-
Dynamic: description-content-type
|
|
33
|
-
Dynamic: home-page
|
|
34
|
-
Dynamic: license-file
|
|
35
|
-
Dynamic: provides-extra
|
|
36
|
-
Dynamic: requires-dist
|
|
37
|
-
Dynamic: requires-python
|
|
38
|
-
Dynamic: summary
|
|
39
|
-
|
|
40
|
-
<p align="center">
|
|
41
|
-
<picture>
|
|
42
|
-
<source srcset="./assets/logo_dark.png" media="(prefers-color-scheme: dark)">
|
|
43
|
-
<source srcset="./assets/logo_light.png" media="(prefers-color-scheme: light)">
|
|
44
|
-
<img src="./assets/logo_light.png" alt="SDForge Logo" height="200">
|
|
45
|
-
</picture>
|
|
46
|
-
</p>
|
|
47
|
-
|
|
48
|
-
## About
|
|
49
|
-
|
|
50
|
-
SDF Forge is a Python library for creating 3D models using Signed Distance Functions (SDFs). It provides a real-time, interactive rendering experience in a native desktop window, powered by GLSL raymarching.
|
|
51
|
-
|
|
52
|
-
## Features
|
|
53
|
-
|
|
54
|
-
- **Simple, Pythonic API:** Define complex shapes by combining primitives using standard operators (`|`, `-`, `&`) and chaining transformations.
|
|
55
|
-
- **Real-time Rendering with Hot-Reloading:** Get instant visual feedback in a lightweight native window powered by `moderngl` and `glfw`. Changes to your script are reloaded automatically.
|
|
56
|
-
- **Mesh Exporting:** Save your creations as `.stl`, `.obj`, or `.glb` files for 3D printing or use in other software.
|
|
57
|
-
- **Interactive Parameters:** Define parameters that can be controlled by UI sliders in real-time (with a compatible UI renderer).
|
|
58
|
-
- **Standalone GLSL Export:** Export your entire scene to a single, self-contained GLSL fragment shader for use in game engines or graphics applications.
|
|
59
|
-
- **Custom GLSL Primitives:** Write custom SDF logic directly in GLSL using the `Forge` object for maximum flexibility and performance.
|
|
60
|
-
|
|
61
|
-
## Getting Started
|
|
62
|
-
|
|
63
|
-
### Hello Forge
|
|
64
|
-
|
|
65
|
-
Define a simple shape and open a real-time preview window with just a few lines of code.
|
|
66
|
-
|
|
67
|
-
```python
|
|
68
|
-
from sdforge import sphere, box
|
|
69
|
-
|
|
70
|
-
# A sphere intersected with a box
|
|
71
|
-
shape = sphere(1) & box(1.5)
|
|
72
|
-
|
|
73
|
-
# Render a preview in a native window.
|
|
74
|
-
# An interactive orbit camera is used by default.
|
|
75
|
-
shape.render()
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Live Preview & Hot-Reloading
|
|
79
|
-
For an interactive workflow, wrap your scene definition in a `main()` function. When you save any changes to the file, the preview window will automatically update.
|
|
80
|
-
|
|
81
|
-
```python
|
|
82
|
-
from sdforge import box, sphere
|
|
83
|
-
|
|
84
|
-
def main():
|
|
85
|
-
"""
|
|
86
|
-
While this script is running, try changing the values below and
|
|
87
|
-
saving the file. The render window will update automatically.
|
|
88
|
-
"""
|
|
89
|
-
box_size = 1.5
|
|
90
|
-
sphere_radius = 1.2
|
|
91
|
-
|
|
92
|
-
scene = box(box_size, radius=0.1) | sphere(sphere_radius)
|
|
93
|
-
return scene
|
|
94
|
-
|
|
95
|
-
if __name__ == "__main__":
|
|
96
|
-
# The render() function automatically enables hot-reloading by default
|
|
97
|
-
# and looks for a `main` function in this file to call upon reload.
|
|
98
|
-
scene = main()
|
|
99
|
-
scene.render()
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Saving to a Mesh File
|
|
103
|
-
You can save any static model to an `.stl`, `.obj`, or `.glb` file. The `.save()` method uses the Marching Cubes algorithm to generate a mesh from the SDF.
|
|
104
|
-
|
|
105
|
-
```python
|
|
106
|
-
from sdforge import sphere, box
|
|
107
|
-
|
|
108
|
-
# A box with a sphere carved out of it
|
|
109
|
-
shape = box(1.5) - sphere(1.2)
|
|
110
|
-
|
|
111
|
-
# Save the model. Higher samples = more detail.
|
|
112
|
-
shape.save('model.obj', samples=2**22)
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Core Concepts
|
|
116
|
-
|
|
117
|
-
### Primitives & Operations
|
|
118
|
-
Create complex objects by starting with primitives and combining them with Python's bitwise operators: `|` for union, `&` for intersection, and `-` for difference.
|
|
119
|
-
|
|
120
|
-
```python
|
|
121
|
-
from sdforge import sphere, box
|
|
122
|
-
|
|
123
|
-
# A box with a sphere carved out of it.
|
|
124
|
-
b = box(size=1.5)
|
|
125
|
-
s = sphere(r=1.0)
|
|
126
|
-
scene = b - s
|
|
127
|
-
|
|
128
|
-
scene.render()
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Transformations & Shaping
|
|
132
|
-
Chain methods to transform, shape, and repeat objects.
|
|
133
|
-
|
|
134
|
-
```python
|
|
135
|
-
import numpy as np
|
|
136
|
-
from sdforge import box, Y
|
|
137
|
-
|
|
138
|
-
# A tall box
|
|
139
|
-
b = box(size=(0.5, 2.5, 0.5))
|
|
140
|
-
|
|
141
|
-
# Twist it around the Y-axis
|
|
142
|
-
# The 'k' parameter controls the amount of twist.
|
|
143
|
-
scene = b.twist(k=3.0).rotate(Y, np.pi / 4)
|
|
144
|
-
|
|
145
|
-
scene.render()
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Materials
|
|
149
|
-
You can assign a unique color to any object or group of objects using the `.color()` method.
|
|
150
|
-
|
|
151
|
-
```python
|
|
152
|
-
from sdforge import sphere, box
|
|
153
|
-
|
|
154
|
-
# A blue sphere is subtracted from a red box.
|
|
155
|
-
red_box = box(1.5, radius=0.1).color(1.0, 0.2, 0.2)
|
|
156
|
-
blue_sphere = sphere(1.2).color(0.3, 0.5, 1.0)
|
|
157
|
-
|
|
158
|
-
scene = red_box - blue_sphere
|
|
159
|
-
|
|
160
|
-
scene.render()
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### Camera & Lighting
|
|
164
|
-
You can override the default interactive camera and lighting to set a static viewpoint or create specific lighting conditions by passing `Camera` and `Light` objects to the renderer.
|
|
165
|
-
|
|
166
|
-
```python
|
|
167
|
-
from sdforge import box, sphere, Camera, Light
|
|
168
|
-
|
|
169
|
-
def main():
|
|
170
|
-
scene = box(1.5, radius=0.1) | sphere(1.2)
|
|
171
|
-
|
|
172
|
-
# A camera positioned at (4, 3, 4), looking at the origin.
|
|
173
|
-
cam = Camera(position=(4, 3, 4), target=(0, 0, 0), zoom=1.5)
|
|
174
|
-
|
|
175
|
-
# A light source with soft shadows
|
|
176
|
-
light = Light(position=(4, 5, 3), shadow_softness=16.0)
|
|
177
|
-
|
|
178
|
-
return scene, cam, light
|
|
179
|
-
|
|
180
|
-
if __name__ == '__main__':
|
|
181
|
-
scene, cam, light = main()
|
|
182
|
-
scene.render(camera=cam, light=light)
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
## Advanced Usage
|
|
186
|
-
|
|
187
|
-
### Interactive Parameters
|
|
188
|
-
Use `Param` objects to define interactive, real-time parameters for your model. A compatible UI-enabled renderer would show these as sliders. The default renderer will use their default values.
|
|
189
|
-
|
|
190
|
-
```python
|
|
191
|
-
from sdforge import box, Param
|
|
192
|
-
|
|
193
|
-
# Create Param objects to control different aspects of the scene.
|
|
194
|
-
# Param(name, default_value, min_value, max_value)
|
|
195
|
-
p_size = Param("Box Size", 0.8, 0.2, 2.0)
|
|
196
|
-
p_radius = Param("Corner Radius", 0.1, 0.0, 0.5)
|
|
197
|
-
|
|
198
|
-
# Use the Param objects just like regular numbers.
|
|
199
|
-
scene = box(size=p_size, radius=p_radius)
|
|
200
|
-
|
|
201
|
-
scene.render()
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Custom GLSL with `Forge`
|
|
205
|
-
For complex or highly-performant shapes, you can write GLSL code directly. This object integrates perfectly with the rest of the API.
|
|
206
|
-
|
|
207
|
-
```python
|
|
208
|
-
from sdforge import sphere, Forge
|
|
209
|
-
|
|
210
|
-
# A standard library primitive
|
|
211
|
-
s = sphere(1.2)
|
|
212
|
-
|
|
213
|
-
# A custom shape defined with GLSL
|
|
214
|
-
# 'p' is the vec3 point in space
|
|
215
|
-
custom_box = Forge("""
|
|
216
|
-
vec3 q = abs(p) - vec3(0.8);
|
|
217
|
-
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
|
|
218
|
-
""")
|
|
219
|
-
|
|
220
|
-
# The Forge object can be combined like any other shape
|
|
221
|
-
scene = s - custom_box
|
|
222
|
-
|
|
223
|
-
scene.render()
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Standalone GLSL Export
|
|
227
|
-
Generate a complete, self-contained GLSL fragment shader for your scene. This file can be used directly in applications like Godot, TouchDesigner, or Three.js.
|
|
228
|
-
|
|
229
|
-
```python
|
|
230
|
-
from sdforge import box, sphere
|
|
231
|
-
|
|
232
|
-
scene = box(1.5, radius=0.1) - sphere(1.2)
|
|
233
|
-
|
|
234
|
-
# This single call generates the entire shader file.
|
|
235
|
-
scene.export_shader("exported_shader.glsl")
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
## Installation
|
|
239
|
-
|
|
240
|
-
### 1. System Dependencies
|
|
241
|
-
|
|
242
|
-
The live viewer relies on `glfw`, which may require you to install its system-level libraries first. This is a common first step before installing the Python package.
|
|
243
|
-
|
|
244
|
-
**On Debian/Ubuntu:**
|
|
245
|
-
```bash
|
|
246
|
-
sudo apt-get install libglfw3-dev
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
**On macOS (with Homebrew):**
|
|
250
|
-
```bash
|
|
251
|
-
brew install glfw
|
|
252
|
-
```
|
|
253
|
-
**On Windows:**
|
|
254
|
-
`glfw` is generally bundled with the Python wheels, so no separate installation is typically needed.
|
|
255
|
-
|
|
256
|
-
### 2. Python Package
|
|
257
|
-
|
|
258
|
-
The library and its core dependencies can be installed using pip.
|
|
259
|
-
|
|
260
|
-
**Standard Installation:**
|
|
261
|
-
This will install the core library, including `numpy`, `moderngl`, and `glfw`, enabling all fundamental features like modeling, live preview with hot-reloading, and exporting to `.stl` and `.obj` formats.
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
pip install sdforge
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
**Optional Features:**
|
|
268
|
-
For additional functionality, you can install "extras":
|
|
269
|
-
|
|
270
|
-
* **`.glb` Export:** To enable saving models to the GLB format, a modern and efficient format for web and game engines.
|
|
271
|
-
```bash
|
|
272
|
-
pip install "sdforge[export]"
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
* **Interactive UI:** To enable UI widgets like sliders for `Param` objects.
|
|
276
|
-
```bash
|
|
277
|
-
pip install "sdforge[ui]"
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
* **Full Installation:** To install all optional features at once.
|
|
281
|
-
```bash
|
|
282
|
-
pip install "sdforge[full]"
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Acknowledgements
|
|
286
|
-
|
|
287
|
-
This project is inspired by the simplicity and elegant API of Michael Fogleman's [fogleman/sdf](https://github.com/fogleman/sdf) library. SDF Forge aims to build on that foundation by adding a real-time, interactive GLSL-powered renderer.
|