Commit 35018597 authored by Laurent Belcour's avatar Laurent Belcour

Adding a stub for the Schlick Fresnel

parent 9d89132e
......@@ -5,6 +5,7 @@
#include <cassert>
#include <cmath>
#include <cstring>
#include <algorithm>
/*! \brief A core implementation of a vector of double.
* \ingroup core
......@@ -238,6 +239,11 @@ template<typename T> int is_in(std::vector<T> ve, T v)
return res;
}
template<typename T> T clamp(T x, T a, T b)
{
return std::max<T>(std::min<T>(x, b), a);
}
#define NOT_IMPLEMENTED() \
std::cerr << "<<ERROR>> not implemented " << __FILE__ \
<< ":" << __LINE__ << std::endl; \
......@@ -251,4 +257,4 @@ throw
#define ALTA_DLL_EXPORT extern "C" __declspec(dllexport)
#else
#define ALTA_DLL_EXPORT extern "C"
#endif
\ No newline at end of file
#endif
#include "function.h"
#include <string>
#include <iostream>
#include <fstream>
#include <limits>
#include <algorithm>
#include <cmath>
#include <core/common.h>
ALTA_DLL_EXPORT function* provide_function()
{
return new schlick();
}
// Overload the function operator
vec schlick::operator()(const vec& x) const
{
return value(x);
}
vec schlick::value(const vec& x) const
{
vec res(_nY);
for(int i=0; i<_nY; ++i)
{
res[i] = R + (1.0 - R) * pow(1.0 - clamp(x[0], 0.0, 1.0), 5.0);
}
return res;
}
//! Load function specific files
void schlick::load(const std::string& filename)
{
std::cerr << "Cannot load a Schlick file." << std::endl;
throw;
}
//! Number of parameters to this non-linear function
int schlick::nbParameters() const
{
return 0;
}
//! Get the vector of parameters for the function
vec schlick::parameters() const
{
vec r(0);
return r;
}
//! Update the vector of parameters for the function
void schlick::setParameters(const vec& p)
{
}
//! Obtain the derivatives of the function with respect to the
//! parameters.
vec schlick::parametersJacobian(const vec& x) const
{
vec r(0);
return r;
}
void schlick::bootstrap(const data* d, const arguments& args)
{
}
#pragma once
// Include STL
#include <vector>
#include <string>
// Interface
#include <core/function.h>
#include <core/data.h>
#include <core/fitter.h>
#include <core/args.h>
#include <core/common.h>
class schlick : public nonlinear_function
{
public: // methods
// Overload the function operator
virtual vec operator()(const vec& x) const ;
virtual vec value(const vec& x) const ;
//! \brief Boostrap the function by defining the diffuse term
virtual void bootstrap(const data* d, const arguments& args);
//! \brief Load function specific files
virtual void load(const std::string& filename) ;
//! \brief Number of parameters to this non-linear function
virtual int nbParameters() const ;
//! \brief Get the vector of parameters for the function
virtual vec parameters() const ;
//! \brief Update the vector of parameters for the function
virtual void setParameters(const vec& p) ;
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
virtual vec parametersJacobian(const vec& x) const ;
//! \brief Provide the dimension of the input space of the function
inline virtual int dimX() const
{
return 1;
}
inline virtual int dimY() const
{
return 1;
}
//! \brief Provide the parametrization of the input space of the function.
//! For this one, we fix that the parametrization is in THETAD_PHID
virtual params::input parametrization() const;
virtual void setParametrization(params::input new_param);
protected: // methods
private: // data
//! Unidimensional Fresnel reflectance at theta = 0
double R;
} ;
TEMPLATE = lib
CONFIG *= plugin
DESTDIR = ../../build
INCLUDEPATH += ../..
HEADERS = function.h
SOURCES = function.cpp
LIBS += -L../../build \
-lcore
......@@ -54,12 +54,6 @@ struct EigenFunctor: Eigen::DenseFunctor<double>
for(int i=0; i<_f->dimY(); ++i)
y(i*_d->size() + s) = _y[i];
/*
// Cosine term. It is supposed to improve the quality of the fit (see Ngan '05).
vec x2(3);
params::convert(&_x[0], _d->input_parametrization(), params::ISOTROPIC_TV_TL_DPHI, &x2[0]);
y *= cos(x2[1]);
*/
}
#ifdef DEBUG
std::cout << "diff vector:" << std::endl << y << std::endl << std::endl ;
......@@ -83,12 +77,7 @@ struct EigenFunctor: Eigen::DenseFunctor<double>
// Get the associated jacobian
vec _jac = _f->parametersJacobian(xi);
/*
// Cosine term. It is supposed to improve the quality of the fit (see Ngan '05).
vec x2(3);
params::convert(&xi[0], _d->input_parametrization(), params::ISOTROPIC_TV_TL_DPHI, &x2[0]);
_jac = _jac * cos(x2[1]);
*/
// Fill the columns of the matrix
#ifdef DEBUG
Eigen::MatrixXd temp (_f->dimY(), _f->nbParameters());
......
TEMPLATE = subdirs
SUBDIRS = \
rational_fitter_cgal \
rational_fitter_quadprog \
# rational_fitter_parallel \
rational_fitter_eigen \
rational_fitter_leastsquare \
rational_function_chebychev \
rational_fitter_matlab \
# rational_fitter_dca \
nonlinear_levenberg_eigen \
nonlinear_function_phong \
nonlinear_function_lafortune \
nonlinear_function_isotropic_lafortune \
data_merl \
# data_astm
rational_fitter_cgal \
rational_fitter_quadprog \
# rational_fitter_parallel \
rational_fitter_eigen \
rational_fitter_leastsquare \
rational_function_chebychev \
rational_fitter_matlab \
# rational_fitter_dca \
nonlinear_levenberg_eigen \
nonlinear_fresnel_schlick \
nonlinear_function_phong \
nonlinear_function_lafortune \
nonlinear_function_isotropic_lafortune \
data_merl \
# data_astm
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