Skip to content
Snippets Groups Projects
Commit 1b4d9e25 authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen
Browse files

Merge branch 'master' of ssh://vo20.nl/git/uva

parents aa4fd943 ec5c92d4
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 25 deletions
*.o
ass*.tar.gz
......@@ -217,8 +217,9 @@ intersect_node(bvh_node *node, intersection_point *ip,
}
else
{
// Leaf node, find shortest triangle and check if it is closer than the
// current closest intersection
// Leaf node, find the shortest triangle in the leaf and check if it is
// closer to the origin than the current closest intersection. If so,
// make it the new closest intersection.
triangle *triangles = leaf_node_triangles(node);
intersection_point ip2;
......@@ -253,13 +254,6 @@ find_first_intersected_bvh_triangle(intersection_point* ip,
ip->t = C_INFINITY;
// If the root has no intersection, none of the BVH nodes does
//
// Note that this step if mkes the program less efficient when the root's
// bounding box has a relatively large surface in the camera screen (has
// lot of ray intersections). This is because every ray intersecting a
// triangle is now tested one time more and every non-intersection ray is
// tested one time less. So, when raytracing large objects, omitting this
// step would be advisable.
if( !bbox_intersect(&t0, &t1, bvh_root->bbox, ray_origin,
ray_direction, 0.0, C_INFINITY) )
{
......
/* Computer Graphics, Assignment, Ray-tracing 2
*
* Student name ....
* Student email ...
* Collegekaart ....
* Date ............
* Comments ........
*
*
* (always fill in these fields before submitting!!)
* Student name .... Sander van Veen & Taddeus Kroes
* Student email ... sandervv@gmail.com & taddeuskroes@hotmail.com
* Collegekaart .... 6167969 & 6054129
* Date ............ 07.11.2010
*/
#include <sys/time.h>
......@@ -160,7 +156,7 @@ ray_trace(void)
vec3 forward_vector, right_vector, up_vector;
int i, j, k, l;
vec3 right_step, down_step;
float image_plane_width, image_plane_height, diff[2] = {0.25, 0.75};
float image_plane_width, image_plane_height, pixel_diff[2] = {0.25, 0.75};
vec3 image_plane_topleft, image_plane_point;
vec3 ray_direction;
vec3 color;
......@@ -203,26 +199,34 @@ ray_trace(void)
{
for (i = 0; i < framebuffer_width; i++)
{
if( do_antialiasing)
if( do_antialiasing )
{
color.x = color.y = color.z = 0;
// Anti-aliasing is on, shoot 4 rays through each point and use the average
color.x = color.y = color.z = 0.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 corresponding point corner on image plane
image_plane_point = v3_add(
image_plane_topleft,
v3_multiply(right_step, i+pixel_diff[k])
);
image_plane_point = v3_add(
image_plane_point,
v3_multiply(down_step, j+pixel_diff[l])
);
// Compute direction for shooting the ray
ray_direction = v3_subtract(image_plane_point, scene_camera_position);
// Determine ray color
// Add ray color for this corner to the current color
color = v3_add(color, ray_color(0, scene_camera_position, ray_direction));
}
}
// Divide by 4 to get the average of all corners, this is the point color
color = v3_multiply(color, 0.25);
}
else
......
File deleted
CC=gcc
WARNING_FLAGS=-Wall -Wextra -Werror-implicit-function-declaration -Wshadow -Wstrict-prototypes -pedantic-errors
CFLAGS=-g -O2 -std=c99 $(WARNING_FLAGS)
LDFLAGS=-g -lGL -lglut -lGLU
.c.o:
$(CC) -c $(CFLAGS) $<
all: main
main: main.o volume.o
$(CC) $(LDFLAGS) -o main main.o volume.o
clean:
rm -f *.o
rm -f main
volume.o : volume.h
main.o : volume.h main.c
volume.o : volume.h volume.c
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment