How the engine works

From Decentraland
Jump to: navigation, search

How the engine works

Decentraland uses our A-Minus renderer. A-minus is an xml scene description format that is a subset of AframeVR.

Why don't we use aframe

There are a few reasons:

  • Performance - our renderer aims to be faster than a-frame for the subset of markup we support
  • Security - A-Frame implicitly trusts all content, we must protect our users from bad actors
  • Multiple-parcels - A-Frame doesn't work well with content loaded from multiple source into one world

How the client works

The client:

  • Requests nearby parcels from the ethereum contract, the contract gives an IPFS hash
  • Loads scene metadata from the ipfs hash
  • Loads the parcel html from the ipfs hash
  • Parcels the html, and converts the scene description to a three.js scenegraph
  • Checks the scenegraph is valid and fits inside the parcel boundaries
  • Adds the scenegraph to the scene and starts rendering

The renderer:

  • Uses webvr-polyfill* so that if you are using a VR headset, you get head tracking, but if you are not using a vr headset, you can use the mouse to look around.

The renderer has *physics*, the avatar is simulated as a 1 meter sphere, and all the geometry in the world is loaded and collided with, so you can climb on top of things, and not walk through walls.

The renderer has two lights, an ambient light of color `0x505050`, and a directional light. The directional light is at 64,64,64, relative to the user (so it appears to be come from the south-east. The sky was pre-rendered using the atmospheric model of indigo renderer. The skybox is rotated around the y axis so that it aligns with the directional light.

The shadow camera is based at the directional light, and is an orthographic camera that is configured to draw shadows up to approximately 50 meters from the user in each direction. We intend to improve shadowing so that there isn't an obvious cut off where shadows just stop working (cascading shadow maps, fading out shadows, various solutions).

Supported formats

The best supported format is .OBJ. We also support .GLTF, but this is very early, and support will probably change (for example gltf support will not allow specifying shaders in the model).

OBJ support includes MTL support, and the engine will load textures from alongside the mtl (assuming they are all uploaded to the same ipfs hash).