What I’m trying to do is create a procedurally generated cityscape for a sidescrolling Godzilla style monster game. What I’m trying to do specifically is generate random buildings. My approach so far has been to have random window patterns appear on a randomly textured building of a random size.
A good example of what we’re trying to do would be the buildings is Canabalt; The difference being that we also want different textures on the buildings as well. What I’ve tried so far is to randomly generate the window patterns, which works, but I still need a way for them to appear on top of the texture for the buildings.
The buildings all move towards the left to give the illusion of movement. What I’m thinking of doing is to have the windows as objects that move along with the buildings, but I’m afraid of what that will do to our draw calls because then wouldn’t each window appear as a new object?
Is there a better way to do this?
This question is probably a little bit too general. No one is gonna explain you how to do this I guess… There are quite a bunch of papers out there describing procedurally generated landscapes, cities and whatever; but it is your job after all to implement it ;). Or use some middleware if there is one at all…
And don’t be afraid, just do it and then you will see if it causes performance issues ^^.
when you use unity pro you could render the buildings together with the windows into a texture and display the texture at an object.
there are some efficient 2d packages in the asset store if you display the windows manually.
another aproach is to use a “tiled” material. this means you have a transparent area around a window and tell the material to wrap around. so you put the same window multiple times on the building and still use one object with one material.
hint: when you use different buildings anyway in a side scroller let them scroll with different speeds to get a depth impresssion.
How would you render the buildings with windows into a texture in Unity Pro like you suggested?
The game requires randomly generated 2d buildings with two textures. The base building texture and then window textures randomly laid on top of the building. The art style is relatively cartoony so the windows don’t have to be perfectly generated but I’m having trouble conceptualizing how to go about this. Any help?
http://forum.unity3d.com/threads/93166-Need-Help-Project-the-image-from-a-camera-onto-a-plane-(security-camera-etc)? last post for example.
i lack the experience to tell you the way directly and i lack the time to try it out for you. so this would require you to try a little bit around. set up a material and play with the tiling settings to get an impression of how they work.
do i understand you right that you also want the textures be generated procedurally at runtime? i thought you have different wall and window textures ready and just want to assemble them to create random buildings.
if you create them procedurally anyway you dont need two separate textures and no tiling tricks. just draw the whole building into its texture.
this could be done with unity indie also with texture2d:setpixel function but i think its very slow but that you have to find out (btw wich platform do you target?). or you render to texture with unity pro.
if you draw this yourself you need to look at different real walls/buildings you want to display and think of their properties you need to mimick for such a look.
you create a texture of 64 x 128 for a building.
then fill it with red color for red bricks.
then go along every 5th line and fill it with a dark red or black for the bound of the brick.
then go along every 9 colums for the same (maybe an additional offset of 4 for every second column to have them staggered).
then fill rectangular areas in a certain distance with your window color.
but it would be easier, faster and better looking if you have prepared a set of hand drawn windows (with 3d light/shadow effect fe) and wall textures and only assemble them procedurally.
Exiguous, what we’re trying to do is simply this. There is no procedural texture generation involved. We have a plane, this has a blank outline of a building with a solid fill color and bricks thrown in here and there. That’s all in a pre-made texture. There will be 3 variants. These building planes get generated with the variants in a random order. Then we are going to have pre-sized planes with textures on then, be randomly distributed over the building plane.