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
8e01b223
Commit
8e01b223
authored
3 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
BackgroundMaterial Refactor
parent
78f8e56a
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
+15
-3
15 additions, 3 deletions
RayTracer/material/BackgroundMaterial.cpp
RayTracer/material/BackgroundMaterial.h
+6
-1
6 additions, 1 deletion
RayTracer/material/BackgroundMaterial.h
with
21 additions
and
4 deletions
RayTracer/material/BackgroundMaterial.cpp
+
15
−
3
View file @
8e01b223
...
...
@@ -5,17 +5,29 @@
namespace
material
{
BackgroundMaterial
::
BackgroundMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
texture
)
:
texture
(
texture
)
{
:
emission_profile
({
texture
})
{
}
BackgroundMaterial
::
BackgroundMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
texture
,
const
util
::
Image
&
distribution
)
:
emission_profile
({
texture
,
distribution
})
{
}
BackgroundMaterial
::
BackgroundMaterial
(
const
util
::
Vec3
&
albedo
)
:
textur
e
(
std
::
make_shared
<
Constant
>
(
albedo
))
{
:
emission_profil
e
(
{
std
::
make_shared
<
Constant
>
(
albedo
)
}
)
{
}
util
::
Vec3
BackgroundMaterial
::
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
return
util
::
Vec3
(
1
,
1
,
1
);
}
util
::
Vec3
BackgroundMaterial
::
emission
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
return
texture
->
color
(
uv
.
first
,
uv
.
second
);
return
emission_profile
.
color
(
uv
.
first
,
uv
.
second
);
}
std
::
pair
<
float
,
float
>
BackgroundMaterial
::
sampleEmissionProfile
()
const
{
return
emission_profile
.
sample
();
}
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
{
...
...
This diff is collapsed.
Click to expand it.
RayTracer/material/BackgroundMaterial.h
+
6
−
1
View file @
8e01b223
#pragma once
#include
"../tools/EmissionProfile.h"
#include
"Material.h"
namespace
material
{
class
BackgroundMaterial
:
public
Material
{
public:
BackgroundMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
texture
);
BackgroundMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
texture
,
const
util
::
Image
&
distribution
);
BackgroundMaterial
(
const
util
::
Vec3
&
albedo
);
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
;
...
...
@@ -17,8 +21,9 @@ class BackgroundMaterial : public Material {
float
calculateLightMultiplier
(
const
util
::
Vec3
&
d_in
,
const
util
::
Vec3
&
d_out
,
const
util
::
Vec3
&
n
)
const
override
;
std
::
optional
<
float
>
emission_pdf
(
float
u
,
float
v
)
const
override
;
private:
std
::
shared_ptr
<
util
::
Sampler
>
textur
e
;
util
::
EmissionProfile
emission_profil
e
;
};
}
// namespace material
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