Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission: Megan Moore #16

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
293 changes: 20 additions & 273 deletions README.md

Large diffs are not rendered by default.

Binary file added img/Closed box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/DOF1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/DOF2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/DOF_1000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/DOF_500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Jittered with -.5, .5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Jittered with 0, 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Proj3_chart1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Proj3_chart2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cornell.2015-09-24_21-39-23z.168samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cornell.2015-09-24_22-03-22z.145samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cornell.2015-09-24_22-46-43z.148samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cornell.2015-09-25_22-03-49z.862samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/final1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/final1000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/motion_blur1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/motion_blur_1000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/no jitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/old seeds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction w prob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction2 large light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction_correct1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/refraction_correct2(water).png
Binary file added img/refraction_correct3(glass).png
Binary file added img/refraction_correctish.png
Binary file added img/refraction_w_light_box.png
Binary file added img/refraction_w_light_sphere.png
Binary file added img/specular1.png
Binary file added img/specular2.png
Binary file added img/specular3.png
Binary file added img/unterminated rays to black.png
66 changes: 62 additions & 4 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 5
EMITTANCE 2

// Diffuse white
MATERIAL 1
Expand Down Expand Up @@ -38,6 +38,36 @@ REFR 0
REFRIOR 0
EMITTANCE 0

// Mirror
MATERIAL 4
RGB 1 1 1
SPECEX 0
SPECRGB 1 1 1
REFL 0
REFR 1
REFRIOR 1.52
EMITTANCE 0

// Mirror
MATERIAL 5
RGB 1 1 1
SPECEX 0
SPECRGB 0 1 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Mirror
MATERIAL 6
RGB 1 1 1
SPECEX 0
SPECRGB 1 1 1
REFL 1
REFR 0
REFRIOR 0
EMITTANCE 0

// Camera
CAMERA
RES 800 800
Expand All @@ -56,7 +86,7 @@ cube
material 0
TRANS 0 10 0
ROTAT 0 0 0
SCALE 3 .3 3
SCALE 4 .3 4

// Floor
OBJECT 1
Expand All @@ -65,14 +95,16 @@ material 1
TRANS 0 0 0
ROTAT 0 0 0
SCALE 10 .01 10
MOVE 0 0 0

// Ceiling
OBJECT 2
cube
material 1
material 0
TRANS 0 10 0
ROTAT 0 0 90
SCALE .01 10 10
MOVE 0 0 0

// Back wall
OBJECT 3
Expand All @@ -81,6 +113,7 @@ material 1
TRANS 0 5 -5
ROTAT 0 90 0
SCALE .01 10 10
MOVE 0 0 0

// Left wall
OBJECT 4
Expand All @@ -89,6 +122,7 @@ material 2
TRANS -5 5 0
ROTAT 0 0 0
SCALE .01 10 10
MOVE 0 0 0

// Right wall
OBJECT 5
Expand All @@ -97,11 +131,35 @@ material 3
TRANS 5 5 0
ROTAT 0 0 0
SCALE .01 10 10
MOVE 0 0 0

// Sphere
OBJECT 6
sphere
material 1
material 6
TRANS -1 4 -1
ROTAT 0 0 0
SCALE 2 2 2
MOVE 0 0 0

// Sphere
OBJECT 7
cube
material 4
TRANS 2 1 -1
ROTAT 0 45 0
SCALE 2 2 2
MOVE 0 0 0

// Sphere
OBJECT 8
sphere
material 5
TRANS -3 1 -1
ROTAT 0 45 0
SCALE 3 3 3
MOVE 0 0 0




149 changes: 149 additions & 0 deletions scenes/cornellTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Emissive material (light)
MATERIAL 0
RGB 1 1 1
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 2

// Diffuse white
MATERIAL 1
RGB .98 .98 .98
SPECEX 0
SPECRGB 1 1 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse red
MATERIAL 2
RGB .85 .35 .35
SPECEX 0
SPECRGB 1 1 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse green
MATERIAL 3
RGB .35 .85 .35
SPECEX 0
SPECRGB 1 1 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Mirror
MATERIAL 4
RGB 1 1 1
SPECEX 0
SPECRGB 1 1 1
REFL 0
REFR 1
REFRIOR 1.52
EMITTANCE 0

// Mirror
MATERIAL 5
RGB 0 0 1
SPECEX 1
SPECRGB 1 1 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Mirror
MATERIAL 6
RGB 0 1 1
SPECEX 1
SPECRGB 1 1 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Camera
CAMERA
RES 800 800
FOVY 45
ITERATIONS 5000
DEPTH 8
FILE cornell
EYE 0.0 5 10.5
VIEW 0 0 -1
UP 0 1 0


// Ceiling light
OBJECT 0
cube
material 0
TRANS 0 10 0
ROTAT 0 0 0
SCALE 4 .3 4

// Floor
OBJECT 1
cube
material 1
TRANS 0 0 0
ROTAT 0 0 0
SCALE 10 .01 10
MOVE 0 0 0

// Ceiling
OBJECT 2
cube
material 0
TRANS 0 10 0
ROTAT 0 0 90
SCALE .01 10 10
MOVE 0 0 0

// Back wall
OBJECT 3
cube
material 1
TRANS 0 5 -5
ROTAT 0 90 0
SCALE .01 10 10
MOVE 0 0 0

// Left wall
OBJECT 4
cube
material 2
TRANS -5 5 0
ROTAT 0 0 0
SCALE .01 10 10
MOVE 0 0 0

// Right wall
OBJECT 5
cube
material 3
TRANS 5 5 0
ROTAT 0 0 0
SCALE .01 10 10
MOVE 0 0 0

// Sphere
OBJECT 6
sphere
material 6
TRANS -1 4 -1
ROTAT 0 0 0
SCALE 3 3 3
MOVE 0 0 0






6 changes: 4 additions & 2 deletions scenes/sphere.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ EMITTANCE 5

// Camera
CAMERA
RES 800 800
RES 10 10
FOVY 45
ITERATIONS 5000
DEPTH 8
Expand All @@ -19,10 +19,12 @@ EYE 0.0 5 10.5
VIEW 0 0 -1
UP 0 1 0

// Sphere
// sphere
OBJECT 0
sphere
material 0
TRANS 0 0 0
ROTAT 0 0 0
SCALE 3 3 3
MOVE 0 2 0

68 changes: 68 additions & 0 deletions src/interactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,76 @@ void scatterRay(
glm::vec3 intersect,
glm::vec3 normal,
const Material &m,
bool out,
thrust::default_random_engine &rng) {
// TODO: implement this.
// A basic implementation of pure-diffuse shading will just call the
// calculateRandomDirectionInHemisphere defined above.


if (m.hasRefractive == 1) {
thrust::uniform_real_distribution<float> probDistrib(0.0f, 1.0f);
float prob = probDistrib(rng);
float angle;
glm::vec3 refractionPoint;


float R_0;
if (out) {
R_0 = ((1.0f - m.indexOfRefraction) / (1.0f + m.indexOfRefraction))*((1.0f - m.indexOfRefraction) / (1.0f + m.indexOfRefraction));
float n_12 = glm::pow(1.0f / m.indexOfRefraction, 2);
angle = 1.0f - n_12 * (1.0f - glm::pow(glm::dot(normal, ray.direction), 2));
}
else {
R_0 = ((m.indexOfRefraction - 1.0f) / (m.indexOfRefraction + 1.0f)) * ((m.indexOfRefraction - 1.0f) / (m.indexOfRefraction + 1.0f));
angle = 1.0f - glm::pow(m.indexOfRefraction, 2) * (1.0f - glm::pow(glm::dot(normal, ray.direction), 2));
}
float reflCoeff = R_0 + (1.0f - R_0) * glm::pow(1.0f - glm::dot(normal, -ray.direction), 5);
if ((1.0f - reflCoeff) > prob && angle > 0.0f) {
if (out == true){ //if ray is coming from air to geom
refractionPoint = glm::refract(ray.direction, normal, 1.0f / m.indexOfRefraction);
ray.out = false;
}
else{ //if ray is coming out of geom into air
refractionPoint = glm::refract(ray.direction, normal, m.indexOfRefraction);
ray.out = true;
}
ray.direction = refractionPoint;
ray.origin = intersect + glm::vec3(0.01f, 0.01f, 0.01f)*(glm::normalize(ray.direction));
color *= m.color;// *(1.0f / reflCoeff);

}
else {
ray.direction = ray.direction - 2.0f*normal*(glm::dot(ray.direction, normal));
ray.origin = intersect + glm::vec3(0.01f, 0.01f, 0.01f)*(glm::normalize(ray.direction));
color *= m.color;// *(1.0f / reflCoeff);
}

}
else if (m.hasReflective == 1) {
ray.direction = ray.direction - 2.0f*normal*(glm::dot(ray.direction, normal));
ray.origin = intersect + glm::vec3(0.01f, 0.01f, 0.01f)*(glm::normalize(ray.direction));
color *= m.color;
}
else if (m.specular.exponent > 0) {
thrust::uniform_real_distribution<float> probDistrib(0.0f, 1.0f);
float prob = probDistrib(rng);
if (.1f > prob) {
ray.direction = ray.direction - 2.0f*normal*(glm::dot(ray.direction, normal));
ray.origin = intersect + glm::vec3(0.01f, 0.01f, 0.01f)*(glm::normalize(ray.direction));
color *= m.specular.color;
}
else {
ray.direction = calculateRandomDirectionInHemisphere(normal, rng);
ray.origin = intersect + glm::vec3(0.01f, 0.01f, 0.01f)*(glm::normalize(ray.direction));
color *= m.color;
}
}
//DIFFUSE
else {
ray.direction = calculateRandomDirectionInHemisphere(normal, rng);
ray.origin = intersect + glm::vec3(0.01f, 0.01f, 0.01f)*(glm::normalize(ray.direction));
color *= m.color;
}

}
Loading