RenderMan  26.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RixShadingBuiltin.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 2023 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 RixBuiltinShading_h
38 #define RixBuiltinShading_h
39 
40 #include <cstddef> // for NULL
41 #include "RixBxdf.h" // for RixBXTransportTrait, etc
42 #include "RixBxdfLobe.h" // for RixBXLobeWeights (ptr only), etc
43 #include "RixShading.h" // for RixSCDetail, etc
44 #include "RiTypesHelper.h" // for RtVector3, etc
45 
48 class RixRNG;
49 struct RtRayGeometry;
50 
51 // Subsurface scattering using diffusion approximations:
52 // Burley normalized or three-lobe parameterization
54 {
55 public:
57  RixShadingContext const* sCtx,
58  RixBxdfFactory* f,
59  void* _instanceData)
60  : RixVolumeIntegrator(sCtx, f, _instanceData)
61  {
62  }
63  struct Params
64  {
66  : _version(5),
67  dmfp(NULL),
68  mfp(NULL),
69  bumpNormal(NULL),
71  followTopology(NULL),
72  flipSssHitVn(false)
73  {
74  }
75 
76  int const _version; // always first in the struct
77 
78  // Parameterization #1 (used by e.g. LamaSSS):
79  // (only set one of *dmfp or *mfp; set the other one to NULL)
80  RtColorRGB const* albedo;
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 e.g. LamaTricolorSSS):
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 const* followTopology; // decrease sss in concave regions? (was uniform before RenderMan 25)
102 
103  bool flipSssHitVn; // flip Vn direction at sss ray hit points (not diffusesss approx shading pts)
104 
105  // future parameters will appear here.
106 
107  char _reserved[32]; // always last in the struct
108  };
109  virtual void GetNearestHits(
110  int nRays,
111  RtRayGeometry const* rays,
112  RixRNG* rng,
113  RixBXLobeTraits const& lobesWanted,
114  RixIntegratorContext& iCtx,
115  RixLightingServices* lightingServices,
116  IntegratorDelegate* lcb,
117  int* numShadingCtxs,
118  RixShadingContext const** shadingCtxs,
119  RtUString const subset = US_NULL,
120  RtUString const excludeSubset = US_NULL,
121  bool isLightPath = false,
122  RtHitSides hitSides = k_SidesBoth,
123  bool isPrimary = false) = 0;
124 
125 protected:
127  virtual ~RixSSDiffusion() {}
128 };
129 
130 // Subsurface scattering as brute-force volume scattering
132 {
133 public:
135  RixShadingContext const* sCtx,
136  RixBxdfFactory* f,
137  void* _instanceData)
138  : RixVolumeIntegrator(sCtx, f, _instanceData)
139  {
140  }
141  struct Params
142  {
144  : _version(1),
145  dmfp(NULL),
146  bumpNormal(NULL)
147  {
148  }
149 
150  int const _version; // always first in the struct
151 
152  // Main parameters: albedo, dmfp, ior, g
153  RtColorRGB const* albedo;
154  RixSCDetail albedoDetail; // is albedo uniform or varying?
155  RtColorRGB const* dmfp; // rgb diffuse mean free path lengths
156  RixSCDetail dmfpDetail; // is dmfp uniform or varying?
157  float const* ior; // index of refraction
158  RixSCDetail iorDetail; // is ior uniform or varying?
159  float const* g; // scattering mean cosine (anisotropy)
160  RixSCDetail gDetail; // is g uniform or varying?
161 
162  // Additional parameters:
163  float diffuseSwitch; // distance for switch between diffuse and sss (ignored: not used for ptsss)
164  float bias;
165  int disableAlbedoInversion; // (obsolete or debug only?)
166  RtUString subset;
169  float unitLength; // multiplier on dmfp values
170 
171  RtVector3 const* bumpNormal; // for bump-mapped normals
172 
173  // future parameters will appear here.
174 
175  char _reserved[32]; // always last in the struct
176  };
177  virtual void GetNearestHits(
178  int nRays,
179  RtRayGeometry const* rays,
180  RixRNG* rng,
181  RixBXLobeTraits const& lobesWanted,
182  RixIntegratorContext& iCtx,
183  RixLightingServices* lightingServices,
184  IntegratorDelegate* lcb,
185  int* numShadingCtxs,
186  RixShadingContext const** shadingCtxs,
187  RtUString const subset = US_NULL,
188  RtUString const excludeSubset = US_NULL,
189  bool isLightPath = false,
190  RtHitSides hitSides = k_SidesBoth,
191  bool isPrimary = false) = 0;
192 
193 protected:
195  virtual ~RixSSPathTraced() {}
196 };
197 
198 class RixNullBxdf : public RixBxdf
199 {
200 public:
202  virtual void GetAllLobeTraits(RixBXLobeTraits*) = 0;
203  virtual int GetNumLobes() = 0;
204 
205  virtual void GenerateSample(
206  RixBXTransportTrait transportTrait,
207  RixBXLobeTraits const* lobesWanted,
208  RixRNG* rng,
209  RixBXLobeSampled* lobeSampled,
210  RtVector3* directions,
211  RixBXLobeWeights& weights,
212  float* forwardPdfs,
213  float* reversePdfs,
214  RtColorRGB* compTrans = NULL) = 0;
215 
216  virtual void EvaluateSample(
217  RixBXTransportTrait transportTrait,
218  RixBXLobeTraits const* lobesWanted,
219  RixRNG* rng,
220  RixBXLobeTraits* lobesEvaluated,
221  RtVector3 const* directions,
222  RixBXLobeWeights& weights,
223  float* forwardPdfs,
224  float* reversePdfs) = 0;
225 
226  virtual void EvaluateSamplesAtIndex(
227  RixBXTransportTrait transportTrait,
228  RixBXLobeTraits const& lobesWanted,
229  RixRNG* rng,
230  int index,
231  int nSamples,
232  RixBXLobeTraits* lobesEvaluated,
233  RtVector3 const* directions,
234  RixBXLobeWeights& weights,
235  float* forwardPdfs,
236  float* reversePdfs) = 0;
237 
238 private:
239  // no parameters..
240  virtual ~RixNullBxdf() {}
241 };
242 
243 // RixLambertBxdf and RixDirac may go here...
244 
245 #endif