Stuff I'm up to.

Procedural City, Part 13: “Release” of Program and Source


Screensaver

Link (YouTube)

I hesitate to call this a “release”. The program has been tested on exactly one computer, which can’t even be called a “test” with a straight face. Not only is this not a release version, it’s not even beta-worthy. Even internal alphas have undergone more scrutiny than this program. It is only my boundless hubris that allows me to call this “version 1.0″.

But I don’t have any machines suitable for testing right now, and I don’t have time to run some sort of open beta. Besides, any such effort would quickly fill up with people who were just there for the software and not really into the whole “test unreliable software and then report in detail all the ways in which it failed to work”.

So I’ll preface this release with a stronger version of the usual disclaimers: No warranty is implied, it might not work, use at your own risk.

Sorry to the Mac users. I do not omit you out of malice, but I’ve never developed for Macs before and have no means of doing so.

Download PixelCity v1.0

Take the PixelCity.scr file out of that archive and put it into your /Windows directory and you should be ready to go. There is no configuration dialog, so when you hit the “settings” button in ScreenSaver configuration, nothing will happen. Just hit F1 while the program is running to get a list of things you can do. Be sure to press ‘E’, as it will show off some full-screen effects I haven’t mentioned or showcased before. (I wanted to have some surprises! Although perhaps seeing the message “This program as performed an illegal operation and needs to close” will sate your desire for surprise.)

Please do consider spreading the word on this project on your blogs or wherever you tell people about cool stuff. Reluctant DM was nice enough to put it up on Digg, but Digg has yet to respond to anything I’ve done. Projects, comics, articles. I’ve gotten links from some internet hotspots, but I’ve never earned more than an indifferent shrug from Digg. It’s a very FARK-esque audience and I doubt I’ll get any digs until I write my magnum opus: Procedural Man Getting Hit in Balls with Baseball. (It works on so many levels!)

Source

I’ve put the project on Google Code, although I’m not sure if I will continue with the project or not. I’d love to keep working on it, but further changes will most likely make for dry reading, and that means the project would no longer be feeding this website. We’ll see.

I’m using MS Dev Studio 6, which turns eleven years old this year. Sorry to those of you using development environments forged sometime during this millennium. This is something I cannot change. Although to be fair, migrating from my platform to your is likely much easier than going the other way.

Development

In Win.h there is a #define that lets you disable screensaver mode, which is crucial for development. Setting SCREENSAVER to 0 will change the behavior of different parts of the program and give you access to the primitive and unintuitive development camera.

If you want to test it in screensaver mode, set SCREENSAVER to 1 and invoke the program with the /s command-line option.

Porting

The program is very much tied to Windows at this point. I tried to quarantine all of the Windows-specific code into its own ghetto module (Win.cpp) but that didn’t really work. The stuff for generating a render contex and loading fonts in Render.cpp is also windows-specific, and of course you must #include windows.h everywhere you use Gl.h, which is just about everywhere. And finally, checking the millisecond timer means calling the Windows-specific GetTickCount (). So those items will probably form your to-to list if you’re looking to port.

Optimizations

There is a lot of work that could be done to speed this thing up. Many promising ideas were suggested in the comments during the three optimization posts.

Switching to vertex buffers would likely give a huge boost. (See the comments at the top of Mesh.cpp.) A lot of improvements could be made to the visibility table and how cell visibility is determined. And I suspect there’s a better way to fill the bloom buffer than the one I’m using now.

I didn’t pursue these because there’s just no point in trying to optimize any further on this machine. To be done right, the changes need to be done on an older machine. Profiling can help, but only in cases where old and new hardware encounter the same bottlenecks. The thing runs at 200fps+ on my machine, and it’s entirely possible that I could ratchet that up to 300fps in such a way that provides almost no benefit to the poor guy running the thing on an old laptop. Furthermore, at this speed it’s pretty hard to detect improvements amid the noise, so it’s hard to get a feel for how effective changes are. (Again, profiling doesn’t tell you about those every-ten-frame lurches that are imperceptible at 200fps and nauseating at 20fps. There is simply no substitute for testing on the right hardware, which is why the loss of my old computer was such a terrible blow. I’m currently watching family members to see if any of them are going to upgrade soon. Ideally, I hope to inherit a ~2004 machine.)

Still, I’d start with vertex buffers.

Derivative Work & Collaborations

I am gratified to see that so many people want the source and are eager to do new and cool things with it. I’m not sure how we should go about this. Google Code isn’t up to tracking a dozen forks of the project, and I don’t have time to administrate that sort of activity anyway. Ideally we want someplace where people can swap code, knowledge, and screenshots. Some people will no doubt struggle getting it to compile on their different (from mine) development environment, and a little help from others can go a long way towards saving everyone time & headaches.

This is ideally the job of a forum, but I’m not in a position to provide one of those right now. It would be perfect if such a thing was available along with Google Code, alas.

I’m open to suggestions.

UPDATE: The codebase is now available on GitHub, which has the source file / social functionality we’re looking for:

http://github.com/skeeto/pixelcity/tree/master

Future Work

While I have many features I’d like to add, I don’t have any immediate plans to do so. Right now I’m going to wait and see if there are any egregious problems with the screensaver.

But if pressed, I suppose I’d like to add the following someday:

  1. Port the thing to wxWidgets, which might give me the cross-platform access I’ve always wanted. (Win, Linux, Mac.)
  2. Implement vertex buffers.
  3. Fiddle around with the city-generation parameters. I don’t think I’m getting as much variety out of the existing code as I could. More mid-size (25 story) buildings with a large footprint might do a lot to break up the “bar graph” effect I have going now.
  4. And of course, the street-level detail is a timehole which is happy to consume any effort I’m willing to put into it.

Thanks for reading. It’s been fun.

A Hundred!20202018There are now 178 comments. My website weeps for mercy.
1 2 3 4

170 comments:

  1. Don’t use vertex arrays, use vertex buffer objects! The VBO extension is available on almost all hardware (even on my integrated intel chipset on my netbook) and stores all the geometry data in GPU memory. As its an extension to vertex arrays, the syntax is practically the same, so you can always fall back on vertex arrays if the hardware doesn’t support it. In my project I noticed about 60% increase in performance when I switched from vertex arrays to VBOs!

    Also try using the framebuffer object (FBO) extension to do your render-to-texture routine for your bloom effect. It’s a really simple API and the optimal method for this type of thing.

    Overall a good project! I’ve enjoyed reading through the progress of it! Well done!


  2. Thanks for sharing your brilliant series and its fruits, the screensaver and its source. Tagging along with your thought process was an insightful trip.

    Suggestion: It would be great if you implemented a properties page w/ a setting that limited the screensaver to a single monitor in a multi-monitor setup. On dual monitors, not only does it bog down but the focal point is the gap between monitors.


  3. Tried it on my work PC; the little section in the screen-saver tab takes 5+ minutes to load(in the tiny window). I’ve waited a few minutes, but nothing happens yet.

    Pentium 4, 3.0gHz, 1.5gb RAM, Windows XP Pro SP3
    Integrated graphics.

    I don’t expect much on this machine, but giving you feedback. Will test again after lunch.


  4. It’s really nice to see the whole development process, and then get to play with the result!

    I also took a moment to play with it on an older computer, right around that 2004 vintage you’re looking for (2.2 GHz Athlon 64, GeForce 7600gs). Running at 1024×768, I get 61 FPS. It’s CPU-limited, though, and does jump slightly about once per second.

    Again, very impressive project. Thanks for posting all the results for us to play with!


  5. I wrote a comment and sent it, but it evaporated somehow.
    City looks great, esp. considering it’s procedurally generated.

    I noticed some visual glitches on the sky texture. I enhanced gamma to make it more visible on the pictures:
    http://imgshack.info/images/ohbdw4pkc6bkhjfmfs.png
    http://imgshack.info/images/rj3e28iauw9dsv25ovfu.png


  6. github.com should give you some features lacking in google code like easy forking.


  7. Runs fine. Get 35-70fps. Machine is: 3.2ghz P4 HT, 2gb Ram, 256mb GeForce 8600gts. Loaded in maybe 4 seconds. Love the extra effects.


  8. This worked really well for me, although the textures looked a little grainy and low-quality on my epic computer. Ultra Graphics Mode?
    It also seems like the street lights are just too big. Like, plainly, they’re just too big, because if you think of the size of a window full of light, and the size of a headlight, you could afford to have the actual bright pixels be very few, I think. Try just doing nothing with the streets, maybe? Then add lights until it’s too much? Grah, you probably did all this anyway. Silly me.

    Still, great work.


  9. What Andrew said — GitHub is perfect for extensive forking, though git is enough of a pain that you should look for web tutorials on how to use it if you’re going to try it. If you already know SVN, this one is pretty good.


  10. I’ve been following this post and its great to finally see the end product! I think it works great as a screensaver. I get 61 fps at 1600×1050 resolution with 2GB ram, 2.8ghz cpu and Nvidia 8800. For some reason I can’t see the sky but the buildings look great.


  11. I can’t get it to load on a multiple monitor machine (3 monitors at 2 different resolutions). However if I don’t extend my desktop (taking back to a single monitor) it works pretty good.

    I didn’t see the skyline either but still looked nice.

    Good work man.


  12. AWESOME! Looks great, and it seamlessly spans over my two monitors (you don’t know how rare this is in 3d screensavers). This is GREAT WORK.
    I’d love a way to see more city though, like making the city 3 times wider and longer so we can see a huge expanse?
    And every 3d app needs a FPS counter :P


  13. Wow. The bloom really hurts framerate on my rig (P4 2.8, 2GB RAM, XP Pro SP3, nVidia GeForce FX 5200 (not my choice) running at 1024×768).

    Default (looks like Vaseline on the lens), it struggles to beat 7FPS. Without bloom (hit E until one before the default) it happily sits at 25.

    It’s still pretty, and believable. I’m not sure what you could do to make the streetlights look more “right”, but they’ll do.


    • McNutcase: I had that exact same card when I did my Terrain project, and I thought of it often when implementing bloom. Cards from that generation were incredibly sensitive to alpha-blending, and are the reason I made it possible to turn the bloom off. :)

      Now that I think of it, the bloom displacement is a fixed value. Something like 30 pixels or so. This means at lower resolutions it will displace over a larger percent of the screen. That’s not the right way to do things.


  14. It worked on my dual monitor setup, although only running at a 5-10fps. I believe that’s because of the 1440×900 and 1280×1024 resolutions though. I’m running it on my Dell laptop from work, 2.5Ghz processor, 2GB of RAM, and Nvidia Quadro NVS 135M chipset for video.


  15. Mine was the 100th download! Do I get a prize?


  16. Have a look at github. It supports a wiki, bug tracking, etc. Barrier to entry is learning a little git, but it’s really not that hard.


  17. Waiting for it to load. I have a very strange setup, though so I really didn’t expect it to work:

    I have a macbook pro with Windows XP running in VMWare Fusion. It sits at a black screen for about 5 minutes and then the loading clock appears, loading at a rate of about 1% every 10 seconds. I haven’t gotten it open yet, because I accidentally moved the mouse.

    Any way to make this thing NOT a screensaver? Ideally it would be nice to not have to avoid touching my mouse lest the thing go away


  18. I just get a black screen….


  19. Beautiful work!

    FWIW I get 61 fps on two 1280×1024 monitors, 3GB RAM Core2 Quad CPU @ 2.40 GHz (4 CPUs), GeForce 8800 GT, XP Pro SP3.


  20. I didn’t see any of the buildings. They are there in wireframe mode, but not in the normal render mode for some reason. I’ll test again on my laptop after work.


  21. at very high resolutions, the bloom displacement (in the second mode) seems to bork too.

    The textures lose quality a little fast when they are almost perfectly side on to the camera too, with the text signs in particular you can see this issue.

    again: AWESOME!


  22. 202
    Primogenitor

    Works for me on Vista x64.

    “This is ideally the job of a forum, but I’m not in a position to provide one of those right now. It would be perfect if such a thing was available along with Google Code, alas. ”

    Google Groups perhaps? I know its basically the old BBS system with a web front-end, but might work well enough.


  23. Runs like crap on my work computers here.

    First, a celeron 2.66 Ghz computer with 512 MB ram I lost patience waiting for the black screen.

    I then tried it on another computer, a GX620. This baby is a P4 3.4 Ghz with 3.5 GB of ram. It’s video card is unknown, as it’s using the standard VGA controller. On this computer, I let the black screen load for a few minutes before I saw anything, in which I saw a white circle with .98% in it. I gave up then.

    I can’t understand why these computers fail at the slightest amounts of work. They struggle badly when I run anything. I tried Dwarf Fortress on the second computer, and quit when the intro video was running at 3 seconds per frame. Is it possible because I’m running on Windows server 2003?

    Will try it on my screaming computer at home later today, though.


    • The long black pause before the loading clock appears is a bit confusing. That’s a pretty quick step, and it’s all CPU. It’s less than a second on my machine. Even going down to a machine with one tenth the power shouldn’t be much over ten seconds.

      There is something wrong happening there.

      Oh, and I just noticed: Memory leak. Every time the city is rebuilt it throws some memory away. Nice one. Who is writing this crap, anyway?


  24. The program runs great as a screen saver. Two 1680 x 1050 screens (3360 wide total) run at 45 FPS with the default startup configuration.


  25. After I finally got it to load, it’s doing about .3FPS on my XP virtual machine on a macbook pro. Granted 3d performance is one of the things that Fusion VMs are the worst at…but I thought it was supposed to be possible to play games and stuff through fusion.

    I’ll try this on my non-virtual PC at home.


  26. nine – that looks like one of the effects from when you hit E… are you sure you didn’t accidentally tap it or something?

    I get high 80′s fps at 1650×1050 on my Core 2 Quad Q9450 @ 2.67 GHZ, 4 gb ram, 1 gb 4870, Vista X64. I get a bit over 200 on the same settings with bloom off.


  27. I cloned the Subversion repository, converted the username, tossed the svn metadata, and put it on GitHub. You can get/see it here,

    http://github.com/skeeto/pixelcity/

    If everyone forks off of this then we have a common base to work from so merging will work without trouble.


  28. Yeah, these computers shouldn’t be performing anything close to an old pentium, so I can’t figure out why things like DF and this have a heart attack doing things that seem CPU related.


  29. Worked on my Vista machine just fine. I’m getting 59-65 FPS and it looks pretty good. I think that if I was getting up to 100 it might look a lot better, but it’s not choppy or anything right now. I do wish there was a way to slow down the panning/movement as it is almost impossible to read the signs at the current speed.


  30. Alas, though I have been waiting in anticipation for this to come out, it chokes and dies on my machines here at work. Given that they only saw fit to give me an inspiron 1525 (Pentium Dual Core 1.86, 2 GB ram, intel 965 express mobile) this doesn’t surprise me. This thing chokes when I compare text files. But I digress. Cranking my resolution as low as it would go and unplugging the external monitor, unfortunately, got me no further.

    My other work machine, equipped with an AMD 64 3200+, 512 mb of ram, and a radeon xpress 200, actually managed to spit out 20 FPS with the bloom off. Bloom on, it stutters along at 11 FPS or so, at 1280×1024. At this point renewed frustration with the jokes they call the machines they equipped me with at the office overwhelmed my desire to see this in action, so I’ll give it another go when I get home and actually have a proper machine to work with.

    I will say that what I saw makes me grin, and I look forward to having it action at home. This should make for an awesome screensaver on my HTPC in the livingroom.


  31. One thing about street lights is that they mostly point downwards (to limit light pollution). Perhaps some way to block out a cone of light about the lights with a certain angle would make them look “more real”.

    I also noticed the trying to turn on frame rate with the f1 help displays does nothing, but trying to display the f1 help when the framerate is showing toggles between the two.

    All in all, great job. First thing I’ve seen in ages that made me want to change from the really slick screensavers.

    Worked without any problems on WinXP, 2x 1680×1050 monitors, driven by Radeon x1550, Intel Core2 6600 @ 2.40 GHz, 2GB RAM. Although with bloom on, it’s a little chunky (~10-14 fps). With just the plain city, or the rainbow window effect, I get ~25-30fps


  32. 2012
    Delta Force Leader

    I can’t get the program to run on my laptop.

    Windows XP SP3
    Intel Celeron M 1.3 GHz
    2 GB RAM

    The program runs in the display properties screensaver tab; however, it takes over a minute to load, looks choppy, and is missing most of the lighting.

    When I try to run the full screensaver, it closes down after 30 seconds without ever displaying anything expect for a black screen.


  33. Update: After coming back from lunch(~ 45 minutes), saw it was 85% done with the loading clock screen. A few minutes later, it finished and actually started. Looks awesome!

    Couldn’t get a framerate for some reason, but it was acting like a slide show- popping up different views of the city, but I never saw any animation.

    Again, this computer lacks any 3-D acceleration, so not surprising. Will see what my semi-cheap but newer laptop does at home.


  34. On my computer at work I get 7 fps with default setting spanning across 2 monitors (1280×1024) (Duel core 2.4, 3.25 gigs of Ram, Radeon HD 2400 Pro). However, if I turn off bloom the frame rate goes up to 40. Also if I turn off the extended monitor the frame rate doubles (no surprise there I guess).

    This is a really cool little program. Thanks for sharing it and thanks for sharing what went into making it.


  35. well, i was very excited. but i get only a black screen. i managed to open task manager and saw that pixelcity was using 50% cpu and about 12mb memory. by the way i am on a core duo 1.6ghz, 2gb ram and winxp. oh and also the very crappy intel 945gm. maybe someone can figure out a fix?


  36. I have a similar configuration to #12 McNutcase + 1152×864 resolution, with similar results. 20fps with no bloom still looks good, though. The buildings look really nice.

    I can see why you were so dissatisfied with the street view; car lights sometimes flicker between red and white viewing them from head-on, look like slivers from the sides, and the lamps don’t look good any angle. For some reason, the lamps seems to exist inside the streets, so it looks like they just hover over the road while cars pass through them.


  37. Google Code now supports Mercurial, which is distributed like Git, but is easier to use and understand and works better on Windows. Details here.


  38. Latitude D820 Laptop with 2.2Ghz Core Duo, 3.2GB ram, dual-monitors 1920×1200 and 1280×1024 on an NVIDIA Quadro NVS 110M.

    It’s choppy – 4FPS with both monitors. The bloom lags behind the buildings by as much as 200 pixels.

    12FPS with just the 1920×1200 display.

    Both letterbox and textures off each have only a 1-2fps improvement.

    Turning off bloom brings it up to 30fps on just the single display – not amazing but usable. There’s a very obvious stutter every second or so that’s distracting.

    Load time with one monitor vs. two is significantly faster. More than half the load time, it seems.

    Cool project; I’ve enjoyed it.


  39. I tried it out on my machine and had no problems, although the sky looks funny–there are distinct corners where the sky boxes join up that makes it look like there’s an enormous black square hovering over the city. Still, that’s a minor quibble. :)


  40. Very nice! I like the eye candy. I just can’t get the boomer or the tank to spawn. Can you help me?


  41. Works fine for me at an average of 20.5 FPS. (edit – switched effects modes and it jumps to 60 fps, so I’m leaving the shiny lights off).

    Couple of things I’d appreciate:
    1) a way to slow it down! It pans a little too quickly for me to be able to read most of the signs. (edit – when I switch effects modes this goes away. Probably a framerate issue).
    2) In wireframe mode (awesome), why are some of the radio towers purple or other random colors? I’m so confused!
    3) Occasionally the skybox has weird texture effects going on. I think it might be the corner, but it’s something to look into.
    4) Can you reduce the amount of awesome? I need to get back to work and the having to wait to see the screensaver prevents that.
    5) Cars crossing left to right and vice versus look really weird while traveling down the street.

    Just a warning: leaving the windows screensaver selector thing on in the background while mozilla is open will slow mozilla down like crazy. Found that out trying to edit this!


  42. I’m getting 75-80 FPS on my AMD Athlon 64 X2 2.3gHz with only 1 GB of RAM and a GeForce 8800 GS. But nothing in the settings is changing the frame rate by more than a frame or two per second for me. On my machine I would certainly call it a success. And it’s entrancing, not just for me but for everybody who’s walked by me since I started playing with it. Thanks so much, Shamus, for sharing the process and the results.


  43. I also have trouble with multiple monitors. Also, it is really choppy, except when I go into “City of Lights” mode, then it becomes totally fluent. What does that tell me about my hardware?

    Also: No fog or working skybox on this Radeon x1600


  44. Sadly doesn’t run on my little Lenovo laptop… It’s a core 2 duo 2.1ghz, butdoesn’t have much of anything in the way of 3d horsepower, though. I imagine that’s why it won’t run.


  45. Ran it on a fellow’s laptop here at work, hooked up to a separate monitor for two displays. Loads MUCH faster than on my GX620, but runs really badly until I disable most effects. The bloom really does lag a few frames behind everything until I do so, though.

    Nice, but I can’t get an F1 menu. Only “E” does something.


  46. Cool. With everything on, I get 5-7 FPS. With everything off, I get a turbo boost to as many as 17 FPS.

    P4 3 GHz
    896 Mb RAM
    ATI Radeon Express 200 Series Integrated Video
    Running at 1280x1024px
    XP Pro SP3

    So there’s an idea of what your 2004 computer can do.


  47. 20207
    Reluctant DM

    Thanks for releasing this Shamus! I can’t wait to try it! The funny thing about Digg is that there is a huge group of people there who would love to hear about this sort of thing but you really need some oomph behind your submissions to get them to stick. I keep being optimistic that even though I don’t have the time to build a gigantic social network centred on Digg that my submissions will get noticed amongst all the lolcats and pron. :) Well, you gained this loyal reader from Digg back in the DMotR days so at least it did something for you! :)


  48. [...] read Shamus’ development diary in its entirety here, or download the Windows screensaver file here. Oh, and thanks to the dudes at @DenkiGames for pointing out Pixel City in the first place! Digg it [...]


  49. It works nicely in linux with Wine :)

    “wine PixelCity.scr /S”

    No hiccups or anything. Loading takes about 4s.

    Specs: C2D 2,8GHz, GT8800, 4GB, Gentoo Linux


  50. “I’m using MS Dev Studio 6…This is something I cannot change.”
    Why can’t you change that? MS VC++ 2008 Express (http://www.microsoft.com/express/vc/) is freely available and is vastly improved.

    Also, 1680×1050 at 61 fps regardless of effects and render mode. I smell a vsync somewhere…


    • Tino Didriksen: Day job. Our software is 15+ years old and has a VERY particular development environment. Any change that I made would have to be adopted by the rest of the team.


1 2 3 4

8 Trackbacks

  1. [...] read Shamus’ development diary in its entirety here, or download the Windows screensaver file here. Oh, and thanks to the dudes at @DenkiGames for pointing out Pixel City in the first place! Digg it [...]

  2. [...] [...]

  3. By Procedural City « Indigo Static on May 5, 2009 at 8:50 pm

    [...] And now the source code has been released! And as expected, my PC can’t handle it =( [...]

  4. [...] 14: Feedback and AssessmentPosted by Shamus on May 7th, 2009   Previous in Projects: Procedural City, Part 13: “Release” of Program and SourceShort [...]

  5. [...] Maggiori info sul progetto le trovate sul blog dell’autore. [...]

  6. [...] Maggiori info sul progetto le trovate sul blog dell’autore. [...]

  7. [...] Maggiori info sul progetto le trovate sul blog dell’autore. [...]

  8. [...] found this not too long [...]

Leave a Reply

Comments are moderated and may not be posted immediately. Required fields are marked *

*
*

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> . Enclose spoilers in <s> or <strike> tags.