#ifndef _SHAVERENDER_H_ #define _SHAVERENDER_H_ // Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 #include #include #include #include #include #include #include #include #include #include #include #include #include #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 AutoClipList; typedef std::list::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