Cycles OSL: fix mistake in recent refactoring, parameters are not set before setup.

This commit is contained in:
Brecht Van Lommel
2013-11-29 17:17:00 +01:00
parent 3bf77c34eb
commit 4d6c877b66
5 changed files with 23 additions and 2 deletions

View File

@@ -50,6 +50,9 @@ public:
float3 fcolors[8];
DiffuseRampClosure() : CBSDFClosure(LABEL_DIFFUSE)
{}
void setup()
{
sc.prim = this;
m_shaderdata_flag = bsdf_diffuse_ramp_setup(&sc);

View File

@@ -49,6 +49,9 @@ public:
float3 fcolors[8];
PhongRampClosure() : CBSDFClosure(LABEL_GLOSSY)
{}
void setup()
{
sc.prim = this;
m_shaderdata_flag = bsdf_phong_ramp_setup(&sc);

View File

@@ -52,6 +52,9 @@ using namespace OSL;
class CubicBSSRDFClosure : public CBSSRDFClosure {
public:
CubicBSSRDFClosure()
{}
void setup()
{
sc.type = CLOSURE_BSSRDF_CUBIC_ID;
sc.data0 = fabsf(average(radius));
@@ -90,6 +93,9 @@ CCLOSURE_PREPARE(closure_bssrdf_cubic_prepare, CubicBSSRDFClosure)
class GaussianBSSRDFClosure : public CBSSRDFClosure {
public:
GaussianBSSRDFClosure()
{}
void setup()
{
sc.type = CLOSURE_BSSRDF_GAUSSIAN_ID;
sc.data0 = fabsf(average(radius));

View File

@@ -96,8 +96,9 @@ public:
AmbientOcclusion, ///< Ambient occlusion
};
CClosurePrimitive (Category category_) : category (category_) { }
CClosurePrimitive (Category category_) : category (category_) {}
virtual ~CClosurePrimitive() {}
virtual void setup() {}
Category category;
};
@@ -110,7 +111,7 @@ public:
CBSDFClosure(int scattering) : CClosurePrimitive(BSDF),
m_scattering_label(scattering), m_shaderdata_flag(0)
{ }
{}
int scattering() const { return m_scattering_label; }
int shaderdata_flag() const { return m_shaderdata_flag; }
@@ -135,6 +136,10 @@ protected:
class Upper##Closure : public CBSDFClosure { \
public: \
Upper##Closure() : CBSDFClosure(TYPE) \
{ \
} \
\
void setup() \
{ \
sc.prim = NULL; \
m_shaderdata_flag = bsdf_##lower##_setup(&sc); \

View File

@@ -156,6 +156,8 @@ static void flatten_surface_closure_tree(ShaderData *sd, int path_flag,
sc.weight = weight;
#endif
prim->setup();
switch (prim->category) {
case CClosurePrimitive::BSDF: {
CBSDFClosure *bsdf = (CBSDFClosure *)prim;
@@ -395,6 +397,8 @@ static void flatten_volume_closure_tree(ShaderData *sd,
sc.weight = weight;
#endif
prim->setup();
switch (prim->category) {
case CClosurePrimitive::Volume: {
/* sample weight */