RenderMan API  23.0
RixShadingBuiltin.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 1986-2019 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 
38 #ifndef RixBuiltinShading_h
39 #define RixBuiltinShading_h
40 
41 #include <cstddef> // for NULL
42 #include "RixBxdf.h" // for RixBXTransportTrait, etc
43 #include "RixBxdfLobe.h" // for RixBXLobeWeights (ptr only), etc
44 #include "RixShading.h" // for RixSCDetail, etc
45 #include "ri.h" // for RtVector3, RtConstPointer
46 
49 class RixRNG;
50 struct RtRayGeometry;
51 
52 // Subsurface scattering using diffusion approximations:
53 // Burley normalized or three-lobe parameterization
55 {
56 public:
58  RixShadingContext const* sCtx,
59  RixBxdfFactory* f,
60  RtPointer _instanceData)
61  : RixVolumeIntegrator(sCtx, f, _instanceData)
62  {
63  }
64  struct Params
65  {
67  : _version(4),
68  dmfp(NULL),
69  mfp(NULL),
70  bumpNormal(NULL),
72  followTopology(0.0f)
73  {
74  }
75 
76  int const _version; // always first in the struct
77 
78  // Parameterization #1 (used by simple/PxrSubsurface):
79  // (only set one of *dmfp or *mfp; set the other one to NULL)
81  RixSCDetail albedoDetail; // is albedo uniform or varying?
82  RtColorRGB const* dmfp; // rgb diffuse mean free path lengths
83  RixSCDetail dmfpDetail; // is dmfp uniform or varying?
84  RtColorRGB const* mfp; // rgb mean free path -- alternative to dmfp
85  RixSCDetail mfpDetail; // is mfp uniform or varying?
86 
87  // Parameterization #2 (used by PxrSkin and PxrLMSubsurface):
88  RtColorRGB const *color1, *color2, *color3; // 3 colors
90  float const *weight1, *weight2, *weight3; // 3 weights
92  float const *dmfp1, *dmfp2, *dmfp3; // 3 diff. mean free path lengths
94 
95  float unitLength;
96 
97  RtVector3 const* bumpNormal; // for bump-mapped normals
98 
99  int continuationRays; // shoot sss continuation rays?
100 
101  float followTopology; // decrease sss in concave regions?
102 
103  // future parameters will appear here.
104 
105  char _reserved[32]; // always last in the struct
106  };
107  virtual void GetNearestHits(
108  int nRays,
109  RtRayGeometry const* rays,
110  RixRNG* rng,
111  RixBXLobeTraits const& lobesWanted,
112  RixIntegratorContext& iCtx,
113  RixLightingServices* lightingServices,
114  IntegratorDelegate* lcb,
115  int* numShadingCtxs,
116  RixShadingContext const** shadingCtxs,
117  RtUString const subset = US_NULL,
118  RtUString const excludeSubset = US_NULL,
119  bool isLightPath = false,
120  RtHitSides hitSides = k_SidesBoth,
121  bool isPrimary = false) = 0;
122 
123 protected:
125  virtual ~RixSSDiffusion() {}
126 };
127 
128 // Subsurface scattering as brute-force volume scattering
130 {
131 public:
133  RixShadingContext const* sCtx,
134  RixBxdfFactory* f,
135  RtPointer _instanceData)
136  : RixVolumeIntegrator(sCtx, f, _instanceData)
137  {
138  }
139  struct Params
140  {
142  : _version(1),
143  dmfp(NULL),
144  bumpNormal(NULL)
145  {
146  }
147 
148  int const _version; // always first in the struct
149 
150  // Parameterization #1 (used by simple/PxrSubsurface):
151  // (only set one of *dmfp or *mfp; set the other one to NULL)
153  RixSCDetail albedoDetail; // is albedo uniform or varying?
154  RtColorRGB const* dmfp; // rgb diffuse mean free path lengths
155  RixSCDetail dmfpDetail; // is dmfp uniform or varying?
156  float const* ior; // index of refraction
157  RixSCDetail iorDetail; // is ior uniform or varying?
158  float const* g; // scattering mean cosine (anisotropy)
159  RixSCDetail gDetail; // is g uniform or varying?
160 
161  float diffuseSwitch; // distance for switch between diffuse and sss (not used for ptsss?)
162  float bias;
163  int disableAlbedoInversion; // (obsolete or debug only?)
167  float unitLength;
168 
169  RtVector3 const* bumpNormal; // for bump-mapped normals
170 
171  // future parameters will appear here.
172 
173  char _reserved[32]; // always last in the struct
174  };
175  virtual void GetNearestHits(
176  int nRays,
177  RtRayGeometry const* rays,
178  RixRNG* rng,
179  RixBXLobeTraits const& lobesWanted,
180  RixIntegratorContext& iCtx,
181  RixLightingServices* lightingServices,
182  IntegratorDelegate* lcb,
183  int* numShadingCtxs,
184  RixShadingContext const** shadingCtxs,
185  RtUString const subset = US_NULL,
186  RtUString const excludeSubset = US_NULL,
187  bool isLightPath = false,
188  RtHitSides hitSides = k_SidesBoth,
189  bool isPrimary = false) = 0;
190 
191 protected:
193  virtual ~RixSSPathTraced() {}
194 };
195 
196 class RixNullBxdf : public RixBxdf
197 {
198 public:
199  virtual RixBXEvaluateDomain GetEvaluateDomain() = 0;
200  virtual void GetAllLobeTraits(RixBXLobeTraits*) = 0;
201  virtual int GetNumLobes() = 0;
202 
203  virtual void GenerateSample(
204  RixBXTransportTrait transportTrait,
205  RixBXLobeTraits const* lobesWanted,
206  RixRNG* rng,
207  RixBXLobeSampled* lobeSampled,
208  RtVector3* directions,
209  RixBXLobeWeights& weights,
210  float* forwardPdfs,
211  float* reversePdfs,
212  RtColorRGB* compTrans = NULL) = 0;
213 
214  virtual void EvaluateSample(
215  RixBXTransportTrait transportTrait,
216  RixBXLobeTraits const* lobesWanted,
217  RixRNG* rng,
218  RixBXLobeTraits* lobesEvaluated,
219  RtVector3 const* directions,
220  RixBXLobeWeights& weights,
221  float* forwardPdfs,
222  float* reversePdfs) = 0;
223 
224  virtual void EvaluateSamplesAtIndex(
225  RixBXTransportTrait transportTrait,
226  RixBXLobeTraits const& lobesWanted,
227  RixRNG* rng,
228  int index,
229  int nSamples,
230  RixBXLobeTraits* lobesEvaluated,
231  RtVector3 const* directions,
232  RixBXLobeWeights& weights,
233  float* forwardPdfs,
234  float* reversePdfs) = 0;
235 
236 private:
237  // no parameters..
238  virtual ~RixNullBxdf() {}
239 };
240 
241 // RixLambertBxdf and RixDirac may go here...
242 
243 #endif
RtColorRGB const * color2
virtual void GetNearestHits(int nRays, 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
RtHitSides
Definition: RixShading.h:99
pxrcore::ColorRGB RtColorRGB
RtColorRGB const * dmfp
#define US_NULL
RtVector3 const * bumpNormal
void * RtPointer
Definition: ri.h:69
This struct represents the characteristics of just one lobe of a bxdf.
Definition: RixBxdfLobe.h:64
RixBXTransportTrait
Definition: RixBxdf.h:248
RtColorRGB const * mfp
RixSSDiffusion(RixShadingContext const *sCtx, RixBxdfFactory *f, RtPointer _instanceData)
virtual ~RixSSPathTraced()
for internal use only.
virtual ~RixSSDiffusion()
for internal use only.
RixSCDetail
Definition: RixShading.h:376
RtColorRGB const * albedo
RtColorRGB const * color1
RtColorRGB const * dmfp
RixSSPathTraced(RixShadingContext const *sCtx, RixBxdfFactory *f, RtPointer _instanceData)
pxrcore::UString RtUString
RtColorRGB const * color3
RtVector3 const * bumpNormal
Definition: RixRNG.h:59
RixBXEvaluateDomain
Definition: RixBxdf.h:121
RtColorRGB const * albedo
RtFloat3 RtVector3
Definition: RiTypesHelper.h:71