RenderManAPI  24.0
RixProjection.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 RixProjection_h
38 #define RixProjection_h
39 
40 #include "RixInterfaces.h" // for RixContext
41 #include "RixShading.h" // for RixParameterList (ptr only), etc
42 #include "prmanapi.h" // for PRMANEXPORT
43 #include "RiTypesHelper.h" // for RtPoint2
44 
46 struct RtRayGeometry;
47 
53 
55 {
56 public:
58 
59  int m_version;
60 
62  int width;
63  int height;
64 
67 
69  float clippingNear;
70  float clippingFar;
71 
77 
79  float shutterOpen;
80  float shutterClose;
81 
85  float const* worldToCameraTimes;
86 
87  char _reserved[32];
88 };
89 
91 {
92 public:
93 
98  {
102  };
103 
109  {
112  };
113 
114  // Projections can be queried at the beginning of rendering for
115  // general properties interesting to the renderer. They should
116  // return k_RixSCInvalidDetail if a particular property is
117  // unsupported. If a property is supported, k_RixSCUniform or
118  // k_RixSCVarying should be returned according to the detail of
119  // the result. A trivial implementation that supports no
120  // properties of any sort should simply return
121  // k_RixSCInvalidDetail.
123  {
124  // enum DicingHint - see above
126 
127  // enum DeepMetric - see above
129 
130  // float: field of view of the plugin for perspective and
131  // spherical. Used by the renderer as hint on how to dice
132  // geometry.
134 
135  // float: depth of field (defocus) for perspective projections
139  };
140 
141  virtual RixSCDetail GetProperty(
143  void const** result) const = 0;
144 
148 
149  virtual void Project(RixProjectionContext& pCtx) = 0;
150 
151  virtual void RenderBegin(RixContext& ctx, RixProjectionEnvironment const& env,
152  RixParameterList const* instanceParams) = 0;
153 
154  virtual void RenderEnd(RixContext& rixCtx) {
155  PIXAR_ARGUSED(rixCtx);
156  }
157 
158 protected:
159  virtual ~RixProjection() {};
160 };
161 
163 {
164 public:
165  int GetInterface() const override { return k_RixProjectionFactory; }
166 
167  // Projection plugins do not support InstanceData. As a consequence, the following methods are
168  // not expected to be implemented and won't be called by the renderer.
169  void CreateInstanceData(RixContext& rixCtx, RtUString const handle,
170  RixParameterList const* instanceParams,
171  InstanceData* instanceData) final
172  {
173  PIXAR_ARGUSED(rixCtx);
174  PIXAR_ARGUSED(handle);
175  PIXAR_ARGUSED(instanceParams);
176  PIXAR_ARGUSED(instanceData);
177  }
178 
179  void SynchronizeInstanceData(RixContext& rixCtx, RtUString const handle,
180  RixParameterList const* instanceParams, uint32_t const editHints,
181  InstanceData* instanceData) final
182  {
183  PIXAR_ARGUSED(rixCtx);
184  PIXAR_ARGUSED(handle);
185  PIXAR_ARGUSED(instanceParams);
186  PIXAR_ARGUSED(editHints);
187  PIXAR_ARGUSED(instanceData);
188  }
189 
191  RixContext& ctx,
192  RtUString const handle,
193  RixParameterList const* pList) = 0;
194 
195  virtual void DestroyProjection(RixProjection const* projection) = 0;
196 
197 protected:
199  ~RixProjectionFactory() override {}
200 };
201 
202 #define RIX_PROJECTIONFACTORYCREATE \
203  extern "C" PRMANEXPORT RixProjectionFactory* CreateRixProjectionFactory(RtUString const hint)
204 
205 #define RIX_PROJECTIONFACTORYDESTROY \
206  extern "C" PRMANEXPORT void DestroyRixProjectionFactory(RixProjectionFactory* factory)
207 
211 
213 {
214 public:
215  int numRays;
216 
222 
223  RtPoint2 const* screen;
224 
231 
232  RtPoint2 const* lens;
234 
241 
242  float* time;
243 
251 
253 
258 
260 
268 
269  virtual void TransformOrigins(
270  RtUString const fromSpace,
271  RtUString const toSpace) = 0;
272  virtual void TransformDirections(
273  RtUString const fromSpace,
274  RtUString const toSpace) = 0;
275 
276 protected:
278  ~RixProjectionContext() override {}
279 };
280 
281 #endif
RtPoint2 const * aperture
Definition: RixProjection.h:233
float * time
Time samples are the raw, canonical samples, distributed in the [0,1) range.
Definition: RixProjection.h:242
float screenWindowLeft
Screen window.
Definition: RixProjection.h:73
int height
Definition: RixProjection.h:63
unsigned worldToCameraNumSamples
World to camera transform.
Definition: RixProjection.h:83
float screenWindowRight
Definition: RixProjection.h:74
RixProjectionEnvironment()
Definition: RixProjection.h:57
pxrcore::ColorRGB RtColorRGB
Definition: RiTypesHelper.h:520
#define k_RixShadingVersion
Definition: RixShading.h:97
DeepMetric
Expresses depth metric to use for samples in deep output.
Definition: RixProjection.h:108
virtual RixSCDetail GetProperty(ProjectionProperty, void const **result) const =0
Rix interfaces are obtained from an RixContext.
Definition: RixInterfaces.h:172
float shutterOpen
Shutter.
Definition: RixProjection.h:79
virtual void DestroyProjection(RixProjection const *projection)=0
Definition: RixShading.h:117
RixShadingPlugin is the base class for RixBxdfFactory, RixDisplacementFactory, RixDisplayFilter, RixIntegrator, RixLightFilter, RixLightFactory, RixPattern, RixProjection, and RixSampleFilter.
Definition: RixShading.h:168
ProjectionProperty
Definition: RixProjection.h:122
Definition: RixProjection.h:136
RixProjection plugins characterize camera and lens projections.
Definition: RixProjection.h:54
Definition: RixProjection.h:99
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: RixProjection.h:179
int numRays
Definition: RixProjection.h:215
DicingHint
Dicing hint value, to be returned by GetProperty when ProjectionProperty == k_DicingHint.
Definition: RixProjection.h:97
Definition: RixProjection.h:162
RixSCDetail
RixSCDetail enumerates the valid sizing qualifiers for SC parameters.
Definition: RixShading.h:432
RixProjectionFactory()
Definition: RixProjection.h:198
void CreateInstanceData(RixContext &rixCtx, RtUString const handle, RixParameterList const *instanceParams, InstanceData *instanceData) final
CreateInstanceData() is called once per plugin-instance.
Definition: RixProjection.h:169
Definition: RiTypesHelper.h:82
virtual void TransformOrigins(RtUString const fromSpace, RtUString const toSpace)=0
Utility methods to transform the rays in-place from one space to another.
Definition: RixProjection.h:100
Definition: RixIntegrator.h:234
RixParameterList exposes the non-varying values that are associated with the definition or editing of...
Definition: RixShading.h:575
virtual void Project(RixProjectionContext &pCtx)=0
Project: is the primary entrypoint for this class.
Definition: RixProjection.h:138
float clippingFar
Definition: RixProjection.h:70
Definition: RixProjection.h:90
virtual RixProjection * CreateProjection(RixContext &ctx, RtUString const handle, RixParameterList const *pList)=0
Definition: RixProjection.h:111
Definition: RixProjection.h:125
RixProjectionContext()
Definition: RixProjection.h:277
int m_version
Definition: RixProjection.h:59
The RixProjectionContext bundles together the main inputs and outputs from the RixProjection::Project...
Definition: RixProjection.h:212
RtMatrix4x4 const * worldToCameraMatrix
Definition: RixProjection.h:84
RtPoint2 const * lens
The lens samples are the raw, canonical samples, uniformly distributed in the [0,1)^2 unit square...
Definition: RixProjection.h:232
~RixProjectionFactory() override
Definition: RixProjection.h:199
virtual void RenderBegin(RixContext &ctx, RixProjectionEnvironment const &env, RixParameterList const *instanceParams)=0
float screenWindowTop
Definition: RixProjection.h:75
float clippingNear
Distance to near and far clipping plane.
Definition: RixProjection.h:69
RtPoint2 const * screen
The screen samples represent samples in screen space with subpixel precision.
Definition: RixProjection.h:223
int GetInterface() const override
Definition: RixProjection.h:165
virtual void RenderEnd(RixContext &rixCtx)
Definition: RixProjection.h:154
Definition: RixProjection.h:128
RtColorRGB * tint
An optional tint to apply to the beauty channel of the shaded rays before pixel filtering.
Definition: RixProjection.h:259
~RixProjectionContext() override
Definition: RixProjection.h:278
int width
Width and height of the image in pixels.
Definition: RixProjection.h:62
pxrcore::Matrix4x4 RtMatrix4x4
Definition: RiTypesHelper.h:74
virtual ~RixProjection()
Definition: RixProjection.h:159
float pixelAspectRatio
Aspect ratio of pixels.
Definition: RixProjection.h:66
pxrcore::UString RtUString
Definition: RiTypesHelper.h:682
Definition: RixProjection.h:133
virtual void TransformDirections(RtUString const fromSpace, RtUString const toSpace)=0
Definition: RixShading.h:280
float const * worldToCameraTimes
Definition: RixProjection.h:85
float shutterClose
Definition: RixProjection.h:80
RtRayGeometry * rays
Projection plugin will normally use the above data to fill the origin, direction, originRadius...
Definition: RixProjection.h:252
float screenWindowBottom
Definition: RixProjection.h:76
Definition: RixProjection.h:110
Definition: RixProjection.h:101
Definition: RixProjection.h:137
char _reserved[32]
Definition: RixProjection.h:87
#define PIXAR_ARGUSED(x)
Definition: prmanapi.h:170