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
41a30a3b
Commit
41a30a3b
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Implemented light functions
parent
4bae0e20
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/CirclePlane.cpp
+21
-0
21 additions, 0 deletions
RayTracer/shape/CirclePlane.cpp
RayTracer/shape/CirclePlane.h
+6
-1
6 additions, 1 deletion
RayTracer/shape/CirclePlane.h
with
27 additions
and
1 deletion
RayTracer/shape/CirclePlane.cpp
+
21
−
0
View file @
41a30a3b
#define _USE_MATH_DEFINES
#include
"CirclePlane.h"
#include
"CirclePlane.h"
#include
"../tools/Random.h"
#include
"math.h"
namespace
shapes
{
namespace
shapes
{
CirclePlane
::
CirclePlane
(
float
radius
,
CirclePlane
::
CirclePlane
(
float
radius
,
const
std
::
shared_ptr
<
material
::
Material
>&
material
)
const
std
::
shared_ptr
<
material
::
Material
>&
material
)
...
@@ -31,4 +36,20 @@ util::AxisAlignedBoundingBox CirclePlane::bounds() const {
...
@@ -31,4 +36,20 @@ util::AxisAlignedBoundingBox CirclePlane::bounds() const {
return
util
::
AxisAlignedBoundingBox
(
util
::
Vec3
(
-
radius
,
0
,
-
radius
),
return
util
::
AxisAlignedBoundingBox
(
util
::
Vec3
(
-
radius
,
0
,
-
radius
),
util
::
Vec3
(
radius
,
0
,
radius
));
util
::
Vec3
(
radius
,
0
,
radius
));
}
}
// THIS IS COPIED AND BAD TODO!!!!
util
::
SurfacePoint
CirclePlane
::
sampleLight
()
const
{
float
u
[
2
]
=
{(
float
)
util
::
dis0to1
(
util
::
gen
),
(
float
)
util
::
dis0to1
(
util
::
gen
)};
float
r
=
std
::
sqrt
(
u
[
0
])
*
radius
;
float
theta
=
2
*
M_PI
*
u
[
1
];
return
util
::
SurfacePoint
(
util
::
Vec3
(
r
*
std
::
cos
(
theta
),
0
,
r
*
std
::
sin
(
theta
)),
util
::
Vec3
(
0
,
-
1
,
0
),
material
);
}
util
::
Vec3
CirclePlane
::
calculateLightEmission
(
const
util
::
SurfacePoint
&
p
,
const
util
::
Vec3
&
d
)
const
{
// Diffus ist hier im dot-product eingebettet
return
p
.
albedo
()
*
(
p
.
emission
()
*
util
::
dot
(
p
.
normal
(),
d
.
normalize
()))
/
std
::
pow
(
d
.
length
(),
2
);
}
}
// namespace shapes
}
// namespace shapes
This diff is collapsed.
Click to expand it.
RayTracer/shape/CirclePlane.h
+
6
−
1
View file @
41a30a3b
#pragma once
#pragma once
#include
"Light.h"
#include
"Shape.h"
#include
"Shape.h"
namespace
shapes
{
namespace
shapes
{
class
CirclePlane
:
public
Shape
{
class
CirclePlane
:
public
Light
,
public
Shape
{
public:
public:
CirclePlane
(
float
radius
,
CirclePlane
(
float
radius
,
const
std
::
shared_ptr
<
material
::
Material
>&
material
);
const
std
::
shared_ptr
<
material
::
Material
>&
material
);
std
::
optional
<
cam
::
Hit
>
intersect
(
const
cam
::
Ray
&
r
)
const
override
;
std
::
optional
<
cam
::
Hit
>
intersect
(
const
cam
::
Ray
&
r
)
const
override
;
util
::
AxisAlignedBoundingBox
bounds
()
const
override
;
util
::
AxisAlignedBoundingBox
bounds
()
const
override
;
util
::
SurfacePoint
sampleLight
()
const
override
;
util
::
Vec3
calculateLightEmission
(
const
util
::
SurfacePoint
&
p
,
const
util
::
Vec3
&
d
)
const
override
;
private:
private:
std
::
shared_ptr
<
material
::
Material
>
material
;
std
::
shared_ptr
<
material
::
Material
>
material
;
const
float
radius
;
const
float
radius
;
...
...
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