Port of my city renderer

Discussion in 'Contribute' started by RHY3756547, Jan 14, 2014.

  1. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    [​IMG]

    Just a heads up, I'm working on fixing Afr0's port of my city renderer. Right now everything's appearing a liitle green, but it's much better than it was (a blue bumpy face from the side).
  2. JWofles

    JWofles Active Member

    I cry every time at the beauty
  3. ddfczm

    ddfczm Administrator Staff Member Moderator

    Now that we have the packets to get into city rendering has anyone done a geometry dump from the DirectX version of EA Land? Should be able to hook it and grab the geometry so we can make sure what were creating is a perfect replica.
  4. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    [​IMG]

    Got it rendering the 3d part + controls exactly the same as the WebGL version. Now I need to do the 2d layer (houses, trees).
    Here is a quick demo:
    https://dl.dropboxusercontent.com/u/122 ... nderer.zip

    Code will be on Github soon, once I actually figure out how it works...

    I'm not sure if the original one used DirectX.. It might have used a software renderer, as it took years to generate even on modern PCs; It's worth a shot though. The places where I know this differs right now is that it draws the vertex colours when zoomed in, which is incorrect! (but looks arguably nicer) It also does not add any lighting, so most cities don't look great. This one looks nice as the lighting is baked into the vertex colour.
  5. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    OK, so I forked the repo but since I did it after I did all this it's completely confused and trying to commit to the real master repo. It's also making two project dollhouses appear on the list of repos on my system...
  6. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    Modified above zipped version to include near view tree rendering!
  7. Afr0

    Afr0 Well-Known Member

    Rhys... you just earned yourself a spot on the credits list, aside from the one you already had under R&D! :D
  8. xezno

    xezno Member

    Whoa...
  9. liinor

    liinor Member

    Project just keeps continuing. :)
  10. Afr0

    Afr0 Well-Known Member

    Pretty sure the original one used software rendering. But they ported EA land to DX9 towards the end of its lifetime.
  11. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    [​IMG]
    Got tile selection working correctly. It's not quite as pretty as the HTML5 version as I'm not applying a smooth gradient mask over the tiles as I was having some trouble with render targets deciding to clear the screen and it's un-antialiased, but it still works and looks like the original. (even more so now that it's not anti aliased ;) )

    It does appear anti aliased if you force AA with the graphics driver though, so if we ever anti aliased the city view the lines would appear smooth at probably the highest performance cost ever.

    Next up are houses and the spotlights, though we should probably work out a data format for these before doing anything.

    As per usual zip is updated with changes.
  12. ddfczm

    ddfczm Administrator Staff Member Moderator

    That looks awesome Rhys, excellent job. So you finally got involved in the XNA / C# code ;). Slippery slope... City rendering was the first thing I looked at when i started contributing to PD over a year ago, i was mostly pissing about. The thing i struggled with most was which blending tile to use when.

    Before i moved onto the UI engine i scraped the internet for city rendering screenshots that showed off the geometry (http://www26.zippyshare.com/v/21511421/file.html). Would be interesting to try compare some with yours.

    Oh and what sort of FPS you getting?
  13. Afr0

    Afr0 Well-Known Member

    ddfczm: We don't have the required packets to get into Cityview. Andrew had to hack the client to get in. I don't remember what he did, but it required changing some memory address or other. That is... we do probably have the required packets because of the packetlog patch that Andrew made, but there's... over 50 packets and we only know what about 5 of them does.
  14. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    I'm getting 60 with weird dips on Intel HD 3000, Constant 60 on NVIDIA Geforce GTX 635M with forced 32x CSAA and 8x texture multisampling.

    Some of the cities might have different Y scales... The current scale is tuned for chartavia and the one I've set up right now, but east jerome doesn't look nearly that steep in my renderer. Map 30 (the merged cities map... why was this in new and improved?) uses a much smaller scale than all the others, it looks crazy spiky when you try it with the default settings.

    You'll notice in those screens that the double line falls off at places in the terrain that are too steep to build on. I have this functionality implemented, but I haven't added any rules for steepness in my function to determine if spaces are buildable.

    An interesting screen in there is one of roads. I had an idea of how to implement them but I'm not sure what map they were on and where to find them. The jcneighb.jpg image features them but they've cut out the city name...
  15. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    OK, so I discovered that each tile in the map has a road value specified by the road map, however there are 128 of these values (steps of 2 in RGB), but only 32 possible road maps, and these already cover all rotations/orientations.

    Roads seem to be 2px thick on the road image, so technically since each image is the side of a road the pixel data should make up many references to sides of roads. But there are 32 images... not 128...

    Edit:

    4 base road corners take weird colour positions:

    ┌ 64
    ┐32
    └ 128
    ┘16

    In comparison, bottom side road is 8, top side is 2, left side is 1, right side is 4.

    Edit2:

    got it! road sides are bits 0-3, road corners are bits 4-7. They can be combined in any fashion. This means I need 2 more UV coords... but that's this pretty much worked out.
  16. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

    [​IMG]

    I got roads mostly working. There seems to be a weird bug where the road lines alternate on intersections... That being said I did have to invert the x UVs to get the roads to display right.

    Looks like trees are rendering a little too high as well.

    https://dl.dropboxusercontent.com/u/122 ... adTest.zip
  17. Afr0

    Afr0 Well-Known Member

    Awesome job! :)
  18. RHY3756547

    RHY3756547 FreeSO Developer Staff Member Moderator

  19. infamousedot

    infamousedot Member

    Wow. That's looking great, awesome work figuring this out!
  20. Afr0

    Afr0 Well-Known Member

    lol @ accidental int divisions - thanks for letting me know! :lol:

    This makes me wanna implement this into the client right away... but the autoupdater is more important. *must keep focused, must keep focused...*

    Edit: I told Eric Bowman when I was porting your code that porting from a weakly typed language to a strongly typed language feels like trying to translate backwards spoken Chinese to a native Russian speaker, and the integer divisions proves me right!

Share This Page