Shaders unification: Phong shading, bump mapping and CommonSurfaceShader on mobile, 100% modern rendering on desktop

Posted on

Steep parallax bump mapping with self-shadowing on Android
Monkey with bump mapping on Android
lizardman animation with bump mapping on Android
FPS game example on Android

I have just finished a large rework of our rendering code 🙂 This unifies desktop (OpenGL) and mobile (OpenGLES) shader rendering better, and brings many new rendering features:

  • You can now choose between Gouraud or Phong shading, on both OpenGLES (mobile) or OpenGL (desktop). Our shaders support all combinations. By default we do Gouraud shading, but you can switch to Phong for the whole scene by Scene.Attributes.PhongShading := true or only for a particular shape using Shape.Shading := shPhong. See also the X3D Shape.shading field.

  • Bump mapping (even steep parallax bump mapping with self-shadowing), specular maps and other CommonSurfaceShader features are now fully available on OpenGLES (mobile platforms).

  • You can set global EnableFixedFunction variable to false on desktops, to force absolutely all rendering to go through shaders, without any fixed-function calls. This makes our desktop rendering 100% based on shaders, instead of the previous mix of shaders and fixed-function operations. This will be the default (on modern GPUs) soon, and you’re welcome to test it now. You can also test it using view3dscene, just pass command-line option --debug-disable-fixed-function.

    Update: TODO: We still use fixed-function commands for shadow volume rendering and occlusion query features. This will be fixed (along with some OpenGLES upgrades), but until then: using these features will make your application call fixed-function commands, regardless of the EnableFixedFunction flag. Contributions to fix it rather sooner than later and most welcome! These are easy, local problems, they just need a dedicated person to handle them!

  • P.S. See also a simple example how to build a scene with custom shaders (X3D ComposedShader node), on display_box_custom_shaders.lpr.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.