render (lxrender.h)

From The Foundry MODO SDK wiki
Jump to: navigation, search
There are security restrictions on this page


Introduction

This module implements the bucket interface that can be used during rendering with sample vectors.

Bucket Object

The bucket is exposed to clients via the render bucket interface, which is actually a packet in the sample vector.

The simplest thing the RenderBucket interface can be used for is to get the thread number of the current rendering thread. This will be a value from 0 through n-1, where n is the number of rendering threads.

(1) SDK: ILxRenderBucket interface
         LXxMETHOD(  unsigned int,
 Thread) (
         LXtObjectID              self);

We can also get the sample vector back from the bucket object.

(2) SDK: ILxRenderBucket interface
         LXxMETHOD(  LxResult,
 SampleVec) (
         LXtObjectID              self,
         void                   **ppvObj);

We can push and pop rays onto the ray stack. These functions are equivalent to those in the Raycast interface.

(3) SDK: ILxRenderBucket interface
         LXxMETHOD(  LxResult,
 PushRay) (
         LXtObjectID              self);

(4) SDK: ILxRenderBucket interface
         LXxMETHOD(  LxResult,
 PopRay) (
         LXtObjectID              self);

GetGIBounce will directly return the number of global illumination bounces prior to the current shading evaluation. This will allow a shader to compare it against the maximum global illumination bounces, and exit if it's already reached the maximum.

(5) SDK: ILxRenderBucket interface
         LXxMETHOD (  int,
 GetGIBounce) (
         LXtObjectID              self);

GetPixel will indirectly (through the x and y argument pointers) return the current pixel being evaluated by this thread.

(6) SDK: ILxRenderBucket interface
         LXxMETHOD (  void,
 GetPixel) (
         LXtObjectID              self,
         int                     *x,
         int                     *y);

GetSubPixel will get the position of the current sample being evaluated within the pixel. It indirectly returns the values via the pointers to x and y. The values returned are between 0.0 and 1.0.

(7) SDK: ILxRenderBucket interface
         LXxMETHOD (  void,
 GetSubPixel) (
         LXtObjectID              self,
         float                   *x,
         float                   *y);

GetTimeOffset will return a value between 0.0 and 1.0 indicating the time within an exposure being currently evaluated (to allow motion / temporal blur in shading, for instance).

(8) SDK: ILxRenderBucket interface
         LXxMETHOD (  float,
 GetTimeOffset) (
         LXtObjectID              self);

(9) SDK: Declarations
 #define LXu_RENDERBUCKET        "ED6F0ABE-F76F-4EED-BEF5-A30FF7F71098"
 #define LXa_RENDERBUCKET        "renderBucket"
 #define LXsP_RENDERBUCKET       "renderBucket"

Here is an example of how to get the render bucket object from the sample vector. Note that the offset should really be computed outside of the Evaluate function as it is a lookup that is too slow in the context of shader evaluation.

(10) SDK: RenderBucket object from the sample vector
 CLxUser_PacketService            pkt_service;
 CLxLoc_RenderBucket              bkt;
 int                              bkt_offset;
 
 bkt_offset  = pkt_service.GetOffset (LXsCATEGORY_SAMPLE, LXsP_RENDERBUCKET);
 pkt_service.PacketObject (vector, bkt_offset, bkt);