fractex 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
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.
- fractex/3d.py +28 -7
- fractex/examples/3d.py +2 -2
- fractex/examples/composite_material.py +1 -0
- fractex/examples/splash.py +56 -39
- {fractex-0.2.0.dist-info → fractex-0.2.1.dist-info}/METADATA +2 -1
- {fractex-0.2.0.dist-info → fractex-0.2.1.dist-info}/RECORD +10 -10
- {fractex-0.2.0.dist-info → fractex-0.2.1.dist-info}/WHEEL +0 -0
- {fractex-0.2.0.dist-info → fractex-0.2.1.dist-info}/entry_points.txt +0 -0
- {fractex-0.2.0.dist-info → fractex-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {fractex-0.2.0.dist-info → fractex-0.2.1.dist-info}/top_level.txt +0 -0
fractex/3d.py
CHANGED
|
@@ -155,6 +155,9 @@ def sample_volume_trilinear(volume: np.ndarray,
|
|
|
155
155
|
Интерполированное значение (C,)
|
|
156
156
|
"""
|
|
157
157
|
depth, height, width, channels = volume.shape
|
|
158
|
+
x = np.float32(x)
|
|
159
|
+
y = np.float32(y)
|
|
160
|
+
z = np.float32(z)
|
|
158
161
|
|
|
159
162
|
# Обрабатываем режим заворачивания
|
|
160
163
|
if wrap_mode == "repeat":
|
|
@@ -162,17 +165,35 @@ def sample_volume_trilinear(volume: np.ndarray,
|
|
|
162
165
|
y = y - np.floor(y)
|
|
163
166
|
z = z - np.floor(z)
|
|
164
167
|
elif wrap_mode == "clamp":
|
|
165
|
-
x
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
if x < 0.0:
|
|
169
|
+
x = 0.0
|
|
170
|
+
elif x > 1.0:
|
|
171
|
+
x = 1.0
|
|
172
|
+
if y < 0.0:
|
|
173
|
+
y = 0.0
|
|
174
|
+
elif y > 1.0:
|
|
175
|
+
y = 1.0
|
|
176
|
+
if z < 0.0:
|
|
177
|
+
z = 0.0
|
|
178
|
+
elif z > 1.0:
|
|
179
|
+
z = 1.0
|
|
168
180
|
elif wrap_mode == "mirror":
|
|
169
181
|
x = np.abs(1.0 - np.abs(1.0 - x * 2.0)) / 2.0
|
|
170
182
|
y = np.abs(1.0 - np.abs(1.0 - y * 2.0)) / 2.0
|
|
171
183
|
z = np.abs(1.0 - np.abs(1.0 - z * 2.0)) / 2.0
|
|
172
184
|
else:
|
|
173
|
-
x
|
|
174
|
-
|
|
175
|
-
|
|
185
|
+
if x < 0.0:
|
|
186
|
+
x = 0.0
|
|
187
|
+
elif x > 1.0:
|
|
188
|
+
x = 1.0
|
|
189
|
+
if y < 0.0:
|
|
190
|
+
y = 0.0
|
|
191
|
+
elif y > 1.0:
|
|
192
|
+
y = 1.0
|
|
193
|
+
if z < 0.0:
|
|
194
|
+
z = 0.0
|
|
195
|
+
elif z > 1.0:
|
|
196
|
+
z = 1.0
|
|
176
197
|
|
|
177
198
|
# Переводим в координаты текстуры
|
|
178
199
|
fx = x * (width - 1)
|
|
@@ -221,7 +242,7 @@ def sample_volume_trilinear(volume: np.ndarray,
|
|
|
221
242
|
# Линейная интерполяция по Z
|
|
222
243
|
result = c0 * (1 - dz) + c1 * dz
|
|
223
244
|
|
|
224
|
-
return result
|
|
245
|
+
return result.astype(volume.dtype)
|
|
225
246
|
|
|
226
247
|
@jit(nopython=True, parallel=True, cache=True)
|
|
227
248
|
def sample_volume_trilinear_batch(volume: np.ndarray,
|
fractex/examples/3d.py
CHANGED
|
@@ -34,7 +34,7 @@ def main():
|
|
|
34
34
|
args = parser.parse_args()
|
|
35
35
|
game_time = 0.0
|
|
36
36
|
player = Player(
|
|
37
|
-
position=np.array([0.5, 0.5,
|
|
37
|
+
position=np.array([0.5, 0.5, 0.9]),
|
|
38
38
|
look_at=np.array([0.5, 0.5, 0.5])
|
|
39
39
|
)
|
|
40
40
|
|
|
@@ -73,7 +73,7 @@ def main():
|
|
|
73
73
|
# Рендеринг
|
|
74
74
|
renderer = VolumeTextureRenderer(cave_with_lava)
|
|
75
75
|
frames = []
|
|
76
|
-
for z in [
|
|
76
|
+
for z in [0.95, 0.85, 0.75, 0.65, 0.55, 0.45]:
|
|
77
77
|
camera_pos = np.array([0.5, 0.5, z])
|
|
78
78
|
frame = renderer.render_raycast(
|
|
79
79
|
camera_pos=camera_pos,
|
fractex/examples/splash.py
CHANGED
|
@@ -80,6 +80,7 @@ def main():
|
|
|
80
80
|
ema_ms = target_ms
|
|
81
81
|
phases = {name: 0.0 for name in presets}
|
|
82
82
|
last_t_base = 0.0
|
|
83
|
+
phase_wrap = 90.0
|
|
83
84
|
|
|
84
85
|
def _upscale_nearest(image: np.ndarray, out_w: int, out_h: int) -> np.ndarray:
|
|
85
86
|
in_h, in_w, _ = image.shape
|
|
@@ -103,20 +104,47 @@ def main():
|
|
|
103
104
|
base_name = presets[(frame // 240) % len(presets)]
|
|
104
105
|
detail_name = presets[(frame // 240 + 1) % len(presets)]
|
|
105
106
|
|
|
106
|
-
phases[base_name]
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
phases[base_name] = (phases[base_name] + delta_t) % phase_wrap
|
|
108
|
+
phases[detail_name] = (phases[detail_name] + delta_t) % phase_wrap
|
|
109
|
+
def _render_layer(base_preset: str, detail_preset: str) -> np.ndarray:
|
|
110
|
+
base_texture = textures[base_preset]
|
|
111
|
+
detail_texture = textures[detail_preset]
|
|
112
|
+
t = phases[base_preset]
|
|
113
|
+
t2 = phases[detail_preset]
|
|
114
|
+
|
|
115
|
+
base_zoom = 1.0 + 0.15 * np.sin(t * 0.25)
|
|
116
|
+
detail_zoom = 2.4 + 0.25 * np.sin(t2 * 0.35)
|
|
117
|
+
|
|
118
|
+
x0 = np.sin(t * 0.12) * 5.0
|
|
119
|
+
y0 = np.cos(t * 0.10) * 5.0
|
|
120
|
+
x1 = np.sin(t2 * 0.22 + 1.2) * 2.0
|
|
121
|
+
y1 = np.cos(t2 * 0.18 + 0.7) * 2.0
|
|
122
|
+
|
|
123
|
+
base_origin_x = -render_w / (2.0 * base_zoom)
|
|
124
|
+
base_origin_y = -render_h / (2.0 * base_zoom)
|
|
125
|
+
detail_origin_x = -render_w / (2.0 * detail_zoom)
|
|
126
|
+
detail_origin_y = -render_h / (2.0 * detail_zoom)
|
|
127
|
+
|
|
128
|
+
base = base_texture.generate_tile(
|
|
129
|
+
base_origin_x + x0,
|
|
130
|
+
base_origin_y + y0,
|
|
131
|
+
render_w,
|
|
132
|
+
render_h,
|
|
133
|
+
zoom=base_zoom,
|
|
134
|
+
)[..., :3]
|
|
135
|
+
detail = detail_texture.generate_tile(
|
|
136
|
+
detail_origin_x + x1,
|
|
137
|
+
detail_origin_y + y1,
|
|
138
|
+
render_w,
|
|
139
|
+
render_h,
|
|
140
|
+
zoom=detail_zoom,
|
|
141
|
+
)[..., :3]
|
|
142
|
+
|
|
143
|
+
depth = 0.35 + 0.15 * np.sin(t * 0.2)
|
|
144
|
+
rgb = np.clip(base * (1.0 - depth) + detail * depth, 0, 1)
|
|
145
|
+
tint = 0.6 + 0.4 * np.sin(t * 0.2)
|
|
146
|
+
rgb = np.clip(rgb * np.array([1.0, tint, 0.9]), 0, 1)
|
|
147
|
+
return rgb
|
|
120
148
|
|
|
121
149
|
now = time.perf_counter()
|
|
122
150
|
dt_ms = (now - last_time) * 1000.0
|
|
@@ -134,31 +162,20 @@ def main():
|
|
|
134
162
|
render_w = max(64, int(width * render_scale))
|
|
135
163
|
render_h = max(64, int(height * render_scale))
|
|
136
164
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
detail_origin_y + y1,
|
|
152
|
-
render_w,
|
|
153
|
-
render_h,
|
|
154
|
-
zoom=detail_zoom,
|
|
155
|
-
)[..., :3]
|
|
156
|
-
|
|
157
|
-
depth = 0.35 + 0.15 * np.sin(t * 0.2)
|
|
158
|
-
rgb_frame = np.clip(base * (1.0 - depth) + detail * depth, 0, 1)
|
|
159
|
-
|
|
160
|
-
tint = 0.6 + 0.4 * np.sin(t * 0.2)
|
|
161
|
-
rgb_frame = np.clip(rgb_frame * np.array([1.0, tint, 0.9]), 0, 1)
|
|
165
|
+
rgb_frame = _render_layer(base_name, detail_name)
|
|
166
|
+
if not selected:
|
|
167
|
+
cycle_len = 240
|
|
168
|
+
transition_len = 60
|
|
169
|
+
cycle_pos = frame % cycle_len
|
|
170
|
+
if cycle_pos >= cycle_len - transition_len:
|
|
171
|
+
next_base = presets[(frame // cycle_len + 1) % len(presets)]
|
|
172
|
+
next_detail = presets[(frame // cycle_len + 2) % len(presets)]
|
|
173
|
+
phases[next_base] = (phases[next_base] + delta_t) % phase_wrap
|
|
174
|
+
phases[next_detail] = (phases[next_detail] + delta_t) % phase_wrap
|
|
175
|
+
next_rgb = _render_layer(next_base, next_detail)
|
|
176
|
+
w = (cycle_pos - (cycle_len - transition_len)) / transition_len
|
|
177
|
+
w = w * w * (3.0 - 2.0 * w)
|
|
178
|
+
rgb_frame = np.clip(rgb_frame * (1.0 - w) + next_rgb * w, 0, 1)
|
|
162
179
|
rgb_frame = _upscale_nearest(rgb_frame, width, height)
|
|
163
180
|
im.set_array(rgb_frame)
|
|
164
181
|
return (im,)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fractex
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Fractal texture engine for procedural and infinite-detail textures.
|
|
5
5
|
Author-email: Timur Isanov <tisanov@yahoo.com>
|
|
6
6
|
License: MIT License
|
|
@@ -43,6 +43,7 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
License-File: LICENSE
|
|
44
44
|
Requires-Dist: numpy
|
|
45
45
|
Requires-Dist: numba
|
|
46
|
+
Requires-Dist: matplotlib
|
|
46
47
|
Dynamic: license-file
|
|
47
48
|
|
|
48
49
|
## Fractex
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
fractex/3d.py,sha256=
|
|
1
|
+
fractex/3d.py,sha256=t6-c7oCXdp3408v4qtba6kZsvD4W8lapmbclxe0gd0o,65460
|
|
2
2
|
fractex/__init__.py,sha256=QheT5gsEbyQjvBo_HKy7rgWuhDepJ_UT1io7n_TcpG8,737
|
|
3
3
|
fractex/advanced.py,sha256=UnyLEtH9rZGYSMhL6W4iZzKjTncx1-ToVGtaXbjujrA,5834
|
|
4
4
|
fractex/cli.py,sha256=_54z7rFeJY4sfZm_XwHuOEkF_g-kJtNmGBPNjyjwXY0,2490
|
|
@@ -10,14 +10,14 @@ fractex/simplex_noise.py,sha256=JuMl0tqo4Qq1XC8fmaxLSiH9GppYVvBhmBI5Zc2ZYpc,4157
|
|
|
10
10
|
fractex/texture_blending.py,sha256=2bgmqqsw6v6M2qDp5cEhC-SjdbnvPGxmZLJf7Iaa7Ds,58506
|
|
11
11
|
fractex/volume_scattering.py,sha256=T04rrW1N4VwimNskVww7K6XB1rEqo0foBXii6wAvhkk,54040
|
|
12
12
|
fractex/volume_textures.py,sha256=o-89qqZ1sk7No8w7UHiCTkdFe_m3NmFwyvBEJooL3is,277
|
|
13
|
-
fractex/examples/3d.py,sha256=
|
|
13
|
+
fractex/examples/3d.py,sha256=F7cmL4LMKZWN-reYi20souwPs9fXp0S-BXA9_TSSCrA,3475
|
|
14
14
|
fractex/examples/3d_integration.py,sha256=jiGv_fkirWLSbADmztVOzfO6EfFNs53C6YyesT3RhPk,3781
|
|
15
15
|
fractex/examples/3d_integration_2d.py,sha256=On2LRHV4IZdF1LcUtlJa6poEqD-RNxkrOFix92lCcfo,2193
|
|
16
16
|
fractex/examples/__init__.py,sha256=w2TZrQjob4nE9eRaWLYEKkaETerHPbdRNCnNgBilCng,857
|
|
17
17
|
fractex/examples/_output.py,sha256=2i8UO6IWYMeUZ2I4f5JW0UJii2nTJbqnKQ8Pqo0MB3U,3367
|
|
18
18
|
fractex/examples/architecture_pattern.py,sha256=gREGvvfahNPpoMzHTW1J_oUi8Szquk5v9P7ClaxP8cU,1936
|
|
19
19
|
fractex/examples/atmosphere.py,sha256=9eLAX3aRO6pMz-GrMaZ7QgocG8NBMznO8vuy6OzNkTA,1824
|
|
20
|
-
fractex/examples/composite_material.py,sha256=
|
|
20
|
+
fractex/examples/composite_material.py,sha256=uEK6oNonIyrpOhEOxhiqZkNKW5pupOVrY0tp2w9gif4,2067
|
|
21
21
|
fractex/examples/crystal_cave.py,sha256=pXmFTi3FCVSULoTEh11JC_w_0PzEVtbLSExnUw0DQRM,1908
|
|
22
22
|
fractex/examples/custom_pattern.py,sha256=ZqX81-lxUI4e5aQwThNqQPKaJrJ5HldTJgn5fZoV-dc,4310
|
|
23
23
|
fractex/examples/fire_flame.py,sha256=X9T5Mm8PMgTiSQMGsSQG9NfbRwVw8Kmk-e-IMieD6TI,8046
|
|
@@ -25,13 +25,13 @@ fractex/examples/game_integration.py,sha256=k85yfez6N46oyR5gXpenbOoxDNMQgRLIDRay
|
|
|
25
25
|
fractex/examples/game_texture.py,sha256=4hwtTOpspIQanQODD2g6opke0Zp5XwTriw8kqdtKLak,6841
|
|
26
26
|
fractex/examples/integration.py,sha256=jJwa3ChUmxikGmqJk_tchDnV3rhuYKlNdEATxdbvf_8,3494
|
|
27
27
|
fractex/examples/physic_integration.py,sha256=uh_ik_j-iiEOowPIvd37jwUDi5v9PZtCYUyHgyJBCC4,2551
|
|
28
|
-
fractex/examples/splash.py,sha256=
|
|
28
|
+
fractex/examples/splash.py,sha256=fBWlj9Bevv9P6reQlVqnumKpvaEOak9aQjoVVaZNABo,7141
|
|
29
29
|
fractex/examples/terrain.py,sha256=rsduhHchbyI6T-RDIzI-S6D07g2_rCSg6JtA4eXGve0,2611
|
|
30
30
|
fractex/examples/underwater.py,sha256=1_SlTVhd-ONEYqyV_B4sCFhSqScmCHQ7f6eRVI7v5X8,3313
|
|
31
31
|
fractex/examples/underwater_volkano.py,sha256=HobJi3ztK-R_VeHfI8oVRZupONbegWnOL40llj_LnaE,4161
|
|
32
|
-
fractex-0.2.
|
|
33
|
-
fractex-0.2.
|
|
34
|
-
fractex-0.2.
|
|
35
|
-
fractex-0.2.
|
|
36
|
-
fractex-0.2.
|
|
37
|
-
fractex-0.2.
|
|
32
|
+
fractex-0.2.1.dist-info/licenses/LICENSE,sha256=CRrETm3c-JFoqpolJMrRIfFXOxOy5uhnvdSVKFP6sVE,1069
|
|
33
|
+
fractex-0.2.1.dist-info/METADATA,sha256=cu1N-Xy7m9hl6KAxbRkGZxNOGcCLZAOJ8uhC8A5rVxE,3629
|
|
34
|
+
fractex-0.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
35
|
+
fractex-0.2.1.dist-info/entry_points.txt,sha256=xgzT1MTUmB69bstzCyxybxJDI7D8nYqsJpBN2UMazL4,45
|
|
36
|
+
fractex-0.2.1.dist-info/top_level.txt,sha256=LFl1_h1YNgANgBDo6d-tPTJzlrO3ny_l5OTItasV9rw,8
|
|
37
|
+
fractex-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|