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
f64f15c0
Commit
f64f15c0
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Make Background inherit from Sphere
parent
1fe1fcb5
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/Background.cpp
+16
-15
16 additions, 15 deletions
RayTracer/shape/Background.cpp
RayTracer/shape/Background.h
+6
-8
6 additions, 8 deletions
RayTracer/shape/Background.h
with
22 additions
and
23 deletions
RayTracer/shape/Background.cpp
+
16
−
15
View file @
f64f15c0
#include
"Background.h"
#define _USE_MATH_DEFINES
#include
<limits>
#include
"../material/BackgroundMaterial.h"
#include
"math.h"
namespace
shapes
{
Background
::
Background
(
const
std
::
shared_ptr
<
material
::
Material
>&
material
)
:
material
(
material
)
{
Background
::
Background
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
)
:
Sphere
(
100
,
std
::
make_shared
<
material
::
BackgroundMaterial
>
(
sampler
)
)
{
}
// TODO TEXELS
// Thit intersect method rightly flips the normal.But the normal is never used
// for non scatter materials, so we do not flip the normal
/*
std::optional<cam::Hit> Background::intersect(const cam::Ray& r) const {
return
std
::
optional
<
cam
::
Hit
>
({
r
(
std
::
numeric_limits
<
float
>::
infinity
()),
util
::
Vec3
({}),
{},
std
::
numeric_limits
<
float
>::
infinity
(),
material
});
}
// Not used
std
::
pair
<
float
,
float
>
Background
::
texture_coordinates
(
const
util
::
Vec3
&
pos
)
const
{
return
std
::
pair
<
float
,
float
>
({});
}
auto hit = Sphere::intersect(r);
if (hit)
hit = std::optional<cam::Hit>(
{{hit->point(), -hit->normal(), hit->texel(), hit->scalar(),
hit->material}});
return hit;
}*/
util
::
AxisAlignedBoundingBox
Background
::
bounds
()
const
{
return
util
::
AxisAlignedBoundingBox
();
...
...
This diff is collapsed.
Click to expand it.
RayTracer/shape/Background.h
+
6
−
8
View file @
f64f15c0
#pragma once
#include
"../sampling/Sampler.h"
#include
"Shape.h"
#include
"Sphere.h"
namespace
shapes
{
class
Background
:
public
S
hap
e
{
class
Background
:
public
S
pher
e
{
public:
Background
(
const
std
::
shared_ptr
<
material
::
Material
>&
material
);
std
::
optional
<
cam
::
Hit
>
intersect
(
const
cam
::
Ray
&
r
)
const
override
;
std
::
pair
<
float
,
float
>
Background
::
texture_coordinates
(
const
util
::
Vec3
&
pos
)
const
override
;
Background
(
const
std
::
shared_ptr
<
util
::
Sampler
>&
sampler
);
// 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
;
private:
std
::
shared_ptr
<
material
::
Material
>
material
;
};
}
// namespace shapes
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