Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
alta
alta
Commits
35018597
Commit
35018597
authored
Aug 21, 2013
by
Laurent Belcour
Browse files
Adding a stub for the Schlick Fresnel
parent
9d89132e
Changes
6
Hide whitespace changes
Inline
Side-by-side
sources/core/common.h
View file @
35018597
...
...
@@ -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
sources/plugins/nonlinear_fresnel_schlick/function.cpp
0 → 100644
View file @
35018597
#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
)
{
}
sources/plugins/nonlinear_fresnel_schlick/function.h
0 → 100644
View file @
35018597
#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
;
}
;
sources/plugins/nonlinear_fresnel_schlick/nonlinear_fresnel_schlick.pro
0 → 100644
View file @
35018597
TEMPLATE
=
lib
CONFIG
*=
plugin
DESTDIR
=
..
/../
build
INCLUDEPATH
+=
..
/..
HEADERS
=
function
.
h
SOURCES
=
function
.
cpp
LIBS
+=
-
L
..
/../
build
\
-
lcore
sources/plugins/nonlinear_levenberg_eigen/fitter.cpp
View file @
35018597
...
...
@@ -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
());
...
...
sources/plugins/plugins.pro
View file @
35018597
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment