1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
#ifndef _SHAVERENDER_H_
#define _SHAVERENDER_H_
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#include <stdio.h>
#include <list>
#include <maya/MColor.h>
#include <maya/MColorArray.h>
#include <maya/MDagPath.h>
#include <maya/MDagPathArray.h>
#include <maya/MFloatArray.h>
#include <maya/MIntArray.h>
#include <maya/MObjectArray.h>
#include <maya/MSceneMessage.h>
#include <maya/MSelectionList.h>
#include <maya/MStringArray.h>
#include <maya/MTime.h>
#include "shaveConstant.h"
#include "shaveGlobals.h"
#include "shaveIO.h"
#include "shaveSDK.h"
#define OCCLUSIONS_IN_DRA 1
#if MAYA_API_VERSION < 20180000
class MDagPath;
class MFnCamera;
#endif
class shaveRenderCallback;
class shaveRenderer;
class shaveRender
{
//need a frank to update shave camera interactively
//during viewport draws -- vlad|03Jun2010
friend class shaveHairUI;
public:
typedef struct
{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
} Pixel;
typedef struct
{
MDagPath cameraPath;
bool nearClipChanged;
double origNearClip;
bool farClipChanged;
double origFarClip;
} AutoClipInfo;
typedef std::list<AutoClipInfo> AutoClipList;
typedef std::list<AutoClipInfo>::iterator AutoClipListIter;
typedef struct
{
WFTYPE shutterOpenCamScene;
WFTYPE shutterCloseCamScene;
WFTYPE shutterOpenShadowScene;
WFTYPE shutterCloseShadowScene;
Pixel* shaveRenderPixels;
float* shaveZBuffer;
int width;
int height;
int aa;
float currentFrame;
float frameOffset;
bool bufferValid;
AutoClipList autoClipCameras;
bool shaveTraceInitialized;
bool haveTracedLights;
} SceneInfo;
enum RenderState
{
kRenderNone,
kRendering,
kRenderingFrame
};
static void bufferRender(
shaveConstant::ShutterState shutter,
const MDagPath& cameraPath,
float frame,
bool needBuffers,
bool doShadowRender,
bool doCameraRender,
bool doOcclusions
);
static void bufferRenderCleanup();
static void buildHairStack(
MObjectArray& shaveNodes,
shaveConstant::ShutterState shutter
);
static void buildOcclusionLists(shaveConstant::ShutterState shutter);
static void cleanupCallbacks();
static void clearHairStack(MObjectArray& shaveHairShapes);
static bool exportIsActive() { return mExportActive; }
static void exportEnd();
static void exportStart();
static void exportStart(MString exportFile);
static void exportStart(
MString exportFile,
bool filePerFrame,
shaveConstant::FileNameFormat nameFormat,
unsigned framePadding,
unsigned compression
);
static void frameEnd(void* clientData);
static void frameStart(void* clientData);
static void geomRender(MObjectArray& shaveNodes);
static void getExportFileInfo(
MString& exportFile,
bool& filePerFrame,
shaveConstant::FileNameFormat& nameFormat,
unsigned& framePadding,
unsigned& compression
);
static const shaveGlobals::Globals&
getFrameGlobals() { return mFrameGlobals; }
static MDagPath getRenderCamPath();
static MString getRenderModeName(shaveConstant::RenderMode mode);
static shaveRenderer* getRenderer();
static SceneInfo* getSceneInfo();
static MStatus getShutterTimes(
float& shutterOpen, float& shutterClose
);
static bool isFirstFrame();
static int renderCameraView(const MDagPath& cameraPath);
static void renderCameraViewCleanup();
static void renderEnd(void* clientData);
static bool rendererIsVray(); //vlad|15Apr2010
static bool rendererIsPrMan();
static void renderStart(void* clientData);
static shaveRender::RenderState renderState();
static MStatus renderSwatch(
MObject shaveNode,
unsigned int resolution,
MString fileName
);
// This method will use Maya's motion blur settings. If you need
static MStatus renderToDRAFile(
SHAVE_RENDER_HOST renderHost,
const MString& fileName,
int voxelResolution,
bool includeOcclusions = false
);
static MStatus renderToDRAFile(
SHAVE_RENDER_HOST renderHost,
const MString& fileName,
int voxelResolution,
MObjectArray shaveNodes,
bool doMotionBlur,
float shutterOpen,
float shutterClose,
bool updateTextureCache,
bool includeOcclusions = false
);
static void saveFrameGlobals()
{ shaveGlobals::getGlobals(mFrameGlobals); }
static void setupCallbacks();
///////////////////////
//static void shutterOpen();
//static void shutterClose();
//static void shutterExport(MString fileName);
///////////////////////
static void vrayKeyFrame();
static void portFieldOfView(
int width,
int height,
double pixelAspect,
double& horizontal,
double& vertical,
MFnCamera& fnCamera
);
protected:
static void computeViewingFrustum(
double window_aspect,
double &left,
double &right,
double &bottom,
double &top,
MFnCamera& cam
);
static void doCamera(
const MDagPath& camPath,
shaveConstant::ShutterState shutter,
SceneInfo& shaveData
);
static void doColorCorrection(
MColor colorMod,
short mapWidth,
short mapHeight,
unsigned char* mapBuffer
);
static void doDensityCorrection(
float density,
short mapWidth,
short mapHeight,
unsigned char* mapBuffer
);
static void doLights();
static void doShadows();
static void initSceneInfo(float frame, bool allocateBuffers);
static bool isIPRActive();
static void renderInterrupted(void* clientData);
static void timeChanged(MTime& newTime, void* clientData);
public:
static bool mHaveInstancedHair;
static bool mHaveNormalHair;
static MObjectArray mHiddenNodes;
static bool mNeedVertexColours;
static shaveConstant::ShadowSource mNormalShadows;
static RenderState mRenderState;
protected:
static bool mCallbacksSet;
static bool mFirstFrame;
static shaveGlobals::Globals mFrameGlobals;
static MIntArray mDisplayModes;
static bool mExportActive;
static unsigned mExportFileCompression;
static unsigned mExportFileFramePadding;
static MString mExportFileName;
static shaveConstant::FileNameFormat mExportFileNameFormat;
static bool mExportFilePerFrame;
static shaveConstant::RenderMode mHairRenderMode;
static bool mRenderAllInstanceHairs;
static bool mRenderAllNormalHairs;
static shaveRenderer* mRenderer;
static bool mRenderInstances;
static SceneInfo mSceneInfo;
static MObjectArray mTemplatedNodes;
//
// Callback Handles
//
static MCallbackId mAfterFrameRenderCallback;
static MCallbackId mAfterRenderCallback;
static MCallbackId mBeforeFrameRenderCallback;
static MCallbackId mBeforeRenderCallback;
static MCallbackId mRenderInterruptedCallback;
static MCallbackId mTimeChangeCallback;
static shaveRenderCallback* mShaveCallback;
};
inline shaveRender::RenderState shaveRender::renderState()
{ return mRenderState; }
inline shaveRender::SceneInfo* shaveRender::getSceneInfo()
{ return &mSceneInfo; }
inline bool shaveRender::isFirstFrame()
{ return mFirstFrame; }
extern bool shaveRenderCancelled;
extern bool shaveEnableProgressBar;
#endif
|