RenderManAPI  24.0
RixIntegrator.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 2020 Pixar. All rights reserved.
5 #
6 # The information in this file (the "Software") is provided for the exclusive
7 # use of the software licensees of Pixar ("Licensees"). Licensees have the
8 # right to incorporate the Software into other products for use by other
9 # authorized software licensees of Pixar, without fee. Except as expressly
10 # permitted herein, the Software may not be disclosed to third parties, copied
11 # or duplicated in any form, in whole or in part, without the prior written
12 # permission of Pixar.
13 #
14 # The copyright notices in the Software and this entire statement, including the
15 # above license grant, this restriction and the following disclaimer, must be
16 # included in all copies of the Software, in whole or in part, and all permitted
17 # derivative works of the Software, unless such copies or derivative works are
18 # solely in the form of machine-executable object code generated by a source
19 # language processor.
20 #
21 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL PIXAR BE
23 # LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
25 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
26 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN NO CASE WILL
27 # PIXAR'S TOTAL LIABILITY FOR ALL DAMAGES ARISING OUT OF OR IN CONNECTION WITH
28 # THE USE OR PERFORMANCE OF THIS SOFTWARE EXCEED $50.
29 #
30 # Pixar
31 # 1200 Park Ave
32 # Emeryville CA 94608
33 #
34 # ------------------------------------------------------------------------------
35 */
36 
37 #ifndef RixIntegrator_h
38 #define RixIntegrator_h
39 
40 #include <math.h> // for sqrtf
41 #include <algorithm> // for max
42 #include <cassert> // for assert
43 #include <cstddef> // for size_t
44 #include "RixBxdfLobe.h" // for RixBXLobeSampled, etc
45 #include "RixInterfaces.h" // for RixContext
46 #include "RixShading.h" // for RixShadingContext, etc
47 #include "RixShadingUtils.h" // for RixIsFinite
48 #include "prmanapi.h" // for PRMANEXPORT, PRMAN_INLINE
49 #include "RiTypesHelper.h" // for RtNormal3, Dot, RtPoint3, etc
50 
51 class RixLPE;
52 class RixLPEState;
54 class RixRNG;
56 
57 typedef unsigned int RixChannelId;
58 static const RixChannelId k_InvalidChannelId = 2147483647;
59 
69 {
72  {
75  } style;
77  {
83  } type;
85 };
86 
98 {
99 public:
111  //
112  virtual bool Splat(RixChannelId id, int iCtxIndex, float const value) = 0;
114  virtual bool Splat(RixChannelId id, int iCtxIndex, RtColorRGB const value) = 0;
115 
127  virtual bool SplatMulti(
128  int nChans, RixChannelId const* ids, int iCtxIndex, float const value) = 0;
130  virtual bool SplatMulti(
131  int nChans, RixChannelId const* id, int iCtxIndex, RtColorRGB const value) = 0;
132 
146  virtual bool Write(RixChannelId id, int iCtxIndex, float const value) = 0;
148  virtual bool Write(RixChannelId id, int iCtxIndex, RtColorRGB const value) = 0;
150  virtual bool Write(RixChannelId id, int iCtxIndex, int const value) = 0;
151 
169  virtual void WriteDistance(
170  int const iCtxIndex,
171  float const distance,
172  bool const isVolume = true,
173  RixShadingContext const* sCtx = nullptr) = 0;
174 
182  virtual void WriteOpacity(RixChannelId id, int iCtxIndex, float const value) = 0;
183  virtual void WriteOpacity(RixChannelId id, int iCtxIndex, RtColorRGB& value) = 0;
184 
192  virtual void SplatOpacity(RixChannelId id, int iCtxIndex, float const opacity) = 0;
193  virtual void SplatOpacity(RixChannelId id, int iCtxIndex, RtColorRGB& opacity) = 0;
194 
208  virtual int AddSample(int iCtxIndex) = 0;
209 
219  virtual void GetDisplayChannels(int* numDisplays, RixDisplayChannel const** displays) = 0;
220 
228  virtual void DiscardIteration(bool redo = false) = 0;
229 
230 protected:
231  virtual ~RixDisplayServices() {}
232 };
233 
235 {
236  enum RayType
237  {
238  k_rtInvalid = 0,
239  k_rtCamera = 1, /* primary visibility ray from a camera */
240  k_rtLight = 2, /* photon ray directly from a light source */
241  k_rtTransmission = 3, /* shadow ray */
242  k_rtDirectlight = 4, /* directlighting ray */
243  k_rtIndirect = 5, /* indirect ray */
244  k_rtNumRayTypes = 6
245  };
246 
248  float originRadius;
250 
251  float raySpread;
252  float minDist;
256  float maxDist;
257  float time;
258 
259  uint16_t raytype;
263  uint16_t shadingCtxIndex;
264  uint16_t rayId;
266 
267  uint32_t private0[5];
269  mutable uint16_t hitId;
272  uint16_t flags;
273 
277  uint16_t wavelength;
278 
281 
294  void InitOrigination(RixShadingContext const* sCtx, RtNormal3 const* Ngn, int _shadingCtxIndex)
295  {
296  this->shadingCtxId = sCtx->shadingCtxId;
297  this->shadingCtxIndex = _shadingCtxIndex;
298  this->integratorCtxIndex = sCtx->integratorCtxIndex[_shadingCtxIndex];
299  if (this->lobeSampled.GetTransmit())
300  {
301  bool const entering = Dot(Ngn[_shadingCtxIndex], this->direction) <= 0.f;
302  this->lobeSampled.SetEntering(entering);
303  }
304  }
305 
314  void InitTransmitOrigination(RixShadingContext const* sCtx, int _shadingCtxIndex)
315  {
316  this->shadingCtxId = sCtx->shadingCtxId;
317  this->shadingCtxIndex = _shadingCtxIndex;
318  this->integratorCtxIndex = sCtx->integratorCtxIndex[_shadingCtxIndex];
319  this->lobeSampled.Set(
320  true, // discrete
321  false, // specular
322  false, // transmit, not reflect
323  false, // scattering
324  false, // not user
325  0, // lpeid
326  0 // lobeid (unused)
327  );
328  this->lobeSampled.SetEntering(true);
329  }
330 
356  RixBXLobeSampled lobe,
357  float rayOriginRadius,
358  float rayOriginSpread,
359  float curvature,
360  float fPdf,
361  bool lightPath = false)
362  {
363  float pdfSpread = 0.0f;
364  float newSpread;
365 
366  // Compute ray spread based on pdf (and hence surface roughness). If Dirac delta, don't use
367  // pdf -- it is 1.0 by convention.
368  if (!lightPath && lobe.GetSolidAngle() && fPdf > 0.0f)
369  {
370  // Inverse square root of pdf is a heuristic that seems to work.
371  assert(fPdf > 0.0f); // Avoid division by 0 (fPdf=inf is okay here).
372  pdfSpread = 0.125f / sqrtf(fPdf);
373  assert(RixIsFinite(pdfSpread));
374  }
375 
376  // Compute ray spread based on surface curvature.
377  if (lobe.GetReflect())
378  {
379  // Treat this as reflection:
380  // - `k_RixBXReflectSpecular`
381  // - `k_RixBXReflectGlossy`
382  // - `k_RixBXReflectDiffuse`
383 
384  // Spread for specular reflection: The new ray spread is the incident ray spread plus
385  // change induced by local curvature. The factor of 2 comes from differentiating the
386  // formula for mirror reflection direction -- see [Igehy99].
387  // Note that we clamp the spread so it doesn't become negative for highly negative
388  // curvature, for example a concave mirror.
389  float curvatureSpread = rayOriginSpread + 2.0f * curvature * rayOriginRadius;
390  newSpread = std::max(curvatureSpread, pdfSpread);
391  }
392  else if (lobe.GetTransmit())
393  {
394  // Treat this as refraction:
395  // - `k_RixBXTransmitSpecular`
396  // - `k_RixBXTransmitGlossy`
397 
398  // Spread for specular transmission -- simpler than [Igehy99] since we only need spread
399  // amount, not differential direction vector:
400  // - newSpread = eta * raySpread - (1.0f - eta) * curvature * rayOriginRadius;
401  //
402  // This can give negative spread and focusing of the ray, with the width of the ray
403  // increasing beyond the focus distance. This is all good and fine, but we skip this
404  // effect for now. For now: simply copy parent ray spread to avoid having to deal with
405  // ior vs. 1/ior
406  newSpread = std::max(rayOriginSpread, pdfSpread);
407 
408  // - `k_RixBXTransmitDiffuse`
409 
410  // Use very conservative spread for diffuse reflection and transmission: same as for
411  // specular/glossy reflection.
412  // (Could do better if we know PixelSamples and diffusemultfactor: compute ray solid
413  // angle = 2pi / (pixsam*diffmultfac)
414  }
415  else
416  {
417  // We have no idea what this ray is, let's use the provided ray spread.
418  newSpread = rayOriginSpread;
419  }
420 
421  // Disallow |newSpread| > 1 or newSpread == nan
422  if (!(newSpread <= 1.0f)) newSpread = 1.0f;
423  if (newSpread < -1.0f) newSpread = -1.0f;
424  assert(-1.0f <= newSpread && newSpread <= 1.0f);
425 
426  this->raySpread = newSpread;
427  }
428 
436  static PRMAN_INLINE uint16_t EncodeWavelength(float wavelength)
437  {
438  return wavelength != 0.0f ?
439  (int((wavelength - 380.0f) * (65534.0f / (780.0f - 380.0f)) + 0.5f) + 1) :
440  0;
441  }
442 
450  static PRMAN_INLINE float DecodeWavelength(uint16_t encodedWavelength)
451  {
452  return encodedWavelength != 0 ?
453  (float(encodedWavelength - 1) * ((780.0f - 380.0f) / 65534.0f) + 380.0f) :
454  0.0f;
455  }
456 };
457 
459 {
462  float dist;
464  float filterSize;
465  float mpSize;
466  uint16_t groupingId;
467  uint16_t unused;
468 };
469 
474 {
475 public:
478  {
480  k_Fixed = 1,
483 
485  };
486 
489  {
492  };
493 
495  : m_version(2),
496  maxIntegrateSize(1024),
497  maxShadingCtxSize(1024),
500  numDisplays(0),
501  displays(0),
502  wantsEmptyIntegrate(false),
503  wantsIncrementBarrier(false),
505  numIncrements(0),
507  lobesWanted(k_RixBXTraitsAllLobe),
508  cameraMediumIOR(1.f),
510  wantsTransmission(false),
511  usesLightingServices(true),
515  {}
516 
527  {
528  for (int i = 0; i < numDisplays; ++i)
529  if (displays[i].channel == name) return &displays[i];
530  return nullptr;
531  }
532 
535 
536  // Some of the following quantities can be modified by the integrator on the object provided to
537  // `RixIntegrator::RenderBegin()`.
538 
553 
555  int const numDisplays;
557 
566 
571  int const numIncrements;
572 
575 
588 
593  bool unused1;
594  bool unused2;
596 
599 
605  char _reserved[15];
606 };
607 
608 namespace RixConstants
609 {
612  static const int k_MaxRaysPerBatch = 32768;
613 }
614 
616 {
617 public:
619  int numRays;
620  int numActiveRays;
630  float* time;
631 
632  virtual RixDisplayServices* GetDisplayServices(int version = 1) const = 0;
633  virtual RixLightingServices* GetLightingServices(int version = 1) const = 0;
634  virtual RixVolumeServices* GetVolumeServices(int version = 1) const = 0;
635  virtual RixRefCntPtr<RixLPE> GetRixLPE(int version = 1) const = 0;
636  virtual RixIntegratorEnvironment const& GetEnv(int version = 1) const = 0;
637 
639  {
640  k_None = 0,
641  k_Primary = 1,
646  };
647 
686  virtual void GetNearestHits(
687  int nRays,
688  RtRayGeometry const* rays,
689  RixBXLobeTraits const& lobesWanted,
690  RtRayGeometry::RayType rayType,
691  int nearestHitFlags,
692  RtUString const subset,
693  RtUString const excludeSubset,
694  RtHitSides hitSides,
695  int* numShadingCtxs,
696  RixShadingContext const** shadingCtxs) = 0;
697 
725  virtual void GetNearestHits(
726  int nRays,
727  RtRayGeometry const* rays,
728  RtRayGeometry::RayType rayType,
729  int nearestHitFlags,
730  RtUString const subset,
731  RtUString const excludeSubset,
732  RtHitSides hitSides,
733  RtHitPoint* hits) = 0;
734 
778  virtual void GetNearestHits(
779  int nRays,
780  RtRayGeometry const* rays,
781  RixBXLobeTraits const& lobesWanted,
782  bool wantsMisses,
783  int* numShadingCtxs,
784  RixShadingContext const** shadingCtxs,
785  // optional inputs:
786  RtUString const subset = US_NULL,
787  RtUString const excludeSubset = US_NULL,
788  bool isLightPath = false,
789  RtHitSides hitSides = k_SidesBoth,
790  bool isPrimary = false,
791  bool isVolume = false,
792  bool stochasticMode = true)
793  {
794  int nearestHitFlags =
795  (isPrimary ? k_Primary : k_None) |
796  (wantsMisses ? k_IncludeMisses : k_None) |
797  (isVolume ? k_ConstrainToVolume : k_None) |
798  (stochasticMode ? k_None : k_ContinuationOpacity);
799  RtRayGeometry::RayType raytype =
800  (isLightPath ? RtRayGeometry::k_rtLight :
802  GetNearestHits(nRays, rays, lobesWanted,
803  raytype, nearestHitFlags, subset, excludeSubset, hitSides, numShadingCtxs, shadingCtxs);
804  }
805 
812  virtual void GetNearestHits(
813  int nRays,
814  RtRayGeometry const* rays,
815  RtHitPoint* hits,
816  // optional inputs:
817  RtUString const subset = US_NULL,
818  RtUString const excludeSubset = US_NULL,
819  RtHitSides hitSides = k_SidesBoth,
820  bool isPrimary = false,
821  bool isVolume = false,
822  bool stochasticMode = true)
823  {
824  int nearestHitFlags =
825  (isPrimary ? k_Primary : k_None) |
826  (isVolume ? k_ConstrainToVolume : k_None) |
827  (stochasticMode ? k_None : k_ContinuationOpacity);
829  GetNearestHits(nRays, rays, raytype,
830  nearestHitFlags, subset, excludeSubset, hitSides, hits);
831  }
832 
856  virtual void GetTransmission(
857  int nRays,
858  RtRayGeometry const* rays,
859  RtColorRGB* transmissions,
860  RtColorRGB* volumeEmissions,
861  // optional input:
862  RtUString const subset = US_NULL,
863  RtUString const excludeSubset = US_NULL) = 0;
864 
873  virtual void ReleaseShadingContexts(
874  int numShadingCtxs, RixShadingContext const** shadingCtxs) = 0;
875 
882  {
884  };
885  virtual void* Allocate(size_t nObjs, size_t objSize, MemCategory) = 0;
886 
887  // contexts for ray misses
888  template <class T> T* Allocate(size_t nObjs)
889  {
890  T* mem = static_cast<T*>(Allocate(nObjs, sizeof(T), k_IntegratorMem));
891  return mem;
892  }
893 
894  template <class T> T* New(size_t nObjs)
895  {
896  T* mem = static_cast<T*>(Allocate(nObjs, sizeof(T), k_IntegratorMem));
897  return new (mem) T[nObjs];
898  }
899 
900 protected:
901  ~RixIntegratorContext() override {}
902 
903 public:
904 };
905 
907 {
908 public:
919  virtual void RenderBegin(
920  RixContext& rCtx,
921  RixIntegratorEnvironment& rixIntegratorEnv,
922  RixParameterList const* rixParameterList) = 0;
923  virtual void RenderEnd(RixContext& ctx) = 0;
924 
932  virtual void Synchronize(
933  RixContext& rCtx,
934  RixSCSyncMsg rixSCSyncMsg,
935  RixParameterList const* rixParameterList)
936  {
937  PIXAR_ARGUSED(rCtx);
938  PIXAR_ARGUSED(rixSCSyncMsg);
939  PIXAR_ARGUSED(rixParameterList);
940  }
941 
942 
960  virtual void IntegrateRays(
961  RixBXLobeTraits const& lobesWanted,
962  int* numShadingCtxs,
963  RixShadingContext const** shadingCtxs,
964  RixIntegratorContext& iCtx)
965  {
966  if (iCtx.numActiveRays)
967  {
968  iCtx.GetNearestHits(
969  iCtx.numActiveRays,
970  iCtx.primaryRays,
971  lobesWanted,
974  US_NULL, /*subset*/
975  US_NULL, /*excludeSubset*/
976  k_SidesFront,
977  numShadingCtxs,
978  shadingCtxs);
979  RixDisplayServices* displayServices = iCtx.GetDisplayServices();
980  for (int i = 0; i < *numShadingCtxs; ++i)
981  {
982  RixShadingContext const* sCtx = shadingCtxs[i];
983  float const* VLen;
985  for (int j = 0; j < sCtx->numPts; ++j)
986  {
987  int ctxIdx = sCtx->integratorCtxIndex[j];
988  displayServices->WriteDistance(ctxIdx, VLen[j], false);
989  }
990  }
991  Integrate(*numShadingCtxs, shadingCtxs, iCtx);
992  }
993  }
994 
1009  virtual void Integrate(
1010  int numShadingCtxs, RixShadingContext const* shadingCtxs[], RixIntegratorContext& iCtx) = 0;
1011 
1025  virtual void GetTransmission(
1026  int nRays,
1027  RtRayGeometry const* rays,
1028  RtColorRGB* transmissions,
1029  RtColorRGB* volumeEmissions,
1030  RtUString const subset,
1031  RtUString const excludeSubset,
1032  RixIntegratorContext& iCtx)
1033  {
1034  PIXAR_ARGUSED(nRays);
1035  PIXAR_ARGUSED(rays);
1036  PIXAR_ARGUSED(transmissions);
1037  PIXAR_ARGUSED(volumeEmissions);
1038  PIXAR_ARGUSED(subset);
1039  PIXAR_ARGUSED(excludeSubset);
1040  PIXAR_ARGUSED(iCtx);
1041  }
1042 
1062  virtual bool GetProperty(
1063  RixIntegratorContext& iCtx,
1064  const int* rayIds,
1065  int nRays,
1066  RayProperty rayProperty,
1067  void const* results)
1068  {
1069  PIXAR_ARGUSED(iCtx);
1070  PIXAR_ARGUSED(rayIds);
1071  PIXAR_ARGUSED(nRays);
1072  PIXAR_ARGUSED(rayProperty);
1073  PIXAR_ARGUSED(results);
1074 
1075  return false;
1076  }
1077 
1101  virtual bool SetProperty(
1102  RixIntegratorContext& iCtx,
1103  const int* rayIds,
1104  int nRays,
1105  RayProperty rayProperty,
1106  void const* values)
1107  {
1108  PIXAR_ARGUSED(iCtx);
1109  PIXAR_ARGUSED(rayIds);
1110  PIXAR_ARGUSED(nRays);
1111  PIXAR_ARGUSED(rayProperty);
1112  PIXAR_ARGUSED(values);
1113 
1114  return false;
1115  }
1116 
1117 protected:
1118  virtual ~RixIntegrator() {}
1119 };
1120 
1122 {
1123 public:
1124  int GetInterface() const override
1125  {
1126  return k_RixIntegratorFactory;
1127  }
1128 
1129  // Integrator plugins do not support InstanceData. As a consequence, the following methods are
1130  // not expected to be implemented and won't be called by the renderer.
1131  void CreateInstanceData(RixContext& rixCtx, RtUString const handle,
1132  RixParameterList const* instanceParams,
1133  InstanceData* instanceData) final
1134  {
1135  PIXAR_ARGUSED(rixCtx);
1136  PIXAR_ARGUSED(handle);
1137  PIXAR_ARGUSED(instanceParams);
1138  PIXAR_ARGUSED(instanceData);
1139  }
1140 
1141  void SynchronizeInstanceData(RixContext& rixCtx, RtUString const handle,
1142  RixParameterList const* instanceParams, uint32_t const editHints,
1143  InstanceData* instanceData) final
1144  {
1145  PIXAR_ARGUSED(rixCtx);
1146  PIXAR_ARGUSED(handle);
1147  PIXAR_ARGUSED(instanceParams);
1148  PIXAR_ARGUSED(editHints);
1149  PIXAR_ARGUSED(instanceData);
1150  }
1151 
1152  virtual RixIntegrator* CreateIntegrator(RixContext& rCtx, RtUString const handle,
1153  RixParameterList const* pList) = 0;
1154 
1155  virtual void DestroyIntegrator(RixIntegrator const* integrator) = 0;
1156 
1157 protected:
1159  {}
1161  {}
1162 };
1163 
1164 #define RIX_INTEGRATORFACTORYCREATE \
1165  extern "C" PRMANEXPORT RixIntegratorFactory* CreateRixIntegratorFactory(const char* hint)
1166 
1167 #define RIX_INTEGRATORFACTORYDESTROY \
1168  extern "C" PRMANEXPORT void DestroyRixIntegratorFactory(RixIntegratorFactory* factory)
1169 
1170 #endif
#define US_NULL
Definition: RiTypesHelper.h:683
PRMAN_INLINE bool GetReflect() const
Definition: RixBxdfLobe.h:680
Definition: RixIntegrator.h:480
All-inlined interface for generating sample points for use by Monte Carlo integration and multiple-im...
Definition: RixRNG.h:59
RixShadingContext is analogous to a RenderMan grid - it is a group of 1 or more points that may be sh...
Definition: RixShading.h:663
T * New(size_t nObjs)
Definition: RixIntegrator.h:894
virtual void GetNearestHits(int nRays, RtRayGeometry const *rays, RtHitPoint *hits, RtUString const subset=US_NULL, RtUString const excludeSubset=US_NULL, RtHitSides hitSides=k_SidesBoth, bool isPrimary=false, bool isVolume=false, bool stochasticMode=true)
Definition: RixIntegrator.h:812
virtual void Integrate(int numShadingCtxs, RixShadingContext const *shadingCtxs[], RixIntegratorContext &iCtx)=0
Integrate() is a secondary entry point for this class.
bool unused1
Max samples to be handled by manifold walking. Defaults to 0 (no manifold walk).
Definition: RixIntegrator.h:593
This class allows integrators to instrospect the rendering environment.
Definition: RixIntegrator.h:473
virtual bool Write(RixChannelId id, int iCtxIndex, float const value)=0
Write() is similar to Splat(), except that it overwrites the existing value instead of accumulating...
virtual void WriteDistance(int const iCtxIndex, float const distance, bool const isVolume=true, RixShadingContext const *sCtx=nullptr)=0
Overwrites the existing hit distance and information.
float dist
Geometric normal on hit.
Definition: RixIntegrator.h:462
uint16_t rayId
Index into the lauching shading context.
Definition: RixIntegrator.h:264
int manifoldWalkMaxSamples
Definition: RixIntegrator.h:595
RtRayGeometry * primaryRays
The primary camera rays.
Definition: RixIntegrator.h:625
PRMAN_INLINE bool GetSolidAngle() const
Definition: RixBxdfLobe.h:662
float maxDist
Minimum hit distance. Used only for primary rays.
Definition: RixIntegrator.h:256
enum RixDisplayChannel::ChannelStyle style
void InitTransmitOrigination(RixShadingContext const *sCtx, int _shadingCtxIndex)
InitTransmission() is analogous to InitOrigination() but should be used for transmission rays...
Definition: RixIntegrator.h:314
float * time
Shutter-normalized times associated with each ray.
Definition: RixIntegrator.h:630
pxrcore::ColorRGB RtColorRGB
Definition: RiTypesHelper.h:520
#define k_RixShadingVersion
Definition: RixShading.h:97
RtUString shadowExcludeSubset
Additional shadow exclusion subset.
Definition: RixIntegrator.h:598
char _reserved[15]
Definition: RixIntegrator.h:605
RixBXLobeSampled lobeSampled
See RayType for possible values.
Definition: RixIntegrator.h:260
virtual bool SplatMulti(int nChans, RixChannelId const *ids, int iCtxIndex, float const value)=0
The multi-channel version of Splat(), taking a list of channels to accumulate to. ...
Rix interfaces are obtained from an RixContext.
Definition: RixInterfaces.h:172
int cameraMediumPriority
Priority of the medium surrounding the camera. Defaults to 0.
Definition: RixIntegrator.h:585
SamplingModes
Indicates the sampling modes supported by the integrator.
Definition: RixIntegrator.h:477
RixShadingPlugin is the base class for RixBxdfFactory, RixDisplacementFactory, RixDisplayFilter, RixIntegrator, RixLightFilter, RixLightFactory, RixPattern, RixProjection, and RixSampleFilter.
Definition: RixShading.h:168
virtual bool GetProperty(RixIntegratorContext &iCtx, const int *rayIds, int nRays, RayProperty rayProperty, void const *results)
Allows for retrieving ray properties.
Definition: RixIntegrator.h:1062
Definition: RixIntegrator.h:79
int m_version
Interface version.
Definition: RixIntegrator.h:534
void SetRaySpread(RixBXLobeSampled lobe, float rayOriginRadius, float rayOriginSpread, float curvature, float fPdf, bool lightPath=false)
Computes ray spread for given reflection/transmission type, pdf, and surface curvature, using two approaches:
Definition: RixIntegrator.h:355
RixChannelId id
Definition: RixIntegrator.h:70
Definition: RixIntegrator.h:80
Definition: RixIntegrator.h:481
int numBootstrapIncrements
Used to request iterations which do not contribute to the final result.
Definition: RixIntegrator.h:574
virtual void SplatOpacity(RixChannelId id, int iCtxIndex, float const opacity)=0
Accumulates a given opacity value into the sample, which will be pixel-filtered and blended to create...
int numActiveRays
Size of the primaryRays array.
Definition: RixIntegrator.h:623
The RixVolumeServices interface allow the renderer to provide services that are useful for volume int...
Definition: RixVolume.h:208
RtFloat3 RtPoint3
Definition: RiTypesHelper.h:70
virtual RixDisplayServices * GetDisplayServices(int version=1) const =0
uint16_t groupingId
Used for ray-tracing bias calculation.
Definition: RixIntegrator.h:466
Definition: RixIntegrator.h:615
virtual void DiscardIteration(bool redo=false)=0
Cancels the results of any calls made to Splat(), SplatMulti(), and Write() during this invocation of...
int maxIntegrateSize
Integration state.
Definition: RixIntegrator.h:544
RixIntegratorFactory()
Definition: RixIntegrator.h:1158
LightingModes
Indicates the lighting modes supported by the integrator.
Definition: RixIntegrator.h:488
uint16_t unused
Attribute "grouping" "id" from the hit geometry.
Definition: RixIntegrator.h:467
virtual ~RixDisplayServices()
Definition: RixIntegrator.h:231
virtual int AddSample(int iCtxIndex)=0
Creates and adds a new sample.
Indicates if the rays should not hit any volumes.
Definition: RixIntegrator.h:645
virtual RixVolumeServices * GetVolumeServices(int version=1) const =0
~RixIntegratorContext() override
Definition: RixIntegrator.h:901
float filterSize
(u,v) coordinates of the hit.
Definition: RixIntegrator.h:464
Definition: RixIntegrator.h:479
Definition: RixIntegrator.h:240
int numRays
Unique identifier for integrator context.
Definition: RixIntegrator.h:619
Indicates if the caller wants the method to return &#39;empty&#39; shading contexts for ray misses...
Definition: RixIntegrator.h:642
Definition: RixIntegrator.h:608
virtual void RenderEnd(RixContext &ctx)=0
float opacityThreshold
Data for internal use.
Definition: RixIntegrator.h:268
virtual void DestroyIntegrator(RixIntegrator const *integrator)=0
virtual bool Splat(RixChannelId id, int iCtxIndex, float const value)=0
Accumulates a value into a given display channel for a given path sample.
int maxShadingCtxSize
The maximum number of points that a shading context will encapsulate.
Definition: RixIntegrator.h:548
virtual void WriteOpacity(RixChannelId id, int iCtxIndex, float const value)=0
Overwrites the current opacity value into the sample, which will be pixel-filtered and blended to cre...
Definition: RixIntegrator.h:640
PRMAN_INLINE bool GetTransmit(bool *entering=NULL) const
Definition: RixBxdfLobe.h:686
This struct represents the characteristics of just one lobe of a bxdf.
Definition: RixBxdfLobe.h:63
virtual void * Allocate(size_t nObjs, size_t objSize, MemCategory)=0
bool wantsTransmission
Expresses whether integrator has a non trivial GetTransmission() method.
Definition: RixIntegrator.h:587
virtual RixIntegratorEnvironment const & GetEnv(int version=1) const =0
Definition: RixIntegrator.h:484
RtUString channel
Definition: RixIntegrator.h:84
virtual void GetBuiltinVar(BuiltinVar, int const **var) const =0
RixDisplayChannel const *const displays
Definition: RixIntegrator.h:556
virtual void GetTransmission(int nRays, RtRayGeometry const *rays, RtColorRGB *transmissions, RtColorRGB *volumeEmissions, RtUString const subset, RtUString const excludeSubset, RixIntegratorContext &iCtx)
The GetTransmission() method will only be called if the integrator has set the wantsTransmission fiel...
Definition: RixIntegrator.h:1025
Definition: RiTypesHelper.h:82
float raySpread
Ray direction.
Definition: RixIntegrator.h:251
RixLPEState * lpeState
User-provided index in the ray bundle.
Definition: RixIntegrator.h:265
Definition: RixIntegrator.h:234
T * Allocate(size_t nObjs)
Definition: RixIntegrator.h:888
Definition: RixShading.h:114
RtHitSides
Definition: RixShading.h:99
Definition: RixIntegrator.h:73
RixParameterList exposes the non-varying values that are associated with the definition or editing of...
Definition: RixShading.h:575
bool unused2
Definition: RixIntegrator.h:594
NearestHitFlags
Definition: RixIntegrator.h:638
float cameraMediumIOR
If the camera is inside a non-trivial participating medium, this is the IOR of the medium...
Definition: RixIntegrator.h:583
Definition: RixIntegrator.h:82
int numPts
numPts is the number of shading points.
Definition: RixShading.h:696
#define PRMAN_ALIGNED_16
Definition: prmanapi.h:109
bool wantsIncrementBarrier
Expresses whether integrator requires all threads to synchronize on each rendering increment...
Definition: RixIntegrator.h:565
bool usesLightingServices
Indicates if the integrator will make use of RixLightingServices.
Definition: RixIntegrator.h:591
MemCategory
Allocate() and New() are utility (fully inlined and templated) methods to assist with memory manageme...
Definition: RixIntegrator.h:881
RtPoint3 P
Definition: RixIntegrator.h:460
PRMAN_INLINE RixDisplayChannel const * GetDisplayChannel(RtUString name) const
Returns the first display channel with the corresponding name.
Definition: RixIntegrator.h:526
float originRadius
Ray origin.
Definition: RixIntegrator.h:248
RixBXLobeTraits lobesWanted
Camera state.
Definition: RixIntegrator.h:580
virtual void RenderBegin(RixContext &rCtx, RixIntegratorEnvironment &rixIntegratorEnv, RixParameterList const *rixParameterList)=0
RenderBegin() and RenderEnd()` bound a rendering session.
SamplingModes supportedSamplingModes
Deprecated.
Definition: RixIntegrator.h:550
int * integratorCtxIndex
integratorCtxIndex maps indices to varying ShadingContext entries to the index associated with Integr...
Definition: RixShading.h:846
int const numIncrements
Total number of increments. This is usually maxsamples.
Definition: RixIntegrator.h:571
virtual void Synchronize(RixContext &rCtx, RixSCSyncMsg rixSCSyncMsg, RixParameterList const *rixParameterList)
Synchronize() is used to occasionally deliver status information from the renderer.
Definition: RixIntegrator.h:932
RayType
Definition: RixIntegrator.h:236
float mpSize
Used for texture filtering.
Definition: RixIntegrator.h:465
Definition: RixIntegrator.h:81
virtual void GetDisplayChannels(int *numDisplays, RixDisplayChannel const **displays)=0
Gets a list of available display channels.
int const numRaysPerIncrement
(unmutable).
Definition: RixIntegrator.h:569
Definition: RixIntegrator.h:458
float time
Maximum hit distance.
Definition: RixIntegrator.h:257
Definition: RixIntegrator.h:243
RtFloat3 RtNormal3
Definition: RiTypesHelper.h:73
Definition: RixIntegrator.h:883
RixSCSyncMsg
RixSCSyncMsgs - are the possible states delivered through Synchronize methods.
Definition: RixShading.h:127
#define PRMAN_INLINE
Definition: prmanapi.h:99
uint16_t shadingCtxIndex
Associated primary ray index.
Definition: RixIntegrator.h:263
virtual RixRefCntPtr< RixLPE > GetRixLPE(int version=1) const =0
Multiple methods of RixDisplayServices require similar parameters:
Definition: RixIntegrator.h:97
Definition: RiTypesHelper.h:546
Usage
Definition: RixLighting.h:142
PRMAN_INLINE int RixIsFinite(float x)
Definition: RixShadingUtils.h:155
RixShadingContext::Id shadingCtxId
Characteristics of the BxDF lobe this ray samples.
Definition: RixIntegrator.h:261
ChannelType
Definition: RixIntegrator.h:76
RtVector3 direction
Radius of ray at its origin.
Definition: RixIntegrator.h:249
RtNormal3 Ng
Hit position.
Definition: RixIntegrator.h:461
RtPoint3 origin
Definition: RixIntegrator.h:247
Definition: RixIntegrator.h:74
struct RixShadingContext::Id shadingCtxId
uint16_t ignoreGroupingId
If non-zero: ignore geometry with the specified Attribute "grouping" "id".
Definition: RixIntegrator.h:280
enum RixDisplayChannel::ChannelType type
virtual void GetNearestHits(int nRays, RtRayGeometry const *rays, RixBXLobeTraits const &lobesWanted, RtRayGeometry::RayType rayType, int nearestHitFlags, RtUString const subset, RtUString const excludeSubset, RtHitSides hitSides, int *numShadingCtxs, RixShadingContext const **shadingCtxs)=0
This version of GetNearestHits() returns ray hits in the form of a list of RixShadingContext.
void InitOrigination(RixShadingContext const *sCtx, RtNormal3 const *Ngn, int _shadingCtxIndex)
InitOrigination() should be called after the ray geometry has been setup for calls to GetNearestHits(...
Definition: RixIntegrator.h:294
void CreateInstanceData(RixContext &rixCtx, RtUString const handle, RixParameterList const *instanceParams, InstanceData *instanceData) final
CreateInstanceData() is called once per plugin-instance.
Definition: RixIntegrator.h:1131
Definition: RixIntegrator.h:482
int GetInterface() const override
Definition: RixIntegrator.h:1124
~RixIntegratorFactory() override
Definition: RixIntegrator.h:1160
Definition: RixLPE.h:127
Length of view vector (type float)
Definition: RixShading.h:949
virtual void IntegrateRays(RixBXLobeTraits const &lobesWanted, int *numShadingCtxs, RixShadingContext const **shadingCtxs, RixIntegratorContext &iCtx)
IntegrateRays() is the primary entry point for this class.
Definition: RixIntegrator.h:960
uint16_t raytype
Shutter-normalized time of ray launch.
Definition: RixIntegrator.h:259
Definition: RixIntegrator.h:78
static PRMAN_INLINE uint16_t EncodeWavelength(float wavelength)
Converts a wavelenght (in nanometers) to a compact 16 bits representation of it.
Definition: RixIntegrator.h:436
RixIntegratorEnvironment()
Definition: RixIntegrator.h:494
Represents the LPE system state of a light transport path.
Definition: RixLPE.h:439
PRMAN_INLINE void Set(bool vDiscrete, bool vSpecular, bool vReflect, bool vContinuation, bool vUser, unsigned char vLpeId, unsigned char vLobeId, bool vThinShadowFlag=false)
Set all fields and also sets the valid bit to true.
Definition: RixBxdfLobe.h:829
virtual void ReleaseShadingContexts(int numShadingCtxs, RixShadingContext const **shadingCtxs)=0
ReleaseShadingContexts() must be called to release the shading contexts created via GetNearestHits()...
Note that the same channel name may appear multiple times within a list of RixDisplayChannels.
Definition: RixIntegrator.h:68
unsigned int RixChannelId
Definition: RixIntegrator.h:55
RtPoint2 uv
Distance to hit point. 0 means &#39;no hit&#39;.
Definition: RixIntegrator.h:463
uint16_t flags
Internal hit id, zero means &#39;no hit.&#39;.
Definition: RixIntegrator.h:272
bool lightingServicesManagesParticipatingMedia
This requests lighting services to multiply the weighted transmission value on the current shading co...
Definition: RixIntegrator.h:604
bool wantsEmptyIntegrate
Increment state.
Definition: RixIntegrator.h:561
This struct represents the characteristics of potentially several lobes of a bxdf in aggregate...
Definition: RixBxdfLobe.h:178
Rays should continue as continuations through semi-opaque surfaces rather than stochastically termina...
Definition: RixIntegrator.h:644
virtual RixIntegrator * CreateIntegrator(RixContext &rCtx, RtUString const handle, RixParameterList const *pList)=0
virtual void GetNearestHits(int nRays, RtRayGeometry const *rays, RixBXLobeTraits const &lobesWanted, bool wantsMisses, int *numShadingCtxs, RixShadingContext const **shadingCtxs, RtUString const subset=US_NULL, RtUString const excludeSubset=US_NULL, bool isLightPath=false, RtHitSides hitSides=k_SidesBoth, bool isPrimary=false, bool isVolume=false, bool stochasticMode=true)
Definition: RixIntegrator.h:778
RayProperty
There are a set of &#39;properties&#39; of a ray the integrator could provide the bxdf that can potentially p...
Definition: RixShading.h:499
pxrcore::UString RtUString
Definition: RiTypesHelper.h:682
PRMAN_INLINE void SetEntering(bool entering)
Definition: RixBxdfLobe.h:785
virtual ~RixIntegrator()
Definition: RixIntegrator.h:1118
shadingCtxId is a unique identifier for this shading context.
Definition: RixShading.h:672
Definition: RixIntegrator.h:906
Definition: RixShading.h:101
Definition: RixShading.h:280
int integratorCtxId
Definition: RixIntegrator.h:618
int const numDisplays
Display state (unmutable).
Definition: RixIntegrator.h:555
static PRMAN_INLINE float DecodeWavelength(uint16_t encodedWavelength)
Converts from encoded 16 bits representation of wavelength to nanometers In both units 0 means "full ...
Definition: RixIntegrator.h:450
virtual bool SetProperty(RixIntegratorContext &iCtx, const int *rayIds, int nRays, RayProperty rayProperty, void const *values)
Allows for retrieving ray properties.
Definition: RixIntegrator.h:1101
virtual RixLightingServices * GetLightingServices(int version=1) const =0
RtFloat3 RtVector3
Definition: RiTypesHelper.h:72
Definition: RixShading.h:103
ChannelStyle
Definition: RixIntegrator.h:71
Indicates if the rays should not hit anything beyond the local volume.
Definition: RixIntegrator.h:643
LightingModes lightingRequirements
Deprecated.
Definition: RixIntegrator.h:552
Definition: RixIntegrator.h:239
Definition: RixIntegrator.h:1121
void SynchronizeInstanceData(RixContext &rixCtx, RtUString const handle, RixParameterList const *instanceParams, uint32_t const editHints, InstanceData *instanceData) final
SynchronizeInstanceData() will only be called if InstanceData::synchronizeHints was set to a non-zero...
Definition: RixIntegrator.h:1141
int16_t integratorCtxIndex
Shading context unique identifier.
Definition: RixIntegrator.h:262
#define PIXAR_ARGUSED(x)
Definition: prmanapi.h:170
uint16_t wavelength
Flags for internal use.
Definition: RixIntegrator.h:277
RixRNG * rngCtx
A pointer to single RixRNG object, properly configured for numRays samples.
Definition: RixIntegrator.h:627
Indicate if the ray should be considered as a primary ray or a continuation of one, uninterrupted from the camera or a light source.
Definition: RixIntegrator.h:641
virtual void GetTransmission(int nRays, RtRayGeometry const *rays, RtColorRGB *transmissions, RtColorRGB *volumeEmissions, RtUString const subset=US_NULL, RtUString const excludeSubset=US_NULL)=0
GetTransmission() can be invoked by an integrator to compute the transmittance between two points in ...