Beginner Geometry Nodes - Procedural Temple | VFX Shorts

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you know legend says it has been foretold thousands of years ago that open source will reign supreme not all agreed calling it a monkey business boy did that backfire these are the first historic mentions the birth of open source welcome to jamunji [Music] i'm trying really hard not to get a copyright strike all right so today i'm going to show you how to create this procedural temple floors stairs top chamber statues all of them are configurable you can turn on and off some of them and i try to make this as beginner friendly as possible by beginner friendly i don't mean this is the first time that you ever opened blender but by beginner friendly i mean that i'm trying to explain as much as possible the thought process that i'm going through when creating this asset that being said like because this liking is useless right now enjoy the video alright so starting as usual with a fresh scene going to geometry nodes i'm going to delete the camera and the light i'm going to create a new node setup so i'm going to call it temple so the first thing that i want to do is i want to create the first floor and for that i'm going to use a cone and i'm going to set the vertices to 4 so that we have now a very tall pyramid the radius stopped to 1.7 and the radius button to 1.85 and the depth to 0.2 the reason why i'm using these values is because i noticed that these are the ones that work the best from testing now i can cut this connection i can add a mesh line plug this into the output instance on points and then i can use this cone and plug it into the instances and now i have all of these floating floors but i want to make them sit on top of each other so if we play with let me just get a bit closer if we play with depth this is what happens and if we play with offset this is what happens so if we make both of these values be equal to each other we will notice that they will perfectly be placed on top of each other so i'm going to add a value node over here set it to 0.2 plug this into depth and then use a combine xyz so that i can control only the z value of this offset and now all of the floors are sitting perfectly on top of each other so this is the first step i'm going to select all of them hit ctrl j and then select the frame and press f2 and i'm going to call this floor count i'm also going to increase the label size to maximum next up we want to scale each of these floors by a certain amount so for this i'm going to use scale instances and the first thing that i want to do i'm going to go into the right view i want whatever i'm going to do next to not affect this first floor these can be affected but this i want to nothing to happen to it so for this i'm going to use i'm going to use here index and compare compare um i'm using currently 3.1 alpha but this can be perfectly done in 3.0 the only difference is that this compare node is called compare floats in 3.0 so don't worry you can follow along so i'm going to use this compare floats and the index starts at 0 1 2 and so on so i want any index that is greater than zero only those to be affected by this scaling right so if you see if i play with these numbers the first floor nothing happens to it so i'm going to reset all these to one let's say that i want to scale each floor to make it smaller by 10 percent and that means that the first floor would be scale of one the next one would be point nine then point eight then point seven and so on but you will notice that we have these indexes over here that if i divide this number this index by 10 and i subtract this from one then i will get from this set of numbers i will get this set of numbers so i'm going to clean this up and i'm going to take index and do exactly what we talked so i'm going to add math node and i said i want to divide the index by 10 and then i want to subtract from 1 [Music] this value and i want this to control only the x and y like we saw earlier so i'm going to use again a combine x y z plug this into x and y and use this as scale and keep the z value to 1. and this is how the temple looks right now let's go first back to the floor count and decrease the mesh line count from 10 to 7 and then you will notice that we can decrease this value to change how this temple looks so that this platform over here has an increasing or decreasing width but unfortunately if i increase the floor count you will notice that the effect starts reversing itself at some point and in order to compensate for this we need to take into account the number of floors that we have over here so first i'm going to use this count and give to the user as an option so i'm going to call this floor count so that it's easily controllable from this menu over here so now i can use this number and plug it here into the divide node and actually instead of dividing the index by the floor count i'm actually going to multiply by divide by 1 over the floor count let me just make this prettier a little bit and this is how the temple would look like i'm going to set this to 7 floors one issue you will notice here is that if i increase the floor count to a very high number the bottom of each floor would be wider than the top of the floor below and i don't know exactly how to account for this how to fix this the only suggestion that i have is to use a sensible number like seven this goes it works well for floors up to nine or ten but usually for a temple that looks like this you would not want a floor count higher than i don't know 10. i'm gonna use seven for this example okay but first let me just select all of these ctrl j and call this floor scale increase the label size and now we can move to the next step which is creating the stairs and for this in order to explain the idea a little bit easier i'm going to use join geometry i'm going to place a cube over here i'm going to add a trans transform node and just move it to the side what i want to do is i want to create a set of stairs on this side but for this i want to start exactly from the middle of this edge on the bottom over here all the way to the top over here and currently if i search for edge i only have edge split there's no direct way to get the edge location like there is for vertices which is position or normals but there is a way that we can find the middle of this edge right here and that is by ending by using a bounding box and a raycast node so let me explain very quickly how this works if i go into top view what this bounding box does is it creates this cube this box that perfectly encapsulates this object the temple and we have a minimum and maximum over here minimum is this point which is the most negative x most negative y and most negative z and the maximum is this point which is the most positive x y and z and if we use this minimum as a source so we're telling the raycast node to cast the ray from this point the minimum and we cast array so we tell the ray direction to be in the positive x and in the positive y at the same time from this point so positive x and positive y and the z will be at zero we are going to project a ray from this point at perfectly 45 degrees in this direction and that ray will hit this edge of the at the bottom and this point so let's see how this works i'm going to take this as geometry and right now we have instances and for bounding box and raycast node we need geometry actual geometry so for this we need to realize instances first so that these nodes would work oh and by the way the way that i'm creating these these points over here is by by holding shift and right clicking and dragging the mouse on top of the noodles so you can create as many as you want anyway and i also want this object as the target geometry i want to cast array on this temple i'm going to plug this here as well and i said that i want the minimum as the source position so now if i use this hit position it's the position that that ray hits the temple we should see that this cube moves exactly on the location of that edge and this is exactly what happened let me just clean this up okay so what exactly can we do with this well instead of placing a cube there we can actually put a mesh line and instead of using transform i'm actually going to set this mesh line instead of offset i'm going to set it to end points delete the transform to a wireframe here i'm going to take the hit position and plug this into the start location of the mesh line and this moved the first point of the line on the edge that we calculated earlier so now i think it's pretty obvious we want to do the same thing for the top edge over here with this point from the mesh line with the end location over here so i'm going to duplicate the raycast node and i can't just use the maximum right now because i still need to be in this quadrant of the x and y axis you can follow the gizmo over here if you go in top view you see that we still want to be in this section of the x and y axis so that means we still need the negative x and the negative y the only difference is that we want the positive z so we need to create this vector because it's a combination of the minimum and maximum so we're going to use separate x y z one for minimum and one for maximum so that and we can use another combine x y z because we said that we want plus z we said that we want the negative x and the negative y but the positive z so now if i take this vector that we created and plug it into source position we make sure that we are also using the target location target geometry sorry all right if we plug the hit position now into end location let me just clean this up and get a bit closer we should see this point moving at the top edge and it works perfectly okay so what can we do now with all of this well we can instance on points again we can place cubes on top of it we can rotate the cubes by 45 degrees on the z and now we have our set of stairs and this is procedural because we can increase and decrease the number of stairs but the stairs remain in position where we placed them so that's very cool next up let's actually make them smaller so i'm going to scale instances and decrease the number over here and if we go into the side view in wireframe we will notice that the cubes are kind of overlapping between each other and what we want instead is that they would sit on top of each other so for this we need to actually scale the z value of the stairs but we need to know exactly by what number and we can find that number by if i go to front view by taking the height of the temple and we divide that by the number of stairs which is 17 in this case and that should give us the height that one stair should have so the first thing i'm going to do uh as i have the floor count over here i'm going to take this input and give the this this input as an option to the user and i'm going to name this stair count i'm going to set this to 10 for now and now i want to find out the height of the temple and for this i can go here in the bounding box where i have the separate xyz and i can use a math node and set this to subtract and i can subtract the maximum z from the minimum and this is going to give me the height of the temple and i say that i want to divide this height i want to divide by the number of stairs so i'm going to take from here this number and plug it on the bottom and i said that i want this number which is the height of the stair to be used here in scale instances to drive the z value so i'm going to use a combine x y z i'm going to drag this down to the divide i want this to control the z x and y i want their scaling to be kept at one so not modifying that scaling at all i'm going to plug this into scale and we will see that the stairs now are skilled accordingly you will let me just clean this up you will notice that there is a little bit of a gap between the stairs and this is because the bottom of the stair has this half a stair offset and so does the topmost stair and we can actually compensate for this by offsetting the start and end location by half a stair but we actually calculated the stair height over here let me drag this here so we actually calculated the stair height over here so we can use this we said that we want only half a stair so we divide that number by two we drag this a little bit to the right i'm going to add a vector math to the start location because i want to add half a stair on the z value so i'm going to combine x y z i want to add half a stair to the start location so this is perfectly aligned and i want to do the same thing for the end location but this time i want to subtract instead let's go to the whoops let's go to the top and see how this works i'm going to subtract and now this this glitch right here is the blender confirmation that there are two overlapping planes and this means that the the stairs are perfectly aligned with the floors so now you will notice that there are no more gaps between the stairs and we can still increase or decrease the stair count as we want all right next up i want to resize the cube the stairs a little bit so i'm going to decrease the x value and then i want to decrease the y value as well so that it doesn't poke outside and you will notice one issue for example this top floor which is very very small forces me to have a very narrow set of stairs and i want to widen them a little bit so i'm going to remove this top floor because i i don't like how it contributes to the overall look and this is actually pretty simple we can go back to the floor count at the beginning and i'm going to use the index and we want two instance floors on all of the points except the last one so i'm going to compare floats if the index is less than the floor count i want those floors to be present but since the index starts at zero and right now we have seven floors the last floor is going to be six so in order to remove the sixth floor we need to add a math node and subtract one from this value over here which is the floor count so now if i plug this result into selection in instance on points the topmost floor has disappeared and you will notice that the stairs are they offset themselves accordingly so this is perfectly procedural it works nice perfect i'm going to select these ctrl j f2 remove top floor and i'm also going to give this option to the user and i'm going to call it remove floor top and i'm going to set it to integer instead and move it up so you can add floors and also remove as many as you want i'm going to keep this at 7 and only the top floor i want it to be removed next up i want to go back to the cube and i want to make it a little bit wider something like this let me select that one as well ctrl j f2 i'm going to call this spheres one out of four increase the label size and the cool thing is you can duplicate all of these nodes and just use different sets of bounding box combinations so that you can cast rays from this point in this direction this point in this direction and this way you can have the same stairs on all of the sides i'm not going to do this because i think you understood at this point so i'm going to leave you to do that if you want and next up we are going to add a block here on the top to serve like a master chamber something i don't know so i'm going to add a cube i'm going to use join geometry and now i have this cube at the bottom and i want to use again the bounding box from over here and i just need a transform to move the cube on the z axis so i'm going to use separate x y z and another combine because i want to take the maximum height only the z value from it and i want to plug that into the translation so this moves the cube the the middle of the cube actually um onto the top platform but we actually want the cube itself to be placed there if we for example use a vector math over here and just increase the z then there's one little problem i can use for example a value and plug this into the vector over here and set it to one i can use this to scale the cube but you can see that this scales towards the center of the cube and i want this cube to be placed on the platform and if i scale i want this to scale while still remaining on the platform so what i'm going to do instead instead of just adding a vector over here i'm going to use this size set it to one and i'm going to use vector math over here and combine x y z so i'm going to add to the position of this cube on the z axis i want to add math half of its size to its current location this time if i use this value over here you will see that the cube is scaled but it remains on the top platform so i'm going to set this to point four point three great i'm going to rotate by 45 degrees on the z and now i want to create two little hallways in this direction and one over here in this direction so i'm going to use a little bit of a trick i place this cube on the platform so i'm going to use the same cube from the same location well first up i need a boolean mesh boolean i'm going to place this here and i'm going to use two additional transforms which is going to use the same cube [Music] from over here and i'm going to plug these transforms into the boolean and i'm also going to use the same vector from here into these transforms but i am going to use a vector and i'm going to use vector math for both of these other transforms oops let me plug this here instead the bottom one and i want each of these cubes to be offset by the same number on the z-axis so i'm going to drag this number down and you will see that the cube reveals itself and i'm going to scale here so for the second transform the second one i am going to scale the x by point three and the y by two and i'm going to do the same thing for the third transform but instead i'm going to reverse the values so x is going to get 2 and the y is going to get 0.3 and this gives me these cutouts these hallways and what this vector over here does is that we can adjust the height of the hallways i'm going to leave that at 0.2 and this should be it oh and also you can use a subdivision surface on the topmost transform and increase the crease to 0.59 something and now if i increase this level i'm going to 0.49 it would give you this rough um chamber like look cube thingy it looks better i'm going to disable this for now because it generally slows down the calculations of the geometry node and yeah i can now select all of these control j f2 and i'm going to call this top block i'm also going to increase the label size as a bonus let's try adding a little bit of a statue on each of these corners on all of the corners of the temple and this is a little bit interesting of a solution and it goes like this i'm going to disable the top block for now i want to create a set of planes that will cast array down on each of these points over here so that i can can retrieve the exact location of all of these points so the first thing that i would need to do is to create the same number of planes as there are floors and then i also need to make them the same size as the top part of each floor so not the bottom but the top so let's try that out first thing i am going to do this here where i created the stairs so i'm going to add a mesh line at this joint geometry i'm going to add mesh line and plug it here i'm going to wire frame so that we can see it and on these let me just drag it all the way over here at the beginning and on this i want to instance on points a bunch of grids planes okay so we have this set of planes right now first thing rotate on z by 45 degrees then i don't need these extra vertices on the middle of each side so i'm going to set x and y to 2. and i want now to set the size of these grids as the top of this floor so if i go back to the floor count i can see that this cone has 1.7 meters on the top so if i go to my grid back and i use 1.7 here let me actually put a value 1.6 and i can use this on the x and the y you will see that there's actually a small difference between the size of this plane and this top floor and this is because the x and y size for the grid means this side and this side that has 1.7 meters but on the cone you will see that it says radius and this radius actually if i go into top view this radius is actually it's actually this radius there's actually a small difference between the two and if you want to find out how to match the numbers what we need to do is to search on google square inside circle and we can use this calculation over here so we already have the radius and if we need to calculate the side we want to multiply the radius by square root of two so if we go back to blender and clean this up and we go back here we said that we want well first let's add a value over here 1.7 plug this into radius top and now i'm going to use this number and plug it into the x i'm going to delete this from over here and that's that number is going to draw drive both the x and the y and we said that math we need to multiply that value with square root square root of 2. so now these grids have the same size as the top of the first floor and this is useful because here where we define the floor scale we can actually scale each floor by this vector so each grid will be scaled to the same size of each floor but first something that i forgot to do is that i want to have the same number of grids as there are floors so first i'm going to drag this all the way to the beginning and i want to plug here the floor count into this and put it back over here and i also want to remove the top floor meaning the top grid so i need to plug this from here into this instance on points from over here so i'm going to uh let me see if i can pick it up i'm going to do just that and that has removed the top floor from over here and now i said that i want to scale the instances well well first first first transform let me just move all of these outside of the temple it doesn't matter how high they are just move them out of the temple then we're going to scale the instances this vector over here will be from floor scale this vector so i'm going to plug this into the scale so now all of the grids are scaled to the same size of the floor i want to realize instances and now i want to cast array from each of these vertices downwards so that i can retrieve these points the position of these points so ray cost i want the target to be the temple so i'm going to take this mesh as the target geometry i want to project array from these planes and not this object so i need to capture attribute i want to capture the position so i'm going to select vector i want to capture the position of these planes only and use those as source position and i want to and i want to cast a ray on the negative z so downwards so this is good so now if i instance on points over here and i use an icosphere [Music] and i plug this here and decrease the radius right we have this setup and this is the payoff this is the final idea i'm going to use set position and i'm going to set the position of all of these mycospheres to be where the rays are hitting so i'm going to plug this here and all of the icospheres should move on the corners of each floor and this is what happened this worked perfectly and i can just scale no just make this a little bit smaller this is perfect now all that i need you will see that this has a radius as well i'm going to use a value 0.1 like this here because i want to offset the icospheres by their radius on the z axis so that they sit on this bottom point so i'm going to add a vector math over here i'm whispering because i don't want to disrupt this effect and i want to place a combine x y z i say that i want to offset by the radius on the z value [Music] and now this is sitting there perfectly this is pretty cool oh this is a perfect opportunity i don't know if i mentioned about the switch node no i haven't um you can use here a switch node and put this into true so now you can use this switch to enable or disable the statues you can have statues or not if you want and you can just take this and drag it to the input again so that the user can decide whether he wants he or she wants to have these statues enabled enable statues so now setting this to 1 gives you the ecospheres zero disables them obviously instead of an ico sphere you can put here an object info and use whatever geometry you want but for demonstration purposes this is perfectly fine and you can also use a switch node over here in stairs and plug this into true and drag this all the way again to the beginning and call this stair stairs one of four enable so you can enable the stairs or disable them and the same thing for the statues and now we can also enable this back the top block and make it subdivided so that it's pretty and uh yeah this is the final result so we can control the number of floors we can control how many floors we remove we can control the number of stairs we can enable and disable statues and stairs so yeah pretty cool alright so i hope you enjoyed this i hope it was useful to you and i'll see you guys in the next one peace
Info
Channel: Catalin Pascaru
Views: 854
Rating: undefined out of 5
Keywords: #b3d, #blender, #cgi, #vfx, #procedural
Id: mhCrTJqf6hw
Channel Id: undefined
Length: 42min 39sec (2559 seconds)
Published: Thu Dec 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.