Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: FOV problem  (Read 3716 times)

0 Members and 1 Guest are viewing this topic.

ILY

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
    • View Profile
FOV problem
« on: September 18, 2007, 08:22:40 AM »

When you set camera FOV to (for example), 45 degrees, wintermute applies it to viewport verically. I mean, its view and projection transformations are set up in such manner, that vertical field of view will be 45 degrees. Since viewport is a rectangle (not a square), field of view in horizontal direction will be more than 45 degrees.

The problem is that 3DS MAX, by default, applies fov horizontally. That means, that horizontal field of view will be 45 degrees, and vertical will be less than 45. So, the image with the same FOV will be look differently in 3DS MAX and WME and prerendered backgrounds became mismathced with their collision model.

Of course, Manual FOV override solves the problem, but maybe it would be more robust to offer an option, whether to apply fov in horizontal or vertical direction?

3DS MAX has such option.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FOV problem
« Reply #1 on: September 18, 2007, 05:35:36 PM »

The trouble is, the 3DS file doesn't contain the actual FOV value, nor the vertical/horizontal info. It's converted to a semi-mysterious "lens" value.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

ILY

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
    • View Profile
Re: FOV problem
« Reply #2 on: September 19, 2007, 03:38:16 AM »

Sorry, seems like I did not explain it clear enough.
The problem is that even when you set fov override to the same value as in 3dsmax, the picture looks differently.
This is because the projection matrix is build in 3dsmax and wme in different ways.

Here is the D3DXMatrixPerspectiveFovLH description in dxsdk. You can see that it builds the matrix in such manner, that the fov is applied in Y-direction.

Code: [Select]
D3DXMATRIX * D3DXMatrixPerspectiveFovLH(
  D3DXMATRIX * pOut,
  FLOAT fov,
  FLOAT Aspect,
  FLOAT zn,
  FLOAT zf
);

This function computes the returned matrix as shown:

xScale     0          0               0
0        yScale       0               0
0          0       zf/(zf-zn)         1
0          0       -zn*zf/(zf-zn)     0

where:
yScale = cot(fov/2)

xScale = Aspect / yScale

Well, but 3DSMAX, by default, computes the xScale and yScale conversely:
Code: [Select]
xScale = cot(fov/2)

yScale = Aspect / xScale

So WME computes yScale, based on fov, and then adjusts xScale accroding to viewport aspect, and 3DSMAX does it visa versa.

----
Updated: fixed bugs in formula
« Last Edit: September 20, 2007, 03:44:12 AM by ILY »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FOV problem
« Reply #3 on: September 19, 2007, 09:20:24 AM »

Ah, I didn't know that, thanks for the info, it might prove very useful :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.04 seconds with 24 queries.