Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
alta
alta
Commits
987c8cf5
Commit
987c8cf5
authored
Oct 08, 2013
by
Laurent Belcour
Browse files
Debuging the product function. Need to rewritte the loading/saving
parent
11476f65
Changes
5
Hide whitespace changes
Inline
Side-by-side
sources/core/common.cpp
View file @
987c8cf5
...
...
@@ -73,13 +73,13 @@ vec product(const vec& a, const vec& b)
}
else
{
#ifdef DEBUG
#if
n
def DEBUG
assert
(
a
.
size
()
==
b
.
size
());
#endif
vec
res
(
b
.
size
());
for
(
int
i
=
0
;
i
<
b
.
size
();
++
i
)
{
res
[
i
]
=
a
[
0
]
*
b
[
i
];
res
[
i
]
=
a
[
i
]
*
b
[
i
];
}
return
res
;
}
...
...
sources/core/function.cpp
View file @
987c8cf5
...
...
@@ -535,22 +535,28 @@ void product_function::setDimX(int nX)
{
f1
->
setDimX
(
nX
);
f2
->
setDimX
(
nX
);
function
::
setDimX
(
f1
->
dimX
());
}
void
product_function
::
setDimY
(
int
nY
)
{
f1
->
setDimY
(
nY
);
f2
->
setDimY
(
nY
);
function
::
setDimY
(
f1
->
dimY
());
}
void
product_function
::
setMin
(
const
vec
&
min
)
{
function
::
setMin
(
min
);
f1
->
setMin
(
min
);
f2
->
setMin
(
min
);
}
void
product_function
::
setMax
(
const
vec
&
max
)
{
function
::
setMax
(
max
);
f1
->
setMax
(
max
);
f2
->
setMax
(
max
);
}
...
...
@@ -574,7 +580,7 @@ vec product_function::parameters() const
params
[
i
]
=
f1_params
[
i
];
}
vec
f2_params
=
parameters
();
vec
f2_params
=
f2
->
parameters
();
for
(
int
i
=
0
;
i
<
nb_f2_params
;
++
i
)
{
params
[
i
+
nb_f1_params
]
=
f2_params
[
i
];
...
...
sources/core/plugins_manager.cpp
View file @
987c8cf5
...
...
@@ -359,9 +359,10 @@ function* plugins_manager::get_function(const arguments& args)
}
}
fresnel
*
func_fres
=
dynamic_cast
<
fresnel
*>
(
get_function
(
arguments
::
create_arguments
(
n
)));
func_fres
->
setBase
(
nl_func
);
return
func_fres
;
nonlinear_function
*
func_fres
=
dynamic_cast
<
nonlinear_function
*>
(
get_function
(
arguments
::
create_arguments
(
n
)));
// func_fres->setBase(nl_func);
// return func_fres;
return
new
product_function
(
nl_func
,
func_fres
);
}
...
...
sources/plugins/nonlinear_fresnel_schlick/function.cpp
View file @
987c8cf5
...
...
@@ -17,7 +17,7 @@ ALTA_DLL_EXPORT function* provide_function()
//! Load function specific files
bool
schlick
::
load
(
std
::
istream
&
in
)
{
fresnel
::
load
(
in
);
//
fresnel::load(in);
// Parse line until the next comment
while
(
in
.
peek
()
!=
'#'
)
...
...
@@ -59,15 +59,6 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
{
bool
is_alta
=
!
args
.
is_defined
(
"export"
)
||
args
[
"export"
]
==
"alta"
;
if
(
is_alta
)
{
f
->
save_call
(
out
,
args
);
}
else
{
out
<<
"("
;
f
->
save_call
(
out
,
args
);
out
<<
")"
;
}
if
(
is_alta
)
{
out
<<
"#FUNC nonlinear_fresnel_schlick"
<<
std
::
endl
;
...
...
@@ -79,7 +70,7 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
}
else
{
out
<<
"
*
schlick_fresnel(L, V, N, X, Y, vec3("
;
out
<<
"schlick_fresnel(L, V, N, X, Y, vec3("
;
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
out
<<
R
[
i
];
...
...
@@ -91,7 +82,6 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
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
)
...
...
@@ -107,7 +97,7 @@ void schlick::save_body(std::ostream& out, const arguments& args) const
}
vec
schlick
::
fresnelV
alue
(
const
vec
&
x
)
const
vec
schlick
::
v
alue
(
const
vec
&
x
)
const
{
double
xp
[
3
],
cart
[
6
];
params
::
convert
(
&
x
[
0
],
input_parametrization
(),
params
::
RUSIN_VH
,
xp
);
...
...
@@ -115,8 +105,8 @@ vec schlick::fresnelValue(const vec& x) const
const
double
dotVH
=
xp
[
0
]
*
cart
[
0
]
+
xp
[
1
]
*
cart
[
1
]
+
xp
[
2
]
*
cart
[
2
];
vec
res
(
_nY
);
for
(
int
i
=
0
;
i
<
_nY
;
++
i
)
vec
res
(
dimY
()
);
for
(
int
i
=
0
;
i
<
dimY
()
;
++
i
)
{
res
[
i
]
=
R
[
i
]
+
(
1.0
-
R
[
i
])
*
pow
(
1.0
-
clamp
(
dotVH
,
0.0
,
1.0
),
5.0
);
}
...
...
@@ -125,12 +115,12 @@ vec schlick::fresnelValue(const vec& x) const
}
//! \brief Number of parameters to this non-linear function
int
schlick
::
nb
Fresnel
Parameters
()
const
int
schlick
::
nbParameters
()
const
{
return
dimY
();
}
vec
schlick
::
get
Fresnel
ParametersMin
()
const
vec
schlick
::
getParametersMin
()
const
{
vec
m
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
m
[
i
]
=
0.0
;
}
...
...
@@ -138,7 +128,7 @@ vec schlick::getFresnelParametersMin() const
}
//! Get the vector of min parameters for the function
vec
schlick
::
get
Fresnel
ParametersMax
()
const
vec
schlick
::
getParametersMax
()
const
{
vec
M
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
M
[
i
]
=
1.0
;
}
...
...
@@ -146,7 +136,7 @@ vec schlick::getFresnelParametersMax() const
}
//! \brief Get the vector of parameters for the function
vec
schlick
::
getFresnelP
arameters
()
const
vec
schlick
::
p
arameters
()
const
{
vec
p
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
p
[
i
]
=
R
[
i
];
}
...
...
@@ -154,14 +144,14 @@ vec schlick::getFresnelParameters() const
}
//! \brief Update the vector of parameters for the function
void
schlick
::
set
Fresnel
Parameters
(
const
vec
&
p
)
void
schlick
::
setParameters
(
const
vec
&
p
)
{
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
R
[
i
]
=
p
[
i
];
}
}
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
vec
schlick
::
getFresnelP
arametersJacobian
(
const
vec
&
x
)
const
vec
schlick
::
p
arametersJacobian
(
const
vec
&
x
)
const
{
const
int
nY
=
dimY
();
double
xp
[
3
],
cart
[
6
];
...
...
@@ -185,7 +175,7 @@ vec schlick::getFresnelParametersJacobian(const vec& x) const
}
void
schlick
::
fresnelB
ootstrap
(
const
data
*
d
,
const
arguments
&
args
)
void
schlick
::
b
ootstrap
(
const
data
*
d
,
const
arguments
&
args
)
{
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
R
[
i
]
=
1.0
;
}
}
sources/plugins/nonlinear_fresnel_schlick/function.h
View file @
987c8cf5
...
...
@@ -12,53 +12,59 @@
#include
<core/common.h>
class
schlick
:
public
fresnel
class
schlick
:
public
nonlinear_function
//
fresnel
{
public:
// methods
schlick
()
{
setParametrization
(
params
::
CARTESIAN
);
}
//! \brief Load function specific files
virtual
bool
load
(
std
::
istream
&
in
)
;
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
fresnelValue
(
const
vec
&
x
)
const
;
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
nb
Fresnel
Parameters
()
const
;
virtual
int
nbParameters
()
const
;
//! \brief Get the vector of parameters for the function
virtual
vec
getFresnelP
arameters
()
const
;
virtual
vec
p
arameters
()
const
;
//! \brief Update the vector of parameters for the function
virtual
void
set
Fresnel
Parameters
(
const
vec
&
p
)
;
virtual
void
setParameters
(
const
vec
&
p
)
;
//! Get the vector of min parameters for the function
virtual
vec
get
Fresnel
ParametersMin
()
const
;
virtual
vec
getParametersMin
()
const
;
//! Get the vector of min parameters for the function
virtual
vec
get
Fresnel
ParametersMax
()
const
;
virtual
vec
getParametersMax
()
const
;
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
virtual
vec
getFresnelP
arametersJacobian
(
const
vec
&
x
)
const
;
virtual
vec
p
arametersJacobian
(
const
vec
&
x
)
const
;
//! \brief Boostrap the function by defining the diffuse term
virtual
void
fresnelB
ootstrap
(
const
data
*
d
,
const
arguments
&
args
);
virtual
void
b
ootstrap
(
const
data
*
d
,
const
arguments
&
args
);
//! \brief resize the parameter vector
virtual
void
setDimY
(
int
nY
)
{
fresnel
::
setDimY
(
nY
);
R
.
resize
(
nY
);
}
//! \brief resize the parameter vector
virtual
void
setDimY
(
int
nY
)
{
function
::
setDimY
(
nY
);
R
.
resize
(
nY
);
}
private:
// data
//!
Unidimensional
Fresnel reflectance at theta = 0
vec
R
;
//! Fresnel reflectance at theta = 0
vec
R
;
}
;
Write
Preview
Supports
Markdown
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