Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RBComb Ray Tracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engeler
RBComb Ray Tracer
Commits
d0250989
Commit
d0250989
authored
3 years ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
added extinction coefficient, removed wrong assertions
parent
8caafb54
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/dielectric.cpp
+13
-8
13 additions, 8 deletions
src/dielectric.cpp
src/dielectric.hpp
+2
-1
2 additions, 1 deletion
src/dielectric.hpp
with
15 additions
and
9 deletions
src/dielectric.cpp
+
13
−
8
View file @
d0250989
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
#include
<cmath>
#include
<cmath>
#include
<cassert>
#include
<cassert>
dielectric
::
dielectric
(
double
index_of_refraction_inside
,
double
index_of_refraction_outside
)
dielectric
::
dielectric
(
double
index_of_refraction_inside
,
double
index_of_refraction_outside
,
double
extinction_inside
)
:
ir_inside
(
index_of_refraction_inside
),
ir_outside
(
index_of_refraction_outside
){
:
ir_inside
(
index_of_refraction_inside
),
ir_outside
(
index_of_refraction_outside
)
,
extinction_inside
(
extinction_inside
)
{
}
}
...
@@ -23,17 +23,22 @@ bool dielectric::scatter(
...
@@ -23,17 +23,22 @@ bool dielectric::scatter(
vec3
unit_direction
=
unit_vector
(
r_in
.
direction
());
vec3
unit_direction
=
unit_vector
(
r_in
.
direction
());
double
refraction_ratio
;
double
refraction_ratio
;
double
ir_in
,
ir_out
;
double
ir_in
,
ir_out
;
double
extinct_in
,
extinct_out
;
vec3
relevant_normal
;
vec3
relevant_normal
;
if
(
rec
.
inbound
){
if
(
rec
.
inbound
){
refraction_ratio
=
ir_outside
/
ir_inside
;
refraction_ratio
=
ir_outside
/
ir_inside
;
ir_in
=
ir_outside
;
ir_in
=
ir_outside
;
ir_out
=
ir_inside
;
ir_out
=
ir_inside
;
extinct_in
=
0.
;
extinct_out
=
extinction_inside
;
relevant_normal
=
rec
.
normal
;
relevant_normal
=
rec
.
normal
;
}
}
else
{
else
{
refraction_ratio
=
ir_inside
/
ir_outside
;
refraction_ratio
=
ir_inside
/
ir_outside
;
ir_in
=
ir_inside
;
ir_in
=
ir_inside
;
ir_out
=
ir_outside
;
ir_out
=
ir_outside
;
extinct_in
=
extinction_inside
.;
extinct_out
=
0.
;
relevant_normal
=
-
rec
.
normal
;
relevant_normal
=
-
rec
.
normal
;
}
}
...
@@ -60,9 +65,9 @@ bool dielectric::scatter(
...
@@ -60,9 +65,9 @@ bool dielectric::scatter(
}
}
int
phase_flips
=
r_in
.
get_phaseflips
();
int
phase_flips
=
r_in
.
get_phaseflips
();
r_reflected
=
ir_out
>
ir_in
?
r_reflected
=
ir_out
>
ir_in
?
ray
(
rec
.
p
,
dir_reflected
,
fraction_reflected
*
r_in
.
get_amplitude
(
),
optical_path_to_p
,
ir_in
,
phase_flips
+
1
,
bounces_left
-
1
)
:
ray
(
rec
.
p
,
dir_reflected
,
fraction_reflected
*
r_in
.
get_amplitude
_at
(
rec
.
t
),
optical_path_to_p
,
ir_in
,
extinct_in
,
phase_flips
+
1
,
bounces_left
-
1
)
:
ray
(
rec
.
p
,
dir_reflected
,
fraction_reflected
*
r_in
.
get_amplitude
(
),
optical_path_to_p
,
ir_in
,
phase_flips
,
bounces_left
-
1
);
ray
(
rec
.
p
,
dir_reflected
,
fraction_reflected
*
r_in
.
get_amplitude
_at
(
rec
.
t
),
optical_path_to_p
,
ir_in
,
extinct_in
,
phase_flips
,
bounces_left
-
1
);
r_refracted
=
ray
(
rec
.
p
,
dir_refracted
,
fraction_refracted
*
r_in
.
get_amplitude
(
),
optical_path_to_p
,
ir_out
,
phase_flips
,
bounces_left
-
1
);
r_refracted
=
ray
(
rec
.
p
,
dir_refracted
,
fraction_refracted
*
r_in
.
get_amplitude
_at
(
rec
.
t
),
optical_path_to_p
,
ir_out
,
extinct_out
,
phase_flips
,
bounces_left
-
1
);
#ifndef NDEBUG
#ifndef NDEBUG
//if(fraction_reflected > 1.){
//if(fraction_reflected > 1.){
...
@@ -74,9 +79,9 @@ bool dielectric::scatter(
...
@@ -74,9 +79,9 @@ bool dielectric::scatter(
std
::
cerr
<<
"refracted ray: origin: "
<<
r_refracted
.
origin
()
<<
", direction: "
<<
r_refracted
.
direction
()
<<
std
::
endl
;
std
::
cerr
<<
"refracted ray: origin: "
<<
r_refracted
.
origin
()
<<
", direction: "
<<
r_refracted
.
direction
()
<<
std
::
endl
;
//}
//}
#endif
#endif
assert
(
fraction_reflected
>=
0.
&&
fraction_refracted
>=
0.
);
//
assert(fraction_reflected >= 0. && fraction_refracted >= 0.);
assert
(
fraction_reflected
<=
1.
&&
fraction_refracted
<=
1.
);
//
assert(fraction_reflected <= 1. && fraction_refracted <= 1.);
assert
(
std
::
fabs
(
fraction_refracted
+
fraction_reflected
-
1.
)
<
0.00000001
);
//
assert(std::fabs(fraction_refracted + fraction_reflected - 1.) < 0.00000001);
assert
(
r_reflected
.
origin
().
x
()
==
rec
.
p
.
x
()
&&
r_reflected
.
origin
().
y
()
==
rec
.
p
.
y
()
&&
r_reflected
.
origin
().
z
()
==
rec
.
p
.
z
());
assert
(
r_reflected
.
origin
().
x
()
==
rec
.
p
.
x
()
&&
r_reflected
.
origin
().
y
()
==
rec
.
p
.
y
()
&&
r_reflected
.
origin
().
z
()
==
rec
.
p
.
z
());
assert
(
r_refracted
.
origin
().
x
()
==
rec
.
p
.
x
()
&&
r_refracted
.
origin
().
y
()
==
rec
.
p
.
y
()
&&
r_refracted
.
origin
().
z
()
==
rec
.
p
.
z
());
assert
(
r_refracted
.
origin
().
x
()
==
rec
.
p
.
x
()
&&
r_refracted
.
origin
().
y
()
==
rec
.
p
.
y
()
&&
r_refracted
.
origin
().
z
()
==
rec
.
p
.
z
());
...
...
This diff is collapsed.
Click to expand it.
src/dielectric.hpp
+
2
−
1
View file @
d0250989
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
class
dielectric
:
public
material
{
class
dielectric
:
public
material
{
public:
public:
dielectric
(
double
index_of_refraction_inside
,
double
index_of_refraction_outside
);
dielectric
(
double
index_of_refraction_inside
,
double
index_of_refraction_outside
,
double
extinction_inside
=
0.
);
virtual
bool
scatter
(
virtual
bool
scatter
(
const
ray
&
r_in
,
const
hit_record
&
rec
,
const
ray
&
r_in
,
const
hit_record
&
rec
,
...
@@ -19,6 +19,7 @@ private:
...
@@ -19,6 +19,7 @@ private:
double
ir_inside
;
//index of refraction inside material
double
ir_inside
;
//index of refraction inside material
double
ir_outside
;
//index of refraction outside material
double
ir_outside
;
//index of refraction outside material
double
extinction_inside
;
//exponential extinction coefficient inside material
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment