Skip to content

Commit

Permalink
Refactor plugin for 3dsmax to share sampler with vray standalone.
Browse files Browse the repository at this point in the history
However, this currently only works with vray4.
Also, had to disable dynamic load.
  • Loading branch information
petermcevoy committed Feb 14, 2021
1 parent 8878a2f commit 5af5b5b
Show file tree
Hide file tree
Showing 17 changed files with 1,723 additions and 2,412 deletions.
56 changes: 4 additions & 52 deletions frontends/vray/vray_thunderloom.cpp
Original file line number Diff line number Diff line change
@@ -1,64 +1,16 @@
// Disable MSVC warnings for external headers.
#pragma warning( push )
#pragma warning( disable : 4251)
#pragma warning( disable : 4996 )
#include "vrayplugins.h"
#include "utils.h"
#include "vrayinterface.h"
#include "vrayrenderer.h"
#include "brdfs.h"
#include "vraytexutils.h"
#include "defparams.h"
#pragma warning( pop )
// Make thunderloom.h (which is included in vray_thunderloom.h)
// expand the implementation code when including here.
#define TL_THUNDERLOOM_IMPLEMENTATION
#include "vray_thunderloom.h"

// NOTE: Some conditional changes in the code to deal with smaller api changes between vray 4 and 5.
#ifndef BUILD_VRAY5
#define BUILD_VRAY5 VRAY_DLL_VERSION_MAJOR >= 5
#endif

#define TL_THUNDERLOOM_IMPLEMENTATION
#include "thunderloom.h"
using namespace VUtils;
using namespace VR;

class BRDFThunderLoomSampler: public BRDFSampler, public BSDFSampler {
int orig_backside;
ShadeVec normal, gnormal;
ShadeMatrix nm, inm;
int nmInited;

// Assigned in init()
tlWeaveParameters* m_tl_wparams;
ShadeVec m_uv;
ShadeTransform m_uv_tm;
ShadeCol m_diffuse_color;
tlYarnType m_yarn_type;
int m_yarn_type_id;

public:
// Initialization
void init(const VRayContext &rc, tlWeaveParameters *weave_parameters);

// From BRDFSampler
ShadeVec getDiffuseNormal(const VR::VRayContext &rc);
ShadeCol getDiffuseColor(ShadeCol &lightColor);
ShadeCol getLightMult(ShadeCol &lightColor);
ShadeCol getTransparency(const VRayContext &rc);

ShadeCol eval( const VRayContext &rc, const ShadeVec &direction, ShadeCol &shadowedLight, ShadeCol &origLight, float probLight,int flags);
void traceForward(VRayContext &rc, int doDiffuse);

int getNumSamples(const VRayContext &rc, int doDiffuse);
VRayContext* getNewContext(const VRayContext &rc, int &samplerID, int doDiffuse);
ValidType setupContext(const VRayContext &rc, VRayContext &nrc, float uc, int doDiffuse);

RenderChannelsInfo* getRenderChannels(void);

// From BSDFSampler
BRDFSampler *getBRDF(BSDFSide side);
};


struct BRDFThunderLoomParams: VRayParameterListDesc {
BRDFThunderLoomParams(void) {
addParamString("filepath", "", -1, "File path to pattern file");
Expand Down
53 changes: 53 additions & 0 deletions frontends/vray/vray_thunderloom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

// Disable MSVC warnings for external headers.
#pragma warning( push )
#pragma warning( disable : 4251)
#pragma warning( disable : 4996 )
#include "vrayplugins.h"
#include "utils.h"
#include "vrayinterface.h"
#include "vrayrenderer.h"
#include "brdfs.h"
#include "vraytexutils.h"
#include "defparams.h"
#pragma warning( pop )

#include "thunderloom.h"

class BRDFThunderLoomSampler: public VR::BRDFSampler, public VR::BSDFSampler {
int orig_backside;
VUtils::ShadeVec normal, gnormal;
VUtils::ShadeMatrix nm, inm;
int nmInited;

// Assigned in init()
tlWeaveParameters* m_tl_wparams;
VUtils::ShadeVec m_uv;
VUtils::ShadeTransform m_uv_tm;
VUtils::ShadeCol m_diffuse_color;
tlYarnType m_yarn_type;
int m_yarn_type_id;

public:
// Initialization
void init(const VUtils::VRayContext &rc, tlWeaveParameters *weave_parameters);

// From BRDFSampler
VUtils::ShadeVec getDiffuseNormal(const VR::VRayContext &rc);
VUtils::ShadeCol getDiffuseColor(VUtils::ShadeCol &lightColor);
VUtils::ShadeCol getLightMult(VUtils::ShadeCol &lightColor);
VUtils::ShadeCol getTransparency(const VUtils::VRayContext &rc);

VUtils::ShadeCol eval( const VUtils::VRayContext &rc, const VUtils::ShadeVec &direction, VUtils::ShadeCol &shadowedLight, VUtils::ShadeCol &origLight, float probLight,int flags);
void traceForward(VUtils::VRayContext &rc, int doDiffuse);

int getNumSamples(const VUtils::VRayContext &rc, int doDiffuse);
VUtils::VRayContext* getNewContext(const VUtils::VRayContext &rc, int &samplerID, int doDiffuse);
VUtils::ValidType setupContext(const VUtils::VRayContext &rc, VUtils::VRayContext &nrc, float uc, int doDiffuse);

VUtils::RenderChannelsInfo* getRenderChannels(void);

// From BSDFSampler
BRDFSampler *getBRDF(VUtils::BSDFSide side);
};
Loading

0 comments on commit 5af5b5b

Please sign in to comment.