On the bright sight I made quite a bit of progress with the building construction itself and got the middle floor section into a working state.
1 - Corners
First I went back into the Corner Node, cleaned up the code a bit and got rid of a bug, where depending on where point 0 was, it would not get assigned an instance attribute, because some of the angles where messed up. I fixed this by appending point 0 to the point array and working with that instead of always adding a special case for the last point of the curve.
2 - Wall Sections
Going back to the wall sections I basically got rid of all my previous code for them. As I stated in a previous blog post, we didn't want to have any scaled tiles, except plain wall tiles, where scaling doesn't matter.However, since Litha added pillars to the modular kit and wanted to have parameters for 'Number of pillars' per building side and 'Wall Tiles in between Pillars' I had to change the way of how I calculated the tile positioning.
I ended up breaking this down into the following steps:
- Calculate the total length of the pillar + in between tiles section and check if it fits onto the building side
- Calculate the number of tiles that fit on each side of the pillar section (needs to be an even number)
- Fill the rest of the wall length with scaled plain wall tiles.
We agreed to have the pillar section in the centre of the building side for now. Of course it would be possible to add the option of offsetting the section, but we'll have to see, if it is necessary.
The code bit for this looks like this, again this version only working for one floor, but I will show the multiple floor version later:
The code bit for this looks like this, again this version only working for one floor, but I will show the multiple floor version later:
I also, similar to the corner pieces, added Parameters to switch through the window frame, window, and pillar meshes.
3 - Floor and Roof Separation
After having figured out the basics for the corners and walls, I moved on to implementing multiple floors, including the option to either add separation pieces to every floor, or to add them only to specific floors.
For the top floor it automatically uses the roof separation tiles, instead of the floor separation ones.
When adding the corners to each row of the building, I also added an attribute to the points, depending on whether it was a wall, floor separation or roof separation row, so I could add the corresponding tiles, when adding the wall sections.
Here are the updated code bits for corners and walls.
I also brought the HDA into Unreal and it seems to be working alright, but we really need to figure out LODs, otherwise we sacrifice performance, where it is not necessary.
For the top floor it automatically uses the roof separation tiles, instead of the floor separation ones.
When adding the corners to each row of the building, I also added an attribute to the points, depending on whether it was a wall, floor separation or roof separation row, so I could add the corresponding tiles, when adding the wall sections.
Here are the updated code bits for corners and walls.
4 - Roof Mesh
Since the roof at that point was just a hole and might have caused issues with lighting (leaving aside, that in a game the rooftop might be visible), I needed to create a mesh from the footprint curve, which I had to do in a separate geometry node. Since Mike explained the use and advantages of detail attributes to me, I thought I could store the point positions of the curve in a detail attribute and use it to recreate the curve. I had some trouble figuring out how to get the attribute reference work with the coordinate parameter of the new curve, so I just used python, modified the attribute to fit the pattern of the coordinates and it ended up working.
After using a divide, poly-extrude and unwrap node, I ended up with a pretty usable roof mesh. I also stored the height of the mid floor section in a detail attribute and used it to offset it.
Complete Middle Floor Section |
5 - To Do
- Fix Import and Read .json file python code
- Add Ground Floor Section
- Figure out Material IDs !!
- LODs
- Collision
Nice!
ReplyDeleteSo is this making one big piece of unique geometry? or is it placing the tile instances into unreal as a bunch of static meshes? The latter is more complex, but would save on geometry memory and permit culling of parts of the building which could help render perf.
Regarding LODs, consider whether you will have a unique normal texture for each tile. If yes, I recommend to point the vertex normals of the LOD0 all in the same direction, away from the building tile before baking the normal map. It will look very strange to have no shading on the LOD0 until the normal is on, and the normal might look very strong, but run with it... the advantage of this is it greatly reduces the visual pop you get when transitioning to a flat plane (or similar) LOD. Feel free to get in touch if that doesn't make sense.
Also, I notice you have a lot of your logic in VEX. That's great, but it might be worth setting yourself a bit of a challenge to see what you can do with the houdini nodes for some of this. The main advantage here is it makes debugging a littel simpler, because you can view the geometry at a certain node and examine the geometry spreadsheet.
Cool stuff, keep it up! :D