Jump to content
  • Advertisement
Sign in to follow this  
yuri

Isometric & orthographic projection confusion

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I first want to say that I'm a total NOOB when it comes to isometric programming. I tried to do a more thorough search for the answer but only yielded people saying use orthographic projection with camera settings (view matrix) of 45 degrees here and ~30 degrees there and voila magic happens. Progression: NO orthographic projection setup yet. Using ID3DXSPRITE and only setting ALPHABLEND on the sprites begin and render the textures yields good results. (0,0) is at the top left of the screen with +x to the right and +y going down. Now once I turn on Orthographic projection with the width and hight my origin is in the center of the screen, +x right, +y going up. Using OBJECTSPACE on the sprites. Render all the graphics yields all my graphics are in the first quadrant. Understandably since I'm working only with positive x and y values. The added bonus of having all my graphics upside down, including my fonts. Ok, nice feature I guess. Makes sense for them to be upside down since the +y is now upside down from my original origin at the top left corner. Quick fix, used the orthographic offcenter projection to put the origin back at the top left corner. Nice, I think. My fonts have turned somewhat distorted. Replaced orthographic offcenter projection with regular (0,0) center screen projection. Now, setting up the view matrix, simple for now. Looking down the z axis with an up vector of 1,1,0 (45 degrees). Now, my upside down textures appear diamond shaped. Well, same width and height for now, so they are at least somewhat diamond shaped. I know that I need a 2:1 ratio for my width and height. But, overall what does this give me? I'll explain further. If I create isometric textures then why would I set this up to have them upside down and create rotation matrices (or flip the y values) to get them to appear right side up, while still holding on to the camera perspective? Wouldn't it be easier to just not use the orthographic projection and camera perspective and plop down the isometric graphics? What added bonus am I not seeing that the orthographic projection and camera perspective gives me? I understand the difference between perspective and orthographic projections. Distance means nothing to the orthographic projection. Will the orthographic projection and camera perspective give me an automatic isometric view regardless of my graphic tiles? I seriously doubt it. Graphic textures is where it's at. Correct this noob.

Share this post


Link to post
Share on other sites
Advertisement
Ok, just to be clear here. It sounds to me like you are using 2d tile sprites. You are using textured quads to display these 2d tiles on the screen with alpha blending.

Now are these tile images square or isometric to begin with?

1. If they are drawn isometric (they are already diamonds) then you don't need to do any of this work. Just draw them as normal. You will still want to use an orthographic projection matrix, when working in 2d you never want perspective distortion. However you don't need to do any rotations.

2. If the tiles are square and you want to distort them into isometric diamonds (or if you want to render 3d models) then you'll need to mess with this. One simple option would of course be to draw the quads as diamonds and let the texture mapping take care of the rest. The other option would be to set up a rotation as you described in your post.

Ok so if I read all that right, your question is why would you choose option 2 over option 1? There are a few potential reasons why you might:

1. It would allow you to mix 2d and 3d graphics: In this case you could still draw all of your 2d stuff in an unrotated orthographic space and only push the 3d objects through the transforms.

2. You might rather use square tile textures than diamonds: Squares tile better in memory, so less wasted file space. Also some people say they are easier to create (this is pretty subjective). On the downside you are going to distort them so you'll lose some detail going from square to iso in the engine. You'll have a little more control over this if you make them iso to begin with.

3. Sloped tiles: Doing sloped tiles in 2d becomes painful quickly. You need to create a lot of variations and even so you are pretty limited on your height transitions by the shear ammount of artwork you need to create. By adjusting the vertex positions and colors of your quads this is pretty easy to do in 3d, and you get a lot more freedom with less art resources.

Getting the isometric transform working can be a little tricky at first, but it's really not that bad. The real driving factor for your choice should be how you want to create your art. If you want to avoid texture distortion and keep that fine level of control you may want to go with iso tiles. If you prefer to create square tiles go the other way. Slopes are a good reason to go 3d, but you can do them in 2d also.

When you get to making your character sprites you'll want to make them in iso from the start anyway, there's no real way around that unless you use real time 3d models. So this decision mainly only applies to the terrain.

Share this post


Link to post
Share on other sites
Thank you for clearing this up. Yes, I'm using square 2d sprites as textured quads. I was forcing my player to look like a short fat guy by the distortion, not good. [grin] I use 3d matrices to handle all movement, etc.

I would like you to explain your sloped tiles vs iso tiles. I read your post a couple of times and I still don't get what you mean by sloped tiles? Aren't they the same as iso tiles. Also, wouldn't the distortion of making square tiles into iso tiles be too great. It seems that it would look much nicer if you just started with iso tiles.

I've got the 45 degree (PI/4) rotation around z-axes, and ~35 degree(PI/5) rotation around x-axis setup for the view and the projection is easy but need to be careful with the origin(center screen vs top left corner). Is there anything else?

Thanks again.

Share this post


Link to post
Share on other sites
Quote:
Original post by yuri
Thank you for clearing this up. Yes, I'm using square 2d sprites as textured quads. I was forcing my player to look like a short fat guy by the distortion, not good. [grin]


Hehe, yep definetly don't transform non-tile sprites. Really the only place it makes sense to do this with a 2d image is transforming square tiles to diamond ones.

Quote:

I would like you to explain your sloped tiles vs iso tiles. I read your post a couple of times and I still don't get what you mean by sloped tiles? Aren't they the same as iso tiles.


This is something that's come up a few times recently. By "sloped" I'm talking about terrain that isn't flat, hills, valleys, etc. X-Com and Ultima Online are good examples of this. If your landscape is essentially flat, or you have a few discrete height levels divided by cliffs then this isn't a problem at all, which is what a lot of 2d top down games (isometric or otherwise) do.

The purely 2d approach to creating slopes (hills) is to create special tiles for each side of the hill. These tiles are not the same size or shape as the diamond tiles that you use for flat ground, and they are shaded to give the illusion of depth. However they do fit together with each other and with the flat tiles. Since in isometrics the world space z axis is mapped to the screen space y axis, it's pretty easy to modify your engine to draw tiles at different heights. However it does make some other tasks more difficult. Hit checking (picking) for example is harder because now there is no longer a 1 to 1 maping between screen space and world space.

Another difficulty of creating sloped tiles is that you end up making a lot of them. A full set of one ground type is 14 tiles (15 if you count the flat version) and thats without any variations. Once you start adding variations and crossing types (you may get some savings there with blending) it can add up fast. Also that is for only one slope angle. You can make the hill as high as you want by tileing the sloped tiles, but it will still have one constant slope.

Using 3d transforms this gets a lot simpler. The outline of the hill can be taken care of by transforms. And you can modulate the tile image by a constant color (or a gradient) to simulate the shading. But you will have some texture distortion compared to the hand crafted solution.

Quote:

Also, wouldn't the distortion of making square tiles into iso tiles be too great. It seems that it would look much nicer if you just started with iso tiles.


It's not as bad for essentially flat surfaces like tiles. You'll get some bluring, but for something like grass or dirt it may not matter. If you want more artistic control you may want to go for diamond tiles. Especially if you aren't doing sloped terrain anyway.

Quote:

I've got the 45 degree (PI/4) rotation around z-axes, and ~35 degree(PI/5) rotation around x-axis setup for the view and the projection is easy but need to be careful with the origin(center screen vs top left corner). Is there anything else?


Regarding the 35 degree thing... That is of course true isometric perspective (120 degrees between world space axis after they have been translated into screen space), but if you are going to work with other 2d sprites you might want to consider "fake" isometric using 2:1 ratio tiles. That's a 30 degree or so rotation instead. Really it just comes down to how you want to draw your artwork, you can make the transform match either way.

Share this post


Link to post
Share on other sites
Thanks again for clearing it up. Yes, it makes sense. I'll just use graphics that simulate the height for now. No sloping yet. Need to learn to crawl before you walk. [wink]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!