Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
alta
alta
Commits
4b5817ba
Commit
4b5817ba
authored
Sep 05, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BRDFExplorer export of Shlick's Fresnel
parent
385f2ad7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
14 deletions
+59
-14
sources/plugins/nonlinear_fitter_nlopt/fitter.cpp
sources/plugins/nonlinear_fitter_nlopt/fitter.cpp
+1
-1
sources/plugins/nonlinear_fresnel_schlick/function.cpp
sources/plugins/nonlinear_fresnel_schlick/function.cpp
+31
-5
sources/plugins/nonlinear_fresnel_schlick/function.h
sources/plugins/nonlinear_fresnel_schlick/function.h
+1
-1
sources/plugins/nonlinear_function_isotropic_lafortune/function.cpp
...ugins/nonlinear_function_isotropic_lafortune/function.cpp
+24
-7
sources/plugins/nonlinear_function_isotropic_lafortune/function.h
...plugins/nonlinear_function_isotropic_lafortune/function.h
+2
-0
No files found.
sources/plugins/nonlinear_fitter_nlopt/fitter.cpp
View file @
4b5817ba
...
...
@@ -168,7 +168,7 @@ bool nonlinear_fitter_nlopt::fit_data(const data* d, function* fit, const argume
{
algorithm
=
NLOPT_LN_PRAXIS
;
}
else
if
(
optimizerName
==
"Nelder-Mead
Simplex
"
)
else
if
(
optimizerName
==
"Nelder-Mead"
)
{
algorithm
=
NLOPT_LN_NELDERMEAD
;
}
...
...
sources/plugins/nonlinear_fresnel_schlick/function.cpp
View file @
4b5817ba
...
...
@@ -40,13 +40,39 @@ void schlick::load(std::istream& in)
void
schlick
::
save_call
(
std
::
ostream
&
out
,
const
arguments
&
args
)
const
{
f
->
save_call
(
out
,
args
);
out
<<
"("
;
f
->
save_call
(
out
,
args
);
out
<<
")"
;
bool
is_alta
=
!
args
.
is_defined
(
"export"
)
||
args
[
"export"
]
==
"alta"
;
if
(
is_alta
)
{
out
<<
"#FUNC nonlinear_fresnel_schlick"
<<
std
::
endl
;
out
<<
"R "
<<
R
<<
std
::
endl
;
out
<<
std
::
endl
;
}
else
{
out
<<
" * schlick_fresnel(L, V, N, X, Y, "
<<
R
<<
")"
;
}
}
void
schlick
::
save_body
(
std
::
ostream
&
out
,
const
arguments
&
args
)
const
{
f
->
save_body
(
out
,
args
);
bool
is_shader
=
args
[
"export"
]
==
"shader"
||
args
[
"export"
]
==
"explorer"
;
if
(
is_shader
)
{
out
<<
std
::
endl
;
out
<<
"vec3 schlick_fresnel(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, float R)"
<<
std
::
endl
;
out
<<
"{"
<<
std
::
endl
;
out
<<
"
\t
vec3 H = normalize(L + V);"
<<
std
::
endl
;
out
<<
"
\t
return vec3(R + (1.0f - R) * pow(1.0f - clamp(dot(H,L), 0.0f, 1.0f), 5));"
<<
std
::
endl
;
out
<<
"}"
<<
std
::
endl
;
}
out
<<
"#FUNC nonlinear_fresnel_schlick"
<<
std
::
endl
;
out
<<
"R "
<<
R
<<
std
::
endl
;
out
<<
std
::
endl
;
}
vec
schlick
::
fresnelValue
(
const
vec
&
x
)
const
{
double
xp
[
2
];
...
...
@@ -101,5 +127,5 @@ vec schlick::getFresnelParametersJacobian(const vec& x) const
void
schlick
::
fresnelBootstrap
(
const
data
*
d
,
const
arguments
&
args
)
{
R
=
1.0
;
R
=
0.1
;
}
sources/plugins/nonlinear_fresnel_schlick/function.h
View file @
4b5817ba
...
...
@@ -21,7 +21,7 @@ class schlick : public fresnel
virtual
void
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
...
...
sources/plugins/nonlinear_function_isotropic_lafortune/function.cpp
View file @
4b5817ba
...
...
@@ -33,7 +33,11 @@ vec isotropic_lafortune_function::value(const vec& x) const
// For each color channel
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
#ifdef WITH_DIFFUSE
res
[
i
]
=
_kd
[
i
];
#else
res
[
i
]
=
0.0
;
#endif
// For each lobe
for
(
int
n
=
0
;
n
<
_n
;
++
n
)
...
...
@@ -52,6 +56,7 @@ vec isotropic_lafortune_function::value(const vec& x) const
if
(
isnan
(
res
[
i
])
||
res
[
i
]
==
std
::
numeric_limits
<
double
>::
infinity
())
{
std
::
cout
<<
"<<ERROR>> invalid value for input: "
<<
x
<<
std
::
endl
;
std
::
cout
<<
" invalid value for parameter: "
<<
parameters
()
<<
std
::
endl
;
}
#endif
}
...
...
@@ -76,7 +81,11 @@ vec isotropic_lafortune_function::value(const vec& x, const vec& p) const
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
// Start with the diffuse term
res
[
i
]
=
_kd
[
i
];
#ifdef WITH_DIFFUSE
res
[
i
]
=
_kd
[
i
];
#else
res
[
i
]
=
0.0
;
#endif
// For each lobe
for
(
int
n
=
0
;
n
<
_n
;
++
n
)
...
...
@@ -116,10 +125,12 @@ void isotropic_lafortune_function::setDimY(int nY)
// Update the length of the vectors
_C
.
resize
(
_n
*
_nY
*
2
)
;
_N
.
resize
(
_n
*
_nY
)
;
#ifdef USE_DIFFUSE
_kd
.
resize
(
_nY
);
for
(
int
i
=
0
;
i
<
nY
;
++
i
)
_kd
[
i
]
=
0.0
;
#endif
}
//! Number of parameters to this non-linear function
...
...
@@ -227,6 +238,7 @@ void isotropic_lafortune_function::bootstrap(const data* d, const arguments& arg
// Check the arguments for the number of lobes
this
->
setNbLobes
(
args
.
get_int
(
"lobes"
,
1
));
#ifdef USE_DIFFUSE
// Set the diffuse component
vec
x0
=
d
->
get
(
0
);
for
(
int
i
=
0
;
i
<
d
->
dimY
();
++
i
)
...
...
@@ -239,7 +251,7 @@ void isotropic_lafortune_function::bootstrap(const data* d, const arguments& arg
_kd
[
j
]
=
std
::
min
(
xi
[
d
->
dimX
()
+
j
],
_kd
[
j
]);
}
std
::
cout
<<
"<<INFO>> found diffuse: "
<<
_kd
<<
std
::
endl
;
#endif
// Upon user request, the starting position of the lobe can be either load
// from a file, a distribution beetwen forward backward and dot directions,
// etc.
...
...
@@ -425,9 +437,14 @@ void isotropic_lafortune_function::save_call(std::ostream& out, const arguments&
void
isotropic_lafortune_function
::
save_body
(
std
::
ostream
&
out
,
const
arguments
&
args
)
const
{
out
<<
"vec3 lafortune(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, vec3 Cx, vec3 Cz, vec3 Nl)"
<<
std
::
endl
;
out
<<
"{"
<<
std
::
endl
;
out
<<
"
\t
vec3 ext_dot = Cx * (dot(L,X)*dot(V,X) + dot(L,Y)*dot(V,Y)) + Cz * dot(L,N)*dot(V,N);"
<<
std
::
endl
;
out
<<
"
\t
return pow(max(ext_dot, vec3(0,0,0)), Nl);"
<<
std
::
endl
;
out
<<
"}"
<<
std
::
endl
;
bool
is_shader
=
args
[
"export"
]
==
"shader"
||
args
[
"export"
]
==
"explorer"
;
if
(
is_shader
)
{
out
<<
"vec3 lafortune(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, vec3 Cx, vec3 Cz, vec3 Nl)"
<<
std
::
endl
;
out
<<
"{"
<<
std
::
endl
;
out
<<
"
\t
vec3 ext_dot = Cx * (dot(L,X)*dot(V,X) + dot(L,Y)*dot(V,Y)) + Cz * dot(L,N)*dot(V,N);"
<<
std
::
endl
;
out
<<
"
\t
return pow(max(ext_dot, vec3(0,0,0)), Nl);"
<<
std
::
endl
;
out
<<
"}"
<<
std
::
endl
;
}
}
sources/plugins/nonlinear_function_isotropic_lafortune/function.h
View file @
4b5817ba
...
...
@@ -100,6 +100,8 @@ class isotropic_lafortune_function : public nonlinear_function
//! \brief The isotropic_lafortune lobe data
int
_n
;
// Number of lobes
vec
_N
,
_C
;
// Lobes data
#ifdef WITH_DIFFUSE
vec
_kd
;
// Diffuse term
#endif
}
;
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