Commit 987c8cf5 authored by Laurent Belcour's avatar Laurent Belcour

Debuging the product function. Need to rewritte the loading/saving

parent 11476f65
......@@ -73,13 +73,13 @@ vec product(const vec& a, const vec& b)
}
else
{
#ifdef DEBUG
#ifndef DEBUG
assert(a.size() == b.size());
#endif
vec res(b.size());
for(int i=0; i<b.size(); ++i)
{
res[i] = a[0]*b[i];
res[i] = a[i]*b[i];
}
return res;
}
......
......@@ -535,22 +535,28 @@ void product_function::setDimX(int nX)
{
f1->setDimX(nX);
f2->setDimX(nX);
function::setDimX(f1->dimX());
}
void product_function::setDimY(int nY)
{
f1->setDimY(nY);
f2->setDimY(nY);
function::setDimY(f1->dimY());
}
void product_function::setMin(const vec& min)
{
function::setMin(min);
f1->setMin(min);
f2->setMin(min);
}
void product_function::setMax(const vec& max)
{
function::setMax(max);
f1->setMax(max);
f2->setMax(max);
}
......@@ -574,7 +580,7 @@ vec product_function::parameters() const
params[i] = f1_params[i];
}
vec f2_params = parameters();
vec f2_params = f2->parameters();
for(int i=0; i<nb_f2_params; ++i)
{
params[i+nb_f1_params] = f2_params[i];
......
......@@ -359,9 +359,10 @@ function* plugins_manager::get_function(const arguments& args)
}
}
fresnel* func_fres = dynamic_cast<fresnel*>(get_function(arguments::create_arguments(n)));
func_fres->setBase(nl_func);
return func_fres;
nonlinear_function* func_fres = dynamic_cast<nonlinear_function*>(get_function(arguments::create_arguments(n)));
// func_fres->setBase(nl_func);
// return func_fres;
return new product_function(nl_func, func_fres);
}
......
......@@ -17,7 +17,7 @@ ALTA_DLL_EXPORT function* provide_function()
//! Load function specific files
bool schlick::load(std::istream& in)
{
fresnel::load(in);
// fresnel::load(in);
// Parse line until the next comment
while(in.peek() != '#')
......@@ -59,15 +59,6 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
{
bool is_alta = !args.is_defined("export") || args["export"] == "alta";
if(is_alta)
{
f->save_call(out, args);
}
else
{
out << "("; f->save_call(out, args); out << ")";
}
if(is_alta)
{
out << "#FUNC nonlinear_fresnel_schlick" << std::endl ;
......@@ -79,7 +70,7 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
}
else
{
out << " * schlick_fresnel(L, V, N, X, Y, vec3(";
out << "schlick_fresnel(L, V, N, X, Y, vec3(";
for(int i=0; i<dimY(); ++i)
{
out << R[i];
......@@ -91,7 +82,6 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
void schlick::save_body(std::ostream& out, const arguments& args) const
{
f->save_body(out, args);
bool is_shader = args["export"] == "shader" || args["export"] == "explorer";
if(is_shader)
......@@ -107,7 +97,7 @@ void schlick::save_body(std::ostream& out, const arguments& args) const
}
vec schlick::fresnelValue(const vec& x) const
vec schlick::value(const vec& x) const
{
double xp[3], cart[6];
params::convert(&x[0], input_parametrization(), params::RUSIN_VH, xp);
......@@ -115,8 +105,8 @@ vec schlick::fresnelValue(const vec& x) const
const double dotVH = xp[0]*cart[0] + xp[1]*cart[1] + xp[2]*cart[2];
vec res(_nY);
for(int i=0; i<_nY; ++i)
vec res(dimY());
for(int i=0; i<dimY(); ++i)
{
res[i] = R[i] + (1.0 - R[i]) * pow(1.0 - clamp(dotVH, 0.0, 1.0), 5.0);
}
......@@ -125,12 +115,12 @@ vec schlick::fresnelValue(const vec& x) const
}
//! \brief Number of parameters to this non-linear function
int schlick::nbFresnelParameters() const
int schlick::nbParameters() const
{
return dimY();
}
vec schlick::getFresnelParametersMin() const
vec schlick::getParametersMin() const
{
vec m(dimY());
for(int i=0; i<dimY(); ++i) { m[i] = 0.0; }
......@@ -138,7 +128,7 @@ vec schlick::getFresnelParametersMin() const
}
//! Get the vector of min parameters for the function
vec schlick::getFresnelParametersMax() const
vec schlick::getParametersMax() const
{
vec M(dimY());
for(int i=0; i<dimY(); ++i) { M[i] = 1.0; }
......@@ -146,7 +136,7 @@ vec schlick::getFresnelParametersMax() const
}
//! \brief Get the vector of parameters for the function
vec schlick::getFresnelParameters() const
vec schlick::parameters() const
{
vec p(dimY());
for(int i=0; i<dimY(); ++i) { p[i] = R[i]; }
......@@ -154,14 +144,14 @@ vec schlick::getFresnelParameters() const
}
//! \brief Update the vector of parameters for the function
void schlick::setFresnelParameters(const vec& p)
void schlick::setParameters(const vec& p)
{
for(int i=0; i<dimY(); ++i) { R[i] = p[i]; }
}
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
vec schlick::getFresnelParametersJacobian(const vec& x) const
vec schlick::parametersJacobian(const vec& x) const
{
const int nY = dimY();
double xp[3], cart[6];
......@@ -185,7 +175,7 @@ vec schlick::getFresnelParametersJacobian(const vec& x) const
}
void schlick::fresnelBootstrap(const data* d, const arguments& args)
void schlick::bootstrap(const data* d, const arguments& args)
{
for(int i=0; i<dimY(); ++i) { R[i] = 1.0; }
}
......@@ -12,53 +12,59 @@
#include <core/common.h>
class schlick : public fresnel
class schlick : public nonlinear_function//fresnel
{
public: // methods
schlick()
{
setParametrization(params::CARTESIAN);
}
//! \brief Load function specific files
virtual bool load(std::istream& in) ;
virtual bool load(std::istream& in) ;
virtual void save_call(std::ostream& out, const arguments& args) const;
virtual void save_body(std::ostream& out, const arguments& args) const;
protected: // methods
virtual vec fresnelValue(const vec& x) const;
virtual vec operator()(const vec& x) const { return value(x); }
virtual vec value(const vec& x) const;
//! \brief Number of parameters to this non-linear function
virtual int nbFresnelParameters() const ;
virtual int nbParameters() const ;
//! \brief Get the vector of parameters for the function
virtual vec getFresnelParameters() const ;
virtual vec parameters() const ;
//! \brief Update the vector of parameters for the function
virtual void setFresnelParameters(const vec& p) ;
virtual void setParameters(const vec& p) ;
//! Get the vector of min parameters for the function
virtual vec getFresnelParametersMin() const;
virtual vec getParametersMin() const;
//! Get the vector of min parameters for the function
virtual vec getFresnelParametersMax() const;
virtual vec getParametersMax() const;
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
virtual vec getFresnelParametersJacobian(const vec& x) const ;
virtual vec parametersJacobian(const vec& x) const ;
//! \brief Boostrap the function by defining the diffuse term
virtual void fresnelBootstrap(const data* d, const arguments& args);
virtual void bootstrap(const data* d, const arguments& args);
//! \brief resize the parameter vector
virtual void setDimY(int nY)
{
fresnel::setDimY(nY);
R.resize(nY);
}
//! \brief resize the parameter vector
virtual void setDimY(int nY)
{
function::setDimY(nY);
R.resize(nY);
}
private: // data
//! Unidimensional Fresnel reflectance at theta = 0
vec R;
//! Fresnel reflectance at theta = 0
vec R;
} ;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment