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
bf501248
Commit
bf501248
authored
3 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Background is now skysphere, sinus correction of distribution in cornstructor implemented
parent
70b9cd3f
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/shape/SkySphere.cpp
+51
-0
51 additions, 0 deletions
RayTracer/shape/SkySphere.cpp
RayTracer/shape/SkySphere.h
+7
-2
7 additions, 2 deletions
RayTracer/shape/SkySphere.h
with
58 additions
and
2 deletions
RayTracer/shape/
Background
.cpp
→
RayTracer/shape/
SkySphere
.cpp
+
51
−
0
View file @
bf501248
#include
"
Background
.h"
#include
"
SkySphere
.h"
#define _USE_MATH_DEFINES
#include
<limits>
...
...
@@ -6,9 +6,23 @@
#include
"math.h"
namespace
shapes
{
Background
::
Background
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
)
SkySphere
::
SkySphere
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
)
:
Sphere
(
100
,
std
::
make_shared
<
material
::
BackgroundMaterial
>
(
sampler
))
{
}
SkySphere
::
SkySphere
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
,
util
::
Image
&
distribution
)
:
Sphere
(
100
,
std
::
make_shared
<
material
::
BackgroundMaterial
>
(
sampler
))
{
for
(
int
x
=
0
;
x
<
distribution
.
width
;
x
++
)
{
for
(
int
y
=
0
;
y
<
distribution
.
height
;
y
++
)
{
auto
color
=
distribution
[{
x
,
y
}];
auto
sinn
=
sin
(
M_PI
*
((
float
)
y
/
distribution
.
height
));
color
=
color
*
sinn
;
distribution
.
setPixel
(
x
,
y
,
color
);
}
}
material
=
std
::
make_shared
<
material
::
BackgroundMaterial
>
(
sampler
,
distribution
);
}
// Thit intersect method rightly flips the normal.But the normal is never used
// for non scatter materials, so we do not flip the normal
/*
...
...
@@ -21,7 +35,17 @@ std::optional<cam::Hit> Background::intersect(const cam::Ray& r) const {
return hit;
}*/
util
::
AxisAlignedBoundingBox
Background
::
bounds
()
const
{
float
SkySphere
::
lightPdf
(
const
util
::
SurfacePoint
&
p
,
const
util
::
Vec3
&
dl_out
)
const
{
auto
uv
=
p
.
texel
();
auto
phi
=
uv
.
second
*
M_PI
;
float
pdf
=
material
->
emission_pdf
(
uv
.
first
,
uv
.
second
).
value_or
(
1
);
pdf
=
pdf
/
(
2
*
M_PI
*
M_PI
*
sin
(
phi
));
return
pdf
;
}
util
::
AxisAlignedBoundingBox
SkySphere
::
bounds
()
const
{
return
util
::
AxisAlignedBoundingBox
();
}
}
// namespace shapes
\ No newline at end of file
This diff is collapsed.
Click to expand it.
RayTracer/shape/
Background
.h
→
RayTracer/shape/
SkySphere
.h
+
7
−
2
View file @
bf501248
#pragma once
#include
"../sampling/Image.h"
#include
"../sampling/Sampler.h"
#include
"Shape.h"
#include
"Sphere.h"
namespace
shapes
{
class
Background
:
public
Sphere
{
class
SkySphere
:
public
Sphere
{
public:
Background
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
);
SkySphere
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
);
SkySphere
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
,
util
::
Image
&
distribution
);
float
lightPdf
(
const
util
::
SurfacePoint
&
p
,
const
util
::
Vec3
&
dl_out
)
const
override
;
// We should have to flip the normal, but it does not matter
// std::optional<cam::Hit> intersect(const cam::Ray& r) const override;
util
::
AxisAlignedBoundingBox
bounds
()
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