implementing a modern, renderman compliant, reyes renderer

31
Implementing a modern, RenderMan compliant, REYES renderer Davide Pasca ribtools.com (contact: davide <at> ribtools.com) 1

Upload: davide-pasca

Post on 24-May-2015

5.013 views

Category:

Technology


1 download

DESCRIPTION

A quick introduction on implementing a RenderMan-like REYES renderer and consideration on future of real-time rendering.

TRANSCRIPT

Page 1: Implementing a modern, RenderMan compliant, REYES renderer

Implementing a modern, RenderMan compliant, REYES renderer

Davide Pascaribtools.com

(contact: davide <at> ribtools.com)

1

Page 2: Implementing a modern, RenderMan compliant, REYES renderer

About REYES

• Reyes or REYES (Renders Everything You Ever Saw)

• A flexible renderer, developed by Lucasfilm CG div. (“Pixar” from 1986)

• First used in 1984 in Start Trek II• ..still used today in Pixar’s Photorealistic

RenderMan

2* Images, from top, are copyright of Paramount Pictures and Pixar (subsidiary of The Walt Disney Company)

Page 3: Implementing a modern, RenderMan compliant, REYES renderer

RenderMan compliant ?

• Defines a renderer with some basic capabilities such as:– A RenderMan graphics state machine– Hidden surface elimination– Pixel filtering and anti-aliasing– User programmable shaders– Texture mapping– Etc…

3

Page 4: Implementing a modern, RenderMan compliant, REYES renderer

REYES features

• Native support for high level surfaces• Dynamic LOD

– Compact representation– Subdivide per-frame based on size on screen– Displace geometry from textures

• High quality filtering• Easier to deal with translucency, motion-blur,

etc.• Can be used together with ray-tracing

4

Page 5: Implementing a modern, RenderMan compliant, REYES renderer

REYES pipeline overview

Split

Dice

Displace

Shade

Sample

5

Page 6: Implementing a modern, RenderMan compliant, REYES renderer

Split (1)

• A parametric surface: P = f(u,v)

• Split until “small enough” size (estimated) on screen

6

Page 7: Implementing a modern, RenderMan compliant, REYES renderer

Split (2)

• Calculate the bounding box in screen-space

• …test against predetermined max screen area

Here, the bounding box is too large..

7

Page 8: Implementing a modern, RenderMan compliant, REYES renderer

Split (3)

• When too large, split the patch

• It’s easy with parametric primitives:

Pnew = f(unew, vnew)

New split points

8

Page 9: Implementing a modern, RenderMan compliant, REYES renderer

Split (4)

• Calculate the bounds of the new sub-patches

Still too large

9

Page 10: Implementing a modern, RenderMan compliant, REYES renderer

Split (5)

• Split recursively until every sub-patch is “small enough”…

Small enough.. this isready to be diced

10

Page 11: Implementing a modern, RenderMan compliant, REYES renderer

What’s “Small Enough” ?

• When most sub-patches fit in a single bucket

• When dicing (see later)

produces a suitable number of samples (sweet spot for performance)

A bucket

Sub-patch insidea single bucketOptimal

Sub-patch touchestwo or more bucketsNot Optimal

11

Page 12: Implementing a modern, RenderMan compliant, REYES renderer

Dice

Dicer• Small enough sub-patches

are diced• Generate a dense grid of

samples (1 pixel-per-sample or more..)

Small enough n_samples <= max_samples

max_samples is set for performance reasonsand to avoid distortion

1 pixel

12

Page 13: Implementing a modern, RenderMan compliant, REYES renderer

Displace• Apply a displacement

shader to the position of the samples

P

Displ. shader + textures

Pdisplaced

myDisplace(){ mag = texture( “dispmap” ); P += normalize(N) * mag; N = calculatenormal(P);}

13

Page 14: Implementing a modern, RenderMan compliant, REYES renderer

Shade• Apply surface and light

shaders to get the color

myShader(){ txcol = texture( “pigment” ); Ci = diffuse(N,txcol); Oi = 1;}

- Position- Surface Color

- Normals-Lights

- …

Surface shader + textures

Sample colors

14

Page 15: Implementing a modern, RenderMan compliant, REYES renderer

Sample – the micropolys

Form virtual micropolygons at the grid samples

Virtual micropolygons 1 pixel

15

Page 16: Implementing a modern, RenderMan compliant, REYES renderer

Sample – sample points

Multiple sub-samples at every pixel

…choose a sampling method: regular, multi-jittered (as shown), etc.

16

Page 17: Implementing a modern, RenderMan compliant, REYES renderer

Sample – gather samples

Samples get the color of the micropolygons they touch

…each sample can have many values if the mpolys are translucent !

17

Page 18: Implementing a modern, RenderMan compliant, REYES renderer

Sample – convolution

Mix the samples together…

…choose a filter: box, triangular, Gaussian, Sinc, etc..

18

Page 19: Implementing a modern, RenderMan compliant, REYES renderer

Sample – final pixel color

The resulting “average” color is assigned to the pixel

…repeat for every pixel 8)

19

Page 20: Implementing a modern, RenderMan compliant, REYES renderer

RibTools: A RenderMan-style renderer R&D

20* Killeroo model from headus Ltd., used with permission.

Page 21: Implementing a modern, RenderMan compliant, REYES renderer

RibTools’ key features

• RenderMan compliant (…almost (^^;))

– Parse RIB scene files– C-like shaders compiler and VM– Parametric surfaces, etc.– Sub-pixel displacement mapping

• Open Sourced (BSD License)• Multi-threaded• Network-distributed• “Future proof” SIMD

Scalability !

21

Page 22: Implementing a modern, RenderMan compliant, REYES renderer

Distributed bucket rendering

• A frame is subdivided into discrete buckets• Buckets are assigned to threads on the CPU or to remote servers via TCP/IP• Geometry, shaders and textures are also transferred via TCP/IP

Multi-core CPU

Remote servers

Works today ! .............. …it’s only a start. Needs optimizations, esp. network.

22

Page 23: Implementing a modern, RenderMan compliant, REYES renderer

Shader system

myShader(){ txcol = texture( “pigment” ); Ci = diffuse(N,txcol); Oi = 1;}

Shader.sl

RSL Compiler__main: mov.vv $v4 N normalize $v5 $v4 mov.vv $v6 $v5 mov.vv $v3 $v6 mov.vv $v7 I faceforward $v8 $v3 $v7 […]

Shader.rrasm

Shader VM

• High-level C-like RenderMan shaders are compiled into custom RRASM assembly

• RRASM is assembled and executed by the Shader Virtual Machine (VM) when rendering

A shading system is an essential part of a renderer

23

Page 24: Implementing a modern, RenderMan compliant, REYES renderer

Shading and SIMD (1)

Values in a grid are treated as arrays…

…N = {

P = {

myDisplace(){ P += N * mag;}

mul $v1 N magadd P P $v1

v1 = SIMD_Mul( N, mag );

P = SIMD_Add( P, v1 );

RSL

RRASM

C

RSL Compiler

Shader VM

24

Page 25: Implementing a modern, RenderMan compliant, REYES renderer

Shading and SIMD (2)Vector SIMD_Add_FPU( Vector a, Vector b ){ for (i=0; i < vec_size; i += 1) { result[i] = a[i] + b[i]; } return result;}

Vector SIMD_Add_SSE( Vector a, Vector b ){ for (i=0; i < vec_size; i += 4) { SSE_Add( &result[i], &a[i], &b[i] ); } return result;}

Vector SIMD_Add_LRB( Vector a, Vector b ){ for (i=0; i < vec_size; i += 16) { LRB_Add( &result[i], &a[i], &b[i] ); } return result;}

SIMD_Add()

No hardware SIMD

SSE

LRBni

1x

4x

16x

OpenCL, CUDA, ?

SIMD_Mul()

25

Page 26: Implementing a modern, RenderMan compliant, REYES renderer

…not fun to debug !

26

Page 27: Implementing a modern, RenderMan compliant, REYES renderer

Prospects for RibTools

• What role will REYES play for real-time ?– The architecture bodes well with multi-core,

vector processors or even GPGPU– Displacement and curved surfaces are best with

smaller-than-a-pixel polygons anyway

• Develop, learn and innovate– Don’t let the others decide for you..

Fully programmable graphics hardware is coming

• Off-line rendering ?– Much more complex, but no real-time constraints

DX11 tessellation..almost micro-polygons! *

RenderAnts: REYES on GPGPUSiggraph 2008, 2009 **

27* From Unigine’s Direct3D 11 tech demo ** Image from RenderAnts renderer

Page 28: Implementing a modern, RenderMan compliant, REYES renderer

Cons and problems

• Requires highly programmable hardware (best if with a flexible texture unit)

• The “RenderMan interface” is a fairly deep standard to follow

• Shader compilers, optimizers.. complex stuff• Comes with other issues:

– Cracks when tessellating, non-planar micropolys, front plane clipping, etc.

..but someone’s got to try it 8)28

Page 29: Implementing a modern, RenderMan compliant, REYES renderer

Questions ?

29

Page 30: Implementing a modern, RenderMan compliant, REYES renderer

References

• RibTools’ web site– http://ribtools.com

• “The RenderMan Interface Specification” (aka RISpec)– https://renderman.pixar.com/products/rispec/

• “Rendering with REYES” (from Pixar)– https://renderman.pixar.com/products/whats_renderman/2.html

• “Production Rendering” (Ian Stephenson Ed.)– http://amazon.com/dp/1852338210

• “Advanced RenderMan” (by A.Apodaca and L.Gritz)– http://amazon.com/dp/1558606181

• “The RenderMan Companion” (by Steve Upstill)– http://amazon.com/dp/0201508680

30

Page 31: Implementing a modern, RenderMan compliant, REYES renderer

Appendix: RibTools system overview

31