Optimized Rendering Techniques Based on Local Cubemaps

Similar documents
Achieving High Quality Mobile VR Games

The Shadow Rendering Technique Based on Local Cubemaps

Optimizing and Profiling Unity Games for Mobile Platforms. Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June

#Short presentation of the guys

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Inside VR on Mobile. Sam Martin Graphics Architect GDC 2016

#Short presentation of the guys

Shadow Techniques. Sim Dietrich NVIDIA Corporation

Real-Time Universal Capture Facial Animation with GPU Skin Rendering

03 RENDERING PART TWO

Enabling immersive gaming experiences Intro to Ray Tracing

Rendering Grass with Instancing in DirectX* 10

Optimizing Mobile Games with ARM. Solo Chang Staff Applications Engineer, ARM

Developing the Bifrost GPU architecture for mainstream graphics

ARM Multimedia IP: working together to drive down system power and bandwidth

Wednesday, July 24, 13

Applications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research

Whiz-Bang Graphics and Media Performance for Java Platform, Micro Edition (JavaME)

Rendering Grass Terrains in Real-Time with Dynamic Lighting. Kévin Boulanger, Sumanta Pattanaik, Kadi Bouatouch August 1st 2006

Applications of Explicit Early-Z Culling

Real-Time Volumetric Smoke using D3D10. Sarah Tariq and Ignacio Llamas NVIDIA Developer Technology

Case 1:17-cv SLR Document 1-3 Filed 01/23/17 Page 1 of 33 PageID #: 60 EXHIBIT C

The Making of Seemore WebGL. Will Eastcott, CEO, PlayCanvas

DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/

Achieving Console Quality Games on Mobile

Computer Graphics. Shadows

Vulkan Multipass mobile deferred done right

Z-Buffer hold pixel's distance from camera. Z buffer

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Computer Graphics 10 - Shadows

Practical Techniques for Ray Tracing in Games. Gareth Morgan (Imagination Technologies) Aras Pranckevičius (Unity Technologies) March, 2014

Could you make the XNA functions yourself?

Shadows. COMP 575/770 Spring 2013

Achieving High-performance Graphics on Mobile With the Vulkan API

Metal for Ray Tracing Acceleration

Abstract. Introduction. Kevin Todisco

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

TSBK03 Screen-Space Ambient Occlusion

Graphics Processing Unit Architecture (GPU Arch)

Programming Graphics Hardware

Render-To-Texture Caching. D. Sim Dietrich Jr.

Radeon ProRender and Radeon Rays in a Gaming Rendering Workflow. Takahiro Harada, AMD 2017/3

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

CocoVR - Spherical Multiprojection

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

Programmable Shaders for Deformation Rendering

Moving Mobile Graphics Advanced Real-time Shadowing. Marius Bjørge ARM

CS GAME PROGRAMMING Question bank

Bringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

HARDWARE ACCELERATED 3D/2D RENDERING

Optimizing Mobile Games with Gameloft and ARM

Hardware- Software Co-design at Arm GPUs

What for? Shadows tell us about the relative locations. Vienna University of Technology 2

Enhancing Traditional Rasterization Graphics with Ray Tracing. March 2015

Adding Spherical Harmonic Lighting to the Sushi Engine. Chris Oat 3D Application Research Group. ATI Research, Inc.

Shadows in the graphics pipeline

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

Vulkan on Mobile. Daniele Di Donato, ARM GDC 2016

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

CS 354R: Computer Game Technology

Streaming Massive Environments From Zero to 200MPH

Course Recap + 3D Graphics on Mobile GPUs

Chapter 10 Computation Culling with Explicit Early-Z and Dynamic Flow Control

Life on the Bleeding Edge: More Secrets of the NVIDIA Demo Team Eugene d Eon NVIDIA Corporation.

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Chapter IV Fragment Processing and Output Merging. 3D Graphics for Game Programming

Opaque. Flowmap Generator 3

Render all data necessary into textures Process textures to calculate final image

The Animation Process. Lighting: Illusions of Illumination

Profiling and Debugging Games on Mobile Platforms

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

CS4620/5620: Lecture 14 Pipeline

of the NVIDIA Demo Team Eugene d Eon 2008 NVIDIA Corporation.

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Mali-G72 Enabling tomorrow s technology today

Mali Demos: Behind the Pixels. Stacy Smith

Performance Analysis and Culling Algorithms

Game Graphics Programmers

CSM Scrolling: An acceleration technique for the rendering of cascaded shadow maps

INFOGR Computer Graphics

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Multi-View Soft Shadows. Louis Bavoil

Many rendering scenarios, such as battle scenes or urban environments, require rendering of large numbers of autonomous characters.

Evolution of GPUs Chris Seitz

Dominic Filion, Senior Engineer Blizzard Entertainment. Rob McNaughton, Lead Technical Artist Blizzard Entertainment

Unreal Engine 4: Mobile Graphics on ARM CPU and GPU Architecture

Introduction to Visualization and Computer Graphics

Ray Tracing Effects without Tracing Rays

GLOBAL ILLUMINATION IN UNITY 5

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Deus Ex is in the Details

How to Work on Next Gen Effects Now: Bridging DX10 and DX9. Guennadi Riguer ATI Technologies

The Rasterization Pipeline

Bringing Hollywood to Real Time. Abe Wiley 3D Artist 3-D Application Research Group

CS354R: Computer Game Technology

Module 13C: Using The 3D Graphics APIs OpenGL ES

3D Authoring Tool BS Content Studio supports Deferred Rendering for improved visual quality

Transcription:

Optimized Rendering Techniques Based on Local Cubemaps Roberto Lopez Mendez Senior Software Engineer, ARM ARM Game Developer Day - London 03/12/2015

Agenda The concept of local cubemaps Optimized rendering techniques based on local cubemaps Reflections Shadows Refractions Wrap up 2

The Concept of Local Cubemaps 3

Cubemaps 4

The Concept of Local Cubemaps Bounding Box Local environment Local environment Local environment V cubemap C P V cubemap C P V cubemap C V V V If we use the view vector V defined in WCS to fetch the texel from the cubemap we will get the smiley face instead of the star. We need to use a new vector V = CP to fetch the correct texel. We need to find the intersection point P of the view vector V with the boundaries of the local environment. We introduce a proxy geometry to simplify the problem of finding the intersection point P. The simplest proxy geometry is the bounding box. Local Cubemap = Cubemap + Cubemap Position + Scene Bounding Box + Local Correction 5

Reflections Based on Local Cubemaps 6

Reflections with Infinite Cubemaps D cubemap R N R Reflective surface Normal N and view vector D are passed to fragment shader from the vertex shader. In the fragment shader the texture colour is fetched from the cubemap using the reflected vector R: float3 R = reflect(d, N); float4 col = texcube(cubemap, R); 7

Incorrect Reflections Reflection generated using a cubemap without any local binding 8

Local Correction Using a Bounding Box as a Proxy Geometry GPU Gems. Chapter 19. Image-Based Lighting. Kevin Bjork, 2004. http://http.developer.nvidia.com/gpugems/gpugems_ch19.html Cubemap Environment Mapping. 2010. http://www.gamedev.net/topic/568829-box-projected-cubemap-environment-mapping/?&p=4637262 Image-based Lighting approaches and parallax-corrected cubemap. Sebastien Lagarde. SIGGRAPH 2012. http://seblagarde.wordpress.com/2012/09/29/image-based-lightingapproaches-and-parallax-corrected-cubemap/ 9

Vertex Shader vertexoutput vert(vertexinput input) { vertexoutput output; output.tex = input.texcoord; // Transform vertex coordinates from local to world. float4 vertexworld = mul(_object2world, input.vertex); // Transform normal to world coordinates. float4 normalworld = mul(float4(input.normal, 0.0), _World2Object); // Final vertex output position. output.pos = mul(unity_matrix_mvp, input.vertex); Passed as varyings to the fragment shader // ----------- Local correction ------------ output.vertexinworld = vertexworld.xyz; output.viewdirinworld = vertexworld.xyz - _WorldSpaceCameraPos; output.normalinworld = normalworld.xyz; } return output; 10

Fragment shader float4 frag(vertexoutput input) : COLOR { float4 reflcolor = float4(1, 1, 0, 0); Calculate reflected vector Ray-box intersection algorithm Local corrected reflected vector // Find reflected vector in WS. float3 viewdirws = normalize(input.viewdirinworld); float3 normalws = normalize(input.normalinworld); float3 refldirws = reflect(viewdirws, normalws); // Working in World Coordinate System. float3 localposws = input.vertexinworld; float3 intersectmaxpointplanes = (_BBoxMax - localposws) / refldirws; float3 intersectminpointplanes = (_BBoxMin - localposws) / refldirws; // Looking only for intersections in the forward direction of the ray. float3 largestrayparams = max(intersectmaxpointplanes, intersectminpointplanes); // Smallest value of the ray parameters gives us the intersection. float disttointersect = min(min(largestrayparams.x, largestrayparams.y), largestrayparams.z); // Find the position of the intersection point. float3 intersectpositionws = localposws + refldirws * disttointersect; // Get local corrected reflection vector. refldirws = intersectpositionws - _EnviCubeMapPos; // Lookup the environment reflection texture with the right vector. reflcolor = texcube(_cube, refldirws); // Lookup the texture color. float4 texcolor = tex2d(_maintex, float2(input.tex)); 11 } return _AmbientColor + texcolor * _ReflAmount * reflcolor;

Correct and Incorrect Reflections Reflection generated after applying the local correction Reflection generated without local correction 12

Filtering Cubemaps to Achieve Visual Effects Development Stage Runtime Can take several minutes on a PC Just use the filtered cubemap 13

Workflow for Offline Cubemap Filtering 14

Benefits and Limitations 1. Simple to implement 2. Very realistic 3. Physically correct Benefits 4. High quality of reflections, no pixel flickering/ instability when moving camera 5. Cubemap texture can be compressed Limitations 1. Only works well in open plan space with no geometry in the centre where the cubemap will likely be generated 2. Objects in the scene must be close to the proxy geometry for good results 3. Only effective for simulating reflections of static geometry 6. Offline filtering effects can be applied which could be very expensive at run time 7. Resource saving technique, important for mobile devices 15

Handling Reflections of Dynamic Objects Reflections from Static Geometry Use Local Cubemap technique Planar Reflections from Dynamic Geometry Use Mirrored Camera technique All Reflections Combine both types of reflections 16

Dynamic Objects Runtime Reflections with a Virtual Camera 17

The Reflection Matrix R = 1 2n x 2 2n x n y 2n x n z 2n x n y 1 2n2 y 2n y n z 2n x n z 2n y n z 2 1 2n z n x = planenormal x n y = planenormal y n z = planenormal z n w = dot(planenormal, normalpos) 18

Rendering Static and Dynamic Reflections - Vertex Shader 19

Rendering Static and Dynamic Reflections - Fragment Shader 20

Combined Reflections 21

Combined Reflections 22

Dynamic Soft Shadows Based on Local Cubemaps 23

Dynamic Soft Shadows Based on Local Cubemaps 24

Dynamic Soft Shadows Based on Local Cubemaps 25

Soft Shadows Based on Local Cubemaps - Vertex Shader 26

Soft Shadows Based on Local Cubemaps - Fragment Shader float4 frag(vertexoutput input) : COLOR { float4 texcolor = tex2d(_maintex, float2(input.tex)); // ---------------- Static Shadows ------------------------------------ float3 vertextolightws = normalize(input.vertextolightinworld); // Apply the local correction to vertextolightws. Apply local correction float3 correctvec = LocalCorrect(vertexToLightWS, input.vertexinworld, _EnviCubeMapPos, _BBoxMin, _BBoxMax); // Fetch the color from the cubemap Fetch shadow color float4 shadowcol = texcubelod(_cube, correctvec); // Build a shadow mask to combine with pixel color Shadow mask float shadowmask = 1.0 - shadowcol.a; 27 Combined color } float4 finalcolor = shadowmask * texcolor; finalcolor.a = 1.0; return finalcolor;

Dynamic Soft Shadows Based on Local Cubemaps Why dynamic? If the position of the light source changes, the shadows are generated correctly using the same cubemap. 28

Dynamic Shadows 29

Dynamic Soft Shadows Based on Local Cubemaps Why Soft? 30

Dynamic Soft Shadows Based on Local Cubemaps 31

Soft Shadows 32

Dynamic Soft Shadows Based on Local Cubemaps 33

Handling Shadows from Different Types of Geometries Shadows from Static Environment Use Local Cubemap technique Shadows from Dynamic Objects Use Shadow Mapping technique All Shadows Combine both types of shadows 34

Combined Shadows 35

Blurred Reflections at the Taiwan Taoyuan International Airport The further from the object the blurrier the reflections 36

Blurred Reflections 37

Blurred Reflections Based on Local Cubemaps 38

Refractions Based on Local Cubemaps 39

Refraction 40

Local Correction to Refraction Vector float3 R rf = refract(d norm, N, n 1 /n 2 ); float4 col = texcube(cubemap, R rf ); Find intersection point P Find vector R rf = CP float4 col = texcube(cubemap, R rf ); 41

Vertex and Fragment Shaders 42

Refraction Based on Local Cubemaps combined with reflections Refraction of semi-transparent object based on local cubemap First pass renders transparent object last with front face culling and no depth buffer writing in order to avoid occluding other objects. Object colour is mixed with reflections and background from the local cubemap, calculated with the local correction applied to the refraction vector Second pass renders transparent object last with back face culling and Z-write off. Object colour is mixed with reflections and background from the local cubemap calculated with the refracted vector with the local correction applied to refraction vector. Finally alpha blended with the previous pass. 43 First pass only back faces with local refraction Second pass only front faces with local refraction and alpha blended with first pass

Refraction Based on Local Cubemaps in the Ice Cave Demo 44

Local Cubemap Applications Reflections based on local cubemaps 2004-2012 Dynamic Soft Shadows based on local cubemaps 2014 Refraction based on local cubemaps 2015 Hopefully more to come 45

Local Cubemaps a Superset of Cubemaps (I) We can think about local cubemaps as a superset of standard cubemaps. The standard cubemap can be considered as a particular case of local cubemap when the BBox is so large that the standard vector and the local corrected vector are the same. The larger the BBox the more R approaches to R. 46

Local Cubemaps a Superset of Cubemaps (II) Infinite Cubemap = lim Local Cubemap BBoxSize The local correction can be seen as just the correct way of fetching the texture in the LOCAL_CUBEMAP! 47

Wrap Up The concepts of local cubemaps and local correction allow for implementing several highly efficient rendering techniques. These are particularly suitable for mobile devices where runtime resources must be carefully balanced. New rendering techniques based on local cubemaps can be effectively combined with other runtime techniques to render different effects for static and dynamic objects together. The concept of local cubemap can be considered as a generalization of the standard cubemap. Built-in/hardware support for this feature could improve its performance and usability. 48

To Find Out More. Find out more about techniques based on local cubemaps at: http://malideveloper.arm.com/documentation/developer-guides/arm-guide-unity-enhancingmobile-games/ http://community.arm.com/groups/arm-mali-graphics/blog/2015/04/13/dynamic-soft-shadowsbased-on-local-cubemap http://community.arm.com/groups/arm-mali-graphics/blog/2014/08/07/reflections-based-onlocal-cubemaps http://community.arm.com/groups/arm-mali-graphics/blog/2015/04/13/refraction-based-on-localcubemaps http://community.arm.com/groups/arm-mali-graphics/blog/2015/05/21/the-power-of-localcubemaps-at-unite-apac-and-the-taoyuan-effect 49

For more information visit the Mali Developer Centre: http://malideveloper.arm.com Revisit this talk in PDF and audio format post event Download tools and resources 50

Thank you Questions The trademarks featured in this presentation are registered and/or unregistered trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved. All other marks featured may be trademarks of their respective owners. Copyright 2015 ARM Limited