Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Taddeüs Kroes
uva
Commits
20795120
Commit
20795120
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
- Implemented anti-aliasing,
parent
802ef1b0
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
graphics/ass7/main.c
+37
-12
37 additions, 12 deletions
graphics/ass7/main.c
with
37 additions
and
12 deletions
graphics/ass7/main.c
+
37
−
12
View file @
20795120
...
...
@@ -158,9 +158,9 @@ void
ray_trace
(
void
)
{
vec3
forward_vector
,
right_vector
,
up_vector
;
int
i
,
j
;
int
i
,
j
,
k
,
l
;
vec3
right_step
,
down_step
;
float
image_plane_width
,
image_plane_height
;
float
image_plane_width
,
image_plane_height
,
diff
[
2
]
=
{
0
.
25
,
0
.
75
}
;
vec3
image_plane_topleft
,
image_plane_point
;
vec3
ray_direction
;
vec3
color
;
...
...
@@ -203,16 +203,41 @@ ray_trace(void)
{
for
(
i
=
0
;
i
<
framebuffer_width
;
i
++
)
{
// Compute corresponding point on image plane
image_plane_point
=
v3_add
(
image_plane_topleft
,
v3_multiply
(
right_step
,
i
+
0
.
5
));
image_plane_point
=
v3_add
(
image_plane_point
,
v3_multiply
(
down_step
,
j
+
0
.
5
));
// Compute direction for shooting the ray
ray_direction
=
v3_subtract
(
image_plane_point
,
scene_camera_position
);
// Determine ray color
color
=
ray_color
(
0
,
scene_camera_position
,
ray_direction
);
if
(
do_antialiasing
)
{
color
.
x
=
color
.
y
=
color
.
z
=
0
;
for
(
k
=
0
;
k
<
2
;
k
++
)
{
for
(
l
=
0
;
l
<
2
;
l
++
)
{
// Compute corresponding point on image plane
image_plane_point
=
v3_add
(
image_plane_topleft
,
v3_multiply
(
right_step
,
i
+
diff
[
k
]));
image_plane_point
=
v3_add
(
image_plane_point
,
v3_multiply
(
down_step
,
j
+
diff
[
l
]));
// Compute direction for shooting the ray
ray_direction
=
v3_subtract
(
image_plane_point
,
scene_camera_position
);
// Determine ray color
color
=
v3_add
(
color
,
ray_color
(
0
,
scene_camera_position
,
ray_direction
));
}
}
color
=
v3_multiply
(
color
,
0
.
25
);
}
else
{
// Compute corresponding point on image plane
image_plane_point
=
v3_add
(
image_plane_topleft
,
v3_multiply
(
right_step
,
i
+
0
.
5
));
image_plane_point
=
v3_add
(
image_plane_point
,
v3_multiply
(
down_step
,
j
+
0
.
5
));
// Compute direction for shooting the ray
ray_direction
=
v3_subtract
(
image_plane_point
,
scene_camera_position
);
// Determine ray color
color
=
ray_color
(
0
,
scene_camera_position
,
ray_direction
);
}
// Output pixel color
put_pixel
(
i
,
j
,
color
.
x
,
color
.
y
,
color
.
z
);
}
...
...
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