Jump to content


Member Since 18 May 2013
Offline Last Active May 23 2017 09:02 PM

Topics I've Started

What makes a vertical FOV from a horizontal one?

04 March 2017 - 06:16 PM

Greetings all,


I have a working software renderer but I'm trying to understand what makes a FOV vertical vs horizontal.

First a bit of background on my setup. My calculations for the camera are as follow: I assume a normalized projection plane that has a height of 2. So from the middle going up 1, and from the middle going down is 1 too, total 2.

We know aspect_ratio = width/height = width/2. Thus width=2*aspect_ratio. So the size of the projection plane (or viewplane, whatever you want to call it) is `2*ar x 2`

From similar triangles relationships when calculating the projected coordinates, we get that d (distance to the projection plane) is `1/Tan(Fov/2)` which is how much we need to scale the unprojected y coordinate by. Divide that by aspect_ratio and that's how much we need to scale x by (because width is 2*ar, so we divide by ar to normalize it)

All of that makes sense to me and it works. Here's my camera setup function (not using matrices):

    void CameraInit(camera *Camera, vec WorldP, fixed Aspect, fixed FOV)
        Camera->Position = WorldP;
        Camera->FOV = FOV;
        // tan fov/2
        Camera->Tan = Math_Tan(Camera->FOV / 2);
        // distance to the projection plane (which is of size=2*ar x 2).
        Camera->ScaleY = 1 / Camera->Tan;
        // we divide x by ar because we want to normalize things on the x too
        // otherwise we'd still be left in the range [-ar, +ar]
        Camera->ScaleX = Camera->ScaleY / Aspect;
        // near/far clipping planes
        Camera->NearZ = (fixed)0.01f;
        Camera->FarZ = (fixed)100.0f;

And here's my perspective projection function:

    INLINE vec CameraToPerspective(vec CameraP, camera *Camera)
        vec Result;
        Result = CameraP;
        fix ZInv = 1/Result.z;
        Result.x = (Result.x * Camera->ScaleX) * ZInv;
        Result.y = (Result.y * Camera->ScaleY) * ZInv;

My question is: What is this 'FOV' that I'm using? Is it a vertical field of view or horizontal? What makes a vertical FOV vs a horizontal one?

Can someone provide a better explanation than "it's because of how you calculate stuff" or "it's because that's how you write it in the matrix" (as given to me here, see comments in the answer...). Throughout this entire software renderer, there is NOT a single line of code that I don't understand deeply and thoroughly (except for quaternions which are still new to me), and I'd like to keep it this way.

Thanks a lot in advance!

Dynamic Aim/up Down Animations?

03 August 2016 - 09:27 PM



I have a character with an aim straight and fire handgun straight animations. I want him to also be able to aim down/up and fire from those poses too. Think Resident Evil 1/2/3.


I'm trying to find a way to do it dynamically to save time and effort for my animator. I was thinking I could dynamically have the upper part of the character body aim up/down and blend in additive the fire/shooting animation.


I'm not sure how to go about having him aim up/down. Do I have to write an IK system for this or is there a more straight-forward solution?


Any books, links, hints or pointers on the subject are appreciated.


Resident Evil 2 "Color masks"?

15 November 2015 - 10:07 PM

I've always been fasinated by prerendered technology. There's just this awesome 90s vibe about it, takes us back to our favoirte childhood games. One of those games for me was Resident Evil. I was talking to a friend today who happened to be in the business of ripping RE animations from ISO and other stuff. He showed me an interesting 'mask' image that left me wondering... (ripped it off using Rice Video Plugin)


Please see attached images.


Now, I don't know much about PS1 development nor its graphics API, so I don't know for sure how they implemented their illusion of depth. I'm almost certain (correct me if I'm wrong) that they didn't have programmable shaders at the time, but I guess it doesn't necessarily mean that they didn't have access to a depth buffer, if that's the case, and they used depth maps, well depth maps are greyscale images usually, which leaves me wondering what those colors mean in that 'mask' image... They definitely look like they're somehow related to depth, but why colored? Couldn't they just have used, say white and magenta?


Any idea what those colors mean?


(And if anybody know some detail about how they created illusion of depth please share)

FSMs vs Behaviour trees in gameplay programming?

16 June 2014 - 12:02 AM

Hi all,


so I was just recently learning about Behavior trees and found them interesting so I decided to implement them. But what I don't understand is, are BTs a replacement for FSMs? in other words, can BTs do anything FSMs do?


I have asked the question here (no answers) with a concrete example that I would love to see how to represent it in a BT.


Your help is greatly appreciated, thanks!

UDK VS Unity3D in making a classical ResidentEvil-like game?

18 May 2013 - 02:30 AM

First hello, first post here smile.png


OK, so for the past 2 months or so, I started working on a game project that me and a buddy of mine have been wanting to make since like, the past year or so. It's pretty much like the good old Resident Evil games, Alone in the dark 4, Parasite eve, etc. Fixed cam, pre-rendered scenes, and pretty much simiar gameplay mechanics to what I just mentioned.


I first thought that Unity would be better for this type of game, I worked a bit in it, I liked how well documented it was, and how easy to use its APIs, plus I got to use my fav lang which is C# - But ran into some trouble that made me think of trying something else (mainly issues with debugging  and crashing sometimes) - I thought the Unity programming env wasn't that good


So I switched to UDK - I made a static camera demo quickly - Again, I thought it would be more suitable for what I'm trying to do - But I just coudln't find my self doing any actual gameplay programming - I was just modding and modifying existince properties, it's like, UDK is forcing the issue I didn't like that. - I have to read through thousands lines of source code just to find what I'm looking for, now that's like a pain in the butt! Also there was little to no tutorials on how to put a a game from scratch all together - in fact I missed the way how I did stuff with Unity. So I'm thinking of getting back! - Although both engines have their ups and downs, but I think the downs from a programmer perspective to UDK is more! - Like for example on-the-fly compilation, good IDE (monodev:free VS nfringe:expensive as hell) and good API documentaion.


We've been flip-flopping between engines like this for a while, I know that the only way to find if the engine's gonna suit us or not, is to dwell deep in it, but I'm just afraid that I waste time diving into something and by the end I find that it's not well-suited for what we're doing - We already wasted time, we can't afford to waste more


That's why I'm asking, what's better for what we're doing? UDK or Unity? - I know it depends on the brains, and that they're both tools and both will work just fine, but I wouldn't mind using the one that will let us reach what we want in a better, faster and more effecient way - I'm willing to work on either.


And case somebody votes for Unity, how far can I go with my game using the free version of Unity?


Any help would be really appreciated! - Thanks all.