Skip to content

Conversation

hmaarrfk
Copy link
Contributor

@hmaarrfk hmaarrfk commented Apr 1, 2024

So maybe I'm hacking too much and feel free to reject this patch, but I'm overlaying one scene onto the main scene to create some kind of picture in picture preview.

It would be really useful to interact with the background of the scene since it indicates that the user has clicked on the picture in picture (but maybe not on an object).

I haven't really gone through the codepath to make picking background textures meaningful but this is already more than enough for me.

Otherwise, the pick just goes to the "object behind my picture in picture".

Thanks for considering

So maybe I'm hacking too much and feel free to reject this patch, but
I'm overlaying one scene onto the main scene to create some kind of
picture in picture preview.

It would be really useful to interact with the background of the scene
since it indicates that the user has clicked on the picture in picture
(but maybe not on an object).

I haven't really gone through the codepath to make picking background
textures meaningful but this is already more than enough for me.

Otherwise, the pick just goes to the "object behind my picture in
picture".

Thanks for considering
@hmaarrfk hmaarrfk requested a review from Korijn as a code owner April 1, 2024 00:46
@hmaarrfk hmaarrfk force-pushed the allow_background_picking branch from 4dfa79a to d2fa038 Compare April 3, 2024 01:42
@hmaarrfk hmaarrfk marked this pull request as draft April 3, 2024 11:57
@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 4, 2024

ok so for the skybox, you basically sample with a direction vector, which isn't super intuitive and I'm not sure how you perfer to return this. The basics are in here. I need to review with a clear head to get something "right".

Some questions I still need to answer for myself:

  • Always return a tuple of length 3?
  • Is it ok to return a "direction vector" for the skybox? or do we want "u, v, face_index" or something of that sort.

@almarklein
Copy link
Member

Oh, I now realize I assumed that the varyings.texcoord always represented the full quad coords, and the .z field indicating the face of the cube, but this is not the case; it's the direction vector. Sorry, my earlier comments may have been confusing because of this.

I propose to keep it simple:

  • In the vertex shader always do varyings.texcoord = vec3<f32>(pos * 0.5 + 0.5, 0.0);
  • For cube texture use new varyings.cubecoord (instead of using textcoord for it).
  • Send this texcoord as picking info and expose it as a coord field in the pick info dict.
  • Forget about cube-specific pick info for now.

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 4, 2024

I propose to keep it simple:

  • In the vertex shader always do varyings.texcoord = vec3(pos * 0.5 + 0.5, 0.0);
  • For cube texture use new varyings.cubecoord (instead of using textcoord for it).
  • Send this texcoord as picking info and expose it as a coord field in the pick info dict.
  • Forget about cube-specific pick info for now.

Are these mutually exclusive options? Sorry the choice of words makes it seem like they could be sequential.

As it stand "right now" (i might force push to cleanup the commit history), the normalized direction vector is being sent. After sleeping on it, it makes sense to me for a direction vector to get sent because in a "skybox" the most important thing might be "the direction where the user clicked".

The "6 sided cube trick" to me feels like a neat graphics trick, but I wonder if it helps or hinders the downstream application from being able to use the information effectively.

For example, I could see an application placing markers:

  • Current position + skybox vector * 10

away as the user clicks on the skybox.

It seems that the picking info is super material specific, so I'm not too worried about that.
I might suggest that the BackgroundImage material loose its ability to take in Cube matrial. When "inputs" change return values, to me that is where the API gets messy.

If:

  • BackgroundImageMaterial throws an error on skybox textures, then it becomes a clear rule that the returned pick info is a 2D coordinate.
  • BackgroundSkyboxMaterial always returns a 3D unit vector.

@almarklein
Copy link
Member

Are these mutually exclusive options? Sorry the choice of words makes it seem like they could be sequential.

No I meant these as a package of choices to keep things simple. In other words, I said: let's forget about the skybox and always return a vector that can be used to see where on the screen the user clicked.

Now that I think about it, the position where the user clicked should (eventually) be part of the info always, the renderer can do that (once we figure out what to do with viewports). So maybe ... forget about any pick info for now! 🤷

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 4, 2024

So maybe ... forget about any pick info for now! 🤷

I'm down, i just want it to "respond" to "mouse move". Right now, moving the mouse over the Background just "ignores it"

@hmaarrfk hmaarrfk marked this pull request as ready for review April 5, 2024 02:22
@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Apr 5, 2024

Keeping it so simple it seems my top level comment is still appropriate.

I added a comment pointing to this discussion. Not sure if you find that appropriate.

Thanks for your time again!

@Korijn Korijn enabled auto-merge (squash) April 5, 2024 05:56
@Korijn Korijn merged commit 0189f81 into pygfx:main Apr 5, 2024
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