RenderMan  26.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
84  RtMatrix4x4 const* worldToCameraMatrix;
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;
233  RtPoint2 const* aperture;
234 
241 
242  float* time;
243 
251 
253 
258 
259  RtColorRGB* tint;
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