2_ray tracing api overview

76
Ray Tracing on the Wizard GPU

Upload: srinivas-kvn

Post on 13-Feb-2017

46 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 2_Ray Tracing API Overview

Ray Tracing on the Wizard GPU

Page 2: 2_Ray Tracing API Overview

Luke Peterson Tobias Hector

Page 3: 2_Ray Tracing API Overview

3 @PowerVRInsider │ #idc16 facebook.com/imgtec

PowerVR GPU Architecture

PowerVR GR6500 System

Memory

Bus

Vertex Data

Master

Tiling Coprocessor

Compute Data

Master

Pixel Data

Master

Unified Shading Cluster Array

Coarse Grain

Scheduler

Host

CPU

Bus

Core Management

Unit

Control and Register Bus Host CPU Interface

Multi-level Memory

Cache Unit (MCU)

2D Core (TLA)

Pixel Coprocessor

System Memory Interface

(+ System-Level Cache for the whole GPU)

USC USC USC USC

Shared Texture Unit Shared Texture Unit

Page 4: 2_Ray Tracing API Overview

4 @PowerVRInsider │ #idc16 facebook.com/imgtec

PowerVR Ray Tracing Wizard Architecture

PowerVR GR6500 System

Memory

Bus

Vertex Data

Master

Tiling Coprocessor

Compute Data

Master

Pixel Data

Master

Scene Hierarchy Generator

Unified Shading Cluster Array

Coarse Grain

Scheduler

Host

CPU

Bus

Core Management

Unit

Control and Register Bus Host CPU Interface

Multi-level Memory

Cache Unit (MCU)

2D Core (TLA)

PowerVR Ray Tracing Unit (RTU)

Ray Intersection Processor

Coherency Engine

Ray Data

Master

Frame Accumulator

Cache

Pixel Coprocessor

System Memory Interface

(+ System-Level Cache for the whole GPU)

USC USC USC USC

Shared Texture Unit Shared Texture Unit

Page 5: 2_Ray Tracing API Overview

www.imgtec.com/idc

Ray tracing is the ability for the shader program for one object to be aware of the

geometry of other objects and trigger additional shaders for those objects.

Page 6: 2_Ray Tracing API Overview

6 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 7: 2_Ray Tracing API Overview

7 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 8: 2_Ray Tracing API Overview

8 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 9: 2_Ray Tracing API Overview

9 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 10: 2_Ray Tracing API Overview

10 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 11: 2_Ray Tracing API Overview

11 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 12: 2_Ray Tracing API Overview

12 @PowerVRInsider │ #idc16 facebook.com/imgtec

Uses of Ray Tracing

Page 13: 2_Ray Tracing API Overview

New Ray Tracing API!

Page 14: 2_Ray Tracing API Overview

14 @PowerVRInsider │ #idc16 facebook.com/imgtec

New Ray Tracing API

• We had OpenRL

• Solid Ray Tracing API

Goodbye OpenRL

Page 15: 2_Ray Tracing API Overview

15 @PowerVRInsider │ #idc16 facebook.com/imgtec

New Ray Tracing API

• We had OpenRL

• Solid Ray Tracing API

• However

• No integration with other GPU features

• Required reworking to expose new features

Goodbye OpenRL

Page 16: 2_Ray Tracing API Overview

16 @PowerVRInsider │ #idc16 facebook.com/imgtec

New Ray Tracing API

• We had OpenRL

• Solid Ray Tracing API

• However

• No integration with other GPU features

• Required reworking to expose new features

• So…

Goodbye OpenRL

Page 17: 2_Ray Tracing API Overview
Page 18: 2_Ray Tracing API Overview

18 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Tracing in OpenGL ES

• Why OpenGL ES 3.1?

• Already has base features

• Plugs in to existing SW solutions

• Integrates with other GPU features

• Well understood and available

Design Choices

Page 19: 2_Ray Tracing API Overview

19 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Tracing in OpenGL ES

• Why OpenGL ES 3.1?

• Already has base features

• Plugs in to existing SW solutions

• Integrates with other GPU features

• Well understood and available

• Modern paradigms

• Direct State Access

• App-managed resource lifetimes

• Bindless resources

Design Choices

Page 20: 2_Ray Tracing API Overview

20 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Tracing in OpenGL ES

• Scene Construction

• Hardware accelerated building

• Re-uses vertex shading

• Output streamed into a hierarchy

• Note: Vertex outputs are in world space

• Ray Traversal

• Emit rays into a scene

• Hardware accelerated traversal

• Shade at intersections

• Accumulate to images

API Overview

Page 21: 2_Ray Tracing API Overview

Scene Construction

Page 22: 2_Ray Tracing API Overview

22 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Scene components

• Equivalent to a “draw call”

• May be multiple “objects”

• Component groups

• Created from number of components

• Represent a scene hierarchy

Scene Components and Component Groups

3

3

2 1

Page 23: 2_Ray Tracing API Overview

23 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Building

• Components are descriptions

• Building executes vertex shaders

• Creates a scene hierarchy

• Merging

• Merge component groups together

• Cheaper than rebuilding

• Used to handle different rates of change

Building and Merging

Page 24: 2_Ray Tracing API Overview

24 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Rebuild parts of a scene at different rates

Building and Merging Illustration

Page 25: 2_Ray Tracing API Overview

25 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Rebuild parts of a scene at different rates

• Static geometry

Building and Merging Illustration

Page 26: 2_Ray Tracing API Overview

26 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Rebuild parts of a scene at different rates

• Static geometry

• Dynamic, per-frame

Building and Merging Illustration

Page 27: 2_Ray Tracing API Overview

27 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Rebuild parts of a scene at different rates

• Static geometry

• Dynamic, per-frame

• Other levels between the two

Building and Merging Illustration

Page 28: 2_Ray Tracing API Overview

28 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Rebuild parts of a scene at different rates

• Static geometry

• Dynamic, per-frame

• Other levels between the two

Building and Merging Illustration

Page 29: 2_Ray Tracing API Overview

29 @PowerVRInsider │ #idc16 facebook.com/imgtec

Scene Construction

• Rebuild parts of a scene at different rates

• Static geometry

• Dynamic, per-frame

• Other levels between the two

• All traversed as part of the same scene

Building and Merging Illustration

Incoming Ray

Page 30: 2_Ray Tracing API Overview

Ray Traversal

Page 31: 2_Ray Tracing API Overview

31 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal Ray Traversal Illustration

Frame

Scene

Page 32: 2_Ray Tracing API Overview

32 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal Ray Traversal Illustration

Frame

Scene

Page 33: 2_Ray Tracing API Overview

33 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal Ray Traversal Illustration

Frame

Scene

Page 34: 2_Ray Tracing API Overview

34 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• What is a ray?

• A typed data packet

• Built-in values describe traversal

• May contain user-defined values

Ray Emission

raytypeIMG {

highp vec3 gl_OriginIMG,

highp vec3 gl_DirectionIMG,

highp float gl_MaxDistanceIMG,

lowp uint gl_SceneIMG,

bool gl_IsOutgoingIMG,

bool gl_RunPrefixProgramIMG,

highp rayprogramIMG gl_PrefixRayProgramIMG,

bool gl_OcclusionTestIMG,

mediump ivec2 gl_PixelIMG,

mediump uint gl_BounceCountIMG,

bool gl_FlipFacingIMG

};

Page 35: 2_Ray Tracing API Overview

35 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• What is a ray?

• A typed data packet

• Built-in values describe traversal

• May contain user-defined values

Ray Emission

raytypeIMG {

highp vec3 gl_OriginIMG,

highp vec3 gl_DirectionIMG,

highp float gl_MaxDistanceIMG,

lowp uint gl_SceneIMG,

bool gl_IsOutgoingIMG,

bool gl_RunPrefixProgramIMG,

highp rayprogramIMG gl_PrefixRayProgramIMG,

bool gl_OcclusionTestIMG,

mediump ivec2 gl_PixelIMG,

mediump uint gl_BounceCountIMG,

bool gl_FlipFacingIMG

};

Page 36: 2_Ray Tracing API Overview

36 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• What is it?

• Shader that runs at beginning of traversal

• Runs a user-defined number of invocations

• Purpose

• Setup and emission of primary rays for each invocation

Frame Shader

Page 37: 2_Ray Tracing API Overview

37 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary);

}

Frame Shader Example

Page 38: 2_Ray Tracing API Overview

38 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary);

}

Frame Shader Example

layout(binding = 0) raytypeIMG PrimaryRay {};

Page 39: 2_Ray Tracing API Overview

39 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary);

}

Frame Shader Example

layout(max_rays = 1) out;

Page 40: 2_Ray Tracing API Overview

40 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary);

}

Frame Shader Example

out PrimaryRay primary;

Page 41: 2_Ray Tracing API Overview

41 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary);

}

Frame Shader Example

primary.gl_OriginIMG = vec3(0.0);

initRayIMG(primary);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

Page 42: 2_Ray Tracing API Overview

42 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary);

}

Frame Shader Example

emitRayIMG(primary);

Page 43: 2_Ray Tracing API Overview

43 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• What is it for?

• Shading at ray intersections

• Executes when a ray hits geometry

• Similar to a fragment shader

• Capabilities

• Access incoming rays

• Access intersection result, including vertices

• Initialise and emit rays

• Accumulate to images

Ray Shader

Page 44: 2_Ray Tracing API Overview

44 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

rayInputHandlerIMG(in PrimaryRay primary)

{

void main() {

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 1.0, 1.0));

}

}

Ray Shader Example

Page 45: 2_Ray Tracing API Overview

45 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

rayInputHandlerIMG(in PrimaryRay primary)

{

void main() {

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 1.0, 1.0));

}

}

Ray Shader Example

rayInputHandlerIMG(in PrimaryRay primary)

Page 46: 2_Ray Tracing API Overview

46 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

rayInputHandlerIMG(in PrimaryRay primary)

{

void main() {

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 1.0, 1.0));

}

}

Ray Shader Example

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

Page 47: 2_Ray Tracing API Overview

47 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

rayInputHandlerIMG(in PrimaryRay primary)

{

void main() {

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 1.0, 1.0));

}

}

Ray Shader Example

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 1.0, 1.0));

Page 48: 2_Ray Tracing API Overview

48 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• 1st ray traced image today!

Draw One Triangle

Page 49: 2_Ray Tracing API Overview

49 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• 1st ray traced image today!

• It’s a single triangle.

Draw One Triangle

Page 50: 2_Ray Tracing API Overview

50 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• 1st ray traced image today!

• It’s a single triangle.

• Woo.

Draw One Triangle

Page 51: 2_Ray Tracing API Overview

51 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• Draw a simple triangle

• No lighting

• No complex geometry

• Blue accumulated to image

• Only added once

• This line of code:

Draw One Triangle

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 1.0, 1.0));

Page 52: 2_Ray Tracing API Overview

52 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal

• Bindless Ray Programs

• Semi-arbitrary shader execution

• Separate from ray intersection shading

• Separate to component ray shaders

• Not associated with geometry

• Specialised uses

• Has directly associated resources

Bindless Ray Shaders

Page 53: 2_Ray Tracing API Overview

53 @PowerVRInsider │ #idc16 facebook.com/imgtec

Ray Traversal Bindless Ray Shader Creation

// Attach a ray program to the program

glAttachShader(myRayProgram, myRayShader);

// Set the program to separable

glProgramParameter(myRayProgram, GL_PROGRAM_SEPARABLE, GL_TRUE);

// Link the program

glLinkProgram(myRayProgram);

// Bind some buffers to it

glRayProgramBufferRangeIMG(myRayProgram, GL_UNIFORM_BUFFER, 0, myUniformBuffer, 0, myUniformBufferSize);

// Create a bindless handle

GLuint64 myRayProgramHandle = glGetRayProgramHandleIMG(myRayProgram);

Page 54: 2_Ray Tracing API Overview

Default Ray Shaders

Page 55: 2_Ray Tracing API Overview

55 @PowerVRInsider │ #idc16 facebook.com/imgtec

Default Ray Shaders Default Ray Shader Illustration

Frame

Scene

Page 56: 2_Ray Tracing API Overview

56 @PowerVRInsider │ #idc16 facebook.com/imgtec

Default Ray Shaders

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

layout(location = 1) uniform highp rayprogramIMG defaultRayShader;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

emitRayIMG(primary, defaultRayShader);

}

Frame Shader Example: Setting a default shader

defaultRayShader

layout(location = 1) uniform highp rayprogramIMG defaultRayShader;

Page 57: 2_Ray Tracing API Overview

57 @PowerVRInsider │ #idc16 facebook.com/imgtec

Default Ray Shaders

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

rayInputHandlerIMG(in PrimaryRay primary)

{

void main() {

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(1.0, 0.0, 0.0, 1.0));

}

}

Ray Shader Example: Default

vec4(1.0, 0.0, 0.0, 1.0))

Page 58: 2_Ray Tracing API Overview

58 @PowerVRInsider │ #idc16 facebook.com/imgtec

Default Ray Shaders

• Accumulates red on miss

• Default shader runs on miss

• Triangle not hit

• Better uses:

• Skyboxes

• World partitions

• Simple light sources

Draw One Triangle – Missed!

Page 59: 2_Ray Tracing API Overview

59 @PowerVRInsider │ #idc16 facebook.com/imgtec

Default Ray Shaders

• Can obviously do lots more!

• Things like…

More Interesting things

Page 60: 2_Ray Tracing API Overview

Prefix Ray Shaders

Page 61: 2_Ray Tracing API Overview

61 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders An illustration

Page 62: 2_Ray Tracing API Overview

62 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders An illustration

Page 63: 2_Ray Tracing API Overview

63 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders An illustration

Attach prefix shader

Page 64: 2_Ray Tracing API Overview

64 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders An illustration

Prefix Shader

Executes

Page 65: 2_Ray Tracing API Overview

65 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders An illustration

Prefix Shader

Executes

Distance Travelled In Cloud

Page 66: 2_Ray Tracing API Overview

66 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders An illustration

Intersection Shader

Executes

Page 67: 2_Ray Tracing API Overview

67 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) out;

out PrimaryRay primary;

layout(location = 0) uniform highp vec2 inverseFrameSize;

layout(location = 1) uniform highp rayprogramIMG prefixRayShader;

void main() {

initRayIMG(primary);

primary.gl_OriginIMG = vec3(0.0);

primary.gl_DirectionIMG = vec3((vec2(gl_FrameCoordIMG) * inverseFrameSize - 0.5).xy, -1.0);

primary.gl_PixelIMG = gl_FrameCoordIMG;

primary.gl_PrefixRayProgramIMG = prefixRayShader;

primary.gl_RunPrefixRayProgramIMG = true;

emitRayIMG(primary);

}

Frame Shader Example: Setting a prefix shader

primary.gl_PrefixRayProgramIMG = prefixRayShader;

layout(location = 1) uniform highp rayprogramIMG prefixRayShader;

primary.gl_RunPrefixRayProgramIMG = true;

Page 68: 2_Ray Tracing API Overview

68 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders

#version 310 es

layout(binding = 0) raytypeIMG PrimaryRay {};

layout(max_rays = 1) PrimaryRay;

layout(location = 0, binding = 0, rgba8) uniform lowp accumulateonly image2D accumulationBuffer;

rayInputHandlerIMG(inout PrimaryRay primary)

{

void main() {

imageAddIMG(accumulationBuffer, ivec2(primary.gl_PixelIMG), vec4(0.0, 0.5, 0.0, 0.0));

primary.gl_RunPrefixProgramIMG = false;

shadeRayIMG(primary);

}

}

Prefix Ray Shader Example

shadeRayIMG(primary);

vec4(0.0, 0.5, 0.0, 0.0))

inout

layout(max_rays = 1) PrimaryRay;

primary.gl_RunPrefixProgramIMG = false;

Page 69: 2_Ray Tracing API Overview

69 @PowerVRInsider │ #idc16 facebook.com/imgtec

Prefix Ray Shaders

• Accumulated cyan

• Still running hit shader

• 0.5 Green added in prefix

• 0.5 Green and 1 blue added in hit

• Results in Cyan!

• Better uses:

• Clouds, smoke, water

• Other non-trivial mediums

Draw One Triangle – Prefixed!

Page 70: 2_Ray Tracing API Overview

Hybrid Ray Shading

Page 71: 2_Ray Tracing API Overview

71 @PowerVRInsider │ #idc16 facebook.com/imgtec

Hybrid Ray Shading

• TBDR Pipeline Recap

• Ignore most of it for now

• On-chip colour buffer!

Our GPU

Vertex

Processing

Clip, Project

& Cull

Geometry

Data

Tiling

Texture Data Frame Buffer

On-C

hip

Buff

ers

Primitive List

Vertex Data

Syste

m M

em

ory

Raster

*1

HSR & Depth

Test

On-Chip

Depth Buffer

Texture &

ShadeAlpha Test Alpha Blend

On-Chip

Colour Buffer

Tag Buffer

*2

Page 72: 2_Ray Tracing API Overview

72 @PowerVRInsider │ #idc16 facebook.com/imgtec

Hybrid Ray Shading

• Frame shader can access on-chip colour buffer

• If run at the end of a render

• Access PLS/Framebuffer Fetch as inputs only

Hybrid Pipeline

Page 73: 2_Ray Tracing API Overview

73 @PowerVRInsider │ #idc16 facebook.com/imgtec

Hybrid Ray Shading

• Rasterizer generates initial data

• Writes out G-Buffer into Pixel Local Storage

• Ray tracing for additional effects

• Shadows

• Reflections

• Etc.

• Post-process as normal

• Use accumulation buffers as input

How do you use hybrid?

Page 74: 2_Ray Tracing API Overview

74 @PowerVRInsider │ #idc16 facebook.com/imgtec

That’s not everything

• This was just an overview!

• Much more to talk about

• More talks!

• 11:50-12:20

• Real Time Ray Tracing Techniques

• 12:20-12:50

• Global Illumination, Progressive Light Map Baking, Fully Interactive GI

• 12:50-1:20

• Advanced Ray Tracing Techniques

We just scratched the surface

Page 75: 2_Ray Tracing API Overview

75 @PowerVRInsider │ #idc16 facebook.com/imgtec

Questions?

Get in touch:

[email protected],

[email protected]

• @tobskihectov

Please come and visit us at booth

#1902 in the South Hall to see our

demos and to collect your very own

Vulkan™ Gnome t-shirt!

Page 76: 2_Ray Tracing API Overview