Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit e33c1724 authored by Laurent Belcour's avatar Laurent Belcour

Adding export of the phong BRDF to BRDF explorer

parent e8b02d62
......@@ -43,6 +43,7 @@ class function
//! \see rational_function.cpp for an example
virtual void save(const std::string& filename, const arguments& args) const
{
std::cout << "<<DEBUG>> Exporting the function" << std::endl;
if(args.is_defined("export"))
{
if(args["export"].compare("c++") == 0)
......@@ -55,6 +56,11 @@ class function
std::cout << "<<INFO>> will export in matlab format" << std::endl;
save_matlab(filename, args);
}
else if(args["export"].compare("explorer") == 0)
{
std::cout << "<<INFO>> will export in BRDF explorer format" << std::endl;
save_brdfexplorer(filename, args);
}
else
{
std::cerr << "<<ERROR>> the export format is unknown" << std::endl ;
......@@ -119,7 +125,7 @@ class function
NOT_IMPLEMENTED();
}
//! \brief Output the rational function as a gnuplot file. It requires
//! \brief Output the function as a gnuplot file. It requires
//! the data object to output the function at the input location only.
virtual void save_gnuplot(const std::string& filename, const data* d,
const arguments& args) const
......@@ -147,18 +153,25 @@ class function
#endif
}
//! \brief Output the rational function using a C++ function formating.
//! \brief Output the function using a C++ function formating.
virtual void save_cpp(const std::string& filename, const arguments& args) const
{
NOT_IMPLEMENTED();
}
//! \brief Output the rational function using a C++ function formating.
//! \brief Output the function using a C++ function formating.
virtual void save_matlab(const std::string& filename, const arguments& args) const
{
NOT_IMPLEMENTED();
}
//! \brief Output the function using a BRDF Explorer formating.
virtual void save_brdfexplorer(const std::string& filename, const arguments& args) const
{
NOT_IMPLEMENTED();
}
protected: // data
......
......@@ -99,4 +99,74 @@ vec phong_function::parametersJacobian(const vec& x) const
return jac;
}
std::ofstream& type_affectation(std::ofstream& out,
const std::string& name,
const vec& x, int nY)
{
if(nY == 1)
out << "float " ;
else
out << "vec" << nY << " ";
out << name << " = ";
if(nY != 1)
out << "vec" << nY << "(";
for(int i=0; i<nY; ++i)
{
if(i != 0) out << ", ";
out << x[i];
}
if(nY != 1)
out << ")";
out << ";" << std::endl;
return out;
}
//! \brief Output the function using a BRDF Explorer formating.
void phong_function::save_brdfexplorer(const std::string& filename,
const arguments& args) const
{
std::ofstream file(filename.c_str(), std::ios_base::trunc);
file << "analytic" << std::endl;
file << std::endl;
// file << "::begin parameters" << std::endl;
// file << "::end parameters" << std::endl;
// file << std::endl;
file << std::endl;
file << "::begin shader" << std::endl;
type_affectation(file, std::string("n"), _N, _nY);
type_affectation(file, std::string("kd"), _kd, _nY);
type_affectation(file, std::string("ks"), _ks, _nY);
file << std::endl;
file << "const float PI = 3.14159265358979323846;" << std::endl;
file << std::endl;
file << "vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )" << std::endl;
file << "{" << std::endl;
file << " vec3 H = normalize(L+V);" << std::endl;
if(_nY == 1)
{
file << " float D = kd + ks * pow(max(0, dot(N,H)),n);" << std::endl;
}
else
{
file << " vec" << _nY << " D = kd + ks * pow(vec" << _nY << "(max(0.0, dot(N,H))),n);" << std::endl;
}
file << " return vec3(D);" << std::endl;
// file << " if (normalized)" << std::endl;
// file << " D *= (2+n) / (2*PI);" << std::endl;
file << "}" << std::endl;
file << std::endl;
file << "::end shader" << std::endl;
file.close();
}
Q_EXPORT_PLUGIN2(phong_function, phong_function)
......@@ -122,6 +122,10 @@ class phong_function : public nonlinear_function, public QObject
}
//! \brief Output the function using a BRDF Explorer formating.
virtual void save_brdfexplorer(const std::string& filename,
const arguments& args) const;
private: // data
//! \brief The phong lobe data
......
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