Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CppRaytracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Yoel
CppRaytracer
Commits
5f485e7f
Commit
5f485e7f
authored
3 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
BackgroundMaterial, comments and refactor
parent
42481ead
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
RayTracer/material/BackgroundMaterial.cpp
+12
-5
12 additions, 5 deletions
RayTracer/material/BackgroundMaterial.cpp
RayTracer/material/BackgroundMaterial.h
+3
-5
3 additions, 5 deletions
RayTracer/material/BackgroundMaterial.h
with
15 additions
and
10 deletions
RayTracer/material/BackgroundMaterial.cpp
+
12
−
5
View file @
5f485e7f
...
...
@@ -17,6 +17,7 @@ BackgroundMaterial::BackgroundMaterial(
BackgroundMaterial
::
BackgroundMaterial
(
const
util
::
Vec3
&
albedo
)
:
emission_profile
({
std
::
make_shared
<
Constant
>
(
albedo
)})
{
}
// Everything in the background material is derived from its emission profile
util
::
Vec3
BackgroundMaterial
::
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
return
util
::
Vec3
(
1
,
1
,
1
);
}
...
...
@@ -24,6 +25,8 @@ util::Vec3 BackgroundMaterial::emission(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
return
emission_profile
.
color
(
uv
.
first
,
uv
.
second
);
}
// This gives us the sampled points uv, which is than used to get the value of
// the pdf and the emission value of the texture
std
::
pair
<
float
,
float
>
BackgroundMaterial
::
sampleEmissionProfile
()
const
{
return
emission_profile
.
sample
();
}
...
...
@@ -31,14 +34,17 @@ std::pair<float, float> BackgroundMaterial::sampleEmissionProfile() const {
std
::
optional
<
float
>
BackgroundMaterial
::
emission_pdf
(
float
u
,
float
v
)
const
{
return
emission_profile
.
pdf
(
u
,
v
);
}
util
::
Vec3
BackgroundMaterial
::
scattered_d
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
{
return
util
::
Vec3
(
0
,
0
,
0
);
// Gets called because scatter checks for the outgoing vector.
// Only really used for reflective material
std
::
optional
<
util
::
Vec3
>
BackgroundMaterial
::
scattered_d
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
{
return
std
::
nullopt
;
}
/*
bool BackgroundMaterial::scatter(const util::Vec3& d,
const util::Vec3& n) const {
return
false
;
}
return false;
}
*/
float
BackgroundMaterial
::
calculateLightMultiplier
(
const
util
::
Vec3
&
d_in
,
const
util
::
Vec3
&
d_out
,
...
...
@@ -46,6 +52,7 @@ float BackgroundMaterial::calculateLightMultiplier(const util::Vec3& d_in,
// Background should not be able to receive any light
return
0
;
}
// Should never get called
float
BackgroundMaterial
::
brdf_pdf
(
const
util
::
Vec3
&
d_out
,
const
util
::
Vec3
&
n
)
const
{
// Background can not scatter so this is fine and will never be used
...
...
This diff is collapsed.
Click to expand it.
RayTracer/material/BackgroundMaterial.h
+
3
−
5
View file @
5f485e7f
...
...
@@ -14,14 +14,12 @@ class BackgroundMaterial : public Material {
util
::
Vec3
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
override
;
util
::
Vec3
emission
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
override
;
std
::
pair
<
float
,
float
>
sampleEmissionProfile
()
const
override
;
util
::
Vec3
scattered_d
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
override
;
bool
scatter
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
override
;
std
::
optional
<
util
::
Vec3
>
scattered_d
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
override
;
// bool scatter(const util::Vec3& d, const util::Vec3& n) const override;
float
calculateLightMultiplier
(
const
util
::
Vec3
&
d_in
,
const
util
::
Vec3
&
d_out
,
const
util
::
Vec3
&
n
)
const
override
;
float
brdf_pdf
(
const
util
::
Vec3
&
d_out
,
const
util
::
Vec3
&
n
)
const
override
;
std
::
optional
<
float
>
emission_pdf
(
float
u
,
float
v
)
const
override
;
...
...
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