Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 2f74d8da by Laurent Belcour

### Adding a Spherical Gaussian distribution for analysis

parent c0f15e40
 ... ... @@ -175,7 +175,7 @@ void blinn_function::save_body(std::ostream& out, out << "{" << std::endl; out << "\tvec3 H = normalize(L + V);" << std::endl; out << "\tvec3 ext_dot = vec3(dot(H,N));" << std::endl; out << "\treturn pow(max(ext_dot, vec3(0,0,0)), Nl);" << std::endl; out << "\treturn ks * pow(max(ext_dot, vec3(0,0,0)), Nl);" << std::endl; out << "}" << std::endl; } ... ...
 #include "function.h" #include #include #include #include #include #include #include #include ALTA_DLL_EXPORT function* provide_function() { return new spherical_gaussian_function(); } // Overload the function operator vec spherical_gaussian_function::operator()(const vec& x) const { return value(x); } vec spherical_gaussian_function::value(const vec& x) const { vec res(dimY()); double dot; params::convert(&x[0], params::CARTESIAN, params::COS_TH, &dot); for(int i=0; i> token; if(token.compare("#FUNC") != 0) { std::cerr << "<> parsing the stream. The #FUNC is not the next line defined." << std::endl; } in >> token; if(token.compare("nonlinear_function_spherical_gaussian") != 0) { std::cerr << "<> parsing the stream. function name is not the next token." << std::endl; } // Parse the lobe for(int i=0; i<_nY; ++i) { in >> token >> _ks[i]; in >> token >> _n[i]; } } void spherical_gaussian_function::save_call(std::ostream& out, const arguments& args) const { bool is_alta = !args.is_defined("export") || args["export"] == "alta"; if(is_alta) { out << "#FUNC nonlinear_function_spherical_gaussian" << std::endl ; for(int i=0; i<_nY; ++i) { out << "Ks " << _ks[i] << std::endl; out << "N " << _n[i] << std::endl; } out << std::endl; } else { out << "spherical_gaussian(L, V, N, X, Y, vec3("; for(int i=0; i<_nY; ++i) { out << _ks[i]; if(i < _nY-1) { out << ", "; } } out << "), vec3("; for(int i=0; i<_nY; ++i) { out << _n[i]; if(i < _nY-1) { out << ", "; } } out << "))"; } } void spherical_gaussian_function::save_body(std::ostream& out, const arguments& args) const { bool is_shader = args["export"] == "shader" || args["export"] == "explorer"; if(is_shader) { out << "vec3 spherical_gaussian(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, vec3 ks, vec3 Nl)" << std::endl; out << "{" << std::endl; out << "\tvec3 H = normalize(L + V);" << std::endl; out << "\tvec3 ext_dot = vec3(dot(H,N));" << std::endl; out << "\treturn ks * exp(Nl * (ext_dot - vec3(1)));" << std::endl; out << "}" << std::endl; } }
 #pragma once // Include STL #include #include // Interface #include #include #include #include #include /*! \brief A spherical Gaussian lobe class. * * \details * A spherical_gaussian lobe is defined as \f\$k_s exp(n (v.p - * 1))\f\$. Where \f\$n\f\$ is the roughness control and \f\$p\f\$ * is the lobe direction and \f\$v\f\$ the evaluation direction. * * *

Plugin parameters

* *
*
• bootstrap function will read the arguments to set * lobe and evaluation directions.
• *
*/ class spherical_gaussian_function : public nonlinear_function { public: // methods spherical_gaussian_function() : _n(1) { setParametrization(params::CARTESIAN); setDimX(6); } // Overload the function operator virtual vec operator()(const vec& x) const ; virtual vec value(const vec& x) const ; //! \brief Load function specific files virtual void load(std::istream& in) ; //! \brief Export function virtual void save_call(std::ostream& out, const arguments& args) const; virtual void save_body(std::ostream& out, const arguments& args) const; //! \brief Boostrap the function by defining the diffuse term //! //! \details virtual void bootstrap(const data* d, const arguments& args); //! \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 get the min values for the parameters virtual vec getParametersMin() 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 virtual int dimX() const { return 6; } //! \brief Set the number of output dimensions void setDimY(int nY); //! \brief Set the number of lobes to be used in the fit void setNbLobes(int N); private: // methods private: // data vec _n, _ks; // Lobes data } ;
 TEMPLATE = lib CONFIG *= plugin \ eigen DESTDIR = ../../build INCLUDEPATH += ../.. HEADERS = function.h SOURCES = function.cpp LIBS += -L../../build \ -lcore
 ... ... @@ -17,6 +17,7 @@ SUBDIRS = \ nonlinear_function_diffuse \ nonlinear_function_blinn \ nonlinear_function_retroblinn \ nonlinear_function_spherical_gaussian \ nonlinear_function_lafortune \ nonlinear_function_isotropic_lafortune \ data_merl \ ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!