Link
4. Renderer
Complex materials
Accurate per-pixel lighting and shadowing, editable by the
shader editor,
provides realistic looks of different kinds of surface materials.
Advanced lighting by real-time area lighting
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 gaining 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 significantly.
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.
Cinematic rendering
Cinematic rendering techniques increase realism significantly.
This includes for example:
-
HDR (high dynamic range) rendering
-
Post rendering effects, for example blooming
Outdoor rendering
Use large worlds and wide open terrains.
This can be combined with the
generic streaming technology.
Reflections and mirroring
The standard shader components of Shark 3D
support a wide variety of reflection and 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
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.
-
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 in most situations
Shark 3D is not the bottleneck.
The limiting factors is the hardware itself
and highly optimized platform specific low-level code doing the hard work.
As a supplementary 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.
Modular renderer architecture
You can easily create new nodes
for the
shader editor.
This includes using multiple rendering passes, multi-texturing,
parameter calculations, shader animations, and much more.
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 feature,
which can be then exposed to the designer
in the
shader editor.
This can be done without having to change C++ code.
For example, a mirror is not just 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.
The mirroring node in the
shader editor
takes care of correctly combining the mirror component
with other components.
Shader animation
Any number of independent animation slots can be passed to the shaders and
shader programs.
The shader animation technique is integrated completely
into Shark 3D
networking.
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 locally on the client automatically,
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 shader 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 usually 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 application configuration.
Shader programs
Using shader programs themselves,
for example to implement materials, is easy.
However, all advanced rendering effects
require a smart combination of shader programs
combined with suitable C++ code.
For example, real-time full scene shadowing effects
cannot be implemented only on shader program 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 shader programs of the GPU,
opening for you the door to new rendering effects.
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 shader 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.
-
Shader 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™
In Shark 3D 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 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 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 run-time.
Visible representation of abstract objects
Shark 3D uses a clear separation
between abstract objects and their graphical representations.
An abstract world 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 world 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.
Just 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.
Backends
Supported backends include:
-
Direct 3D
-
OpenGL
-
OpenGL ES
-
Proprietary console hardware
(see also platforms)
-
Other backends
Pluggable visibility components
Depending on the particular 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.
Support of advanced rendering techniques
World management needs to work with advanced,
cutting-edge rendering features.
A very simple instance is the question of finding out
which static and dynamic objects are influenced by a light source.
This can be answered by the
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 features,
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.
Another important aspect is that the object database
is separated from the logical scene graph.
More importantly, the database approach provided us with the foundation
and freedom we needed to push the renderer without hitting limits all the time.