Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 93395177 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Adding Schlick's geometry term. Seems to work.

parent 2324d389
#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();
}
//! Load function specific files
bool schlick::load(std::istream& in)
{
// fresnel::load(in);
// Parse line until the next comment
while(in.peek() != '#')
{
char line[256];
in.getline(line, 256);
// If we cross the end of the file, or the badbit is
// set, the file cannot be loaded
if(!in.good())
return false;
}
// Checking for the comment line #FUNC nonlinear_fresnel_schlick
std::string token;
in >> token;
if(token != "#FUNC")
{
std::cerr << "<<ERROR>> parsing the stream. The #FUNC is not the next line defined." << std::endl;
return false;
}
in >> token;
if(token != "nonlinear_fresnel_schlick")
{
std::cerr << "<<ERROR>> parsing the stream. function name is not the next token." << std::endl;
return false;
}
// R [double]
for(int i=0; i<dimY(); ++i)
{
in >> token >> w[i];
}
return true;
}
void schlick::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_shadowing_schlick" << std::endl ;
for(int i=0; i<dimY(); ++i)
{
out << "K " << w[i] << std::endl;
}
out << std::endl;
}
else
{
out << "shadowing_schlick(L, V, N, X, Y, vec3";
for(int i=0; i<dimY(); ++i)
{
out << w[i];
if(i < _nY-1) { out << ", "; }
}
out << "))";
}
}
void schlick::save_body(std::ostream& out, const arguments& args) const
{
bool is_shader = args["export"] == "shader" || args["export"] == "explorer";
if(is_shader)
{
out << std::endl;
out << "vec3 shadowing_schlick(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, vec3 K)" << std::endl;
out << "{" << std::endl;
out << "\tconst float dotLN = dot(L, N);" << std::endl;
out << "\tconst float dotVN = dot(L, N);" << std::endl;
out << std::endl;
out << "\tconst vec3 GL = dotLN / (dotLN + K * (dotLN - 1.0));" << std::endl;
out << "\tconst vec3 GV = dotVN / (dotVN + K * (dotVN - 1.0));" << std::endl;
out << std::endl;
out << "\treturn vec3(GL*GV);" << std::endl;
out << "}" << std::endl;
out << std::endl;
}
}
vec schlick::value(const vec& x) const
{
vec res(dimY());
const double u = x[5];
const double v = x[2];
for(int i=0; i<dimY(); ++i)
{
const double Gu = u / (u + w[i] * (1.0 - u));
const double Gv = v / (v + w[i] * (1.0 - v));
res[i] = Gu*Gv;
}
return res;
}
//! \brief Number of parameters to this non-linear function
int schlick::nbParameters() const
{
return dimY();
}
vec schlick::getParametersMin() const
{
vec m(dimY());
for(int i=0; i<dimY(); ++i) { m[i] = 0.0; }
return m;
}
//! \brief Get the vector of parameters for the function
vec schlick::parameters() const
{
vec p(dimY());
for(int i=0; i<dimY(); ++i) { p[i] = w[i]; }
return p;
}
//! \brief Update the vector of parameters for the function
void schlick::setParameters(const vec& p)
{
for(int i=0; i<dimY(); ++i) { w[i] = p[i]; }
}
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
vec schlick::parametersJacobian(const vec& x) const
{
const int nY = dimY();
vec jac(nY*nY);
const double u = x[5];
const double v = x[2];
for(int i=0; i<nY; ++i)
for(int j=0; j<nY; ++j)
{
if(i == j)
{
// const double denom_u
const double Gu = u / (u + w[i] * (1.0 - u));
const double Gv = v / (v + w[i] * (1.0 - v));
const double dGu = - u*(1.0 - u) / pow(u + w[i]*(1.0-u), 2);
const double dGv = - v*(1.0 - v) / pow(v + w[i]*(1.0-v), 2);
jac[j*dimY() + i] = Gu*dGv + Gv*dGu;
}
else
{
jac[j*dimY() + i] = 0.0;
}
}
return jac;
}
void schlick::bootstrap(const data*, const arguments&)
{
// Start with a non occluding value for k
for(int i=0; i<dimY(); ++i) { w[i] = 0.0; }
}
#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//fresnel
{
public: // methods
schlick()
{
setParametrization(params::CARTESIAN);
setDimX(6);
}
//! \brief Load function specific files
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 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 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) ;
//! Get the vector of min parameters for the function
virtual vec getParametersMin() const;
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
virtual vec parametersJacobian(const vec& x) const ;
//! \brief Boostrap the function by defining the diffuse term
virtual void bootstrap(const data* d, const arguments& args);
//! \brief resize the parameter vector
virtual void setDimY(int nY)
{
function::setDimY(nY);
w.resize(nY);
}
private: // data
//! Fresnel reflectance at theta = 0
vec w;
} ;
TEMPLATE = lib
CONFIG *= plugin \
eigen
DESTDIR = ../../build
INCLUDEPATH += ../..
HEADERS = function.h
SOURCES = function.cpp
LIBS += -L../../build \
-lcore
......@@ -18,6 +18,7 @@ SUBDIRS = \
nonlinear_fresnel_normalized_schlick \
nonlinear_fresnel_retroschlick \
nonlinear_shadowing_smith \
nonlinear_shadowing_schlick \
nonlinear_function_diffuse \
# nonlinear_function_microfacets \
nonlinear_function_abc \
......
......@@ -18,7 +18,8 @@
<action name="data2brdf">
<!-- Input and output arguments of the action -->
<input name="../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" />
<!--<input name="../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D__BRDF_min_retro_lobe_dense.alta" />-->
<input name="../papers/retro/mesures/original/Bande_orange/3d/633nm/Fichiers_definitifs/densify_helmholtz/Bande_orange_3D_dense__nbsgrid_162.alta" />
<output name="./results/3d/retro/half/Bande_orange_beck_back.brdf" />
<!-- Define the function to use -->
......@@ -33,6 +34,7 @@
<!-- Parameters -->
<parameter name="min" value="[0.1, -2, -2]" />
<parameter name="max" value="[0.3, 2, 2]" />
<parameter name="cos-fit" value="" />
</action>
<action name="data2brdf">
......@@ -43,7 +45,7 @@
<!-- Define the function to use -->
<function name="nonlinear_function_diffuse" />
<function name="nonlinear_function_retrobeckmann">
<!--<parameter name="fresnel" value="./build/libnonlinear_shadowing_smith.so"/>-->
<parameter name="fresnel" value="./build/libnonlinear_shadowing_schlick.so"/>
</function>
<!-- Define the ftting procedure to use -->
......@@ -51,8 +53,8 @@
<!-- Parameters -->
<parameter name="min" value="[0.1, -2, -2]" />
<parameter name="max" value="[0.9, 2, 2]" />
<!--<parameter name="bootstrap" value="./results/3d/retro/half/Bande_orange_beck_back.brdf" />-->
<parameter name="max" value="[1.7, 2, 2]" />
<parameter name="bootstrap" value="./results/3d/retro/half/Bande_orange_beck_back.brdf" />
<parameter name="cos-fit" value="" />
</action>
......
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