Shark 3D renderer

1. Realism by technology

Realistic materials by per-pixel lighting

Accurate per-pixel lighting and shadowing gives a realistic look of different kinds of surface materials.

New level of realism by real-time area lights

A real-time full scene light source may be not only a point light source, but also an area light source generating extended soft penumbras.

As in reality, the penumbra width and shadow sharpness vary depending on the distance from the occluder and the shape of the light source. At the occluder, the shadow edge starts sharply, getting more and more soft with the distance. For example, a rectangular ceiling light casts corresponding full scene soft shadows in real-time. Objects truly stand on a floor without floating effect.

Such techniques are implemented in a highly optimized way, using tricks and aggressive approximations at the right places.

Consistent real-time full scene soft and hard shadowing

All objects in the world can cast shadows on all objects, including self-shadowing and penumbras. Furthermore, all objects in the world including characters and the light sources can be dynamic. The 3d scenes look more realistic and get more depth. Especially real-time full scene soft shadowing increases realism a lot.

In contrast to simple shadowing techniques or techniques relying on precalculated data, Shark 3D lighting and shadowing looks consistent. For example, if a dynamic character is partly shadowed by some static pillar, the shadow of the character vanishes correctly within the shadow of the pillar. Also dynamic objects cast shadows onto other dynamic objects. Thereby, shadowing looks realistic and natural.

Different kinds of light sources

Different kinds of light sources provide various kinds of lighting effects. For example, projected textures can be used for example to add projected spot lights.

Avoiding artifacts

Shark 3D provides techniques that are designed to work as robustly as possible avoiding artifacts.

For example, all various variants of shadow mapping have the well-known in-principle aliasing limitations. Typical problematic situations are long distance views when looking into the direction where the light comes from. With Shark 3D you can get nice full scene soft shadows without artifacts also in such situations.

A different aspect of avoiding artifacts is for example render-to-texture in conjunction with antialiasing, which sometimes causes subtle issues and requires special care to avoid artifacts.

Combining features

Due to the modular structure of the Shark 3D shader system, real-time full scene shadowing can be combined with other rendering features in a flexible way.

Details by normal maps

Normal maps can be used for normal mapping, parallax mapping and other per-pixel techniques. This makes it possible to render details of characters and objects photo-realistically in real-time.

Cinematic rendering

Cinematic rendering techniques increase realism a lot. This includes for example:

  • HDR (high dynamic range) rendering.
  • Post rendering effects, for example blooming.
  • Others.

Outdoor rendering

Use large worlds and wide open terrains. This can be combined with the generic streaming technology.

Level of detail

The mesh preparation tool can import or precalculate LOD stages of a mesh. The designer has full control of LOD and can create optimal visual results at optimized polygon counts.

Mirroring

The standard shader components of Shark 3D support a wide variety of mirroring effects. This includes reflections and refractions of approximately planar surfaces or using dynamic environment mapping. Mirrors can be transparent and opaque, static and mobile. It also includes distortion effects like for example the standard case of water surfaces with animated ripples.

Special effects

Standard modules provide features like the following:

  • Particles.
  • Fog.
  • Import of precalculated lighting.
  • TrueType Unicode text rendering.
  • 3d text: Extruded 3d meshes including bevels and mapping coordinates from TrueType Unicode text.
  • Video files on textures.
  • Many other features.

2. Optimized for detailedness

Performance optimizations

Shark 3D is highly optimized for rendering as many details as possible. This includes:

  • Performance is a core aspect when selecting and developing rendering algorithms. Performance must be good in complex scenes of real-world projects.
  • Locally optimize all performance critical code.
  • Executing per-pixel and per-vertex work on the GPU using platform specific code.
  • Executing per-vertex work on console specific co-processors using platform specific code.
  • Optimizing bandwidth by taking advantage of console specific data paths.
  • Optimizing bandwidth by storing vertex and index data in GPU memory or GPU accessible memory optimized for the particular platform.
  • Platform specific mesh optimization. Optimize triangle and vertex ordering to take best advantage of vertex caching features of the particular hardware.
  • Other platform-specific optimizations.
  • Other portable optimizations.

In practice, this means that not Shark 3D is the bottleneck. The limiting factors are only the hardware itself and highly optimized platform specific low-level code doing the hard work. As a side effect, on PCs Shark 3D can take advantage of better hardware and better drivers automatically.

Giving control

State changes are expensive. In addition, ordering render tasks in the right way has a huge impact on performance. Especially for complex non-local render effects unfortunately there are no simple generic rules for best ordering of render tasks. Therefore Shark 3D gives the shader programmer detailed control of ordering render tasks.

3. Assembling shaders

Creating shaders by configuration

New shaders can be created by configuring shader components without needing C++ or script code.

This includes using multiple rendering passes, multi-texturing, parameter calculations, shader animations, and much more. Using all these features don't require scripts or C++-code.

Another feature of configuration is to define different rendering techniques depending on the available hardware. Depending on the presence of particular 3d-card features, one of several shader variants is selected.

Also new shader components can be included into a Shark 3D based application simply by configuration.

Shader modifier components

Multiple shader components may be combined to a compound shader. This can be done purely by configuration. Thus, combining features of different shaders to generate a particular new unique shader can be done purely by configuration. No line of C++ code has to be changed.

For example, a mirror is not simply implemented by a single shader. Instead, at least two shaders work together. These two shaders build a compound shader, which is assigned to the mirror object. The first shader component implements the mirroring functionality. This shader may for example generate a texture containing the mirror image. The second shader component is used to render this texture, and possibly to apply additional effects, for example distortion. Thereby, the mirroring feature can be combined with other features provided by different shaders.

Shader animation

Any number of independent animation slots can be passed to the shaders and shader programs, including pixel and vertex shader programs. The shader animation technique is integrated completely into Shark 3D networking.

These features are all accessible on a simple configuration level. For example, a sensor volume may start and stop a pixel program shader animation. The animation may be controlled by the server, but is executed completely on the client. Such features can be implemented fully on a configuration level needing only few configuration entries. There is no need for any C++ code or scripting code.

Each animation slot can be configured in different ways. First, it can be a simple animation, which is played automatically locally on the client, for example for decorative shader animations. But it is also possible to control an animation slot by the server, taking advantage of all advanced animation techniques of Shark 3D, including server-client optimizations and interpolations.

As a very simple example, you can write a shader blending two textures into each other controlled by a script on server-side. All this can be done by configuration without any line of C++ or script code.

As another example, you may write a customized shader for an energy-protected door in a game using animated pixel and vertex programs. This shader may use one automatic animation slot for a decorative energy fluctuation animation, and a second animation slot for fading between an open and closed state of the gate, which is controlled by the server. Also this sample can be implemented without any line of C++ or script code.

Target-platform specific optimizations

Consoles and PC, but also different PC 3d hardware have different hardware capabilities. Shark 3D consistently uses the following philosophy: Shader sections that are the same on multiple platforms are defined only once; shader sections that are target platform specific can be optimized individually.

There are special shader components that define different shader sub-sections depending on the current hardware. This can be done completely on configuration level. In the extreme case you can define separate shaders depending on the current 3d hardware and current game configuration.

Vertex and pixel programs

Using vertex and pixel programs themselves, for example to implement normal-mapping, is easy. However, all advanced rendering effects require a smart combination of vertex and pixel programs combined with suitable C++ code. For example, real-time full scene shadowing effects cannot be implemented only on per-vertex and per-pixel level. In general, advanced rendering effects have many interactions with other modules, for example scene management, lighting, shadowing, and animations.

For that purpose, we designed a universal shader program mechanism that is smoothly integrated into the Shark 3D shader and animation system. The developer can combine the advantages of the configurable shader system, lighting and shadowing modules with vertex and pixel programs of 3d chips, opening for you the door to new rendering effects.

4. Re-entrant Modular Shader System™

Importance of an open renderer architecture

One aspect is that a shader system makes it easily possible to create new shaders by plugging together individual functionalities. However, on this level you are limited to the sandbox of the renderer features provided by the particular shader system.

Advanced projects typically come to the point where the built-in rendering features are not sufficient, even if you can combine and configure them in a very flexible way.

Therefore it is very important that the renderer is not a closed system. Instead, the renderer must be very modular on C++ level, too. This makes it possible to add completely new rendering techniques in a modular way without having to modify or even rewrite the renderer.

Advanced rendering techniques work in very different ways

A real open modular architecture is especially important, because there exists no right rendering technique for every situation. For example, there exists a more or less unlimited number of different soft shadowing techniques. Different rendering techniques often don't differ only locally in some vertex and pixel programs, but differ in more fundamental, global ways. For example:

  • Objects in the scene may have to be enumerated by different culling rules.
  • Render targets may have to be used in different ways and at different times.
  • The program flow regarding scene traversal and rendering into render targets can vary.
  • Different global rendering recursions using different modes and parameters may be needed.
  • Vertex and pixel programs may need very special parameters.
  • Others.
And depending on the particular project, and often even depending on the particular level or scene, you need to have the freedom to easily and quickly implement a particular special rendering technique.

The Re-entrant Modular Shader System™ of Shark 3D

The answer of Shark 3D to this challenge is the Re-entrant Modular Shader System™. This means that all local and global rendering functionalities are completely moved into independent, decoupled shader components. The core renderer does not know anything about particular global rendering techniques.

Instead, all advanced local and global rendering effects described above and included in the Shark 3D SDK are implemented in separate, independent shader modules. And new advanced local or global rendering features can be implemented in a modular way without having to change the core rendering code of Shark 3D.

Basically the core renderer loop does nothing more than activating shader components. And shader components communicate using generic interfaces that are not limited to particular global rendering techniques.

Implementing features in a clean and modular way

For example, in Shark 3D, the core renderer does not know anything about shadowing at all. Instead, all shadowing techniques - whether plain shadow maps, plain shadow volumes, or more sophisticated techniques requiring sophisticated render target juggling - are implemented by independent shader modules.

Another sample is that the core renderer does not know anything about mirroring. Especially, mirrors are not hard-coded in the renderer. Instead, a mirror is implemented by an independent shader module.

Combining different advanced rendering techniques

Another important aspect is that for high-end projects you often have to combine multiple different advanced rendering techniques at one time. For example, you need to combine different lighting and shadowing techniques within one scene.

This means that for example that different scene traversals and different ways how render targets are used are active at one time.

Shark 3D naturally supports this. You can combine different advanced rendering techniques in an orthogonal, modular and clean way.

Analogy to non-real-time rendering

Advanced non-real-time renderers don't only provide a shader system where you can create shaders by assembling individual rendering features. In addition, a flexible extensibility is crucial. Every advanced non-real-time renderer has very powerful generic interfaces to plugin new rendering techniques.

The Re-entrant Modular Shader System™ of Shark 3D brings the same power to real-time rendering. There is no renderer with fixed functionality anymore, which only can be enhanced or customized by modifying the core renderer. Instead, the renderer is completely modular. This opens new unique possibilities for high-end game projects.

Shader linking

Complex compound shaders easily consist of a dozen shader components. To keep control over complex rendering effects, Shark 3D provides a smart shader linker: Data like render targets, textures, geometry handles, and animation states are bound using human-readable identifiers. Depending on the available hardware, the shader components are linked together for optimal execution performance at runtime.

5. Workflow

Live editing shaders

Based on the Live editing the running console and PC game technology of Shark 3D, you can interactively manipulate and test all shaders. This includes modifying the shader parameters and modifying vertex and pixel programs. This is useful both for designers and developers.

For instance, the designer can change shader parameters and see the results in the running game level without having to restart Shark 3D. The designer does not only have a limited material preview, but can see all changes in the running game.

The developer can change pixel programs and can inspect the change immediately in the running game level.

Optimize the workflow pipeline for your project

The main strength of the editor is that you can easily customize and extend your user interfaces and workflow according to all your needs. For a new shader, you only have to write a simple configuration entry, providing the proprietary shader parameter in a comfortable way.

For example, a developer may have created a new shadow-volume effect, based on existing or new C++ shader components, vertex or pixel programs, and having used the Shark 3D shader language. By writing a simple customized configuration entry, every designer can assign this new shader to objects, and manipulate proprietary shader parameters.

For this new proprietary shader, the designer can use all workflow features. This includes Live editing the running console and PC game, so that the designer can see shader parameter changes in the running game.

6. Shader user interfaces

The shader editor

Using the Shark 3D editor, designers can edit shaders very comfortably.

Stand-alone or integrated

The shader editor exists in different variants. First, the designer can use the stand-alone editor to edit shaders. Furthermore, the shader editor also exists as plugin for other tools. For example, in this way the designer can edit the shaders directly in 3D Studio Max™.

These are default mechanisms. Using the modular structure of the component editor and the component architecture, it is easy to integrate shader editing functionality into other tools, including proprietary tools.

7. World management

Generic object data base

The generic object data base of Shark 3D provides a powerful basis for various Shark 3D components. This includes for example the renderer, collision detection (if not using an external physics package), sound management, and sensor objects. The Shark 3D object database allows efficient object enumerations in a flexible way. For example, a simple object enumeration would be: "Which other objects are less than 10 meters away from this object?".

Support of advanced rendering techniques

World management needs to work with advanced, cutting-edge rendering features. A very simple sample is the question of finding out which static and dynamic objects are influenced by a light source. This can be answered by the Shark 3D object database in an efficient and elegant way. Different kinds of rendering effects like advanced shadowing and mirroring effects require to access and enumerate objects in a different way. Especially new non-trivial rendering effect requires a new way of accessing the object database. Therefore, in practice a generic object database that is designed for flexibility from the beginning has turned out to be an essential foundation.

Shark 3D provides a modern basis for these modern requirements. This includes among others that Shark 3D provides a clear separation of the Shark 3D visibility system from a generic object database. The object database provides generic object enumeration that may or may not be related to visibility aspects. More importantly, the database approach provided us with the foundation and freedom we needed to push the renderer without hitting limits all the time.

Pluggable visibility components

Depending on the particular game situation, you can add a culling component for efficiently culling non-visible world parts and objects. This automatically includes static and dynamic world parts and objects. This includes not only classical objects, but also light objects and effects.

Instancing

Shark 3D thoroughly supports and takes advantage of instancing. Especially on consoles, instancing is a powerful mechanism to build complex levels needing an minimal amount of memory. Instances can be defined in multiple ways:

  • Define multiple instances of the same object (e.g. trees) already in your 3d modeling tool, for example 3D Studio Max™.
  • Define positions in your modeling tool, and create instances of objects (e.g. characters) at these positions by an actor component in Shark 3D. See also the Editor for details about creating such components.
  • Create instances of objects by C++ code.
  • Others.

Multiple instances can have different textures, shaders, and animation states. These states can be also switched at runtime by scripting.

8. PVS

PVS (potentially visible sets) are precalculated visibility data. The advantage of this technique is that accessing precalculated data is nearly for free at runtime. Thereby, also for very large worlds, only the potentially visible objects cost rendering performance.

PVS sample case

The following image a simple sample scene of a game level:

Rendering this scene brute-force without PVS gives the following wireframe:

The wireframe modus shows all primitives that are sent to the 3d hardware. The complete level part that intersects the view frustum is rendered and therefore costs performance, but only a small percentage is effectively visible in the end. Note that the white lump near the middle represents not only some few objects, but a major part of the complete level at a larger distance.

However rendering using precalculated PVS gives the following result:

Only potentially visible objects are rendered and only they cost any performance.

Flexible world management with PVS

Shark 3D PVS is separated from a dynamic object database. This means: Shark 3D is a combination of static techniques with dynamic techniques. What can be done efficiently at runtime is done at runtime; what would be expensive is precalculated.

You can mix static and dynamic approaches in a flexible way and optimize the static parts by PVS. For example, you can dynamically create a building that itself is static and is optimized by PVS.

Although the PVS visibility data is precalculated, dynamic objects, of course, also can take advantage of PVS. For example, if a character currently is inside a particular room, and this room is stored as being not visible from the current camera position, both the room and the character are not rendered.

Optimized PVS workflow

You don't have to recalculate PVS data for every tiny change. Typically the previous calculated PVS data is still good enough for testing your change. This means in practice: You can modify everything in your level and see your changes in the running Shark 3D based application. PVS may be also calculated in the background without hurting the edit-and-run work flow.

Advanced PVS

Shark 3D PVS is not only valuable for indoor, but also for many outdoor scenes. Precalculated portal visibility can be considered as special case of Shark 3D PVS. Shark 3D PVS gives you explicit control of sectoring if you want. For example, you can explicitly define sections, and PVS calculates visibility between these sections for you.

Better performance characteristics with PVS

The main advantage of using precalculated visibility data compared to calculating visibility at runtime is a better performance characteristics. Calculating visibility at runtime is costly. Typically, for fast scenes the return on investment is positive. But for complex scenes the return on investment often is negative, making slow scenes even slower. In contrast, using precalculated data like PVS is much better in improving complex, problematic scenes, because the complex work of precalculation already was done off-line. The lookup time needed at runtime is always cheap both for simple and complex scenes.

At the end, the question is: Do the complex work at runtime? Or do it off-line, and only use a simple look-up at runtime? The second approach does not waste performance at runtime and does not risk a negative return on investment of valuable processor time.

9. Viewport system

Visible representation of abstract objects

Shark 3D uses a clear separation between abstract objects and their graphical representations. An abstract game state can have no, one or multiple graphical representations in different physical graphical contexts. Each physical context can have no, one or multiple viewports that share the same hardware resources.

These relationships are managed automatically. For example, a graphical context may be re-created due to a fundamental configuration change. Or a new graphical context may be connected to an existing abstract game state. Then the corresponding context resources are created and uploaded automatically. If necessary, this automatically includes reloading such data from disk. For example such data may be texture data, vertex buffer data and index buffer data.

Renderable objects

If you want, you can write a render component that fully bypasses the complete shader system. Simply register such an object directly with the renderer object database, and the object will get calls for rendering.

Multiple 3d states and viewports

An unlimited number of unrelated or related 3d states and viewports can be displayed at the same time on the client. For example, this may include a main 3d world, main 3d sky, and a display. All features available for the main 3d world can be used also for the sky.

10. Backends

Supported backends include:
  • Console hardware (see Platforms).
  • Direct 3D.
  • OpenGL.
  • Other backends.