Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 67 additions & 97 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/shaders/custom_material.wesl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> {
let p = mesh.world_position.xyz * 0.02 + globals.time * 0.1;
let n = snoise33(p) * 0.5 + 0.5;

let light_dir = normalize(vec3(0.5, 1.0, 0.3));
let light_dir = normalize(vec3(0.5, -1.0, 0.3));
let diffuse = max(dot(normalize(mesh.world_normal), light_dir), 0.15);

return vec4(n * diffuse, 1.0) * color;
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/gen_colored_surface.wesl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {

let h = height(x, z, t);
position[i * 3u + 0u] = x;
position[i * 3u + 1u] = h;
position[i * 3u + 1u] = -h;
position[i * 3u + 2u] = z;

let e = 0.12;
let hl = height(x - e, z, t);
let hr = height(x + e, z, t);
let hd = height(x, z - e, t);
let hu = height(x, z + e, t);
let n = normalize(vec3<f32>(hl - hr, 2.0 * e, hd - hu));
let n = normalize(vec3<f32>(hl - hr, -2.0 * e, hd - hu));
normal[i * 3u + 0u] = n.x;
normal[i * 3u + 1u] = n.y;
normal[i * 3u + 2u] = n.z;
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/gen_surface.wesl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
h = h + 0.25 * h * abs(h);

position[i * 3u + 0u] = x;
position[i * 3u + 1u] = h;
position[i * 3u + 1u] = -h;
position[i * 3u + 2u] = z;

if gx + 1u < nx && gy + 1u < ny {
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/particles_emit_gpu_spawn.wesl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
let theta = hash_unit(seed) * 6.2831853;
let r = sqrt(hash_unit(seed * 2u + 1u));
let dirxz = vec2<f32>(cos(theta), sin(theta)) * r;
let dy = 0.7 + 0.3 * hash_unit(seed * 3u + 7u);
let dy = -(0.7 + 0.3 * hash_unit(seed * 3u + 7u));
let v = vec3<f32>(dirxz.x, dy, dirxz.y) * spawn.speed.x;

position[slot * 3u + 0u] = spawn.pos.x;
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/particles_lifecycle_aging.wesl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
}

age[i] = age[i] + dt;
position[i * 3u + 1u] = position[i * 3u + 1u] - dt * 1.5;
position[i * 3u + 1u] = position[i * 3u + 1u] + dt * 1.5;

let remaining = clamp(1.0 - age[i] / ttl, 0.0, 1.0);
let s = remaining * remaining;
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/plexus_curve.wesl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
sin(params.fz * t + params.time * 0.23),
) * params.scale;
position[i * 3u + 0u] = world.x;
position[i * 3u + 1u] = world.y;
position[i * 3u + 1u] = -world.y;
position[i * 3u + 2u] = world.z;

let rainbow = hsv2rgb(vec3<f32>(fract(u + params.time * 0.03), 0.75, 1.0));
Expand Down
4 changes: 2 additions & 2 deletions crates/processing_pyo3/examples/Basics/Camera/move_eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def setup():
def draw():
background(0.0)

# Change height of the camera with mouseY (the world is y-up)
camera(30.0, -mouse_y, 220.0, # eyeX, eyeY, eyeZ
# Change height of the camera with mouseY
camera(30.0, mouse_y, 220.0, # eyeX, eyeY, eyeZ
0.0, 0.0, 0.0, # centerX, centerY, centerZ
0.0, 1.0, 0.0) # upX, upY, upZ

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def draw():
perspective(PI / 3.0, width / height, 10, far)
else:
ortho(-width / 2.0, width / 2.0, -height / 2.0, height / 2.0, 10, far)
# Rotations about x run the other way in the y-up world
rotate_x(PI / 6)
rotate_x(-PI / 6)
rotate_y(PI / 3)
box(180)

Expand Down
3 changes: 1 addition & 2 deletions crates/processing_pyo3/examples/Basics/Camera/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def draw():
perspective(fov, aspect, camera_z / 10.0, camera_z * 10.0)

translate(30, 0, 0)
# Rotations about x run the other way in the y-up world
rotate_x(PI / 6)
rotate_x(-PI / 6)
rotate_y(PI / 3 + mouse_y / height * PI)
box(45)
translate(0, 0, -50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def draw():
no_fill()
stroke(1.0)
push_matrix()
translate(500 - width / 2, height / 2 - height * 0.35, -200)
translate(500 - width / 2, height * 0.35 - height / 2, -200)
sphere(280)
pop_matrix()

Expand Down
3 changes: 1 addition & 2 deletions crates/processing_pyo3/examples/Basics/Lights/directional.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def draw():
background(0.0)
dir_y = (mouse_y / height - 0.5) * 2
dir_x = (mouse_x / width - 0.5) * 2
# The world is y-up, so the vertical direction is flipped
light.look_at(-dir_x, dir_y, -1)
light.look_at(-dir_x, -dir_y, -1)
translate(-100, 0, 0)
sphere(80)
translate(200, 0, 0)
Expand Down
9 changes: 4 additions & 5 deletions crates/processing_pyo3/examples/Basics/Lights/mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ def setup():
mode_3d()
no_stroke()

# Lights are created once; the world is y-up, so the y of every
# position and direction is flipped
# Lights are created once
# Orange point light on the right
point = point_light((0.59, 0.39, 0.0), 3000000000.0, 600.0, 1.0, # Color
position=(200, 150, 0)) # Position
position=(200, -150, 0)) # Position

# Blue directional light from the left
directional = directional_light((0.0, 0.4, 1.0), 4000.0, # Color
Expand All @@ -28,8 +27,8 @@ def setup():
# Yellow spotlight from the front
spot = spot_light((1.0, 1.0, 0.43), 2000000000.0, 600.0, 1.0, # Color
PI / 4, PI / 2, # Angle, concentration
position=(0, -40, 200), # Position
look_at=(0, -40 + 0.5, 200 - 0.5)) # Direction
position=(0, 40, 200), # Position
look_at=(0, 40 - 0.5, 200 - 0.5)) # Direction
roughness(0.6)


Expand Down
11 changes: 5 additions & 6 deletions crates/processing_pyo3/examples/Basics/Lights/mixture_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def draw():
for x in range(0, width + 1, 60):
for y in range(0, height + 1, 60):
push_matrix()
translate(x - width / 2, height / 2 - y, 0)
translate(x - width / 2, y - height / 2, 0)
rotate_y(remap(mouse_x, 0, width, 0, PI))
rotate_x(remap(mouse_y, 0, height, 0, PI))
box(90)
Expand All @@ -31,11 +31,10 @@ def draw():

def define_lights():
global point, directional, spot
# The lights are created once, placed relative to the top-left corner
# as in the original (the world is centered and y-up)
# The lights are created once, in the original's top-left coordinates
# Orange point light on the right
point = point_light((0.59, 0.39, 0.0), 3000000000.0, 600.0, 1.0, # Color
position=(200 - width / 2, height / 2 + 150, 0)) # Position
position=(200 - width / 2, -150 - height / 2, 0)) # Position

# Blue directional light from the left
directional = directional_light((0.0, 0.4, 1.0), 4000.0, # Color
Expand All @@ -44,8 +43,8 @@ def define_lights():
# Yellow spotlight from the front
spot = spot_light((1.0, 1.0, 0.43), 2000000000.0, 600.0, 1.0, # Color
PI / 4, PI / 2, # Angle, concentration
position=(-width / 2, height / 2 - 40, 200), # Position
look_at=(-width / 2, height / 2 - 40 + 0.5, 200 - 0.5)) # Direction
position=(-width / 2, 40 - height / 2, 200), # Position
look_at=(-width / 2, 40 - height / 2 - 0.5, 200 - 0.5)) # Direction
roughness(0.6)


Expand Down
3 changes: 1 addition & 2 deletions crates/processing_pyo3/examples/Basics/Lights/on_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def draw():
spin += 0.01

push_matrix()
# Rotations about x run the other way in the y-up world
rotate_x(-PI / 9)
rotate_x(PI / 9)
rotate_y(PI / 5 + spin)
box(150)
pop_matrix()
Expand Down
17 changes: 8 additions & 9 deletions crates/processing_pyo3/examples/Basics/Lights/spot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,27 @@ def setup():
no_stroke()
fill(0.8)

# Lights are created once and positioned relative to the top-left corner
# as in the original (the world is centered and y-up)
# Lights are created once, in the original's top-left coordinates
# Light the bottom of the sphere
bottom = directional_light((0.2, 0.4, 0.49), 4000.0, look_at=(0, 1, 0))
bottom = directional_light((0.2, 0.4, 0.49), 4000.0, look_at=(0, -1, 0))

# Orange light on the upper-right of the sphere
orange = spot_light((0.8, 0.6, 0.0), 10000000000.0, 1200.0, 1.0, 0.0, PI / 12,
position=(360 - width / 2, height / 2 - 160, 600),
look_at=(360 - width / 2, height / 2 - 160, 0))
position=(360 - width / 2, 160 - height / 2, 600),
look_at=(360 - width / 2, 160 - height / 2, 0))

# Moving spotlight that follows the mouse
blue = spot_light((0.4, 0.6, 0.8), 10000000000.0, 1200.0, 1.0, 0.0, PI / 12,
position=(360 - width / 2, height / 2, 600),
look_at=(360 - width / 2, height / 2, 0))
position=(360 - width / 2, -height / 2, 600),
look_at=(360 - width / 2, -height / 2, 0))
roughness(0.6)


def draw():
background(0.0)

blue.position(360 - width / 2, height / 2 - mouse_y, 600)
blue.look_at(360 - width / 2, height / 2 - mouse_y, 0)
blue.position(360 - width / 2, mouse_y - height / 2, 600)
blue.look_at(360 - width / 2, mouse_y - height / 2, 0)

sphere(120, 60, 60)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def draw():
global ry
background(0.0)

translate(0, -100, -200)
translate(0, 100, -200)
rotate_z(PI)
rotate_y(ry)
shape(rocket) # GAP: shape(model) draws a loaded model
Expand Down
4 changes: 2 additions & 2 deletions crates/processing_pyo3/examples/Demos/Graphics/planets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setup():
# pointLight(255, 255, 255, 0, 0, 0) at the sun's position, and
# pointLight(255, 255, 255, 0, 0, -150) at the screen corner for planet1
sun_light = point_light((1.0, 1.0, 1.0), 1000000.0, 1200.0, 1.0, position=(0, 0, -300))
planet_light = point_light((1.0, 1.0, 1.0), 1000000.0, 1200.0, 1.0, position=(-width / 2, height / 2, -150))
planet_light = point_light((1.0, 1.0, 1.0), 1000000.0, 1200.0, 1.0, position=(-width / 2, -height / 2, -150))


def draw():
Expand Down Expand Up @@ -64,7 +64,7 @@ def draw():

pop_matrix()

translate(0.25 * width, -0.1 * height, 50)
translate(0.25 * width, 0.1 * height, 50)
texture(surftex1)
sphere(150, 40, 40)
no_texture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def draw():
opacity = 1.0 - lifetimes[n] / part_lifetime

if lifetimes[n] == 0:
# Re-spawn dead particle (the 3D origin is the canvas center, y up)
# Re-spawn dead particle (the 3D origin is the canvas center)
positions[n].x = mouse_x - width / 2
positions[n].y = height / 2 - mouse_y
positions[n].y = mouse_y - height / 2

angle = random(0, TWO_PI)
s = random(0.5 * speed, 0.5 * speed)
Expand All @@ -62,7 +62,7 @@ def draw():
positions[n].x += velocities[n].x
positions[n].y += velocities[n].y

velocities[n].y -= gravity
velocities[n].y += gravity
draw_particle(positions[n], opacity)

fcount += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ def draw():
tints[n] = [1.0, 1.0, 1.0, opacity]

if lifetimes[n] == 0:
# Re-spawn dead particle (the 3D origin is the canvas center, y up)
positions[n] = [mouse_x - width / 2, height / 2 - mouse_y, 0.0]
# Re-spawn dead particle (the 3D origin is the canvas center)
positions[n] = [mouse_x - width / 2, mouse_y - height / 2, 0.0]
angle = random(0, TWO_PI)
s = random(0.5 * speed, 0.5 * speed)
velocities[n].x = s * cos(angle)
velocities[n].y = s * sin(angle)
else:
positions[n][0] += velocities[n].x
positions[n][1] += velocities[n].y
velocities[n].y -= gravity
velocities[n].y += gravity
else:
tints[n] = [0.0, 0.0, 0.0, 0.0]

Expand Down
12 changes: 6 additions & 6 deletions crates/processing_pyo3/examples/Demos/Tests/multiple_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ def draw():
arcball.run()
if mouse_is_pressed:
fill(0.0)
text("Mouse pressed on parent.", 10 - width / 2, height / 2 - 10)
text("Mouse pressed on parent.", 10 - width / 2, 10 - height / 2)
fill(0.0, 0.94, 0.0)
ellipse(mouse_x - width / 2, height / 2 - mouse_y, 60, 60)
ellipse(mouse_x - width / 2, mouse_y - height / 2, 60, 60)
mouse_pressed_on_parent = True
else:
fill(0.08)
ellipse(0, 0, 60, 60)
mouse_pressed_on_parent = False
box(100)
if child.g.mouse_is_pressed:
text("Mouse pressed on child.", 10 - width / 2, height / 2 - 30)
text("Mouse pressed on child.", 10 - width / 2, 30 - height / 2)

child.draw()

Expand Down Expand Up @@ -69,17 +69,17 @@ def draw(self):
arcball2.run()
if g.mouse_is_pressed:
g.fill(0.94, 0.0, 0.0)
g.ellipse(g.mouse_x - g.width / 2, g.height / 2 - g.mouse_y, 20, 20)
g.ellipse(g.mouse_x - g.width / 2, g.mouse_y - g.height / 2, 20, 20)
g.fill(1.0)
g.text("Mouse pressed on child.", 10 - g.width / 2, g.height / 2 - 30)
g.text("Mouse pressed on child.", 10 - g.width / 2, 30 - g.height / 2)
else:
g.fill(1.0)
g.ellipse(0, 0, 20, 20)

g.draw_box(100, 200, 100)
if mouse_pressed_on_parent:
g.fill(1.0)
g.text("Mouse pressed on parent", 20 - g.width / 2, g.height / 2 - 20)
g.text("Mouse pressed on parent", 20 - g.width / 2, 20 - g.height / 2)


# Ariel and V3ga's arcball class with a couple tiny mods by Robert Hodgin
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/Demos/Tests/redraw_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def setup():

def draw():
background(1.0, 0.0, 0.0)
ellipse(mouse_x - width / 2, height / 2 - mouse_y, 100, 50)
ellipse(mouse_x - width / 2, mouse_y - height / 2, 100, 50)
print("draw")


Expand Down
7 changes: 3 additions & 4 deletions crates/processing_pyo3/examples/Topics/Geometry/space_junk.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ def setup():
int(random(-10, 10)), int(random(-140, 140)),
int(random(-140, 140)), int(random(-140, 140))))

# Set up some different colored lights, placed relative to the top-left
# corner as in the original (the world is centered and y-up)
# Set up some different colored lights, in the original's top-left coordinates
blue_light = point_light((0.2, 0.4, 1.0), 3000000000.0, 600.0, 1.0,
position=(65 - width / 2, height / 2 - 60, 100))
position=(65 - width / 2, 60 - height / 2, 100))
red_light = point_light((0.78, 0.16, 0.24), 3000000000.0, 600.0, 1.0,
position=(-65 - width / 2, height / 2 + 60, -150))
position=(-65 - width / 2, -60 - height / 2, -150))

# Raise overall light in scene
ambient_light(0.27, 0.27, 0.04) # GAP: ambient_light()
Expand Down
Loading
Loading