RenderMan API  23.0
RixLightFilter.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 #ifndef RixLightFilter_h
38 #define RixLightFilter_h
39 
40 #include <cstddef> // for NULL, size_t
41 #include <new> // for operator new
42 #include "RixInterfaces.h" // for RixContext
43 #include "RixShading.h" // for RixShadingContext, etc
44 #include "prmanapi.h" // for PRMANEXPORT
45 #include "ri.h" // for RtConstPointer, etc
46 
47 class RixLPEState;
49 struct RixBXLobeWeights;
50 
66 {
67 public:
68  virtual int GetInterface() const override
69  {
70  return k_RixLightFilter;
71  }
72 
76  virtual void Filter(RixLightFilterContext const* lfCtx, RtPointer instanceData,
77  int const numSamples, int const* shadingCtxIndex,
78  RtVector3 const* directions, float const* distances,
79  float const* lightPdfsDirect, RixBXLobeWeights* contribution) = 0;
80 
90  {
93  };
95 
97  RixLightFilterContext const* lfCtx,
98  RtConstPointer instanceData, float* result) const = 0;
99 
100  // Lights can be queried for general properties. If a particular property
101  // is unsupported, GetProperty() should return k_RixSCInvalidDetail.
102  // Otherwise, return k_RixSCUniform or k_RixSCVarying according to the
103  // detail of the result.
105  {
106  // RtUString: The group(s) to which the filter belongs for linking purposes.
107  // If empty, the light filter is enabled everywhere.
110  };
111 
112  virtual RixSCDetail GetProperty(RtConstPointer instanceData, LightFilterProperty prop,
113  void const** result) const = 0;
114 
115 protected:
117  {}
118  virtual ~RixLightFilter()
119  {}
120 
121 };
122 
123 // clang-format off
124 #define RIX_LIGHTFILTERPLUGINCREATE \
125  extern "C" PRMANEXPORT RixLightFilter* CreateRixLightFilter(const char* hint)
126 
127 #define RIX_LIGHTFILTERPLUGINDESTROY \
128  extern "C" PRMANEXPORT void DestroyRixLightFilter(RixLightFilter* modifier)
129 // clang-format on
130 
142 {
143 public:
144  int numPts;
145 
148  virtual bool IsEnabled(RtConstPointer instance, RtPointer* instanceData) const = 0;
149 
151  virtual void GetBuiltinVar(RixShadingContext::BuiltinVar, int const** var) const = 0;
152  virtual void GetBuiltinVar(RixShadingContext::BuiltinVar, float const** var) const = 0;
153  virtual void GetBuiltinVar(RixShadingContext::BuiltinVar, RtFloat3 const** var) const = 0;
154  virtual void GetBuiltinVar(RixShadingContext::BuiltinVar, RixLPEState* const** var) const = 0;
155 
157  virtual RixSCDetail GetPrimVar(RtUString const name, float fill, float const** var,
158  float const** radius = NULL) const = 0;
159  virtual RixSCDetail GetPrimVar(RtUString const name, RtFloat2 fill, RtFloat2 const** var,
160  float const** radius = NULL) const = 0;
161  virtual RixSCDetail GetPrimVar(RtUString const name, RtFloat3 fill, RtFloat3 const** var,
162  float const** radius = NULL) const = 0;
163  virtual RixSCDetail GetPrimVar(RtUString const name, RtUString const** var) const = 0;
164  virtual RixSCDetail GetPrimVar(RtUString const name, RtMatrix4x4 const& fill,
165  RtMatrix4x4 const** var) const = 0;
166 
171  virtual int Transform(RixShadingContext::TransformInterpretation interp,
172  RtUString const fromSpace, RtUString const toSpace, RtFloat3* var,
173  float* width = NULL) const = 0;
174 
175  // Separate source and destination arrays.
176  virtual int Transform(RixShadingContext::TransformInterpretation interp,
177  RtUString const fromSpace, RtUString const toSpace,
178  RtFloat3 const* srcVar, RtFloat3* dstVar, float const* srcWidth,
179  float* dstWidth) const = 0;
180 
188  virtual int Transform(RixShadingContext::TransformInterpretation interp,
189  RtUString const fromSpace, RtUString const toSpace, int numPts,
190  int const* shadingCtxIndex, RtFloat3 const* srcVar, RtFloat3* dstVar,
191  float const* srcWidth, float* dstWidth) const = 0;
198  // use "placement new" and not rely on invocation of a destructor.
199  virtual void* Allocate(size_t n, size_t size) const = 0;
200 
208  template <class T>
209  T* New(size_t nObjs) const
210  {
211  T* mem = static_cast<T*>(Allocate(nObjs, sizeof(T)));
212  return new (mem) T[nObjs];
213  }
214 
226  class Allocator
227  {
228  public:
229  Allocator(RixLightFilterContext const* lfCtx) : m_lfCtx(lfCtx)
230  {}
231  template <typename T>
232  T* Allocate(int num)
233  {
234  if (num == 0) return NULL;
235  return (T*)m_lfCtx->Allocate(num, sizeof(T));
236  }
237 
238  private:
239  RixLightFilterContext const* m_lfCtx;
240  };
241 
242 protected:
244  {}
245 };
246 
247 #endif
virtual void Filter(RixLightFilterContext const *lfCtx, RtPointer instanceData, int const numSamples, int const *shadingCtxIndex, RtVector3 const *directions, float const *distances, float const *lightPdfsDirect, RixBXLobeWeights *contribution)=0
The amount by which a light&#39;s radiance is multiplied.
void * RtPointer
Definition: ri.h:69
virtual ~RixLightFilter()
RixSCDetail
Definition: RixShading.h:376
virtual RixSCDetail GetProperty(RtConstPointer instanceData, LightFilterProperty prop, void const **result) const =0
Allocator(RixLightFilterContext const *lfCtx)
T * New(size_t nObjs) const
virtual ~RixLightFilterContext()
pxrcore::UString RtUString
#define k_RixShadingVersion
Definition: RixShading.h:97
pxrcore::Matrix4x4 RtMatrix4x4
Definition: RiTypesHelper.h:73
void const * RtConstPointer
Definition: ri.h:86
pxrcore::Float3 RtFloat3
Definition: RiTypesHelper.h:68
virtual bool GetRadianceModifier(FilterRadianceModifierProperty property, RixLightFilterContext const *lfCtx, RtConstPointer instanceData, float *result) const =0
virtual int GetInterface() const override
RtFloat3 RtVector3
Definition: RiTypesHelper.h:71