nesdev.com https://forums.nesdev.com/ 

Isometric trigonometry and the NES pixel aspect ratio https://forums.nesdev.com/viewtopic.php?f=21&t=9381 
Page 1 of 1 
Author:  tepples [ Tue Oct 09, 2012 8:58 pm ] 
Post subject:  Isometric trigonometry and the NES pixel aspect ratio 
A couple years ago, Bananmos expressed disappointment that my Russian Roulette tech demo was textbased. Around the same time, I started learning to use Blender. So lately I've been doing some 3D modeling for a graphical refresh, when I noticed this: The video chips in several classic consoles from the ColecoVision through the Super NES all output pixels at 315/88*3/2 = 5.37 MHz. At this dot rate, the BT.601 clean aperture* is 280x240 dots, making each dot an 8:7 rectangle (source). The right triangle with legs 1 and 2 units has a hypotenuse √5 = 2.236 units, and the smallest angle θ is arctan(1/2) = 26.565°. Code: _,o _,'  _,'  _,' θ)  ooo Now take an orthographic projection of 3D space into 2D and rotate it so that the camera points 26.565 degrees down. Adding the plane of the camera to the diagram produces this view, seen from the left side: Code: \ \ \ _,o _,' \ _,'  \ _,' θ)  \ ooo At this angle, a vector two units back and a second vector one unit up would project to the same length. This length is slightly smaller than the length of a vector along the plane, just as the long leg of the triangle is slightly smaller than the hypotenuse. How much smaller? For an angle with tangent t and cosine c, it is a trigonometric identity 1 + t² = 1/c². But the above triangle was designed such that tan θ = 1/2. So if the hypotenuse of the above triangle is 1 unit, the long leg is 2√5/5 = 0.8944. This is just 2% longer than 0.875, the height of a scanline in pixelwidths. So at this angle, 16 pixels to the right, 16 pixels up, and 8 pixels front to back represent very close to the same distance. And this is how the viewpoint works in a lot of "isometric" games for these consoles, such as Snake Rattle 'n Roll, Solstice, and the Genesis version of Viewpoint. Should I also run the analysis for a different angle that might work better for the 320x224 mode of the Genesis and PS1 (clean aperture is 350x240) and quarter D1 (352x240)? And this is what I came up with in Blender: * In before kyuusaku mentions preBT.601 standards. 
Author:  tepples [ Tue Oct 16, 2012 6:41 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
And this is what I get when I reduce it to NES specs: 
Author:  Bananmos [ Wed Oct 17, 2012 3:21 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
Those 3d characters actually look pretty nice, and with some careful retracing&retouching work you'll probably be able to make the NES versions recognizable But is your sprite budget so small that you need to limit yourself to 16pixel wide characters? What kind of view are you considering for your game? Topdown or sideviewbeat'em up ala Street Fighter 2? 
Author:  tepples [ Wed Oct 17, 2012 3:38 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
As I wrote above, it's top down in the sense that pressing up goes north, like in an "isometric" game. I'm not tile limited, as I have plenty of CHR RAM. But I'm limited to 16px wide characters for the same reason as RC ProAm or the Kunio games. If I were to step up to 24px wide, then four characters on a line, or two characters and a bunch of things on the ground or in the trees, would cause horrible flicker. The only way I could extend the budget is by ditching the NES. 
Author:  Bananmos [ Wed Oct 17, 2012 4:47 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
But what kind of setting are you looking for in your graphical reboot of Russian Roulette? Four players facing it off by passing the gun around, with no ability or need to walk around? In that case you could be creative by limitations, and try to carefully place them in a circle wide enough as to not cause flicker... But then again, I may be totally missing the look you want to have in this game? 
Author:  tepples [ Wed Oct 17, 2012 4:59 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
Multiple rule set support is part of it. This is for HHCO, and I could change the art style for different rule sets, but only as inspiration comes. I may post mockups as I get time. 
Author:  tepples [ Sat Oct 20, 2012 8:17 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
This is what I was planning to plug the sprites into: 
Author:  3gengames [ Sat Oct 20, 2012 9:22 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
That looks really good IMO! 
Author:  Bananmos [ Sun Oct 21, 2012 3:33 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
So just redesign your map a bit to move the two bottom characters a bit down so they will never be on the same scanline as the cherries in the trees, and you can make them 24 pixels or maybe even 32 pixels, wide which would look a lot nicer IMO. Don't think any player would even notice that your aestethic choice comes from a hardware limitation, except for the few hardware geeks on this forum 
Author:  tepples [ Fri Nov 30, 2012 4:00 pm ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
tepples wrote: Should I also run the analysis for a different angle that might work better for the 320x224 mode of the Genesis and PS1 (clean aperture is 350x240) and quarter D1 (352x240)? I did so for the record. Strictly, "isometric" refers to a parallel projection along the diagonal of a cube, from one corner to the opposite corner. This means one unit northeast plus one unit northwest projects to the same as one unit up. The triangle in this case would have a base of √2, the length of the bottom face's diagonal, a height of 1, and a hypotenuse of √3, the length of the cube's diagonal. The slope is 1/√2 = 0.7071, and the angle of the image plane is arctan(1/√2) = 35.2644 degrees down from horizontal. Code: _,o._ _,' . `._ o:_ (θ _:o  `._ ' _,'   `o'  _,o  , '  ` .  _,:  θ o._  _,o' ` `._  _,' ++ `o'+o All right angles in the cube project to 60 degree angles (θ) or 120 degree angles (2θ), whose sine is √3/2 = .866. So one unit northeast and one unit southeast project to .866 of the length of two units up. The 160px, 320px, or 640px mode of the Apple II, Atari 2600, IBM CGA, Amiga, and many other secondgeneration home computers and game consoles outputs one, two, or four dots for each cycle of the color subcarrier: 315/88 MHz. For example, two dots per cycle produces a pixel aspect ratio of 6:7, or 0.857, very close to the ideal. The 320px mode of the Sega Genesis squeezes 320 pixels in the same time as 256 pixels of the TMS9918 family, meaning pixels are only fourfifths as wide as they are in 256px mode. This gives it a pixel aspect ratio of 32:35 (0.914) instead of 8:7. This is a bit wider than the expected 0.866. 
Author:  slobu [ Mon Dec 03, 2012 10:19 am ] 
Post subject:  Re: Isometric trigonometry and the NES pixel aspect ratio 
As a side I wonder if your research could go into a tile editor with realtime conversion between topdown and isometric tiles like in IsoEdit for Project Zomboid http://theindiestone.com/binky/2011/12/ ... ndthings/ 
Page 1 of 1  All times are UTC  7 hours 
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ 