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
90d47f0b
Commit
90d47f0b
authored
3 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Diffuse Refactor
parent
8e01b223
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
RayTracer/material/DiffuseMaterial.cpp
+20
-6
20 additions, 6 deletions
RayTracer/material/DiffuseMaterial.cpp
RayTracer/material/DiffuseMaterial.h
+7
-1
7 additions, 1 deletion
RayTracer/material/DiffuseMaterial.h
with
27 additions
and
7 deletions
RayTracer/material/DiffuseMaterial.cpp
+
20
−
6
View file @
90d47f0b
...
@@ -12,24 +12,38 @@ namespace material {
...
@@ -12,24 +12,38 @@ namespace material {
DiffuseMaterial
::
DiffuseMaterial
(
DiffuseMaterial
::
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
,
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
,
const
std
::
shared_ptr
<
util
::
Sampler
>&
emission_texture
)
const
std
::
shared_ptr
<
util
::
Sampler
>&
emission_texture
)
:
albedo_texture
(
albedo_texture
),
emission_texture
(
emission_texture
)
{
:
albedo_texture
(
albedo_texture
),
emission_profile
({
emission_texture
})
{
}
DiffuseMaterial
::
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
,
const
std
::
shared_ptr
<
util
::
Sampler
>&
emission_texture
,
const
util
::
Image
&
distribution
)
:
albedo_texture
(
albedo_texture
),
emission_profile
({
emission_texture
,
distribution
})
{
}
}
DiffuseMaterial
::
DiffuseMaterial
(
DiffuseMaterial
::
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
)
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
)
:
albedo_texture
(
albedo_texture
),
:
albedo_texture
(
albedo_texture
),
emission_
textur
e
(
emission_
profil
e
(
std
::
make_shared
<
Constant
>
(
Constant
(
util
::
Vec3
(
0
,
0
,
0
))))
{
{
std
::
make_shared
<
Constant
>
(
Constant
(
util
::
Vec3
(
0
,
0
,
0
)))
}
)
{
}
}
DiffuseMaterial
::
DiffuseMaterial
(
const
util
::
Vec3
&
color
)
DiffuseMaterial
::
DiffuseMaterial
(
const
util
::
Vec3
&
color
)
:
albedo_texture
(
std
::
make_shared
<
Constant
>
(
Constant
(
color
))),
:
albedo_texture
(
std
::
make_shared
<
Constant
>
(
Constant
(
color
))),
emission_
textur
e
(
emission_
profil
e
(
std
::
make_shared
<
Constant
>
(
Constant
(
util
::
Vec3
(
0
,
0
,
0
))))
{
{
std
::
make_shared
<
Constant
>
(
Constant
(
util
::
Vec3
(
0
,
0
,
0
)))
}
)
{
}
}
util
::
Vec3
DiffuseMaterial
::
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
util
::
Vec3
DiffuseMaterial
::
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
return
albedo_texture
->
color
(
uv
.
first
,
uv
.
second
);
return
albedo_texture
->
color
(
uv
.
first
,
uv
.
second
);
}
}
util
::
Vec3
DiffuseMaterial
::
emission
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
util
::
Vec3
DiffuseMaterial
::
emission
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
{
return
emission_texture
->
color
(
uv
.
first
,
uv
.
second
);
return
emission_profile
.
color
(
uv
.
first
,
uv
.
second
);
}
std
::
pair
<
float
,
float
>
DiffuseMaterial
::
sampleEmissionProfile
()
const
{
return
emission_profile
.
sample
();
}
std
::
optional
<
float
>
DiffuseMaterial
::
emission_pdf
(
float
u
,
float
v
)
const
{
return
emission_profile
.
pdf
(
u
,
v
);
}
}
util
::
Vec3
DiffuseMaterial
::
scattered_d
(
const
util
::
Vec3
&
d
,
util
::
Vec3
DiffuseMaterial
::
scattered_d
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
{
const
util
::
Vec3
&
n
)
const
{
...
...
This diff is collapsed.
Click to expand it.
RayTracer/material/DiffuseMaterial.h
+
7
−
1
View file @
90d47f0b
#pragma once
#pragma once
#include
"../tools/EmissionProfile.h"
#include
"Material.h"
#include
"Material.h"
namespace
material
{
namespace
material
{
...
@@ -7,11 +8,15 @@ class DiffuseMaterial : public Material {
...
@@ -7,11 +8,15 @@ class DiffuseMaterial : public Material {
public:
public:
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
,
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
,
const
std
::
shared_ptr
<
util
::
Sampler
>&
emission_texture
);
const
std
::
shared_ptr
<
util
::
Sampler
>&
emission_texture
);
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo_texture
,
const
std
::
shared_ptr
<
util
::
Sampler
>&
emission_texture
,
const
util
::
Image
&
distribution
);
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo
);
DiffuseMaterial
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
albedo
);
DiffuseMaterial
(
const
util
::
Vec3
&
color
);
DiffuseMaterial
(
const
util
::
Vec3
&
color
);
util
::
Vec3
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
override
;
util
::
Vec3
albedo
(
const
std
::
pair
<
float
,
float
>&
uv
)
const
override
;
util
::
Vec3
emission
(
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
,
util
::
Vec3
scattered_d
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
override
;
const
util
::
Vec3
&
n
)
const
override
;
bool
scatter
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
override
;
bool
scatter
(
const
util
::
Vec3
&
d
,
const
util
::
Vec3
&
n
)
const
override
;
...
@@ -19,9 +24,10 @@ class DiffuseMaterial : public Material {
...
@@ -19,9 +24,10 @@ class DiffuseMaterial : public Material {
float
calculateLightMultiplier
(
const
util
::
Vec3
&
d_in
,
float
calculateLightMultiplier
(
const
util
::
Vec3
&
d_in
,
const
util
::
Vec3
&
d_out
,
const
util
::
Vec3
&
d_out
,
const
util
::
Vec3
&
n
)
const
override
;
const
util
::
Vec3
&
n
)
const
override
;
std
::
optional
<
float
>
emission_pdf
(
float
u
,
float
v
)
const
override
;
private:
private:
std
::
shared_ptr
<
util
::
Sampler
>
albedo_texture
;
std
::
shared_ptr
<
util
::
Sampler
>
albedo_texture
;
std
::
shared_ptr
<
util
::
Sampler
>
emission_
textur
e
;
util
::
EmissionProfile
emission_
profil
e
;
};
};
}
// namespace material
}
// 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