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
bd07a516
Commit
bd07a516
authored
3 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Fixing the break, continue issues
parent
c40617e9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
RayTracer/sampling/Scene.cpp
+11
-8
11 additions, 8 deletions
RayTracer/sampling/Scene.cpp
with
11 additions
and
8 deletions
RayTracer/sampling/Scene.cpp
+
11
−
8
View file @
bd07a516
...
...
@@ -70,23 +70,26 @@ util::Vec3 Scene::directLighting(const cam::Hit& h, cam::Ray r) const {
cam
::
Ray
(
sample_point
.
point
(),
h
.
point
()
-
sample_point
.
point
(),
cam
::
epsilon
,
1
-
cam
::
epsilon
,
false
);
// When the surface normal and the shadowray dont point in the same
// hemisphere, the ray hits the surface, so we can
break
if
(
util
::
dot
(
shadow_ray
.
d
,
sample_point
.
normal
())
<=
0
)
break
;
// hemisphere, the ray hits the surface, so we can
continue
if
(
util
::
dot
(
shadow_ray
.
d
,
sample_point
.
normal
())
<=
0
)
continue
;
auto
shadow_hit
=
group
.
intersect
(
shadow_ray
);
// If the shadowray his something we can
break
if
(
shadow_hit
)
break
;
// If the shadowray his something we can
continue
if
(
shadow_hit
)
continue
;
auto
light_pdf
=
light
->
lightPdf
(
sample_point
,
shadow_ray
.
d
);
// This happens when the shaodow ray is beyond the surfaces normal.
// This means, that the shadow ray hits the surface and we can break
if
(
light_pdf
<=
0
)
break
;
// This means, that the shadow ray hits the surface and we can
// continue
if
(
light_pdf
<=
0
)
continue
;
auto
brdf
=
h
.
calculateLightMultiplier
(
shadow_ray
.
d
.
normalize
(),
-
r
.
d
,
h
.
normal
());
auto
L
=
light
->
lightEmission
(
sample_point
);
// Dot product could be negative, in that case
break
// Dot product could be negative, in that case
continue
auto
cosine_term
=
std
::
max
<
float
>
(
util
::
dot
(
-
shadow_ray
.
d
.
normalize
(),
h
.
normal
()),
0
);
if
(
cosine_term
<=
0
)
break
;
if
(
cosine_term
<=
0
)
{
continue
;
}
auto
scatterFunction
=
(
brdf
*
L
*
cosine_term
)
/
light_pdf
;
// Add the values from this light to the others
...
...
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