Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
20795120
Commit
20795120
authored
Nov 08, 2010
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Implemented anti-aliasing,
parent
802ef1b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
12 deletions
+37
-12
graphics/ass7/main.c
graphics/ass7/main.c
+37
-12
No files found.
graphics/ass7/main.c
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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment