Author Topic: How does FF7 knows in which order to render layer of tiles vs 3D characters  (Read 2241 times)

tigrou

  • *
  • Posts: 3
    • View Profile
I am wondering how the FF7 rendering engine works.

What I have understood so far is that the game is tile based.

AFAIK, there is several layers of tiles used in the game :
- Usually one main background, containing 90% of the field (everything that is always behind all 3D characters)
- One 2nd layer for things that can be in front of 3D characters (eg : a fence, a tree)
- Some additional layers for animation (eg : door closed or open, smoke ... )

To render a frame :

First draw main background
Then all 3D characters behind 2nd layer
Then 2nd layer
Then all 3D characters in front of 2nd layer

The question is : how does the game knows, for a given 3D character, if it should be rendered after or before a layer ?

Is that information stored in the walkmesh data (thus for each triangle) ? or is it scripted (if yes how) ?

Same for switching layer for door open / closed based on player position


EDIT : I took a look using Makou Reactor :

Doors are simply special 3D lines added over the walkmesh which if passed by will trigger a sound + switch a layer parameter (to display the door open/closed)
Field animation (eg : fan, smoke) is done using scripts (which will turn some layers parameter on / off over the time)

It's still unclear to me how the game render 3D objects against layer
« Last Edit: 2015-09-27 09:44:27 by tigrou »

Halfer

  • *
  • Posts: 142
    • View Profile
http://wiki.qhimm.com/view/FF7/Field_Module

I don't quite understand what you are striving for with that information. There's an order which the engine uses to load the field and 3d models but the time between their loading is probably so small that it's insignificant.

tigrou

  • *
  • Posts: 3
    • View Profile
@Halfer : from the qhimm wiki :

Quote
The backgrounds are actually 16x16 blocks that are loaded into VRAM and then assembled into the video buffer every frame. The system allows for layers to obscure the 3D entities using a simple painter's algorithm

Painter algorithm means you first render distant parts then parts which are nearer thereby covering some areas of distant parts.

So order is very important. It will make some 3D objects of the field (eg : characters) appears behind or above the tiles depending of that order.

In case of FF7, you first want to render layer0 (the main background) then some 3D characters , then layer1, partially covering some 3D characters (eg : characters behind a house),  then again some 3D characters (not covered by anything) and so on

I clearly understand this part.

The real question is , depending the position on the field, how do you know if a character is behind or above a given tile/layer ?

Here is an example, if player is on A you shouldl render is this order : Layer0, Layer1, Player
If player is on  B, this order : Layer0, Player, Layer1 (so he appears behind the fence)

Since a 3D character is on a walkmesh you know it's Z value. But (AFAIK) you don't have the Z values of individual tiles.


« Last Edit: 2015-09-27 13:13:02 by tigrou »

Halfer

  • *
  • Posts: 142
    • View Profile
I see.

In case of FF7 the MIM files are handled by data on DAT files. http://wiki.qhimm.com/view/FF7/Field_Module/DAT/Tile_Map

Aali

  • *
  • Posts: 1196
    • View Profile
Each tile (except for the first layer) has a given Z coordinate, it's all in the field file format. I would also like to point out that since the PC version uses Z-buffering, it does not have to do any of this manually and characters are simply drawn before all the tiles are drawn.

tigrou

  • *
  • Posts: 3
    • View Profile
Thanks Aali, this fully answer my question.