RenderManAPI  24.0
RixBxdf.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 RixBxdf_h
38 #define RixBxdf_h
39 
40 #include <cstddef> // for NULL
41 #include <vector> // for vector
42 #include "RixBxdfLobe.h" // for RixBXLobeTraits, etc
43 #include "RixShading.h" // for RixSCShadingMode, etc
44 #include "prmanapi.h" // for PRMANEXPORT, PRMAN_INLINE
45 #include "RiTypesHelper.h" // for RtColorRGB, etc
46 
47 class RixBxdf;
50 class RixOpacity;
51 class RixRNG;
53 class RixPostLighting;
54 struct RtRayGeometry;
55 
113 // RixBXEvaluateDomain tells Integrator the domain over which
114 // lighting/connecting/merging needs to be done.
115 // Reflect/Front = light samples are from the side the ray came from
116 // Transmit/Back = light samples are opposite the side the ray came from
117 // Outside = light samples are from the side the surface normal points into
118 // Inside = light samples are from the side the surface normal points away from
119 // The difference between Both and Volume is whether there's a cosine
120 // term (for surfaces) or not (for volumes).
122 {
123  // clang-format off
124  k_RixBXEmptyDomain = 0, // black hole (possibly emissive)
125 
126  // Elementary subdomains
127  // V = view , L = light/connect/merge, N = normal, ------ = surface
128  k_RixBXOutsideReflect = 1, // V\ N /L
129  //----------
130  //
131 
133  //----------
134  // V/
135 
137  //----------
138  // V/ \L
139 
141  //----------
142  // \L
143 
144  // Common domains
147  // for reference to v19/20 shaders, these are equivalent
148  // k_RixBXFront = k_RixBXReflect,
149  // k_RixBXBack = k_RixBXTransmit,
153 
154  k_RixBXVolume = 16 // light from all directions
155  // clang-format on
156 };
157 
159  RtVector3 const& N, RtVector3 const& V)
160 {
161  // we've been told to sample everything, so don't reject
162  if (domain & k_RixBXVolume || domain == k_RixBXBoth) return true;
163  if (domain == k_RixBXEmptyDomain) return false;
164 #if 0
165  // reference implementation
166  float dpL = L.Dot(N);
167  float dpV = N.Dot(V);
168 
169  switch(domain){
170  case k_RixBXOutsideTransmit: // 2
171  return (dpL > 0.0f && dpV < 0.0f);
172  break;
173  case k_RixBXOutsideReflect: // 1
174  return (dpL > 0.0f && dpV > 0.0f);
175  break;
176  case k_RixBXInsideTransmit: // 8
177  return (dpL < 0.0f && dpV > 0.0f);
178  break;
179  case k_RixBXInsideReflect: // 4
180  return (dpL < 0.0f && dpV < 0.0f);
181  break;
182  case k_RixBXInside: // 12
183  return (dpL < 0.0f);
184  break;
185  case k_RixBXOutside: // 3
186  return (dpL > 0.0f);
187  break;
188  case k_RixBXReflect: // 5
189  return ((dpL > 0.0f) != (dpV < 0.0f));
190  break;
191  case k_RixBXTransmit: // 10
192  return ((dpL > 0.0f) == (dpV < 0.0f));
193  break;
194  case k_RixBXOutsideTransmit | k_RixBXInsideReflect: // 2 | 4 = 6
195  return ((dpL > 0.0f && dpV < 0.0f) || (dpL < 0.0f && dpV < 0.0f));
196  break;
197  case k_RixBXOutsideReflect | k_RixBXInsideTransmit: // 1 | 8 = 9
198  return ((dpL > 0.0f && dpV > 0.0f) || (dpL < 0.0f && dpV > 0.0f));
199  break;
201  return ((dpL > 0.0f && dpV < 0.0f) || (dpL > 0.0f && dpV > 0.0f) ||
202  (dpL < 0.0f && dpV < 0.0f));
203  break;
205  return ((dpL > 0.0f && dpV > 0.0f) || (dpL < 0.0f && dpV > 0.0f) ||
206  (dpL < 0.0f && dpV < 0.0f));
207  break;
209  return ((dpL > 0.0f && dpV < 0.0f) || (dpL < 0.0f && dpV > 0.0f) ||
210  (dpL < 0.0f && dpV < 0.0f));
211  break;
213  return ((dpL > 0.0f && dpV > 0.0f) || (dpL > 0.0f && dpV < 0.0f) ||
214  (dpL < 0.0f && dpV > 0.0f));
215  break;
216  default:
217  return false;
218  }
219 #else
220  float dpL = L.Dot(N);
221  if (domain == k_RixBXInside || domain == k_RixBXOutside)
222  {
223  // We can avoid the dot product with V in these two cases
224  if (domain == k_RixBXOutside) return (dpL > 0.0f);
225  if (domain == k_RixBXInside) return (dpL < 0.0f);
226  }
227  else
228  {
229  float dpV = N.Dot(V);
230  bool valid = false;
231  // clang-format off
232  valid = valid ||
233  ((domain & k_RixBXOutsideTransmit) && (dpL > 0.0f && dpV < 0.0f));
234  valid = valid ||
235  ((domain & k_RixBXOutsideReflect) && (dpL > 0.0f && dpV > 0.0f));
236  valid = valid ||
237  ((domain & k_RixBXInsideTransmit) && (dpL < 0.0f && dpV > 0.0f));
238  valid = valid ||
239  ((domain & k_RixBXInsideReflect) && (dpL < 0.0f && dpV < 0.0f));
240  return valid;
241  // clang-format on
242  }
243 #endif
244  return true;
245 }
246 
247 // RixBXTransportTrait tells Bxdf the subset of light transport to consider.
249 {
250  k_RixBXDirectLighting = 1 << 0, // (direct lighting samples only)
251  k_RixBXIndirectLighting = 1 << 1, // (indirect lighting samples only)
253 };
254 
255 // Tells whether ray end points lies in volume or on boundary(interface)
257 {
262 };
263 
265 {
266 public:
267  int GetInterface() const override
268  {
269  return k_RixBxdfFactory;
270  }
271 
299  {
300  // clang-format off
302 
303  // returns RixOpacity for opacity
305  // do not set unless k_ComputesOpacity is set
307 
308  // returns RixOpacity for presence
310  // do not set unless k_ComputesPresence is set
312 
314 
315  // has interior integration requirements
317  // supports transmission
319  // requires volume, not surface, primvars
321  // supports overlapping of interiors
323  //
325  // subsurface interior integration
327 
328  // computes opacity for camera/indirect rays too
330 
331  // blocks volumes. Will only have an effect if
332  // kComputesInterior is also not set.
334 
335  // returns RixPostLighting
337 
338  // cannot support non-stochastic opacity
340 
341  // clang-format on
342  };
343 
344  virtual int GetInstanceHints(void* instanceData) const = 0;
345 
346  // Any parameter registered with an ID higher or equal to k_TemporalParamIsProperty will be
347  // evaluated using GetProperty calls instead using the same ID. Since the type cannot be
348  // inferred from the param table the caller is responsible for ensuring proper type safety on
349  // EvalTemporalParam calls.
350  enum
351  {
353  };
354  virtual void RegisterTemporalVolumeParams(void* instanceData,
355  std::vector<int>& paramId) const = 0;
356 
385  virtual RixBxdf* BeginScatter(RixShadingContext const*, RixBXLobeTraits const& hints,
386  RixSCShadingMode, void* parentData, void* instanceData) = 0;
387 
388  // usually called by RixBxdf::Release()
389  virtual void EndScatter(class RixBxdf* bxdf) = 0;
390 
420  virtual RixOpacity* BeginOpacity(RixShadingContext const*, RixSCShadingMode, void* parentData,
421  void* instanceData) = 0;
422 
423  virtual void EndOpacity(class RixOpacity*) = 0;
424 
455  void* parentData, void* instanceData) = 0;
456 
457  virtual void EndInterior(RixVolumeIntegrator*) = 0;
458 
488  void* parentData, void* instanceData) = 0;
489 
490  virtual void EndSubsurface(RixVolumeIntegrator*) = 0;
491 
494  virtual float GetIndexOfRefraction(void* instanceData) const = 0;
495 
498  void* parentData, void* instanceData)
499  {
500  PIXAR_ARGUSED(parentData);
502 
503  return NULL;
504  }
505 
506  virtual void EndPostLighting(class RixPostLighting*)
507  {}
508 
509 protected:
511  {}
512  ~RixBxdfFactory() override
513  {}
514 };
515 
516 // RixBxdf holds all state computed by BeginScatter, including
517 // the RixShadingContext.
518 class RixBxdf
519 {
520 public:
521  RixBxdf(RixShadingContext const* sCtx, RixBxdfFactory* factory)
522  : shadingCtx(sCtx), bxdfFactory(factory)
523  {}
524 
525  virtual ~RixBxdf()
526  {}
527 
529  {
530  return shadingCtx;
531  }
533  {
534  return bxdfFactory;
535  }
536 
537  // The domain over which this Bxdf evaluates samples. Note
538  // that it may Generate discrete samples in any direction, this only
539  // tells where incoming samples could Evaluate to non-zero.
541 
542  // The types of samples this BxdfEvaluator can generate.
543  virtual void GetAggregateLobeTraits(RixBXLobeTraits* t) = 0;
544 
546  {
547  RixBXLobeTraits t;
548  this->GetAggregateLobeTraits(&t);
549  return t;
550  }
551 
552  // Bxdfs can be queried for general material properties to
553  // facilitate integration tasks. Bxdfs should return
554  // k_RixSCInvalidDetail if a particular property is unsupported.
555  // If a property is supported Bxdf should return k_RixSCUniform or
556  // k_RixSCVarying according to the detail of the result. A trivial
557  // implementation that supports no properties of any sort should
558  // simply return k_RixSCInvalidDetail.
560  {
561  k_Albedo, // RtColorRGB
562  k_MaterialIor // float
563  };
564  virtual RixSCDetail GetProperty(BxdfProperty, void const** result) const = 0;
565 
566  // EmitLocal: used for baked, pre-integrated, indirect results. A
567  // trivial implementation with no local emission should simply
568  // return false, indicating to the integrator that 'result' is
569  // untouched and that the integrator should not do anything with
570  // the results. For bxdfs that do have local emission, they should
571  // return true and write shadingCtx->numPts colors to the 'result'
572  // array. The integrator will then include the returned colors in
573  // the direct lighting for the geometry.
574  virtual bool EmitLocal(RtColorRGB* result) = 0;
575 
609  virtual void GenerateSample(RixBXTransportTrait transportTrait,
610  RixBXLobeTraits const* lobesWanted, RixRNG* rng,
612  RixBXLobeSampled* lobesSampled, RtVector3* directions,
613  RixBXLobeWeights& weights, float* forwardPdfs, float* reversePdfs,
614  RtColorRGB* compTrans = NULL) = 0;
615 
639  virtual void EvaluateSample(RixBXTransportTrait transportTrait,
640  RixBXLobeTraits const* lobesWanted, RixRNG* rng,
641  RixBXLobeTraits* lobesEvaluated,
642  RtVector3 const* directions,
644  RixBXLobeWeights& weights, float* forwardPdfs,
645  float* reversePdfs) = 0;
646 
647  // EvaluateSamplesAtIndex:
648  // Do multiple evals at a single shading point. Also see the documentation
649  // above for EvaluateSample().
650  virtual void EvaluateSamplesAtIndex(RixBXTransportTrait transportTrait,
651  RixBXLobeTraits const& lobesWanted, RixRNG* rng, int index,
652  int numSamples,
654  RixBXLobeTraits* lobesEvaluated,
655  RtVector3 const* directions, RixBXLobeWeights& weights,
656  float* forwardPdfs, float* reversePdfs) = 0;
657 
658  // Release does any cleanup that might be needed (often none and the
659  // base implementation is fine) and then calls the base implementation.
660  // A RixBxdf that contains another RixBxdf would need to call Release
661  // on its child as part of its own Release.
662  virtual void Release()
663  {
664  if (bxdfFactory) bxdfFactory->EndScatter(this);
665  }
666 
667 protected:
670 };
671 
672 // RixOpacity objects are obtained from the BxdfFactory::BeginOpacity
673 // when it determines conditions warrant non-trivial responses to
674 // either or both of Presence and Opacity queries. GetPresence
675 // is invoked when an object isn't trivially 'present' and may
676 // be used for radiance queries to infer "ray continuation". It is
677 // useful to express cutouts as, for example, a leaf shape modeled
678 // with a texture map. Most objects are trivially present and the
679 // BxdfFactory should respond to NULL RixOpacity when the
680 // RixSCShadingMode is k_RixSCPresenceQuery. In the case of
681 // an opaque leaf, BxdfFactory should instantiate a RixOpacity
682 // subclass to respond to GetPresence requests and the
683 // "presence closure" should be constructed with the minimum
684 // state required to respond to this request. If our example
685 // leaf is opaque for shadowing, the BxdfFactory should respond
686 // to BeginOpacity requests with NULL for k_RixSCTransmissionQuery.
687 // But if the shadow of the leaf wants leaf coloration, BxdfFactory
688 // should produce a RixOpacity subclass that combines the effects
689 // of presence and coloration into a single opacity value. Since
690 // opacity can be colored, keep in mind that it is the inverse of
691 // transparency and user interfaces usually prefer to present
692 // a transparency color to the user.
693 //
695 {
696 public:
698  : shadingCtx(sCtx), bxdfFactory(factory)
699  {}
700  virtual ~RixOpacity()
701  {}
703  {
704  return bxdfFactory;
705  }
707  {
708  return shadingCtx;
709  }
710 
722  virtual bool GetPresence(float* result) = 0;
723 
734  virtual bool GetOpacity(RtColorRGB* result) = 0;
735 
736  virtual void Release()
737  {
738  if (bxdfFactory) bxdfFactory->EndOpacity(this);
739  }
740 
741 protected:
744 };
745 
746 // RixVolumeIntegrators can be obtained from the BxdfFactory at
747 // the hit point where a ray enters an interior region.
748 // A VolumeIntegrator can be seen as a delegate for the real
749 // IntegratorCtx that implements special behavior behind the
750 // GetNearestHits and GetTransmission methods. The idea is
751 // that the integration complexity in a volume region can be
752 // hidden from the outside world by reducing more complex
753 // light-paths into a single measurement of energy thruput,
754 // transmission, coupled with potentially distinct shading
755 // contexts to capture light transfer into the volume region.
756 // VolumeIntegrators can either be built-in or compiled-in to
757 // a bxdf. In the former case, a reference to an instance of
758 // a VolumeIntegrator should be obtained from the RixShadingContext.
759 // To support pre-constructed builtin VolumeIntegrators we offer
760 // a generic method to pass instance parameters to the integrator.
761 // Typically builtin VolumeIntegrators define a struct comprised of
762 // the parameters it requires from the enclosing bxdf factory.
763 // The memory for (and evaluation of) the parameters is the responsibility
764 // of the enclosing bxdf. This extra dance is required to diminish
765 // the likelihood of disruption caused by the addition of new parameters
766 // by plugin/builtin volume integrators. In the direct-linked case
767 // clients can bypass the SetParameters convenience routines in
768 // favor of direct constructor.
770 {
771 public:
772  RixVolumeIntegrator(RixShadingContext const* sCtx, RixBxdfFactory* f, void* _instanceData)
773  : bxdfFactory(f),
774  instanceData(_instanceData),
775  params(NULL),
776  surfaceCtx(sCtx),
777  volumeCtx(NULL)
778  {}
780  {}
781 
782  // Interfaces to obtain the shading context is slightly different for
783  // volume integrators compared with bxdfs. There are two contexts for
784  // shading contexts; one representing the volume "surface" (the interface
785  // for the volume) and one for the volume interior. The surface context
786  // can be obtained by using GetShadingCtx. The returned context can never
787  // be NULL. To obtain a shading context for volume interiors, use
788  // GetVolumeShadingCtx.
790  {
791  return surfaceCtx;
792  }
793 
795  {
796  return volumeCtx;
797  }
798 
800  {
801  return bxdfFactory;
802  }
803 
804  // This method should be used with caution. In most circumstances, the factory that is set by
805  // the constructor should suffice and should not need to be overriden. The only known situation
806  // which requires the use of this method involves nested Bxdfs, when an outer RixBxdfFactory's
807  // implementation of BeginInterior delegates to a nested inner RixBxdfFactory's implementation
808  // of BeginInterior. In this situation, it may be appropriate for the outer RixBxdfFactory
809  // to override the volume integrator's bxdf factory with this method, in order to guarantee
810  // that the renderer can correctly find the outer RixBxdfFactory for calls to BeginScatter().
811  //
812  // RixVolumeIntegrator* OuterFactory::BeginInterior(...) {
813  // RixBxdfFactory* innerFactory = ...;
814  // RixVolumeIntegrator* integrator = innerFactory->BeginInterior(...);
815  // if (integrator) {
816  // integrator->SetBxdfFactory(this); // factory override
817  // }
818  // return integrator;
819  // }
821  {
822  bxdfFactory = factory;
823  }
824 
825  void* GetInstanceData() const
826  {
827  return instanceData;
828  }
829 
830  // Same caveats for SetBxdfFactory() apply to SetInstanceData() - it is likely only useful for
831  // nested Bxdf situations.
832  void SetInstanceData(void* data)
833  {
834  instanceData = data;
835  }
836 
837  virtual void SetParameters(void const* subclassParams)
838  {
839  params = subclassParams;
840  }
841 
843  {
844  public:
845  virtual void PerformDirectLighting(RixShadingContext const&,
846  RixBXLobeTraits const* lobesWanted, int step) = 0;
847 
848  protected:
850  {}
851  };
852 
853  virtual void Release()
854  {
855  if (bxdfFactory) bxdfFactory->EndInterior(this);
856  }
857 
858  // Volumes can be queried for general material properties to
859  // facilitate integration tasks. Volumes should return
860  // k_RixSCInvalidDetail if a particular property is unsupported.
861  // If a property is supported the volume should return
862  // k_RixSCUniform or k_RixSCVarying according to the detail of the
863  // result.
865  {
866  k_DensityType, // int - value should be one of
867  // k_DensityFloat/k_DensityColor
868  k_DensityFloat, // float
869  k_DensityColor, // RtColorRGB
870  k_MaxDensity, // float
871  k_Velocity, // RtFloat3
874  k_DensityFloatId, // param id for float density
875  k_DensityColorId, // param id for color density
876  k_Emission, // RtColorRGB
877  };
878  virtual RixSCDetail GetProperty(VolumeProperty, void const** /* result */) const
879  {
880  // Note: currently we offer a default implementation. We may
881  // choose to enforce implementing this in the future so we
882  // encourage you to implement this method.
883  return k_RixSCInvalidDetail;
884  }
885 
886  // Begin/EndVolumeSampling: can be called by a volume integrator
887  // to obtain a mutable shading context for the purposes of
888  // sampling its volume region. The resulting shading context
889  // has the same size as its creator context. Two options
890  // for cleanup are offered. If the volume integrator wishes
891  // to expose/publicize a new shading context to the primary
892  // integrator, it should set exposeVol to a non-NULL
893  // RixBXLobeTraits pointer (which usually points to the same
894  // RixBXLobeTraits passed to the interior's GetNearestHits
895  // method). The optional membership array can be used to
896  // communicate the subset of points on the current shading
897  // context that should be conveyed to the new one. A non-zero
898  // value signals the membership request in a new context. If
899  // NULL, all points will be used to construct a new shading
900  // context. In this usage, the return result will be a distinct
901  // shading context appropriate for use by the primary
902  // integrator. If exposeVol is NULL, the the result is NULL and
903  // internal volume sampling state is released.
905  {
906  const RixShadingContext* sCtx = GetShadingCtx();
907  RixShadingContext* newCtx = sCtx->BeginVolumeSampling();
908  volumeCtx = newCtx;
909  return volumeCtx;
910  }
911 
912  RixShadingContext const* EndVolumeSampling(RixBXLobeTraits const* exposeVol = NULL,
913  int const* membership = NULL)
914  {
915  const RixShadingContext* sCtx = GetShadingCtx();
916  const RixShadingContext* newCtx = sCtx->EndVolumeSampling(volumeCtx, exposeVol, membership);
917  volumeCtx = NULL;
918 
919  return newCtx;
920  }
921 
922  virtual void GetNearestHits(int numRays, RtRayGeometry const* rays, RixRNG* rng,
923  RixBXLobeTraits const& lobesWanted, RixIntegratorContext& iCtx,
924  RixLightingServices* lightingServices,
925  // results: (per-ray transmission deposited
926  // on resulting ShadingContexts'
927  // transmission field). Inscattered
928  // radiance can be splatted directly to
929  // the screen.
930  IntegratorDelegate* lcb, int* numShadingCtxs,
931  RixShadingContext const** shadingCtxs,
932  // optional inputs:
933  RtUString const subset = US_NULL,
934  RtUString const excludeSubset = US_NULL, bool isLightPath = false,
935  RtHitSides hitSides = k_SidesBoth, bool isPrimary = false) = 0;
936 
937  // We provide a default implementation of GetTransmission because
938  // some volume integrators may be opaque to transmission rays.
939  // This occurs when the only supported light transport mode is indirect.
940  // In this case, the volume integrator's associated bxdffactory may
941  // select to return a NULL volume integrator for transmission queries.
942  virtual void GetTransmission(int numRays, RtRayGeometry const* rays, RixRNG* rng,
943  RixIntegratorContext& iCtx, RtColorRGB* transmissions,
944  // optional output
945  RtColorRGB* emission,
946  // optional input;
947  RtUString const subset = US_NULL,
948  RtUString const excludeSubset = US_NULL)
949  {
950  PIXAR_ARGUSED(rays);
951  PIXAR_ARGUSED(rng);
952  PIXAR_ARGUSED(iCtx);
953  PIXAR_ARGUSED(emission);
954  PIXAR_ARGUSED(subset);
955  PIXAR_ARGUSED(excludeSubset);
956  for (int i = 0; i < numRays; ++i)
957  {
958  transmissions[i] = RtColorRGB(0.0f);
959  }
960  }
961 
962 protected:
965  void const* params;
966 
967 private:
968  RixShadingContext const* surfaceCtx;
969  RixShadingContext* volumeCtx;
970 };
971 
973 {
974 public:
976  : shadingCtx(sCtx), bxdfFactory(factory)
977  {}
978 
980  {}
981 
982  // Release does any cleanup that might be needed (often none and the
983  // base implementation is fine) and then calls the base implementation.
984  virtual void Release()
985  {
987  }
988 
989  virtual void Filter(int const numLightSamples, RtVector3 const* directions,
990  float const* distances, const RixLight** lights,
991  RixBXLobeWeights* bxdfWeights, RixBXLobeWeights* lightWeights,
992  RtColorRGB* transmissions) = 0;
993 
994 protected:
997 };
998 
999 // clang-format off
1000 #define RIX_BXDFPLUGINCREATE \
1001  extern "C" PRMANEXPORT RixBxdfFactory* CreateRixBxdfFactory(const char* hint)
1002 
1003 #define RIX_BXDFPLUGINDESTROY \
1004  extern "C" PRMANEXPORT void DestroyRixBxdfFactory(RixBxdfFactory* bxdf)
1005 // clang-format on
1006 
1007 #endif
virtual bool GetOpacity(RtColorRGB *result)=0
GetOpacity: fill shadingCtx->nPts worth of RtColor opacity values.
#define US_NULL
Definition: RiTypesHelper.h:683
Definition: RixBxdf.h:124
VolumeProperty
Definition: RixBxdf.h:864
All-inlined interface for generating sample points for use by Monte Carlo integration and multiple-im...
Definition: RixRNG.h:59
Definition: RixBxdf.h:875
Definition: RixBxdf.h:264
RixShadingContext is analogous to a RenderMan grid - it is a group of 1 or more points that may be sh...
Definition: RixShading.h:663
virtual void EndOpacity(class RixOpacity *)=0
Definition: RixBxdf.h:304
Definition: RixBxdf.h:261
virtual void EndPostLighting(class RixPostLighting *)
Definition: RixBxdf.h:506
Definition: RixBxdf.h:313
virtual void GetNearestHits(int numRays, RtRayGeometry const *rays, RixRNG *rng, RixBXLobeTraits const &lobesWanted, RixIntegratorContext &iCtx, RixLightingServices *lightingServices, IntegratorDelegate *lcb, 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)=0
Definition: RixBxdf.h:326
RixLight This base class defines the interface for light sources.
Definition: RixLight.h:117
Definition: RixBxdf.h:866
Definition: RixBxdf.h:324
Definition: RixBxdf.h:152
RixBxdfFactory * GetBxdfFactory()
Definition: RixBxdf.h:702
Definition: RixBxdf.h:870
RixBXEvaluateDomain
The RixBxdf interface is a shading plugin responsible for creating a RixBxdf from the the ShadingCont...
Definition: RixBxdf.h:121
virtual ~RixPostLighting()
Definition: RixBxdf.h:979
RixBxdfFactory * GetBxdfFactory()
Definition: RixBxdf.h:532
Definition: RixBxdf.h:251
Definition: RixBxdf.h:132
InstanceHints
Most Bxdfs do not require special opacity handling or support interior shading.
Definition: RixBxdf.h:298
pxrcore::ColorRGB RtColorRGB
Definition: RiTypesHelper.h:520
#define k_RixShadingVersion
Definition: RixShading.h:97
RixShadingContext const * EndVolumeSampling(RixBXLobeTraits const *exposeVol=NULL, int const *membership=NULL)
Definition: RixBxdf.h:912
virtual void Release()
Definition: RixBxdf.h:984
virtual float GetIndexOfRefraction(void *instanceData) const =0
Returns the index of refraction of the material.
RixShadingPlugin is the base class for RixBxdfFactory, RixDisplacementFactory, RixDisplayFilter, RixIntegrator, RixLightFilter, RixLightFactory, RixPattern, RixProjection, and RixSampleFilter.
Definition: RixShading.h:168
Definition: RixBxdf.h:306
Definition: RixBxdf.h:562
Definition: RixBxdf.h:128
RixBxdfFactory * bxdfFactory
Definition: RixBxdf.h:743
virtual class RixVolumeIntegrator * BeginInterior(RixShadingContext const *, RixSCShadingMode, void *parentData, void *instanceData)=0
BeginInterior creates a RixVolumeIntegrator for the current shading context.
Definition: RixBxdf.h:311
virtual void SetParameters(void const *subclassParams)
Definition: RixBxdf.h:837
Definition: RixBxdf.h:260
Definition: RixShading.h:113
Definition: RixIntegrator.h:615
RixBxdfFactory * bxdfFactory
Definition: RixBxdf.h:669
Definition: RixBxdf.h:301
Definition: RixBxdf.h:136
RixSCDetail
RixSCDetail enumerates the valid sizing qualifiers for SC parameters.
Definition: RixShading.h:432
Definition: RixBxdf.h:694
PRMAN_INLINE bool RixVisibleToDomain(RixBXEvaluateDomain domain, RtVector3 const &L, RtVector3 const &N, RtVector3 const &V)
Definition: RixBxdf.h:158
virtual void EvaluateSample(RixBXTransportTrait transportTrait, RixBXLobeTraits const *lobesWanted, RixRNG *rng, RixBXLobeTraits *lobesEvaluated, RtVector3 const *directions, RixBXLobeWeights &weights, float *forwardPdfs, float *reversePdfs)=0
Bxdf is expected to evaluate itself subject to the lobesWanted request.
Definition: RixBxdf.h:151
RixVolumeIntegrator(RixShadingContext const *sCtx, RixBxdfFactory *f, void *_instanceData)
Definition: RixBxdf.h:772
RixBxdfFactory * bxdfFactory
Definition: RixBxdf.h:996
This struct represents the characteristics of just one lobe of a bxdf.
Definition: RixBxdfLobe.h:63
RixBxdf(RixShadingContext const *sCtx, RixBxdfFactory *factory)
Definition: RixBxdf.h:521
RixBXRayFlags
Definition: RixBxdf.h:256
virtual RixBxdf * BeginScatter(RixShadingContext const *, RixBXLobeTraits const &hints, RixSCShadingMode, void *parentData, void *instanceData)=0
BeginScatter is expected to return a RixBxdf for the current ShadingContext.
Definition: RixBxdfLobe.h:428
virtual ~IntegratorDelegate()
Definition: RixBxdf.h:849
Definition: RixIntegrator.h:234
RtHitSides
Definition: RixShading.h:99
Definition: RixBxdf.h:252
Definition: RixBxdf.h:259
virtual ~RixBxdf()
Definition: RixBxdf.h:525
RixSCShadingMode
RixSCShadingMode conveys the current operating mode associated with the shading context.
Definition: RixShading.h:553
virtual void EvaluateSamplesAtIndex(RixBXTransportTrait transportTrait, RixBXLobeTraits const &lobesWanted, RixRNG *rng, int index, int numSamples, RixBXLobeTraits *lobesEvaluated, RtVector3 const *directions, RixBXLobeWeights &weights, float *forwardPdfs, float *reversePdfs)=0
void const * params
Definition: RixBxdf.h:965
Definition: RixShading.h:434
Definition: RixBxdf.h:250
Definition: RixBxdf.h:154
Definition: RixBxdf.h:309
Definition: RixBxdf.h:769
virtual void GetTransmission(int numRays, RtRayGeometry const *rays, RixRNG *rng, RixIntegratorContext &iCtx, RtColorRGB *transmissions, RtColorRGB *emission, RtUString const subset=US_NULL, RtUString const excludeSubset=US_NULL)
Definition: RixBxdf.h:942
RixShadingContext const * GetShadingCtx() const
Definition: RixBxdf.h:789
Definition: RixBxdf.h:869
virtual void Release()
Definition: RixBxdf.h:662
Definition: RixBxdf.h:145
RixShadingContext * GetVolumeShadingCtx() const
Definition: RixBxdf.h:794
RixShadingContext const * shadingCtx
Definition: RixBxdf.h:742
virtual bool EmitLocal(RtColorRGB *result)=0
RixBXTransportTrait
Definition: RixBxdf.h:248
virtual void GenerateSample(RixBXTransportTrait transportTrait, RixBXLobeTraits const *lobesWanted, RixRNG *rng, RixBXLobeSampled *lobesSampled, RtVector3 *directions, RixBXLobeWeights &weights, float *forwardPdfs, float *reversePdfs, RtColorRGB *compTrans=NULL)=0
Bxdf is expected to generate a sample direction and lobe weights for each point in the ShadingContext...
void SetInstanceData(void *data)
Definition: RixBxdf.h:832
RixShadingContext const * shadingCtx
Definition: RixBxdf.h:995
PRMAN_INLINE RixBXLobeTraits GetAllLobeTraits()
Definition: RixBxdf.h:545
virtual class RixVolumeIntegrator * BeginSubsurface(RixShadingContext const *, RixSCShadingMode, void *parentData, void *instanceData)=0
BeginSubsurface creates a RixVolumeIntegrator for the current shading context.
virtual RixOpacity * BeginOpacity(RixShadingContext const *, RixSCShadingMode, void *parentData, void *instanceData)=0
BeginOpacity creates a RixOpacity for the current shading context.
#define PRMAN_INLINE
Definition: prmanapi.h:99
virtual RixSCDetail GetProperty(BxdfProperty, void const **result) const =0
Definition: RixBxdf.h:150
virtual void EndScatter(class RixBxdf *bxdf)=0
Definition: RixBxdf.h:972
virtual void Release()
Definition: RixBxdf.h:853
RixBxdfFactory()
Definition: RixBxdf.h:510
Definition: RixBxdf.h:258
Usage
Definition: RixLighting.h:142
virtual bool GetPresence(float *result)=0
GetPresence: fill shadingCtx->nPts worth of float presence values.
virtual void PerformDirectLighting(RixShadingContext const &, RixBXLobeTraits const *lobesWanted, int step)=0
void * instanceData
Definition: RixBxdf.h:964
Definition: RixBxdf.h:876
RixShadingContext const * shadingCtx
Definition: RixBxdf.h:668
RixPostLighting(RixShadingContext const *sCtx, RixBxdfFactory *factory)
Definition: RixBxdf.h:975
Definition: RixBxdf.h:140
Definition: RixBxdf.h:871
RixOpacity(RixShadingContext const *sCtx, RixBxdfFactory *factory)
Definition: RixBxdf.h:697
virtual void EndInterior(RixVolumeIntegrator *)=0
virtual void Filter(int const numLightSamples, RtVector3 const *directions, float const *distances, const RixLight **lights, RixBXLobeWeights *bxdfWeights, RixBXLobeWeights *lightWeights, RtColorRGB *transmissions)=0
virtual void EndSubsurface(RixVolumeIntegrator *)=0
virtual void RegisterTemporalVolumeParams(void *instanceData, std::vector< int > &paramId) const =0
Definition: RixBxdf.h:874
virtual int GetInstanceHints(void *instanceData) const =0
int GetInterface() const override
Definition: RixBxdf.h:267
~RixBxdfFactory() override
Definition: RixBxdf.h:512
RixBxdfFactory * bxdfFactory
Definition: RixBxdf.h:963
virtual RixBXEvaluateDomain GetEvaluateDomain()=0
Definition: RixBxdf.h:316
Definition: RixBxdf.h:333
Definition: RixBxdf.h:561
RixShadingContext const * GetShadingCtx()
Definition: RixBxdf.h:528
void SetBxdfFactory(RixBxdfFactory *factory)
Definition: RixBxdf.h:820
This struct represents the characteristics of potentially several lobes of a bxdf in aggregate...
Definition: RixBxdfLobe.h:178
virtual ~RixVolumeIntegrator()
Definition: RixBxdf.h:779
pxrcore::UString RtUString
Definition: RiTypesHelper.h:682
void * GetInstanceData() const
Definition: RixBxdf.h:825
Definition: RixBxdf.h:146
Definition: RixBxdf.h:868
virtual RixShadingContext * BeginVolumeSampling() const =0
Definition: RixBxdf.h:322
RixShadingContext * BeginVolumeSampling()
Definition: RixBxdf.h:904
virtual RixPostLighting * BeginPostLighting(RixShadingContext const *, RixSCShadingMode, void *parentData, void *instanceData)
parentData role is similar to the one of BeginScatter().
Definition: RixBxdf.h:497
RtFloat3 RtVector3
Definition: RiTypesHelper.h:72
Definition: RixShading.h:103
virtual void Release()
Definition: RixBxdf.h:736
virtual ~RixOpacity()
Definition: RixBxdf.h:700
virtual void GetAggregateLobeTraits(RixBXLobeTraits *t)=0
RixBxdfFactory * GetBxdfFactory() const
Definition: RixBxdf.h:799
Definition: RixBxdf.h:518
virtual RixShadingContext const * EndVolumeSampling(const RixShadingContext *, RixBXLobeTraits const *exposeVol=NULL, int const *membership=NULL) const =0
virtual RixSCDetail GetProperty(VolumeProperty, void const **) const
Definition: RixBxdf.h:878
#define PIXAR_ARGUSED(x)
Definition: prmanapi.h:170
BxdfProperty
Definition: RixBxdf.h:559
RixShadingContext const * GetShadingCtx()
Definition: RixBxdf.h:706