Terasology/docs/Rendering.md
Tobias Nett 2d8ef61e80
doc: move wiki content to docsify page (#5155)
* rename docs to docs-pre-merge
* add wiki content based on commit e4d4b10424f24eed6583ea0e998da8aa32a27a3f
* replace wikilinks with markdown links in _sidebar
* use sidebar link text as title via ` autoHeader: true` 
* rename files with `:` or `,` in the name
* use the wiki Home page as entry point instead of the repo README
2023-10-31 14:46:35 +01:00

2.5 KiB

DISCLAIMER: the Renderer is undergoing major refactoring. The information provided here is so far correct and describes the only way at this stage to access rendering functionality. A major goal of the refactoring work however is to eventually provide a much more powerful API that will allow to expand, improve and even replace the renderer functionality available. Stay tuned! =)

RenderSystem interface

To get the engine to call your custom rendering functions, you need to have a System implementing the RenderSystem interface. This interface contains a method for some of the rendering passes executed by the engine. Add your code to the method that best fits the type of rendering you want to do. Usually this will be either renderOpaque or renderAlphaBlend, depending on whether or not you want to display transparent objects. The functions will be called automatically, while the system is registered to the engine.

WorldRenderer

More often then not, you will need more information then just the description of the objects you want to render. It is likely that you also need to have access to the camera position. The WorldRenderer can provide this amongst other useful stuff, such as block lighting information. To get access to the WorldRenderer, add a public WorldRenderer attribute to your system, with a @In annotation. The engine will assign an instance of WorldRenderer to this automatically.

@RegisterSystem(RegisterMode.CLIENT)
class MySystem implements WorldRenderer {
  @In
  public WorldRenderer worldRenderer;
  
  ... other code ...

  public void renderOpaque() {
    Camera camera = worldRenderer.getActiveCamera();
    ... rendering code ...
  }
}

OpenGL and GLSL

Terasology uses OpenGL 2.1 for all it's rendering. Shaders are written in the corresponding GLSL version 1.2.