Blender 3.3 - Procedural Dungeons with Geometry Nodes Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to another blender geometry notes tutorial and this time let's create a dungeon maker which can be useful for conceptual level design here in blender or for custom tabletop map creation so let's do it let's open up blender and i'm using version 3.3 which is the latest production build at the time of recording this video first of all let's reorganize some of the elements here delete default cube and light hide camera and create a new collection called my dungeons inside of that collection let's add a plane with its default size and name it dungeon and now we can go to geometry nodes tab with plane selected create a new geometry node setup i'll call mine dungeon maker the main idea here is to generate dungeon walls procedurally based on the planes that we create manually which means that this should turn later into dungeon corridors alright in geometry nodes editor let's start with extrude mesh node with faces selected in the drop down and with offset scale used as wall's height this value we can add as group input to use in modifiers properties to better see what's happening with the geometry we can adjust a few viewport shading settings change lighting to flat enable shadow and cavity now we can clearly see all the corners of the mesh and you can notice now that we have some unwanted faces inside of this geometry but we can remove them with unchecking individual option in the extrude node now since we're building dungeons in a tabletop style we want to remove this top face here the perfect note for that is going to be the lead geometry node select faces in the drop down and as a selection we can use top value from the extrude node and as you can see only the top face has disappeared alright but what we have missing here is the floor to add it back we can use join geometry and connect both the extruded mesh and the base geometry perfect since we have all of that built we can test how changing the plane in edit mode will change the result nice now we can add thickness to the wall and to do that let's add another extrude node and decrease the offset scale until we satisfied now extrude node leaves us only with the outer the extruded faces of the geometry to get the inner part back a join geometry node and join this result with the mesh from step before and we may face one small issue here if we apply the modifier right now we can observe that the vertices are not connected to connect them let's add merge by distance node which will connect all vertices that are located near each other within the specified distance and now vertices are connected but beside that there are a few other issues so let's fix them real quick let's enable face orientation and as you can see right now there are some overlaps and wrong face orientation highlighted in red face direction can be fixed with flip faces node which we will put right here and everything turned blue right away as for the overlaps let's add mesh boolean node right before merging by distance which will unite all the faces awesome so this is a simple base logic for wall generation based on the planes now we can add few additional options to group input like this offset scale value and this individual option whether to use connected or quad walls now we can add a frame to group all of these nodes to have everything well organized alright now before we switch to material building and instancing interior within dungeon i want to show you how to make this dungeon out of procedural grid [Music] so since we want to have this as a feature let's add a switch node with base geometry connected into full socket now this switch boolean can go to group input and when we toggle it we can see that everything disappeared and this is because we need to have something connected into the true socket and this something is going to be mesh primitive grid now when we change number of vertices to 2 and size to 2 meters we can see a simple unsubdivided plane which is what we need let's create a grid based on the parameters we input so in the group inputs let's add three integer fields for cell size grid size x and grid size y and also let's set defaults for all of them minimum and default values should be set to 1. now let's make the size x and y of the grid to be step based or cell size based for this add a math node multiply cell size by grid size x and put it into size x of the grid node and do the same thing for the size y now with these values we can control how many cells we have with the specified cell size but it is not subdivided yet to subdivide this box geometry add a map node take the grid size x add 1 to it and plug it into vertices x and do the same thing for vertices y as a result we'll get subdivisions of this grid based on the number of cells on x and y axis and we can observe this in wireframe mode perfect but we have no walls here at all we can add those with checking individual here but those are not going to be the corridors instead let's delete some random cells in this grid so add delete geometry node after the grid select faces in the drop down and for the selection we'll use random value node with boolean set as data type as you can see we already have the result using seed and probability options will randomize this grid however probability works a bit different from what we expect what we need is that when we set probability to 1 all of the cells will appear so we can change that with map range node and switch minimum and maximum values for this probability setting now we can test the randomization options for the procedural corridors let's add probability and c to the group input and since we're getting a lot of inputs in here it would be nice to organize them by categories for me the best way to do this is to add a string inputs with no connections and names for each category and in modifiers properties we can specify names for those groups now since we've done that let's rename all of those input values to not get confused later as for the nodes let's add those to a frame with ctrl j perfect the next step is to apply materials for this paper box look-alike dungeon so let's create two materials one for the walls and one for the floor and we can create them in the materials section of this object but they won't be applied to properly apply materials in geometry nodes we need to use set material node so let's add these four walls and for the floor with materials selected accordingly good let's move to shading tab and start making materials first let's make walls so i want to use realistic textures for this and the best place to find free realistic textures for pbr materials is poly heaven they have lots of textures hdri and models so i've picked some textures and 2k resolution to use for my project drag and drop the fuse texture into the editor let's preview this one right here it is called roth block wall now even connected to the base color it doesn't seem to work the thing is we need to specify how to apply this texture to geometry so with node wrangler add-on enabled select texture and press ctrl t texture coordinate and mapping nodes appeared let's change vector from uv to object the texture became visible but it is stretched to fix this let's rotate texture in the mapping node i've found that 90 degrees on x axis and 33 degrees on y axis work best however we can adjust these values as needed let's also add a value to control the scale of the texture as for me 0.7 or 0.8 work best now the next thing we can do to customize this texture is to add some moss we can do this with ambient occlusion node if we preview this node we won't see the ambient occlusion until we switch to render mode in cycles engine and when we've selected those we can see all those shadows in the corners to make this effect stronger we can adjust black and white values with color ramp node now we can use this as a factor in mix rgb node where our diffuse texture will go to color 2 and color 1 is going to be that dark green color representing moss now let's connect this mix rgb into principled bsdf and import the rest of the textures for this material roughness normal map and displacement for these three we need to make sure to set color space to none color to avoid unnecessary shading defects and let's quickly connect textures to their corresponding sockets with same mapping node used as vector for a normal map we need to use two additional nodes normal map and bump node as for the displacement plug it into the height socket of the bump node after connecting all the textures we can see that normal strength can be reduced at least twice yeah we get the level of details we want now let's fix that problem with the top faces unfortunately we cannot fix this from this material so we're going to create a new one let's duplicate wall's material and rename it and in geometry nodes add another set material node right after previous wall material of course we need to reset the rotation for that new material and specify the faces that we need this material to be applied to faces that are pointing up or down so let's take normal input node separate x y z since normal gives us directions on x y and z and use compare node to check if z axis is not equal zero [Music] the result of this compare is going to be the selection for the wall's top material now let's work on floor material the process is going to be exactly the same at the beginning just with different textures i'm using large sandstone blocks from poly heaven add mapping nodes and adjust texture scale since we have huge plane area covered with a seamless texture let's break it with some sand let's add another principle bsdf and mix both of them with mixshader node factor should be driven by most grave texture we can preview this texture and adjust parameters and levels with color ramp for the second principle bsdf i'm going to use coast sand texture with its own mapping nodes now let's quickly connect the remaining textures for this material and we're good with the floor wow now it's the most exciting part of this geometry node setup adding interior to this dungeon so let's create another collection called assets with sub-collections i have pre-made a few models for dungeon interiors to not make this tutorial too long so i have a couple of assets here all of them have privates at zero and translated according to their position on the one meter in height wall one door asset two types of blocked windows a chest two types of pillars and some barrels these assets are grouped into a collection called wall decor also there is a torch with separated components torch itself fire and point light these items have separate collection called wall lights [Music] and the last but not the least floored floor decor collection with one asset hatch cool let's hide all these assets from the viewport and from render and return to our dungeon so the first thing we want to do is to put all of those pillars door and windows on the walls and specifically on these inner faces that means that we want to have points on those faces and we have a perfect note for that mesh to point so let's find this node and plug the geometry we want to convert the points into the mesh socket select faces in the drop down and to view this points we can join them with the rest of geometry with join geometry node like so now let's replace these points with our wall decor assets at instance on points node right here once we've added this node points disappeared because we need to have objects here in this instance socket so let's drag and drop the whole wall decor collection and plug it into instance it looks like a total mess to make it right we need to check pick instance checkbox to select only one object from that collection also in the collection info select separate children and reset children checkboxes looks better but all the instances are too small and placed too high let's fix the scaling first as you remember assets were designed for a 1 meter wall so we can use wall's height value from the group input and plug it into the scale socket of instance on points as for the location since points are generated in center of each phase let's translate all those assets down half of their height which means 0.5 meters now the rotation we want instance to get the direction based on the wall it is located on for this let's get a normal of that face there is an excellent node transfer attribute let's add this node we want to get normal so let's select vector and the data type drop down as a source we're going to use geometry that we use as points for instances and the attribute itself normal input node now we have this normal as an attribute right here so let's use it for calculating the rotation of each instance with align euler to vector node plug this normal attribute into the vector socket and the rotation output into the rotation of instance on point node as well as select y as the local axis of the object everything just got hidden inside of the wall so we need to rotate objects 180 degrees and we can do it either for each object in the collection or use already added transform node and rotate objects 180 degrees on z axis now we can test how it will work with different variations of dungeons [Music] as you can see when we extrude edges in the source geometry objects populate automatically on each face and there are a few additional things we can do to improve this the first one we may want to change objects on their positions so we have this instance index socket with which we can specify index of the object in the collection and even add a random value node with integer selected as a data type and there are multiple use cases for this we can either specify exact index of the object like 0 or a range of indexes from 0 to 3 but when we put 100 for example random value node will keep selecting only those items that are in the collection and with the seed option we can randomize items picked for the points another option the probability of instance of an object on the wall add another random value node with boolean set as data type and plug that into a selection socket we have probability and seed options on whether object will appear on the wall now it may happen that we decide to make some small walls at corners for example we don't want to have large window on that wall so we can include that in the selection of points for instances but we need to get the size of that wall and specifically how wide it is so we want to transfer another attribute float this time as for the attribute it is going to be face area source is going to be same geometry [Music] to calculate how wide is that wall face we can divide this face area attribute by wall's height [Music] now we can compare the result of this against some value which will state if the width of the face is greater than that value then put an instance on that face and by multiplying these two selections we will get a combination yeah and it works now let's quickly reorganize all of this and add required values to group input but it's not a dungeon if there are no torches on walls so let's add those the process is very similar to what we've just done and mash the points node connect same mesh as we used for wall decor instances add instance on points and join that with the rest of the geometry drag and drop collection with the wall light and plug it into the instance socket and we won't check separate children and reset children options since we want all items from the collection instanced as they are for the rotation we can use the same output value as for wall decor and of course use transform node to rotate the object 180 degrees on z what we don't want is for a light to be instance on same locations as wall decor so we can use the same probability output value and compare it against a value it should not be equal to one and here we are we can adjust probability of wall decor and wall lights with a single slider now since we have point light included in wall light collection we can go to render view and adjust the power of that light or even color if we want [Music] additionally for light selection we can add another random value node with boolean and multiply it by existing selection we will get additional probability setting for the light okay the last item for this setup floor decor let's add those hatches with the same method convert mesh to point this time we will use floor as a mesh add instance on points and join that with the rest of the geometry [Music] drag and drop collection with floor decor elements add a random value with boolean data type for the selection select separate children reset children and pick instance options just in case we want to add additional items to this collection we can also randomize the rotation of the hatch instances on z axes add combine x y z node and plug it into rotation and a random value node with integer data type and range from 0 to 3 and multiply it by 90. add another math node and convert this value to radians and plug it into z socket of combine xyz node and it looks like this is it you may add additional models to these collections to have more different elements play with procedural settings and instances probability and seed so i hope you enjoyed this tutorial please like and subscribe if you did as always you can get this project on hio thank you very much for your attention and have a great time of the day take care bye
Info
Channel: Retroshaper
Views: 37,432
Rating: undefined out of 5
Keywords: blender, blender3d, procedural, generated, asset, art, stylized, tutorial, assets, model, 3d, conceptart, tabletop, castle, generation, proceduralism, howto
Id: s7NFsEPBtcA
Channel Id: undefined
Length: 30min 24sec (1824 seconds)
Published: Mon Sep 12 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.