Skip to content

Submission: Levi Cai #6

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

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1e5ab52
Initial implementation of pipeline working but no lighting
arizonat Oct 5, 2015
90c3514
Things are...inverted?
arizonat Oct 5, 2015
052c9c5
Changed fixed integer to be the full size
arizonat Oct 6, 2015
9a3034b
Almost fully working pipeline, race conditions still present
arizonat Oct 6, 2015
d9d467b
Merge remote-tracking branch 'upstream/master'
arizonat Oct 6, 2015
ae7b1a3
Added keyboard and mouse control, but still have freezing issues
arizonat Oct 8, 2015
c5887d7
Merge remote-tracking branch 'upstream/master'
arizonat Oct 8, 2015
9f119ff
Mostly working now, camera rotation is funky though
arizonat Oct 9, 2015
873d8d4
Added cow normals image
arizonat Oct 10, 2015
e3634e8
Initial implementation of geometry shader, sort of works
arizonat Oct 10, 2015
1dce804
Better camera control with mouse
arizonat Oct 10, 2015
3a50887
Back to originalish code...but still whacky perspective transforms
arizonat Oct 10, 2015
e6d597e
Fixed the crazy perspective transform
arizonat Oct 10, 2015
8be8b0b
Added antialiasing with simple patterns
arizonat Oct 11, 2015
59dedb4
Added additional antialiasing renders
arizonat Oct 11, 2015
e3512f9
Instancing working, a little sketchy, but working
arizonat Oct 11, 2015
9857be7
Update README.md
arizonat Oct 11, 2015
84e5f69
Performance tweaks
arizonat Oct 11, 2015
8cafc04
Buncha renders
arizonat Oct 11, 2015
90e16fa
Merge branch 'master' of https://github.com/arizonat/Project4-CUDA-Ra…
arizonat Oct 11, 2015
a490924
Update README.md
arizonat Oct 11, 2015
42d246a
Update README.md
arizonat Oct 11, 2015
e050dac
Update README.md
arizonat Oct 11, 2015
69fe126
Update README.md
arizonat Oct 11, 2015
57f9fb9
A few more renders
arizonat Oct 11, 2015
569affc
Added some charts
arizonat Oct 11, 2015
9bbb2f2
Update README.md
arizonat Oct 11, 2015
8c7ca48
Update README.md
arizonat Oct 11, 2015
4750d91
Update README.md
arizonat Oct 12, 2015
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
420 changes: 87 additions & 333 deletions README.md

Large diffs are not rendered by default.

Binary file added renders/aa_vs_fps.png.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 renders/anti_aliasing_3_v_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 renders/anti_aliasing_cow_3_v_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 renders/cow_color_interpolation.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 renders/cow_initial_GS.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 renders/cow_instancing.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 renders/cow_normals.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 renders/cows_normals.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 renders/depth_test_flower.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 renders/pie_chart.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 renders/render_gone_wrong.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 renders/trisize_vs_fps.png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 84 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
*/

#include "main.hpp"
#include <cuda.h>
#include <glm/gtc/constants.hpp>
#include <glm/gtx/rotate_vector.hpp>

static Cam cam;
static bool camIsMobile;
static glm::vec2 oldCursorPos;

//-------------------------------
//-------------MAIN--------------
Expand Down Expand Up @@ -78,7 +85,7 @@ void runCuda() {
dptr = NULL;

cudaGLMapBufferObject((void **)&dptr, pbo);
rasterize(dptr);
rasterize(dptr, cam);
cudaGLUnmapBufferObject(pbo);

frame++;
Expand All @@ -99,13 +106,27 @@ bool init(obj *mesh) {

width = 800;
height = 800;

cam.width = width;
cam.height = height;
cam.pos = glm::vec3(0.0f, 0.0f, 5.0f);
cam.focus = glm::vec3(0.0f, 0.0f, 0.0f);
cam.up = glm::vec3(0.0f, -1.0f, 0.0f);
cam.fovy = 45.0f * glm::pi<float>() / 180.0f;
cam.zNear = 0.1f;
cam.zFar = 100.0f;
cam.aspect = 1.0f;

window = glfwCreateWindow(width, height, "CIS 565 Pathtracer", NULL, NULL);
if (!window) {
glfwTerminate();
return false;
}
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, keyCallback);
glfwSetScrollCallback(window, scrollCallback);
glfwSetCursorPosCallback(window, cursorCallback);
glfwSetMouseButtonCallback(window, mouseCallback);

// Set up GL context
glewExperimental = GL_TRUE;
Expand Down Expand Up @@ -270,7 +291,68 @@ void errorCallback(int error, const char *description) {
}

void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) {

glm::vec3 camView = glm::normalize(cam.focus - cam.pos);
glm::vec3 camUp = cam.up;
glm::vec3 camRight = glm::cross(camView, camUp);

if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
glfwSetWindowShouldClose(window, GL_TRUE);
}
}
else if (key == GLFW_KEY_DOWN && action == GLFW_PRESS){
cam.pos += camUp * 0.1f;
cam.focus += camUp * 0.1f;
}
else if (key == GLFW_KEY_UP && action == GLFW_PRESS){
cam.pos += camUp * -0.1f;
cam.focus += camUp * -0.1f;
}
else if (key == GLFW_KEY_RIGHT && action == GLFW_PRESS){
cam.pos += camRight * -0.1f;
cam.focus += camRight * -0.1f;
}
else if (key == GLFW_KEY_LEFT && action == GLFW_PRESS){
cam.pos += camRight * 0.1f;
cam.focus += camRight * 0.1f;
}
// Reset
else if (key == GLFW_KEY_R && action == GLFW_PRESS){
cam.pos = glm::vec3(0.0, 0.0, 4.0);
cam.focus = glm::vec3(0.0);
}
}

void scrollCallback(GLFWwindow *window, double x_offset, double y_offset){
glm::vec3 camView = glm::normalize(cam.focus - cam.pos);
cam.pos += camView * (float)y_offset;
cam.focus += camView * (float)y_offset;
}

void mouseCallback(GLFWwindow *window, int button, int action, int mods){
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS){
camIsMobile = true;
}
else {
camIsMobile = false;
}
}

void cursorCallback(GLFWwindow *window, double x_pos, double y_pos){
glm::vec3 camView = glm::normalize(cam.focus - cam.pos);
glm::vec3 camUp = cam.up;
glm::vec3 camRight = glm::cross(camView, camUp);

glm::vec3 rotatedView;

if (camIsMobile){
float x_diff = x_pos - oldCursorPos[0];
float y_diff = y_pos - oldCursorPos[1];

rotatedView = glm::rotate(camView, y_diff/100.0f, camRight);
rotatedView = glm::rotate(rotatedView, x_diff/100.0f, camUp);
cam.up = camUp;
cam.focus = cam.pos + glm::normalize(rotatedView);
}
oldCursorPos[0] = x_pos;
oldCursorPos[1] = y_pos;
}
3 changes: 3 additions & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ void deleteTexture(GLuint *tex);
void mainLoop();
void errorCallback(int error, const char *description);
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods);
void scrollCallback(GLFWwindow *window, double x_offset, double y_offset);
void mouseCallback(GLFWwindow *window, int button, int action, int mods);
void cursorCallback(GLFWwindow *window, double x_pos, double y_pos);
Loading