Skip to main content
added 462 characters in body
Source Link
Sam
  • 31
  • 2

I would like to detect if a cube is in the right half of the camera's view:

enter image description here

I'm trying to do this with geometry nodes. Here's what I have so far:

enter image description here

(Bottom half of this image) I normalize the cube's position, bring it to view-space and perform a dot product on it (with the camera's local x-axis?) and output the dp value as an attribute.

(Top-left of this image) I use this dp value to color the cube in the scene.

(Top-right of this image) There's a camera with its local axis orientation annotated on the screen as well as the cube I mentioned before.

enter image description here

The problem I'm having here is I don't think I'm using the correct camera's positive x-axis when performing the dot product. When I move the cube around the camera on the x-y plane, the cube turns black when it's on the right side of the camera (meaning the dp <= 0) and when it's on the left side of the camera, it turns white (dp > 0), which is the complete opposite of what I want.

Here's a video showing the incorrect result: https://i.sstatic.net/UQzbW.jpg

I know I can simply add a "Math" node after the "Separate XYZ" and multiply it by -1 to flip it but I want to get the correct positive x-axis without having to flip it.

Edit: Please ignore the incorrect use of the "Separate XYZ" into the dot product node; it inputs a vector with a value of (X,X,X) into the dot product. I thought it was going to input (X,0,0) into it. I fixed that tiny mistake by putting a "Combine XYZ" (using (X,0,0) as the values) after the "Separate XYZ". But this is a moot point because if you look at @RobinBetts reply below, I need to use "Vector" and "Vector Rotate" for the local x-axis instead anyway.

I would like to detect if a cube is in the right half of the camera's view:

enter image description here

I'm trying to do this with geometry nodes. Here's what I have so far:

enter image description here

(Bottom half of this image) I normalize the cube's position, bring it to view-space and perform a dot product on it (with the camera's local x-axis?) and output the dp value as an attribute.

(Top-left of this image) I use this dp value to color the cube in the scene.

(Top-right of this image) There's a camera with its local axis orientation annotated on the screen as well as the cube I mentioned before.

enter image description here

The problem I'm having here is I don't think I'm using the correct camera's positive x-axis when performing the dot product. When I move the cube around the camera on the x-y plane, the cube turns black when it's on the right side of the camera (meaning the dp <= 0) and when it's on the left side of the camera, it turns white (dp > 0), which is the complete opposite of what I want.

Here's a video showing the incorrect result: https://i.sstatic.net/UQzbW.jpg

I know I can simply add a "Math" node after the "Separate XYZ" and multiply it by -1 to flip it but I want to get the correct positive x-axis without having to flip it.

I would like to detect if a cube is in the right half of the camera's view:

enter image description here

I'm trying to do this with geometry nodes. Here's what I have so far:

enter image description here

(Bottom half of this image) I normalize the cube's position, bring it to view-space and perform a dot product on it (with the camera's local x-axis?) and output the dp value as an attribute.

(Top-left of this image) I use this dp value to color the cube in the scene.

(Top-right of this image) There's a camera with its local axis orientation annotated on the screen as well as the cube I mentioned before.

enter image description here

The problem I'm having here is I don't think I'm using the correct camera's positive x-axis when performing the dot product. When I move the cube around the camera on the x-y plane, the cube turns black when it's on the right side of the camera (meaning the dp <= 0) and when it's on the left side of the camera, it turns white (dp > 0), which is the complete opposite of what I want.

Here's a video showing the incorrect result: https://i.sstatic.net/UQzbW.jpg

I know I can simply add a "Math" node after the "Separate XYZ" and multiply it by -1 to flip it but I want to get the correct positive x-axis without having to flip it.

Edit: Please ignore the incorrect use of the "Separate XYZ" into the dot product node; it inputs a vector with a value of (X,X,X) into the dot product. I thought it was going to input (X,0,0) into it. I fixed that tiny mistake by putting a "Combine XYZ" (using (X,0,0) as the values) after the "Separate XYZ". But this is a moot point because if you look at @RobinBetts reply below, I need to use "Vector" and "Vector Rotate" for the local x-axis instead anyway.

Became Hot Network Question
edited title
Link
Sam
  • 31
  • 2

Dot product of vector with cameracamera's local positive x-axis?

Source Link
Sam
  • 31
  • 2

Dot product of vector with camera local x-axis?

I would like to detect if a cube is in the right half of the camera's view:

enter image description here

I'm trying to do this with geometry nodes. Here's what I have so far:

enter image description here

(Bottom half of this image) I normalize the cube's position, bring it to view-space and perform a dot product on it (with the camera's local x-axis?) and output the dp value as an attribute.

(Top-left of this image) I use this dp value to color the cube in the scene.

(Top-right of this image) There's a camera with its local axis orientation annotated on the screen as well as the cube I mentioned before.

enter image description here

The problem I'm having here is I don't think I'm using the correct camera's positive x-axis when performing the dot product. When I move the cube around the camera on the x-y plane, the cube turns black when it's on the right side of the camera (meaning the dp <= 0) and when it's on the left side of the camera, it turns white (dp > 0), which is the complete opposite of what I want.

Here's a video showing the incorrect result: https://i.sstatic.net/UQzbW.jpg

I know I can simply add a "Math" node after the "Separate XYZ" and multiply it by -1 to flip it but I want to get the correct positive x-axis without having to flip it.