Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alta
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alta
alta
Commits
d1ea2117
Commit
d1ea2117
authored
Nov 13, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tool to export in polar format
parent
4e11dcdb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
120 deletions
+108
-120
sources/plugins/nonlinear_function_retrobeckmann/function.cpp
...ces/plugins/nonlinear_function_retrobeckmann/function.cpp
+6
-55
sources/softs/brdf2gnuplot/main.cpp
sources/softs/brdf2gnuplot/main.cpp
+102
-65
No files found.
sources/plugins/nonlinear_function_retrobeckmann/function.cpp
View file @
d1ea2117
...
...
@@ -14,28 +14,6 @@ ALTA_DLL_EXPORT function* provide_function()
{
return
new
beckmann_function
();
}
vec
beckmann_function
::
G
(
const
vec
&
x
)
const
{
vec
res
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
const
double
cl
=
x
[
2
]
/
(
_a
[
i
]
*
sqrt
(
1
-
x
[
2
]
*
x
[
2
]));
const
double
cv
=
x
[
5
]
/
(
_a
[
i
]
*
sqrt
(
1
-
x
[
5
]
*
x
[
5
]));
res
[
i
]
=
1.0
;
if
(
cl
<
1.6
)
{
res
[
i
]
*=
(
3.535
*
cl
+
2.181
*
cl
*
cl
)
/
(
1
+
2.276
*
cl
+
2.577
*
cl
*
cl
);
}
if
(
cv
<
1.6
)
{
res
[
i
]
*=
(
3.535
*
cv
+
2.181
*
cv
*
cv
)
/
(
1
+
2.276
*
cv
+
2.577
*
cv
*
cv
);
}
}
return
res
;
}
// Overload the function operator
vec
beckmann_function
::
operator
()(
const
vec
&
x
)
const
...
...
@@ -56,8 +34,7 @@ vec beckmann_function::value(const vec& x) const
dot
=
std
::
max
(
x
[
0
]
*
x
[
3
]
+
x
[
2
]
*
x
[
4
]
+
x
[
2
]
*
x
[
5
],
0.0
);
}
// Compute the Shadow term to init res
vec
res
=
G
(
x
);
vec
res
=
vec
::
Zero
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
...
...
@@ -68,11 +45,11 @@ vec beckmann_function::value(const vec& x) const
if
(
dot
>
0.0
&&
x
[
2
]
*
x
[
5
]
>
0.0
)
{
res
[
i
]
*
=
_ks
[
i
]
/
(
4.0
*
x
[
2
]
*
x
[
5
]
*
M_PI
*
a2
*
dh2
*
dh2
)
*
expo
;
res
[
i
]
=
_ks
[
i
]
/
(
4.0
*
x
[
2
]
*
x
[
5
]
*
M_PI
*
a2
*
dh2
*
dh2
)
*
expo
;
}
else
{
res
[
i
]
*
=
0.0
;
res
[
i
]
=
0.0
;
}
}
return
res
;
...
...
@@ -146,9 +123,6 @@ vec beckmann_function::parametersJacobian(const vec& x) const
dot
=
std
::
max
(
x
[
0
]
*
x
[
3
]
+
x
[
2
]
*
x
[
4
]
+
x
[
2
]
*
x
[
5
],
0.0
);
}
// Get the geometry term
vec
g
=
G
(
x
);
vec
jac
(
dimY
()
*
nbParameters
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
...
...
@@ -163,10 +137,10 @@ vec beckmann_function::parametersJacobian(const vec& x) const
const
double
fac
=
(
4.0
*
x
[
2
]
*
x
[
5
]
*
M_PI
*
a2
*
dh2
*
dh2
);
// df / dk_s
jac
[
i
*
nbParameters
()
+
j
*
2
+
0
]
=
g
[
i
]
*
expo
/
fac
;
jac
[
i
*
nbParameters
()
+
j
*
2
+
0
]
=
expo
/
fac
;
// df / da_x
jac
[
i
*
nbParameters
()
+
j
*
2
+
1
]
=
-
g
[
i
]
*
_ks
[
i
]
*
(
expo
/
(
4.0
*
x
[
2
]
*
x
[
5
]))
*
((
2
*
a
*
dot
)
/
(
M_PI
*
a2
*
a2
*
dh2
))
*
(
1
+
(
dh2
-
1.0
)
*
dot
/
(
a2
*
dh2
*
dot
));
jac
[
i
*
nbParameters
()
+
j
*
2
+
1
]
=
-
_ks
[
i
]
*
(
expo
/
(
4.0
*
x
[
2
]
*
x
[
5
]))
*
((
2
*
a
*
dot
)
/
(
M_PI
*
a2
*
a2
*
dh2
))
*
(
1
+
(
dh2
-
1.0
)
*
dot
/
(
a2
*
dh2
*
dot
));
}
else
{
...
...
@@ -301,29 +275,6 @@ void beckmann_function::save_body(std::ostream& out, const arguments& args) cons
if
(
is_shader
)
{
out
<<
"vec3 g_beckmann(vec3 M, vec3 N, vec3 a)"
<<
std
::
endl
;
out
<<
"{"
<<
std
::
endl
;
out
<<
"
\t
float d = dot(M,N);"
<<
std
::
endl
;
out
<<
"
\t
vec3 c = d / (a * sqrt(1.0f-d));"
<<
std
::
endl
;
out
<<
"
\t
vec3 r;"
<<
std
::
endl
;
out
<<
"
\t
if(c.x < 1.6f) {"
<<
std
::
endl
;
out
<<
"
\t\t
r.x = (3.535*c.x + 2.181*c.x*c.x) / (1 + 2.276*c.x + 2.577*c.x*c.x);"
<<
std
::
endl
;
out
<<
"
\t
} else {"
<<
std
::
endl
;
out
<<
"
\t\t
r.x = 1.0f;"
<<
std
::
endl
;
out
<<
"
\t
}"
<<
std
::
endl
;
out
<<
"
\t
if(c.y < 1.6f) {"
<<
std
::
endl
;
out
<<
"
\t\t
r.y = (3.535*c.y + 2.181*c.y*c.y) / (1 + 2.276*c.y + 2.577*c.y*c.y);"
<<
std
::
endl
;
out
<<
"
\t
} else {"
<<
std
::
endl
;
out
<<
"
\t\t
r.y = 1.0f;"
<<
std
::
endl
;
out
<<
"
\t
}"
<<
std
::
endl
;
out
<<
"
\t
if(c.z < 1.6f) {"
<<
std
::
endl
;
out
<<
"
\t\t
r.z = (3.535*c.z + 2.181*c.z*c.z) / (1 + 2.276*c.z + 2.577*c.z*c.z);"
<<
std
::
endl
;
out
<<
"
\t
} else {"
<<
std
::
endl
;
out
<<
"
\t\t
r.z = 1.0f;"
<<
std
::
endl
;
out
<<
"
\t
}"
<<
std
::
endl
;
out
<<
"
\t
return r;"
<<
std
::
endl
;
out
<<
"}"
<<
std
::
endl
;
out
<<
std
::
endl
;
out
<<
"vec3 retrobeckmann(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, vec3 ks, vec3 a)"
<<
std
::
endl
;
out
<<
"{"
<<
std
::
endl
;
out
<<
"
\t
vec3 R = 2*dot(V,N)*N - V;"
<<
std
::
endl
;
...
...
@@ -332,7 +283,7 @@ void beckmann_function::save_body(std::ostream& out, const arguments& args) cons
out
<<
"
\t
float ln = dot(L,N);"
<<
std
::
endl
;
out
<<
"
\t
float vn = dot(V,N);"
<<
std
::
endl
;
out
<<
"
\t
"
<<
std
::
endl
;
out
<<
"
\t
return ks / (4 * "
<<
M_PI
<<
" * a*a * ln*vn) * exp((bn*bn - 1.0) / (a*a*bn*bn))
* g_beckmann(L,N,a) * g_beckmann(V,N,a)
;"
<<
std
::
endl
;
out
<<
"
\t
return ks / (4 * "
<<
M_PI
<<
" * a*a * ln*vn) * exp((bn*bn - 1.0) / (a*a*bn*bn));"
<<
std
::
endl
;
out
<<
"}"
<<
std
::
endl
;
}
}
sources/softs/brdf2gnuplot/main.cpp
View file @
d1ea2117
...
...
@@ -33,93 +33,130 @@ int main(int argc, char** argv)
}
// Load a function file
function
*
f
=
plugins_manager
::
get_function
(
args
[
"input"
])
;
function
*
f
=
plugins_manager
::
get_function
(
args
[
"input"
])
;
// Create output file
std
::
ofstream
file
(
args
[
"output"
].
c_str
(),
std
::
ios_base
::
trunc
);
file
.
precision
(
10
);
// Load a data file
data
*
d
=
NULL
;
if
(
args
.
is_defined
(
"data"
))
{
std
::
cout
<<
"<<INFO>> Using data
\"
"
<<
args
[
"data"
]
<<
"
\"
"
<<
std
::
endl
;
d
=
plugins_manager
::
get_data
()
;
std
::
cout
<<
"<<INFO>> Using data
file
\"
"
<<
args
[
"data"
]
<<
"
\"
"
<<
std
::
endl
;
d
=
plugins_manager
::
get_data
()
;
d
->
load
(
args
[
"data"
])
;
}
/*
// Print the distance to the data to check if it correspond to the value
// computed prior.
double L2 = f->L2_distance(d);
double Linf = f->Linf_distance(d);
std::cout << "<<INFO>> L2 distance to data = " << L2 << std::endl;
std::cout << "<<INFO>> Linf distance to data = " << Linf << std::endl;
*/
// Check the kind of plot to do
bool
plot_error
=
false
;
bool
linear_plot
=
false
;
if
(
args
.
is_defined
(
"error"
))
{
std
::
cout
<<
"<<INFO>> Exporting an error plot"
<<
std
::
endl
;
plot_error
=
true
;
}
else
if
(
args
.
is_defined
(
"linear_error"
))
{
std
::
cout
<<
"<<INFO>> Exporting linear error plot"
<<
std
::
endl
;
linear_plot
=
true
;
}
// Create output file
std
::
ofstream
file
(
args
[
"output"
].
c_str
(),
std
::
ios_base
::
trunc
);
file
.
precision
(
10
);
// Print the distance to the data to check if it correspond to the value
// computed prior.
double
L2
=
f
->
L2_distance
(
d
);
double
Linf
=
f
->
Linf_distance
(
d
);
std
::
cout
<<
"<<INFO>> L2 distance to data = "
<<
L2
<<
std
::
endl
;
std
::
cout
<<
"<<INFO>> Linf distance to data = "
<<
Linf
<<
std
::
endl
;
if
(
d
!=
NULL
)
{
for
(
int
i
=
0
;
i
<
d
->
size
();
++
i
)
// Check the kind of plot to do
bool
plot_error
=
false
;
bool
linear_plot
=
false
;
if
(
args
.
is_defined
(
"error"
))
{
vec
v
=
d
->
get
(
i
)
;
vec
x
(
f
->
dimX
());
if
(
f
->
input_parametrization
()
==
params
::
UNKNOWN_INPUT
)
{
memcpy
(
&
x
[
0
],
&
v
[
0
],
f
->
dimX
()
*
sizeof
(
double
));
}
else
{
params
::
convert
(
&
v
[
0
],
d
->
input_parametrization
(),
f
->
input_parametrization
(),
&
x
[
0
]);
}
std
::
cout
<<
"<<INFO>> Exporting an error plot"
<<
std
::
endl
;
plot_error
=
true
;
}
else
if
(
args
.
is_defined
(
"linear_error"
))
{
std
::
cout
<<
"<<INFO>> Exporting linear error plot"
<<
std
::
endl
;
linear_plot
=
true
;
}
vec
y2
=
f
->
value
(
x
)
;
if
(
!
linear_plot
)
{
for
(
int
u
=
0
;
u
<
d
->
dimX
();
++
u
)
file
<<
v
[
u
]
<<
"
\t
"
;
}
else
if
(
d
!=
NULL
)
{
for
(
int
i
=
0
;
i
<
d
->
size
();
++
i
)
{
file
<<
i
<<
"
\t
"
;
}
vec
v
=
d
->
get
(
i
)
;
vec
x
(
f
->
dimX
());
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
{
if
(
plot_error
)
if
(
f
->
input_parametrization
()
==
params
::
UNKNOWN_INPUT
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
<<
"
\t
"
;
memcpy
(
&
x
[
0
],
&
v
[
0
],
f
->
dimX
()
*
sizeof
(
double
))
;
}
else
if
(
linear_plot
)
else
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
params
::
convert
(
&
v
[
0
],
d
->
input_parametrization
(),
f
->
input_parametrization
(),
&
x
[
0
]);
}
vec
y2
=
f
->
value
(
x
)
;
if
(
!
linear_plot
)
{
for
(
int
u
=
0
;
u
<
d
->
dimX
();
++
u
)
file
<<
v
[
u
]
<<
"
\t
"
;
}
else
{
file
<<
y2
[
u
]
<<
"
\t
"
;
file
<<
i
<<
"
\t
"
;
}
}
file
<<
std
::
endl
;
for
(
int
u
=
0
;
u
<
d
->
dimY
();
++
u
)
{
if
(
plot_error
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
<<
"
\t
"
;
}
else
if
(
linear_plot
)
{
file
<<
(
v
[
d
->
dimX
()
+
u
]
-
y2
[
u
])
/
v
[
d
->
dimX
()
+
u
]
<<
"
\t
"
;
}
else
{
file
<<
y2
[
u
]
<<
"
\t
"
;
}
}
file
<<
std
::
endl
;
}
}
else
{
std
::
cerr
<<
"<<ERROR>> data argument is incorrectly defined"
<<
std
::
endl
;
}
}
else
}
else
if
(
args
.
is_defined
(
"polar-plot"
))
{
std
::
cerr
<<
"<<ERROR>> --data is not defined"
<<
std
::
endl
;
vec
spherical
(
4
);
spherical
[
0
]
=
args
.
get_float
(
"inc-angle"
,
0.0
);
spherical
[
1
]
=
M_PI
;
const
int
N
=
args
.
get_int
(
"samples"
,
100
)
/
2
;
// Plot retro direction
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
spherical
[
2
]
=
0.5
*
M_PI
*
double
(
i
)
/
double
(
N
);
spherical
[
3
]
=
M_PI
;
vec
x
(
f
->
dimX
());
params
::
convert
(
&
spherical
[
0
],
params
::
SPHERICAL_TL_PL_TV_PV
,
f
->
input_parametrization
(),
&
x
[
0
]);
vec
y
=
f
->
value
(
x
);
file
<<
-
spherical
[
2
]
<<
"
\t
"
;
for
(
int
k
=
0
;
k
<
f
->
dimY
();
++
k
)
{
file
<<
y
[
k
]
<<
"
\t
"
;
}
file
<<
std
::
endl
;
}
// Plot forward direction
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
spherical
[
2
]
=
0.5
*
M_PI
*
double
(
i
)
/
double
(
N
);
spherical
[
3
]
=
0.0
;
vec
x
(
f
->
dimX
());
params
::
convert
(
&
spherical
[
0
],
params
::
SPHERICAL_TL_PL_TV_PV
,
f
->
input_parametrization
(),
&
x
[
0
]);
vec
y
=
f
->
value
(
x
);
file
<<
spherical
[
2
]
<<
"
\t
"
;
for
(
int
k
=
0
;
k
<
f
->
dimY
();
++
k
)
{
file
<<
y
[
k
]
<<
"
\t
"
;
}
file
<<
std
::
endl
;
}
}
file
.
close
();
...
...
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