Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Implementing a modern, RenderMan compliant, REYES renderer


Published on

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

Published in: Technology, Art & Photos
  • Be the first to comment

Implementing a modern, RenderMan compliant, REYES renderer

  1. 1. Implementing a modern, RenderMan compliant, REYES renderer<br />Davide Pasca<br /><br />(contact: davide<at><br />1<br />
  2. 2. About REYES<br />Reyes or REYES (Renders Everything You Ever Saw)<br />A flexible renderer, developed by Lucasfilm CG div. (“Pixar” from 1986)<br />First used in 1984 in Start Trek II<br />..still used today in Pixar’s Photorealistic RenderMan<br />2<br />* Images, from top, are copyright of Paramount Pictures and Pixar (subsidiary of The Walt Disney Company)<br />
  3. 3. RenderMan compliant ?<br />Defines a renderer with some basic capabilities such as:<br />A RenderMan graphics state machine<br />Hidden surface elimination<br />Pixel filtering and anti-aliasing<br />User programmable shaders<br />Texture mapping<br />Etc…<br />3<br />
  4. 4. REYES features<br />Native support for high level surfaces<br />Dynamic LOD<br />Compact representation<br />Subdivide per-frame based on size on screen<br />Displace geometry from textures<br />High quality filtering<br />Easier to deal with translucency, motion-blur, etc.<br />Can be used together with ray-tracing<br />4<br />
  5. 5. REYES pipeline overview<br />5<br />
  6. 6. Split (1)<br />A parametric surface: P = f(u,v)<br />Split until “small enough” size (estimated) on screen<br />6<br />
  7. 7. Split (2)<br />Calculate the bounding box in screen-space<br />…test against predetermined max screen area<br />Here, the bounding box is too large..<br />7<br />
  8. 8. Split (3)<br />When too large, split the patch<br />It’s easy with parametric primitives:<br />Pnew = f(unew, vnew)<br />New split points<br />8<br />
  9. 9. Split (4)<br />Calculate the bounds of the new sub-patches<br />Still too large<br />9<br />
  10. 10. Split (5)<br />Split recursively until every sub-patch is “small enough”…<br />Small enough.. this is<br />ready to be diced<br />10<br />
  11. 11. What’s “Small Enough” ?<br />When most sub-patches fit in a single bucket<br />When dicing(see later) produces a suitable number of samples (sweet spot for performance)<br />Sub-patch inside<br />a single bucket<br />Optimal<br />Sub-patch touches<br />two or more buckets<br />Not Optimal<br />A bucket<br />11<br />
  12. 12. Dice<br />Small enough sub-patches are diced<br />Generate a dense grid of samples (1 pixel-per-sample or more..)<br />1 pixel<br />Small enough n_samples <= max_samples<br />max_samples is set for performance reasons<br />and to avoid distortion<br />12<br />
  13. 13. Displace<br />Apply a displacement shader to the position of the samples<br />myDisplace()<br />{<br /> mag = texture( “dispmap” );<br />P += normalize(N) * mag;<br /> N = calculatenormal(P);<br />}<br />13<br />
  14. 14. Shade<br />Apply surface and light shaders to get the color<br />myShader()<br />{<br /> txcol = texture( “pigment” );<br /> Ci = diffuse(N,txcol);<br />Oi = 1;<br />}<br />14<br />
  15. 15. Sample – the micropolys<br />Form virtualmicropolygons at the grid samples<br />1 pixel<br />Virtual micropolygons<br />15<br />
  16. 16. Sample – sample points<br />Multiple sub-samples at every pixel<br />…choose a sampling method: regular, multi-jittered (as shown), etc.<br />16<br />
  17. 17. Sample – gather samples<br />Samples get the color of the micropolygons they touch<br />…each sample can have many values if the mpolys are translucent !<br />17<br />
  18. 18. Sample – convolution<br />Mix the samples together…<br />…choose a filter: box, triangular, Gaussian, Sinc, etc..<br />18<br />
  19. 19. Sample – final pixel color<br />The resulting “average” color is assigned to the pixel<br />…repeat for every pixel 8)<br />19<br />
  20. 20. RibTools: A RenderMan-style renderer R&D<br />20<br />* Killeroo model from headus Ltd., used with permission.<br />
  21. 21. RibTools’ key features<br />RenderMan compliant(…almost (^^;))<br />Parse RIB scene files<br />C-like shaders compiler and VM<br />Parametric surfaces, etc.<br />Sub-pixel displacement mapping<br />Open Sourced (BSD License)<br />Multi-threaded<br />Network-distributed<br />“Future proof” SIMD<br />Scalability !<br />21<br />
  22. 22. Distributed bucket rendering<br />Multi-core CPU<br />Remote servers<br /><ul><li>A frame is subdivided into discrete buckets
  23. 23. Buckets are assigned to threads on the CPU or to remote servers via TCP/IP
  24. 24. Geometry, shaders and textures are also transferred via TCP/IP</li></ul>Works today !<br />…it’s only a start. Needs optimizations, esp. network.<br />..............<br />22<br />
  25. 25. Shader system<br />A shading system is an essential part of a renderer<br /><br />Shader.rrasm<br />myShader()<br />{<br /> txcol = texture( “pigment” );<br /> Ci = diffuse(N,txcol);<br />Oi = 1;<br />}<br />RSL Compiler<br />__main:<br />mov.vv $v4 N<br /> normalize $v5 $v4<br />mov.vv $v6 $v5<br />mov.vv $v3 $v6<br />mov.vv $v7 I<br />faceforward $v8 $v3 $v7<br /> […]<br /><ul><li> High-level C-like RenderMan shaders are compiled into custom RRASM assembly
  26. 26. RRASM is assembled and executed by the ShaderVirtual Machine (VM) when rendering</li></ul>Shader VM<br />23<br />
  27. 27. Shading and SIMD (1)<br />Values in a grid are treated as arrays…<br />…<br />myDisplace()<br />{<br />P += N * mag;<br />}<br />…<br />N = {<br />RSL<br />P = {<br />RSL Compiler<br />mul $v1 N mag<br />add PP $v1<br />RRASM<br />Shader VM<br />v1 = SIMD_Mul( N, mag );<br />P= SIMD_Add(P, v1 );<br />C<br />24<br />
  28. 28. Shading and SIMD (2)<br />Vector SIMD_Add_FPU(Vector a, Vector b )<br />{<br /> for (i=0; i < vec_size; i += 1)<br /> {<br />result[i] = a[i] + b[i];<br /> }<br /> return result;<br />}<br />1x<br />No hardware SIMD<br />SIMD_Add()<br />Vector SIMD_Add_SSE(Vector a, Vector b )<br />{<br /> for (i=0; i < vec_size; i += 4)<br /> {<br />SSE_Add( &result[i], &a[i], &b[i] );<br /> }<br /> return result;<br />}<br />SSE<br />SIMD_Mul()<br />4x<br />…<br />LRBni<br />Vector SIMD_Add_LRB(Vector a, Vector b )<br />{<br /> for (i=0; i < vec_size; i += 16)<br /> {<br />LRB_Add( &result[i], &a[i], &b[i] );<br /> }<br /> return result;<br />}<br />OpenCL, CUDA, ?<br />16x<br />25<br />
  29. 29. …not fun to debug !<br />26<br />
  30. 30. Prospects for RibTools<br />What role will REYES play for real-time ?<br />The architecture bodes well with multi-core, vector processors or even GPGPU<br />Displacement and curved surfaces are best with smaller-than-a-pixel polygons anyway<br />Develop, learn and innovate<br />Don’t let the others decide for you..Fully programmable graphics hardware is coming<br />Off-line rendering ?<br />Much more complex, but no real-time constraints<br />DX11 tessellation<br />..almost micro-polygons! *<br />RenderAnts: REYES on GPGPU<br />Siggraph 2008, 2009 **<br />27<br />* From Unigine’s Direct3D 11 tech demo ** Image from RenderAnts renderer<br />
  31. 31. Cons and problems<br />Requires highly programmable hardware (best if with a flexible texture unit)<br />The “RenderMan interface” is a fairly deep standard to follow<br />Shader compilers, optimizers.. complex stuff<br />Comes with other issues:<br />Cracks when tessellating, non-planar micropolys, front plane clipping, etc.<br />..but someone’s got to try it 8)<br />28<br />
  32. 32. Questions ?<br />29<br />
  33. 33. References<br />RibTools’ web site<br /><br />“The RenderMan Interface Specification” (aka RISpec)<br /><br />“Rendering with REYES” (from Pixar)<br /><br />“Production Rendering” (Ian Stephenson Ed.)<br /><br />“Advanced RenderMan” (by A.Apodaca and L.Gritz)<br /><br />“The RenderMan Companion” (by Steve Upstill)<br /><br />30<br />
  34. 34. Appendix: RibTools system overview<br />31<br />