Skip to content

Commit 2096f22

Browse files
committed
DOCS: updated examples and tests to adapt to impostor sphere
1 parent 2cfc870 commit 2096f22

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

docs/examples/viz_billboard_spheres.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
# These are actual 3D mesh spheres with vertices and faces.
3535

3636
geometry_spheres = actor.sphere(
37-
centers=centers + np.array([[0, -2, 0]]), colors=colors, radii=radii, opacity=1
37+
centers=centers + np.array([[0, -2, 0]]),
38+
colors=colors,
39+
radii=radii,
40+
opacity=1,
41+
impostor=False,
3842
)
3943

4044
###############################################################################

fury/actor/tests/test_curved.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
def test_sphere():
2323
centers = np.array([[0, 0, 0]])
2424
colors = np.array([[1, 0, 0]])
25-
validate_actors(
26-
centers=centers, colors=colors, actor_type="sphere", impostor=False
27-
)
25+
validate_actors(centers=centers, colors=colors, actor_type="sphere", impostor=False)
2826

2927

3028
def test_cylinder():

fury/wgsl/billboard_render.wgsl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@ fn vs_main(in: VertexInput) -> Varyings {
4949
varyings.world_pos = vec3<f32>(world_pos);
5050

5151
// Load color if available - colors are duplicated 6x like positions
52-
let color = load_s_colors(billboard_index * 6);
53-
varyings.color = vec4<f32>(color, 1.0);
52+
$$ if color_buffer_channels == 4
53+
varyings.color = vec4<f32>(load_s_colors(billboard_index * 6));
54+
$$ elif color_buffer_channels == 3
55+
varyings.color = vec4<f32>(load_s_colors(billboard_index * 6), 1.0);
56+
$$ elif color_buffer_channels == 2
57+
let cvalue = load_s_colors(billboard_index * 6);
58+
varyings.color = vec4<f32>(cvalue.r, cvalue.r, cvalue.r, cvalue.g);
59+
$$ elif color_buffer_channels == 1
60+
let cvalue = load_s_colors(billboard_index * 6);
61+
varyings.color = vec4<f32>(cvalue, cvalue, cvalue, 1.0);
62+
$$ endif
5463

5564
return varyings;
5665
}

fury/wgsl/billboard_sphere_render.wgsl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@ fn vs_main(in: VertexInput) -> Varyings {
4949
var varyings: Varyings;
5050
varyings.position = vec4<f32>(clip_pos);
5151
varyings.world_pos = vec3<f32>(world_pos);
52-
let color = load_s_colors(billboard_index * 6);
53-
varyings.color = vec4<f32>(color, 1.0);
52+
$$ if color_buffer_channels == 4
53+
varyings.color = vec4<f32>(load_s_colors(billboard_index * 6));
54+
$$ elif color_buffer_channels == 3
55+
varyings.color = vec4<f32>(load_s_colors(billboard_index * 6), 1.0);
56+
$$ elif color_buffer_channels == 2
57+
let cvalue = load_s_colors(billboard_index * 6);
58+
varyings.color = vec4<f32>(cvalue.r, cvalue.r, cvalue.r, cvalue.g);
59+
$$ elif color_buffer_channels == 1
60+
let cvalue = load_s_colors(billboard_index * 6);
61+
varyings.color = vec4<f32>(cvalue, cvalue, cvalue, 1.0);
62+
$$ endif
5463
varyings.texcoord_vert = vec2<f32>(tex_coord);
5564
varyings.billboard_center = vec3<f32>(world_center.x, world_center.y, world_center.z);
5665
varyings.billboard_right = vec3<f32>(cam_right.x, cam_right.y, cam_right.z);

0 commit comments

Comments
 (0)