Raycasting with Geometry Nodes | Blender 3.0 tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you ever picked around in the yarmouth notes workspace you probably stumble upon a note called raycast and after fiddling around with it a bit chances sorry came to the conclusion that it seems a bit too complex to easily make sense of but no worries my plan with this video is to demystify at least the core features of what i think is one of the most powerful and versatile notes available right now [Music] before i get into how raycasting works let's create some geometry we can use to demonstrate add a plane that we can apply the unit's modifier to also add a monkey head and position it below the plane this will be the object that we use to cast race on in the geometry nodes workspace select the plane and press new then drag the monkey from the scene overview into the geonose tree and set the object info node to relative delete the group input and instead add a grid [Music] set the size to 3 in both x and y i set both vertices x and y to something like 100 then add an instance on points node and connect it to the group output then connect the grid node to the instance of points node next add a cube from the mesh primitives and connect it to the instance input of the instance on points node of course the cubes are way too big so set the size to something like 0.015 with the geometry in place let's add the raycast node before we do anything with it let's go over what some of these inputs and outputs actually mean ray length just tells the node the max distance that rays are allowed to travel so anything further away than this value will not be detected by the ray casting ray direction tells the node in what direction to cast a race and this vector is in local space which means that it is dependent on the rotation of the object that is casting the rays in our case since we haven't rotated the plane negative 1 on the z-axis is the same as negative 1 on the global z-axis so the rays will be cast straight down towards the monkey you might have noticed that while the raycast node has a geometry input it doesn't have a geometry output instead the outputs of the request node has to do with information that can be extracted from the point that the ray actually hit to illustrate connect the object info node to the geometry socket of the request node then add a set position node after the instance on points node if we connect the hit position from the raycast node to the position of the set position node you will notice that all the currents are now scattered on the surface of the monkey if we then connect the s hit from the request node to the selection of the set position node it's immediately more apparent what's going on in essence rays are being cast from the geometry created in the geonote system straight down wherever array hit is detected we then use the position of that hit to set the position of that geometry but then using the is hit information which is a boolean that returns true if a hit is detected and otherwise false we can create a mask that determines what parts of the geometry that should be affected hit normals gives us the normal vector of the face that the ray has hit and hit distance which we will use in a moment gives us the distance that the ray traveled before hitting something so let's say that instead of placing the cubes on the surface of the monkey we instead want to displace them upwards to create a sort of imprint effect this is where hit distance comes in handy add a math node set to multiply [Music] another math note set to subtract a map range node a combined xyz node and a separate xyc node connect the hit distance to the multiply node and set the value to negative 1. then connect the multiply node to the top socket of the subtract node connect the location of the object info node to the separate xyz node and then connect the c output to the bottom socket of the subtract node then connect the subtract node to the c input of the combined xyc node and finally connect that node to the offset input of the set position node [Music] to make sure that no cube goes below zero on the z axis plug the map range node between the subtract node and the combined xyz node set both from max and two max to some larger value like 10. at this point to get the more pin like effect you can change the sea size of the cube to further demonstrate the power of raycasting let's also create this scanner effect disable the collection and create a new collection and rename it to instance objects in this collection add a monkey and rename it to head bass then duplicate it and rename the new copy to head wire with the head wire object selected go to the modifiers tab and add a subdivision surface modifier set to simple and set the number of subdivisions to two then add a wireframe modifier after that disable the instant subject collection and create a new collection in this new collection add a plane [Music] and then add an empty with the plane selected go to the geometry nodes workspace and press new then drag the empty into the unnotes instance and set the object info node to relative like before delete the group input and instead add a grid and set the size x and y to 0.75 next add a transform node and connect both location rotation and scale from the object info node to the corresponding sockets of the transform node and then connect the grid node to it if we connect the transform node to the group output we can now change both position scale and rotation of the grid by using this empty make two duplicates of the arabic infant node and swap the empty object with the two monkeys [Music] add a urine geometry node and connect the transformer to it along with the monkeys add a separate geometry node and place it between the object infant node containing the headwire object and the join geometry node finally add a rayquez node with its ray direction set to 0 0 1 and connect the transform node to the yamda input [Music] as you might have guessed all we need to do now is connect these hit outputs to the selection input of the separate arm to node to get the desired effect the way it works is that the monkey geometries are casting rays straight up in the scene and when array hits whatever object we have set as a target geometry in this case the grid it will register that ray as a hit we then use that hit information to create a mask with a separate geometry node and that is what these two selection and inverted outputs are useful for if we instead connected the inverted output to the joining armor node we will get the geometry whose rays did not register hit to make the wireframe look more like a scanner enable the instance collection and with the head wire object selected go to the materials tab and create a new material [Music] scroll down to the mission section and set the mission strength to 15 and select the bright color to make the effect pop even more and easy go to the render properties tab and enable bloom the main thing to keep in mind when it comes to rayquez note is that it doesn't do much on its own instead the point of it is to provide you with information about whatever array has hit it is then up to you to use that information in a meaningful way so with that i hope that this video has given you some insight into how the raycast note works at least enough that you can start playing around with it yourself [Music] [Music] you
Info
Channel: Khamurai
Views: 4,053
Rating: undefined out of 5
Keywords:
Id: oU-QQ3uPLOA
Channel Id: undefined
Length: 9min 20sec (560 seconds)
Published: Sun Nov 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.