Skip to content

Conversation

hmaarrfk
Copy link
Contributor

@hmaarrfk hmaarrfk commented Apr 3, 2024

My first observation are:

  • My pointer_move event is no longer getting triggered for the one I attached to my scene.
  • It still doesn't make the lines on the example code not block the pip. Maybe i missed something?

xref: #702

General todo list

  • Get pointer picking to work as expected on examples/feature_demo/image_click_events.py
  • Go through each of the demos to assess if they are broken or not.
  • Fix the broken demo files
  • Decide on appropriate default values for the pickability of different material.

@hmaarrfk hmaarrfk requested a review from Korijn as a code owner April 3, 2024 01:42
@hmaarrfk hmaarrfk marked this pull request as draft April 3, 2024 01:42
@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 3, 2024

In building #700 i learned that a "pick" is generated everytime you move your mouse, so for the very least, the background of the scene should be made pickable to get the mouse movement events.

@almarklein
Copy link
Member

I think I know what's missing. In blender.py, the get_color_descriptors() will produce a descriptor for the picking, but this should happen conditionally now. I think we can add a material_write_pick arg to get_color_descriptors().

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 5, 2024

I think I tried something like your suggestion in 65cb368

but it seems that have crashed quite badly on me.

I'll have to sleep on this. maybe read more about GPUs

@almarklein
Copy link
Member

I think I tried something like your suggestion in 65cb368

Not exactly what I meant. Sorry for being not sufficiently clear. I meant that in the implementation of the get_color_descriptors() methods that produce a color descriptor for picking, this should be optional. In particular, these cases:

def get_color_descriptors(self, blender):
bf, bo = wgpu.BlendFactor, wgpu.BlendOperation
return [
{
"format": blender.color_format,
"blend": {
"alpha": (bf.one, bf.zero, bo.add),
"color": (bf.one, bf.zero, bo.add),
},
"write_mask": wgpu.ColorWrite.ALL,
},
{
"format": blender.pick_format,
"blend": None,
"write_mask": wgpu.ColorWrite.ALL,
},
]

def get_color_descriptors(self, blender):
bf, bo = wgpu.BlendFactor, wgpu.BlendOperation
return [
{
"format": blender.color_format,
"blend": {
"alpha": (bf.one, bf.one_minus_src_alpha, bo.add),
"color": (bf.one, bf.one_minus_src_alpha, bo.add),
},
"write_mask": wgpu.ColorWrite.ALL,
},
{
"format": blender.pick_format,
"blend": None,
"write_mask": wgpu.ColorWrite.ALL,
},
]

def get_color_descriptors(self, blender):
bf, bo = wgpu.BlendFactor, wgpu.BlendOperation
return [
{
"format": blender.frontcolor_format,
"blend": {
"alpha": (bf.one, bf.zero, bo.add),
"color": (bf.one, bf.zero, bo.add),
},
"write_mask": wgpu.ColorWrite.ALL,
},
{
"format": blender.pick_format,
"blend": None,
"write_mask": wgpu.ColorWrite.ALL,
},
]

And these methods of the passes are all called via this method of the blender object:

def get_color_descriptors(self, pass_index):
return self.passes[pass_index].get_color_descriptors(self)

@almarklein
Copy link
Member

I'll have to sleep on this. maybe read more about GPUs

Not so much related to GPU's. The pipeline.py is probably the trickiest code in pygfx to follow, because it's where a lot of things come together.

@hmaarrfk hmaarrfk force-pushed the make_write_pick_optional branch 2 times, most recently from 08d0377 to f9014ff Compare April 6, 2024 03:40
@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 6, 2024

my notes
  • validate_helpers2.py

    • PASS: Used the mouse to move the axes.
    • PASS: This continue to work even after write_pick is false
  • validate_line_2d.py

    • PASS: can still control rotating the camera
  • validate_line_dash.py

    • PASS: can still control camera
  • validate_line_thickness_space.py

    • PASS: can still control camera
  • validate_meshslice.py

    • FAIL: hover over mesh no longer produced text on the screen.
    • FIX: Needed to make the mesh pickable
  • validate_skybox.py

    • FAIL: Skybox disappeared????? But the reflection in the ball is still good???
    • FIX: Neded to make the skybox pickable???? what??? why....
    • REASON: It seems that some feature of the skybox shader is using write_pick as a detection of the opaque pass.
  • collection_line.py

    • PASS: can zoom in with mouse
  • cube_wx.py

    • UNTESTED
  • light_view.py

    • UNRELATED FAIL: AttributeError: module 'pylinalg' has no attribute 'Quaternion'
    • PASS: Camera control
  • reactive_rendering.py:

    • UNREALTED: ModuleNotFoundError: No module named 'observ'
    • MUST CHECK: event_handlers added
  • examples/other/sponza_scene.py

    • UNRELATED FAIL: RuntimeError: Could not find 'glTF-Sample-Models' directory.
  • clipping_planes.py

    • PASS: can rotate things
  • cube.py

    • FAIL: background disappeared
    • FIX: Neded to make the background pickable???? what??? why....
    • REASON: It seems that some feature of the background shader is using write_pick as a detection of the opaque pass.
  • light_basic.py

    • seems like i can move around. seems like the light is working
  • object_bounding_box.py

    • seems like the bounding box shows up
  • orbit_camera.py

    • FAIL: background doesn't show up
    • FIX: Same as other background stuffs
  • points_basic.py

    • FAIL: background not rendered
    • FIX: Background(pick_write=True)

Feature

  • aomap.py

  • colormap_channels.py

  • colormap_image.py

  • colormap_mesh.py

  • custom_object1.py

  • custom_object2.py

  • custom_object3.py

  • cylinder.py

  • dynamic_env_map.py -- Background pick_write bug

  • env_maps.py -- Background pick_write bug

  • flat_shaded_torus.py

  • fly_controller.py

  • geometry_cubes.py

  • geometry_image.py

  • geometry_klein_bottle.py

  • geometry_mobius.py

  • geometry_plane.py

  • geometry_polyhedron.py

  • geometry_polyhedron_subdivisions.py

  • geometry_torus_knot.py

  • helpers_gizmo.py -- fixed

  • helpers_stats.py

  • image_click_events.py -- You can now click the points!!! and it clicks through them!!!

  • image_overlay.py

  • image_plus_points.py

  • instancing_mesh.py

  • light_directional_shadow.py

  • lightmap.py

  • light_shadow.py

  • light_spotlight_shadows.py

  • light_spotlights.py

  • line_basic.py

  • line_performance.py

  • line_segments.py

  • line_thick.py

  • look_at.py

  • manual_matrix_update.py

  • map_click_events_to_world.py -- looks black... add pick_write=True... -- background hack

  • mesh_depth_material.py

  • mesh_dynamic.py

  • mesh_slice.py

  • multiprocessing_zmq

  • multi_select.py -- Had to add picking to cubes

  • multi_slice1.py -- background hack

  • multi_slice2.py -- background hack

  • paint_to_texture.py -- background hack, image must be write_pick=True

  • panzoom_camera.py -- background hack

  • pbr2.py -- background skybox hack

  • pbr.py -- background skybox hack

  • physical_color.py

  • picking_color.py -- background hack -- cube write pick

  • picking_mesh.py -- background hack -- write pick on objects

  • picking_points.py -- write_pick enabled

  • quad_mesh.py -- background hack -- write pick on objects

  • README.rst

  • scene_in_a_scene.py -- background hack

  • scene_overlay.py

  • scene_subplots1.py

  • scene_subplots2.py -- background hack

  • scene_subplots_video.py

  • show_image.py

  • show_scene.py

  • show_stl.py

  • skybox.py -- background hack

  • skybox_rotate.py -- background hack

  • spheres.py

  • synced_video.py

  • text_contrast.py -- background hack

  • text_snake.py -- and object pick write

  • text_waterfall.py -- background hack

  • transparency1.py

  • transparency2.py

  • volume_render1.py -- object pick write

  • volume_render2.py

  • volume_slice1.py

  • volume_slice2.py

  • volume_slice3.py -- pick_write object

  • wireframe1.py

  • wireframe2.py

  • wireframe_material.py

  • world_bounding_box.py

hmaarrfk added a commit to hmaarrfk/pygfx that referenced this pull request Apr 6, 2024
This was found in pygfx#704

It seems that write_pick was previously used a sentinel to detect the
type of pass that was getting used.

It is currently defined as true when:

* BasePass
* OpaquePass
* FullOpaquePass
* SimpleSinglePass
* FrontmostTransparencyPass
@hmaarrfk hmaarrfk force-pushed the make_write_pick_optional branch 2 times, most recently from 611d3b7 to 90f27e3 Compare April 6, 2024 13:26
Korijn pushed a commit that referenced this pull request Apr 8, 2024
#711)

This was found in #704

It seems that write_pick was previously used a sentinel to detect the
type of pass that was getting used.

It is currently defined as true when:

* BasePass
* OpaquePass
* FullOpaquePass
* SimpleSinglePass
* FrontmostTransparencyPass
@hmaarrfk hmaarrfk force-pushed the make_write_pick_optional branch from 90f27e3 to 9825550 Compare April 9, 2024 09:24
@hmaarrfk hmaarrfk marked this pull request as ready for review April 9, 2024 13:49
@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 9, 2024

Ok i added a note in the docs about the change in the default value.

Hopefully this is good to go.

@hmaarrfk hmaarrfk force-pushed the make_write_pick_optional branch from a78bd05 to 799da22 Compare April 9, 2024 13:50
@Korijn
Copy link
Collaborator

Korijn commented Apr 10, 2024

Have you confirmed toggling pick_write at runtime works as expected?

Looks good to go other than some small typos, see my inline comments.

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 10, 2024

Have you confirmed toggling pick_write at runtime works as expected?

No.

I need to think of a "demo" test for this.

Co-authored-by: Korijn van Golen <korijn@gmail.com>
@Korijn Korijn enabled auto-merge (squash) April 10, 2024 13:57
@Korijn
Copy link
Collaborator

Korijn commented Apr 10, 2024

Have you confirmed toggling pick_write at runtime works as expected?

No.

I need to think of a "demo" test for this.

We'll merge, would be great if you could still follow up on that check.

Thanks a ton!

@almarklein
Copy link
Member

Have you confirmed toggling pick_write at runtime works as expected?

I just checked, and it does not 😛 Created #720 to track. I can have a look.

@hmaarrfk
Copy link
Contributor Author

😮‍💨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants