don't click here

So You Want to make 2D slopes?

Discussion in 'Fangaming Discussion' started by Andrew75, Jan 26, 2018.

  1. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Okay so yeah guys, What I'm about to show here is not a new idea by any means and its basic 3D modeling knowledge. I'm Using 3D Studio for this tut, but I'm sure something like this can be adapted to Blender as well.
    (So far... I havnt seen it used for 2D pixel art in fan games (╯°□°)╯︵ ┻━┻

    Anyhow.... Last year......On the Sonic Time Twisted Discord chat
    (This trick was not used for time twisted btw), Someone was trying to come up with a way to do slopes with a specific styling and pixel layout. They showed me some kind of tool slope generation tool, the tool didn't do what they needed. ( I think the tool was called PWZ)
    Soo.....I thought that the style that they needed could easily be done in 3D and just render out the result. Perhaps there are better ways of going about this. This is just the way I did it, and thought you guys may like to see how it was done.

    Here are a few result examples:

    Top part of the image shows a comparison between my method and the original tiles from Hydrocity's tubes is bottom image.
    This makes me wonder,,, How did Sonic Team produce the tubes in the first place? could It have been a 3D model that they rendered out ? or perhaps had some special custom tool to deform shapes in 2D directly?
    [​IMG]

    Ok some other examples.....
    [​IMG]
    [​IMG]
    [​IMG]

    Higher res,,,,
    [​IMG]

    My poor level mock up using textures someone gave me....
    I made the light beams and the light poles were mods of the ground texture tiles lol
    [​IMG]

    First, decide on what resolution you want to use for your level chunk. for this example we're going to go with 256X256.
    So okay, taking into account 256 x 256, we will set up the renderer and camera as follows. We will also adjust some render settings so that your output texture rendered matches the source texture colors 1 to 1.
    (you will also need to set the Material's self Illumination to 100, screen will be found in the Material part of the tutorial)

    In regards to scale, I'm using 3Ds max default settings, and grid spacing of 1 unit.
    this is so that 1 grid unit will be the same as 1 pixel of our render. and will allow us to snap some polygons or vertex later on so you don't render part of your mesh off-screen or unaligned for example.

    [​IMG]

    [​IMG]


    Settings in the below image are Render settings and Preference settings. ( I wont go over how you get here, google is your friend)
    Try to match the settings in the screenshots where I have the yellow lines.
    [​IMG]
    [​IMG]

    Next the camera set up! add a camera and make it 0 0 and 0 ( the distance from the object does not matter from the object you going to see. since the camera should be set in orthographic projection mode. Lens MM and FOV degree can be adjusted to fine tune the area of the render (the size, not the resolution)
    Note:Try to match the screenshot below. Also play with the FOV and Lens MM to see what happens later when rendering.

    [​IMG]

    Turn on Show safe frame. This shows exactly what the camera sees and what area will be rendered.
    [​IMG]


    Next we will make a spline. place the spline points so that the spline ends do not move outside the safe frame of the camera when in the front viewport.
    A trick we can do so we can model in a proper 2D viewport, instead of the camera's viewport which does not always display the grid:
    Make a plane model 256x256, and align it to the camera's center point, so if the camera is center at 0 0 0 than place the plane at 0 0 0, than move the plane away from the camera towards the background, the plane will now represent the viewing area of the camera in 2D space.
    this will make it easier to model out your shapes and make sure they stay inside the viewing area. and now you can also see the grid to boot!

    Also make sure you have snaps turned on so that the Spline's vertex points snap to the grid. ( endpoints are circled)

    [​IMG]


    Set up your spline settings as follows so we can display some physical polygons.
    Note: that I will be applying a 32 pixel by 32 pixel texture to the spline so I make it 32 in the settings.
    Note2: u can right click spline vertex and change them to smooth, corner, or Bezier handels.

    [​IMG]


    Also for splines, we set how many times the spline model is subdivided. ( you can also further tweak this in the edit poly mode if you need to add , move or remove edges)
    The steps only subdivide along areas of the spline that bend by the way.
    I used 15 as the number because in this spline's case it will divide it into 32 sections along the bendy area. so 15 actually created a power of 2 here for easy UV snapping in a later section of this tutorial.
    [​IMG]

    To keep thing simple for the UV unwrap process , Add an edit poly and than select and delete all polygons except the front area.
    [​IMG]


    One more thing can be done in Edit poly mode!
    Move the vertex and snap them to the nearest grid point so that your mesh fits perfectly in the render area!


    [​IMG]
    [​IMG]





    Now for the umm..... Material set up:
    We have the mesh and now we want to tile a 32 x 32 pixel texture across it.
    Just copy my settings below ! ( you can tweak the tiling amount for different situations so you can help minimize stretching or squashing along the length of tour spline run.

    Oh yeah ! Before you do the tiling, lets set up the Self-Illumination to 100 as the final step to get 1 to 1 color compassion when you render out the final image.
    Screen also shows the diffuse color which is where the texture should be placed. after placing the texture click where the arrow is pointing in the screenshot.

    [​IMG]


    As you can see below I used tiling of 8 and 1 in the UV space. ( use whatever looks best and come back and tweak later after the UV unwrapping step)
    Note: You could actually use a long texture strip with more details and without tiling in the max settings.
    (this would allow for more visual variation than just tiling the same texture 8 or whatever times along the spline, So maybe you want grass like section on the left and a rocks section on the right of the path)

    [​IMG]



    Next we will apply a UV Unwrap Modifier, I will not teach you how to UV unwrap but! You can look at the image to see how my UV layout looks.
    Note: Because I tiled my texture by 8 we get a wider UV Areas than what you would normally get without the tile set in the material.

    I like to snap to pixel when doing UV layouts for some sections of the UV unwrap. Use the snap feature with good judgment!
    (in this case I actually snaped all the vertex positions to the texture since. I guess-timated the model subdivision back in the spline properties so that the Polygon edges would align closely with the texture map resolution.
    [​IMG]
     
  2. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    P.S. here is a comparison of similar slopes but generated in the PWZ tool thing that couldn't produce the results my friend was after.
    There is really nothing wrong with them, its like saying I need this style ,, or I need that style, it all comes down to personal preference and what style you are going for.
    The below images are generated from the PWZ tool. It seems the pixels are shifted around in vertical columns. They can also be reproduced in the 3d method outlined in the post above, but you would need to tweak the UVs.

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]


    My 3D method from the post above as reference:
    ( notice how the grass flows along with the shape? )
    [​IMG]
    [​IMG]

    Edit:
    OK ! ! Here is a similar result using the 3D method reproducing the vertical pixel row column shift of the PWZ tool. (Simply done by tweaking the UV Unwrap)

    [​IMG]
     
  3. ICEknight

    ICEknight

    Researcher Researcher
    That... is really cool.

    I wouldn't rule out that SEGA used this method for achieving some of the regular curvatures, since they already had to use 3D for things like Emerald Hill's corkscrew paths and (probably) Hidrocity's water slides.
     
  4. Flygon

    Flygon

    Member
    This is excellent advice!

    I do wonder how artists should approach manual touch-up for the dithered artwork distorted this way. I do worry a few could go lazy, and not touch it up at all.
     
  5. Mastered Realm

    Mastered Realm

    Member
    3,830
    556
    93
    -
    That's really good for some cases, specially the metalic one you posted, but for bricks and vegetation it's still best to do it by hand:


    [​IMG]
    [​IMG]
     
  6. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Yeah it all comes down to what style you are going for, it can always make for a good starting point for some pixel art magic as well XD
    Anyhow the tut I posted was meant for someone who wants to have the tiles follow the shape of the path.
    Love the shading you got going on with the example you tossed together there.

    Edit:
    Just for some fun:
    Took some tiles from your shaded version and made a 32x32 texture tiled that by 8x in max and applied it to the model for render.

    [​IMG]
     
  7. Mastered Realm

    Mastered Realm

    Member
    3,830
    556
    93
    -
    Thanks! I just thought it was relevant to post it here so we don't end up with fangames doing this:

    [​IMG]
     
  8. ICEknight

    ICEknight

    Researcher Researcher
    Actually, I'd say the second slope is lacking something...

    [​IMG]

    There. Best of both worlds. :v:
     
  9. Mastered Realm

    Mastered Realm

    Member
    3,830
    556
    93
    -
    Slope: Sonic 4 edition hahahaha
     
  10. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    XD! Yeah there you goes !! Got to be creative,.,,
    Hey Hey Hey!! Lets have some more fun ! Someone make a long strip and send it back to me, something with variation..... and ill stick it onto the model and render it out.
    Strip should be 32 high x 256 wide, Maybe have go from grass to bricks and than to grass again, and randomly knock out some of the bricks threw-out the length of the texture. ( perhaps you could add some moss patches too for good measure.
    But yeah the moss could be added on after the render too.
     
  11. Mastered Realm

    Mastered Realm

    Member
    3,830
    556
    93
    -
    Do you think you can update your method to generate distortions while keeping the middle spacing constant?

    The results you post seem to be using the Top-spacing as the reference.

    [​IMG]

    The structure of the path seems perfect in your examples, but the texture mapping doesn't follow the steps perfectly, why?
     
  12. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    hmm,,, I don't have time to wright up a new tutorial just today... I think its mainly the fault of the way that the spline generates the mesh. the mesh lines are not spaced evenly, But the UV lines are spaced evenly.
    You can try to match the spacing of the UV lines manually if you like. (Also to note: when you move your spline handles you need to be carful with them, the spline handles determine spacing too)

    Other solution create a maxscript that generates the geo for the spline with even spacing.
    Another method would be to make a long model with lots of even cuts, than add a bone at each cut, than after you have your Rig, you can attach the bones to the spline with even spacing to get a better result. (I used this technique for making animated paths for the UDK build of AXSX)
    ( this would be a much longer tutorial btw)

    But hmmmm, adding to the current tutorial
    One idea,,, and I have not tried this,,, but it should work.....You can add an edit poly on top of your UV unwrap and tick the preserve UVs tickbox, after that clone your main spline two times,,,and than snap it to the top and bottom of your polygon mesh.
    this will serve as a shape you can trace and snap the vertex of the mesh to. you would have to eyeball the end result to how you see fit. ( u may have to do some stuff in the in editor as well)

    Also something to note, when doing the spline, you can design the spacing so that each space will fit to an 8 x 8 tile and snap the UV to every 8 pixels. but you need your mesh to also be spaced evenly.

    There are a lot of tricks you could use. Wish I had more time to show them.

    Here we see the spacing is not the same from the top to the bottom. Again you can manually move UVs to fix this by eyeballing it, and its a pain!
    [​IMG]
     
  13. Cooljerk

    Cooljerk

    NotEqual Tech, Inc - VR & Game Dev Oldbie
    4,505
    201
    43
    haha, what timing Andrew. I've been working on an image editing program for a couple of years now, and this precise stuff is just what I'm working on. These notes will actually be useful to me for my own implementation.
     
  14. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Very nice ! I'm sure the community will love your tool!
    Make sure to PM me when its done or post a link here even if you make a topic with its release.
     
  15. Cooljerk

    Cooljerk

    NotEqual Tech, Inc - VR & Game Dev Oldbie
    4,505
    201
    43
    Incidentally, I never A) noticed that the tubes in Hydrocity Zone had a checkered pattern as a kid, and B) that the pattern rotates with the tube.

    lol
     
  16. Ritz

    Ritz

    Subhedgehog Member
    4,086
    110
    43
    That's a particularly cool and clean method- kinda feel bad about pointing out that you can get a similar result way faster and more intuitively using Illustrator's brush tool. I don't think too many people are aware that Illustrator can distort raster graphics:

    [​IMG]
     
  17. winterhell

    winterhell

    Member
    1,165
    7
    18
    Oh wow
     
  18. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Well there you go folks , an easier method !
    Can you give us a sample after its saved out to a .png file?
     
  19. Ritz

    Ritz

    Subhedgehog Member
    4,086
    110
    43
    Sure:
    [​IMG]

    Illustrator can export indexed color images via Save for Web, so you can spit out MD-ready assets sans the necessary manual cleanup (I couldn't work around the seams where the tile loops on curves with the brush settings alone). Just make sure to apply Effect > Rasterize to your art before exporting, since Illustrator's otherwise pretty lax about what "no anti-aliasing" actually means.

    EDIT: Just remembered that the other plus for this method is that it does a good job of maintaining the relative scale of the art while resizing paths:
    [​IMG]
     
  20. Andrew75

    Andrew75

    Technical Artist Member
    2,030
    107
    43
    Project AXSX(Sonic Xtreme) + Misc Projects
    Oh wow !! that makes things so much easier! If I ever do a 2D fangame I will be sure try this out someday, thanks for sharing!
    But yeah I think Sonic Team may have used something like this to do some tracks for Sonic 3.