190 likes | 362 Views
Shader Study 2007.5.30 이동현. Integrating Shaders into the Vision Rendering Engine. Vision engine. http://www.trinigy.net/ Games Helldorado The Show Warlord. Shaders in the Vision Engine. Multi-platform game engine. Shaders in the Vision Engine. Effects Fallback
E N D
Shader Study 2007.5.30 이동현 Integrating Shaders into the Vision Rendering Engine
Vision engine • http://www.trinigy.net/ • Games • Helldorado • The Show • Warlord
Shaders in the Vision Engine • Multi-platform game engine
Shaders in the Vision Engine • Effects • Fallback • Fallbacks are alternative, usually simpler, versions of a complex shader that are used whenever the hardware requirements for a shader version higher up in the hierarchy are not met.
Assigning Shaders to Geometry • Static Effects • Statically assigned by the artists. • Do not need to be updated, removed, or replaced in runtime. • Dynamic Effects • Volumetric fog • Dynamic lighting
Dynamic Effects – point light Do not want to assign the shader to all the objects in a scene
Shader assignment types • Shaders that are statically assigned by artists in the production tools: material properties, rendering styles. • Shaders that are dynamically assigned in the game code – for example, when highlighting selected objects. • Volume-based shader assignments-useful for dynamic lights, volumetric effects, and the like.
Rendering order • Base pass • Base texture * static lighting • Ex) Objects that do not have dynamic light • Zcull • Save pixel processing power • Opaque objects • front-to-back in order to improve early Z rejection. • Translucent objects • Sorted back-to-front, to minimize visual artifacts. • Addition rendering passes • The problem of finding the right rendering order gets a little more complex.
Rendering order – cont • There are shaders which have to be drawn before the usual base*lighting pass is rendered. • Cartoon outline shader – use vertex program to extrude the rendered geometry along the normal vectors. • Drawn as an additive blend pass after the base*lighting pass. • Such as additional rendering passes for dynamic lights. • Should be rendered after almost everything else. • For effect • Not properties of the rendered surface itself, but rather properties of the space between the rendered surface and the camera.
Rendering order – cont • A bad idea • If static geometry is actually behind the translucent primitives? • All effects on translucent primitives would have to be rendered right after rendering the primitive itself. – not very feasible due to performance reason.( too many state changes ) • Render the effects passes separately for opaque and translucent primitives.
Rendering order – cont • As long as the artists know how to handle translucent geometry and are aware of the fact that there are limitations to be considered, a loop like the above one will be sufficient. • The problem that still has to be solved is the rendering order between the base pass and the shaders applied to the same geometry. • Multi-pass rendering with multiple shaders. • Render pass property is set to each fallbacks. • This way, it is possible to render to render the cartoon outlines mentioned above before the base pass is drawn, and if the geometry is illuminated by a light source, a lighting shader can be rendered on top of the base pass. • Using a sorting key ensures that the fog is always rendered last.
Shader Callback Functions • Per-frame callback function. • Per-primitive callback function. • Called for each single triangle but rather on batches of triangles. • Fur shader. – the shader loops through each single shell and increases the normal extrusion distance in each iteration.
Reducing Overhead for State Setup • Shader-based rendering pipeline • Batching triangles with the same shader setup • Reducing state setup changes. • A sorting key encoded into a single 64-bit value. • Int64 iKey = (iUserKey<<48) | (iDistance<<16) | iStateSetupID; • The batches might differ in their individual diffuse base texture
Textures • Procedurally generated textures into the shader system of the Vision Engine. • Custom modifier functions have to be implemented and registered and can finally be accessed in the shader definition. • Examples • Converting height maps to vector maps( though for fine details, using dedicated art tool plugins is recommended) • Normalization cubemaps. • All kinds of gradients and characteristic functions for texture lookups. • Cel shading lookups with dedicated mipmap levels. • Creating texture alpha channels for texture “color key” emulation.