vec2 pos = vec2(ceil(p.x/c.x), ceil(p.z/c.z));The idea behind this is: Using the mod function for repetition is like dividing the space into individual cells. By dividing p by c, you get the 2D position of the cell in this "checkerboard". The ceil function serves to ensure each cell is represented by only one (int) value, since the rand function always returns the same output when given the same input.
While I was trying to think of ways around generating random heights, Gabe suggested to try using multiple repetition patterns to simulate a varied but modular city. I think combining both these methods would produce good results, and I will be working on this this week.
I've been experimenting with adding details to buildings, and I decided to use IQ's method in his menger fractals to create windows. The basic idea is to create a cross that extends infinitely, and subtract it from the rectangular building bodies repeatedly to create window spaces. The rand function from before also resulted in some "free" variations, as seen below:
Windows and Ledges |
I guess these buildings can be considered generic residential ones. I'll be experimenting with some more different types this week to add variation to the city. You can see the current work in progress here.
thanks for the credits :)
ReplyDeletewith the windows they are starting to really look like buildings, cool
Looking good so far. For shading, consider doing procedural bricks or stone. Check out the Orange Book code: http://3dshaders.com/home/index.php?option=com_weblinks&catid=14&Itemid=34. Since you know when your shading a window or not, shade windows separately perhaps by marching another ray into the scene or just an environment map.
ReplyDelete