How To Make Rendering Prettier

glTF model from Sketchfab

This page is the opposite of the manual page How to optimize your games :)

  • Use Physical-Based Rendering (PBR).

    The easiest way to use PBR is by using glTF format for your assets. glTF by default uses PBR materials. You can design and export glTF with PBR e.g. using Blender.

    You can also read about PBR in X3D. In short: Michalis has designed PBR in X3D 4 to match glTF PBR exactly.

  • Use bump mapping. In Blender, just set a normalmap texture (texture that affects normal vectors) and export to glTF.

    Internally we do bump mapping by Material.normalTexture or PhysicalMaterial.normalTexture X3D fields.

  • Use other textures (occlusion texture, emission texture, specular and shininess texture (Phong), metallic/roughness texture (PBR)) to provide interesting features varying over the surface.

    See Material (Phong) or PhysicalMaterial (PBR) in X3D 4 for various optional texture slots to affect various additional material parameters.

  • If you still use (older, simpler, faster) Phong lighting model, then at least set the shading to Phong (not Gouraud). You can set shading per-shape, but usually it’s easier to just set Scene.Attributes.PhongShading := true for the whole scene (TCastleScene instance).

    Note that Phong shading is activated automatically (for a particular shape) when you use PBR, bump mapping or shadow maps or some other engine effect. So you may not need to actually request it explicitly.

  • Use screen effects (post-processing).

  • Use effects like mirrors and shadows.

  • Use animation blending when appropriate. To do this, set TCastleScene.DefaultAnimationTransition to non-zero on your scene, or use PlayAnimation with TPlayAnimationParameters.TransitionDuration set as non-zero.

  • Use gamma correction. It is automatically used with PhysicalMaterial, so it is automatically used with glTF models using PBR. You can set GammaCorrection := gcAlways to just use it always (also with Phong lighting or unlit materials).

    This makes calculations more correct with respect to reality. This should be turned "on" from the begging of working on your graphic assets — as it necessarily affects to colors of everything.

  • Try and use one of the tone mapping options if you feel they improve your colors.

  • You can increase the number of allowed lights per shape using Scene.Attributes.MaxLightsPerShape. view3dscene has a menu item to experiment with it ("View -> Max Lights Per Shape…​"). A test model is in demo-models: gltf/multiple_animated_lights.

To improve this documentation just edit the source of this page in AsciiDoctor (simple wiki-like syntax) and create a pull request to Castle Game Engine WWW (cge-www) repository.