The Chase Pushing the Limits of Modern Mobile GPU Renaldas Zioma, Unity Technologies Ole Ciliox, Unity Technologies
The Chase High-End Mobile Demo Built with off-the-shelf Unity 4.2
The Chase Goals Impressive Skin Shading High Poly Count No Screen Upscaling 2048 x 1536 Approach OpenGL ES3.0
Target Hardware SGX 543-554 (ipad4) Adreno 320-330 Tegra 4 Mali T62x 5
Overview 250-300K vertices per frame ~10% of GPU workload 40K vertices per character Subsurface Scattering ~5% of GPU workload 1/4 screen resolution Skin shading ~50% of GPU workload (in close-up)
Other features Hair /w procedural animations Atmospheric scattering Anamorphic Lens Flares on GPU Metalic ish surfaces >30fps on ipad4 7
Skin Requirements Sub-surface scattering Physically based shading 2 specular lobes Reflections Linear lighting Based on experience from Butterfly Effect High-end PC Demo 8
Skin Quality One observation for realistic skin Specular behavior... together with Fresnel and reflections...... is equally (and potentially even more) important than diffuse/scattering Want! High quality specular 2 specular lobes
Skin Controls 10
(Mobile) Reality Sub-surface scattering in multiple layers doable render incoming light in screen-space buffer and blur low resolution Physically based shading hard mobile GPUs are still very limited on ALU performance even simplest energy conserving Blinn-Phong requires a lot of ALU
Mobile Reality Per-pixel reflections expensive require per-pixel normals to be transformed from Tangent to World space Linear lighting (srgb) OpenGL ES3.0 provides builtin support still might be impractical on available mobile GPU fullscreen linear to srgb resolve very high screen resolution potentially more memory bandwidth
Implementation considerations Expensive shading & lighting Let's precompute as much possible offline... and store results in Look Up Texture (LUT) Linear lighting Let's do where it matters most... only in skin shader
PBS approximation with LUT CookTorrance BRDF defined as would need at least 3D texture for isotropic case Micro-facet model simplifications Beckmann + Fresnel not from light! + very approximate G term Christian Schüler s approximation of CookTorrance [Schüler09]
PBS approximation with LUT icro-facet model simplifications Beckmann + Fresnel not from light! + very approximate G term Christian Schüler s approximation of CookTorrance [Schüler09]
PBS approximation with LUT Encode roughness in mip-chain or treat as constant per material (approach we took) Now both can be stored in 2D texture! Pick whichever you like Schüler uses BRDF slice that captures most information [Disney12] We observed that artist preferred unrealistic Fresnel falloff for skin - parabola! Much cheaper than Schlick's approximation - could avoid storing in LUT
PBS approximation with LUT Schüler uses BRDF slice that captures most information [Disney12] Image courtesy of Brent Burley and Walt Disney Animation Studios
Skin LUT layout Data stored in separate channels: Fresnel term 1st specular lobe 2nd specular lobe Diffuse energy conservation term reflected vs scattered (diffused) energy 32 x 128 texture 18
SSSSS (yep, abbreviation) Pretty much standard screen-space texture diffusion technique 1) Render lighting to off-screen texture (1/4 resolution) 2) Blur 3) Apply in final pixel-shader as ambient term 19
SSSSS Blur Alpha channel as mask to prevent leaking from "oustide" the skin Convert bounding volumes of geometry to nonoverlapping screen-space quads blur only inside quad 20
Linear lighting Approximate srgb with 2.0 to avoid pow() function pow() is still very expensive on mobiles Use only in the final pass of the skin shader srgb -> linear for albedo and reflection texture linear -> srgb for pixel output 21
Final Skin shader pass Putting it all together LUT 4 channels Fresnel term Yfresnel 1st specular lobe Ylobe1 2nd specular lobe Ylobe2 Diffuse energy conservation term Ydiffusion 22
Skin shader trade-offs 1 dominant per-pixel light Rest of lights per-vertex Spherical Harmonics per-vertex Cubemap reflection /w per-vertex normal 23
Skin shader stats 4 independent texture reads albedo+reflectivity map normal map reflection cubemap SSS buffer 1 dependent texture read (LUT) 44 ALU ops (4 dot, 1 normalize, 1 sqrt, etc) actually not bad texture / ALU balance for ipad4 24
Eyes Same approach as skin except we do not render eye contribution into SSS buffer otherwise eyes tend to "stick out" Parallax offset to model refraction inside eye lens 25
Atmospheric Scattering Requirements Rayleigh / Mie scattering Sun haze Blends with skybox 26
Mobile Reality Rayleigh / Haze evaluating Rayleigh is not cheap even if per-vertex would like to have per-pixel fog Fog blends with skybox standard trick is to store distant fog colors in cubemap if possible, would like to avoid that additional cubemap 27
LUT again! Precompute resulting color and amount of scattering in LUT 2D LUT angle to sun distance to fragment 128x128 texture 28
Details Mixed sun haze and distance scattering in nonphysically correct, but visually pleasing way linear combination driven by relative luminance of both components 29
Details Eventually abandoned physically based scattering instead exposed arbitrary 1D curve added additional term that warps scattering amount depending on height Tinted atmospheric scattering in the opposite direction from the sun with color defined by artist adds more color variation uses half of LUT where angle to sun is greater than 90 degrees 30
Skybox Simply evaluate scattering & haze at infinite distance blend into skybox depending on height Cheaper than using fog color from cubemap but more destructive for skybox 31
Environment shader stats 3-4 independent texture reads albedo+reflectivity map reflection cubemap lightmap (optional) projected shadow 1 dependent texture read (atmospheric LUT) Additional coarse color and reflectivity stored in vertex colors 13-19 ALU ops potentially underutilized ALU 32
Thank you! Useful link: http://unity3d.com/company/jobs/