Finding Next Gen CryEngine2

  • Upload
    newman

  • View
    53

  • Download
    2

Embed Size (px)

DESCRIPTION

Finding Next Gen CryEngine2. Martin Mittring Lead Graphics Programmer Crytek GmbH. Far Cry. Shipped March 2003 Publisher: Ubisoft Platform: PC. Crysis. Not released yet Publisher: Electronic Arts Platform: PC. Introduction. Far Cry ( CryEngine 1) s hipped March 2003: - PowerPoint PPT Presentation

Citation preview

  • Finding Next GenCryEngine2 Martin MittringLead Graphics ProgrammerCrytek GmbH

  • Far CryCrysisShipped March 2003Publisher: UbisoftPlatform: PC Not released yetPublisher: Electronic ArtsPlatform: PC

  • IntroductionFar Cry (CryEngine 1) shipped March 2003:Outdoor with long view range, paradise lookGameplay: AI, physics, non linear, exploreTechnology: Per pixel shading, realtime shadows, HDR, up to shader model 2.x/3.0

    we wanted to push the technical limits again

  • Goals (1/2): three different environments Jungle paradiseMany objects, height map, ocean, view distance, sky and sun light Alien indoor Many point lights, dark, huge room like sections, geometry occlusion, fog volumes Ice environment Ice Material layer, subsurface scattering, Ambient lighting

  • Goals (2/2):Cinematographic quality renderingDynamic light and shadowsMGPU & MCPUGame design requested 21km x 21kmTarget GPU from SM 20 to SM 40 (DirectX10)High Dynamic RangeDynamic environment (breakable)Developing game and engine together

  • Concept PhaseBlur Studio www.blur.com

  • Overview Shaders and shadingShader combinations problem, 3DcTM for normal maps, Per pixel scene depth, World Space ShadingDirect Lighting and Indirect LightingDirect: SM, soft SM, Shadow mask, deferred, VSMIndirect: 3D Transport Sampler, RAM, SSAOLevel of DetailDissolveOcean

  • Shaders and shading

  • Shaders and shadingCryEngine 1VS and PS up to SM 30 Fallback: T&L and register combinerber-shader with many #ifdef for specializations (multiple lights, fog, shadow, CM reflection, bump, )Shader cache manually created (NVIDIA & ATI)DirectX and unsupported OpenGLSupported HLSL and CGFunctionality like FX techniques

  • Shaders and shadingCryEngine 2 (1/3)Shader combinations problemdynamic branchingreducing combinations and accepting less functionality and less performanceseparating into multiple passesDistributed Job System to compile the shader cache3DcTM for normal mapsreconstruct z in pixel shaderTIF to DDSDXT5 fallback, BC5 for Direct3D10 (XY swap in shader)

  • Shaders and shadingCryEngine 2 (2/3)Per pixel scene depthEarly z pass (more draw calls)Format: R16,R16G16, R32 or nativeWS position [with offset] in 1 instructionUse: Shadow Mask, Global Fog, Volumetric Fog, Soft Z Buffered Particles, DOF, Motion Blur, Beach/ Ocean, EdgeAA, Sun Rays

  • Shaders and shadingCryEngine 2 (3/3)World Space vs. Tangent Space Shadingbetter shading qualityless interpolators (Pos, Tangent, Binormal, Orientation) with multiple lightsunified shader (like Cubemap reflection)per scene constants instead of per object constantslonger pixel shaderLess appropriate for low spec

  • Direct Lighting

  • Shadowing Approach in CryEngine 1Shadow maps and projected shadows for sunPCF if available, some aliasingBlurry precomputed vegetation shadowsStencil shadows for point lights (CPU performance)Dot3Lightmaps (normal mapped Lightmaps) patent, efficient and simple for static diffuse case like a lightmap, stores: avg. light direction (in TS) and colour with blend value to blend between diffuse and ambient case

  • Experiments after Far CryStatic occlusion mapsLike light maps but texture channels store light occlusionper pixel lighting including specular for static geometryslower than light maps but faster than dynamic solutionsDynamic occlusion mapsupdated with shadow map render2texture (dilation)double aliasing and limited resolutionStatic occlusion maps with shadow mapsLimited success with adjusted penumbra size

  • The plan for CryEngine 2clean unified shadow systemdrop stencil shadowsApproach direct and indirect lighting with specialized solutionsShadow maps with multiple lookupsRandom 2D noise texture

  • Screen space randomized lookupplain, PCF, 8 samples, 8 samples+blur, PCF+8 samples, PCF+8 samples+blur 2D: rotated disk samples (random 2d base)2D: construct samples (random 2d vectors)3D: plane mirroring (random normals)

  • Random Texture projectionScreen spaceTiled 64x64, no mipsAnimated noise ?Light spaceTiled 256x256, mippedMoving with cameraSnapping for stable resultsFiltered1, no jittering8, world space8, screen space8, world space

  • Shadow mask textureOne ARGB texture allows up to four lights per pixelSeparate shadow from shadingMultiple shadow casting lights per passfinal rendering with sun and two shadow-casting lightslight mask texture with three lights in the RGB channels

  • Deferred shadow mask generationOpaque only (including alpha test)Based on EarlyZ pass, less draw callsLookup center position in 1 instructionSun: 2-4 parallel shadowmap slicesOmni light: 6 shadowmaps pyramidsShadow mask generation restricted to volumes marked in the stencil buffer

  • Variance shadow mapswith variance shadow mapswithout variance shadow maps

  • Variance shadow mapsInexpensive very soft shadowsLeaking with multiple casters in front of each otherSuits the terrain shadows propertiesAlternatives are less preverableOnly terrain is casting VSMDeferred applied to the shadow mask

  • Indirect Lighting (3DTS, RAM, SSAO)

  • Plan: 3D Transport SamplerA tool to compute Global Illumination dataMultiCPU, distributed, extendableImplementation: Photon mapperUnwrapping based on existing UV mappingOutput:Lightmap, [Dot3Lightmap]Lightmap with 4 normals oriented to the surfaceRAM

  • Real time ambient maps (1/2)

  • Real time ambient maps (2/2)One scalar ambient occlusion value per texel Reconstruction in the shader based on:texel with the occlusion valuelight color, relative position and attenuation radiussurface normalArtist tweakable values (bounce color, radius)Normal map, portals, multiple lights combinedDrawbacks: preprocess, static, resolution, memory

  • Screen Space Ambient Occlusion (1/2)3D sample distribution scaled with distanceSamples tested against the depth buffer, far samples with less influenceAO is a function of the number of exposed samplesPer pixel rotation with 4x4 texture (reflect), Smart blurring (depth buffer) Fully dynamic, view dependecy rarely visible, texture cache trashingResults depend on asset tessellation and tweaking

  • Screen Space Ambient Occlusion (2/2)

  • Level of Detail

  • LOD (Level of Detail)Indoor requires good occlusion but dense outdoor environment requires LODObjects need to look good in all distancesOnly PS scales nicely with distance

    Specialized Solutions: ocean, static LOD, vegetation sprites

  • Dissolve LOD/LOD LOD/Sprite transitions, Objects fadingPer pixel dissolve in EarlyZ pass only, further passes use ZEqualDissolve texture projected in screen space Texkill, alpha-test or A2CPost processing EdgeAA hides artifactsTransition phase should be finished quicky (for performance and look)

  • Water surface LOD

  • Square water sectorsFFT based water animation for a small sectorLODs with static IB but shared VBSharing VB degrades quality because of aliasingFaded perturbation for distant vertices and limited the perturbation in the nearShoreline based on vertex animated static meshUsed in ATI tech demo the ProjectDrawbacks: CPU, aliasing, LOD popping

  • Screen-space tessellation (1/3)Brute force approachScreen space tessellated quadWater plane projectionPerturbed in VSVertex cacheZ buffered

  • Screen-space tessellation (2/3)without edge attenuationwith edge attenuationVertices moved in XYZEdge attenuation to fix the bordersAlso works with camera roll

  • Screen-space tessellation (3/3)Lower tessellation to adjust quality/speed ratioFFT via vertex texture (if available)Shading: procedural shore, fog, shadow receiving, RGB independent refraction, Caustics

    Drawbacks: aliasing, view-dependent because of attenuation, no physics interaction

  • Camera aligned tessellation (1/2)camera aligned from top downcamera aligned from viewer perspective Static mesh with top down projectionMoving with camera (snapping to reduce aliasing)Extruded horizon borderAttenuation to fade out perturbation before horizon

  • Camera aligned tessellation (2/2)Camera alignedScreen-space tessellationNot view dependent (compare borders)Proper physics iteractionLess aliasing (compare horizon)Drawbacks: small triangles, vertex texture lookup

  • ConclusionCrysis will be shipped soonLeaving the path leads to new challengesIterations are necessaryMore creation time for less improvementsBig scale productionWide range of hardware means compromisesDepth from EarlyZ good for current generation

  • Acknowledgements Based on the passionate work of many programmers, artist and designersVladimir Kajalin, Andrey Khonich, Tiago Sousa, Carsten Wenzel and Nick KasyanIntensive special support namely Miguel Sainz, Yury Uralsky and Philipp GerasimovAdditional thanks to Natasha Tatarchuk and Tim Parlett

  • [email protected]

    Cinematographic quality rendering without hitting the Uncanny Valley

    -> However technical goals alone wernt enough, we had to find the lok of the new game there would be much more to talk aboutCombining static occlusion maps with shadow maps in multi pass (results in overhead to avoid double shadowing)Terrain shadows properties (very soft, little details, mostly single caster, almost static, affecting all kind of objects)Alternatives are less preverable (horizon maps, occlusion maps, shadowmaps) arent soft enough or work only for terrain

    Per pixel dissolve in early z pass only, further passes use z equal comparison (rarely causes issues with multi pass rendering)A2C (alpha to coverage)

    Crysis: PC, CryEngine2 Leaving the path leads to new challenges (DX10, shader combinations, dynamic branching, streaming) Big scale production (64bit, production, streaming) Depth from EarlyZ good for current generation (older generation: cheap PS, more drawcalls hurt a lot)