Skip to content
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
1 change: 1 addition & 0 deletions PROJ1_WIN/565Raytracer/565Raytracer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<CudaCompile>
<CompileOut>$(ProjectDir)$(Platform)/$(Configuration)/%(Filename)%(Extension).obj</CompileOut>
<Include>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include;C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.0/C/common/inc;../shared/glew/includes;../shared/freeglut/includes</Include>
<CodeGeneration>compute_20,sm_20</CodeGeneration>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down
6 changes: 5 additions & 1 deletion PROJ1_WIN/565Raytracer/565Raytracer.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommandArguments>scene="../../scenes/sampleScene.txt"</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>scene="J:\downloads_folder_till_sept26\gundeep-Project1-Raytracer-7a21b6b\scenes\sampleScene.txt"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>scene="J:\downloads_folder_till_sept26\gundeep-Project1-Raytracer-7a21b6b\scenes\sampleScene.txt"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
35 changes: 35 additions & 0 deletions PROJ1_WIN/565Raytracer/Debug/565Raytracer.Build.CppClean.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\565RAYTRACER.EXE.EMBED.MANIFEST
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\565RAYTRACER.EXE.EMBED.MANIFEST.RES
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\565RAYTRACER.EXE.INTERMEDIATE.MANIFEST
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\565Raytracer_manifest.rc
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\cl.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\CL.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\CL.write.1.tlog
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\GLSLUTILITY.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\IMAGE.OBJ
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.6420.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.6420.write.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.6420-cvtres.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.6420-cvtres.write.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link.write.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link-cvtres.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\link-cvtres.write.1.tlog
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\MAIN.OBJ
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\mt.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\mt.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\mt.write.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\raytraceKernel.cu.cache
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\rc.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\rc.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\rc.write.1.tlog
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\SCENE.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\STB_IMAGE.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\STB_IMAGE_WRITE.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\UTILITIES.OBJ
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Debug\vc100.idb
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\DEBUG\VC100.PDB
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\DEBUG\565RAYTRACER.EXE
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\DEBUG\565RAYTRACER.ILK
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\DEBUG\565RAYTRACER.PDB
21 changes: 21 additions & 0 deletions PROJ1_WIN/565Raytracer/Release/565Raytracer.Build.CppClean.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\565RAYTRACER.EXE.INTERMEDIATE.MANIFEST
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\cl.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\CL.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\CL.write.1.tlog
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\GLSLUTILITY.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\IMAGE.OBJ
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\link.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\link.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\link.write.1.tlog
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\MAIN.OBJ
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\mt.command.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\mt.read.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\mt.write.1.tlog
C:\Users\gundeep\Downloads\Project1-Raytracer\PROJ1_WIN\565Raytracer\Release\raytraceKernel.cu.cache
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\SCENE.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\STB_IMAGE.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\STB_IMAGE_WRITE.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\UTILITIES.OBJ
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\565RAYTRACER\RELEASE\VC100.PDB
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\RELEASE\565RAYTRACER.EXE
C:\USERS\GUNDEEP\DOWNLOADS\PROJECT1-RAYTRACER\PROJ1_WIN\RELEASE\565RAYTRACER.PDB
Binary file added PROJ1_WIN/readme_raytracer.pdf
Binary file not shown.
Binary file added PROJ1_WIN/renders/Render1.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 PROJ1_WIN/renders/diffusecolor.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 PROJ1_WIN/renders/raytracer_gpu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion src/interactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,19 @@ __host__ __device__ glm::vec3 calculateRandomDirectionInHemisphere(glm::vec3 nor
//Now that you know how cosine weighted direction generation works, try implementing non-cosine (uniform) weighted random direction generation.
//This should be much easier than if you had to implement calculateRandomDirectionInHemisphere.
__host__ __device__ glm::vec3 getRandomDirectionInSphere(float xi1, float xi2) {
return glm::vec3(0,0,0);


// to locate a point on the sphere we need two things the colatitute phi and longitude theta.

// then we can create a table of Data

const float r = std::sqrt(1.0f - xi1 * xi1);
const float phi = 2 * xi2;

return glm::vec3(glm::cos(phi) * r, glm::sin(phi) * r, xi1);



}

//TODO (PARTIALLY OPTIONAL): IMPLEMENT THIS FUNCTION
Expand Down
241 changes: 240 additions & 1 deletion src/intersections.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "utilities.h"
#include <thrust/random.h>

using namespace glm;

//Some forward declarations
__host__ __device__ glm::vec3 getPointOnRay(ray r, float t);
__host__ __device__ glm::vec3 multiplyMV(cudaMat4 m, glm::vec4 v);
Expand Down Expand Up @@ -72,7 +74,244 @@ __host__ __device__ glm::vec3 getSignOfRay(ray r){
//Cube intersection test, return -1 if no intersection, otherwise, distance to intersection
__host__ __device__ float boxIntersectionTest(staticGeom box, ray r, glm::vec3& intersectionPoint, glm::vec3& normal){

return -1;
vec4 VO= vec4 (r.direction.x,r.direction.y,r.direction.z,0);
vec4 PO= vec4 (r.origin.x,r.origin.y,r.origin.z,1);

VO= glm::vec4(multiplyMV(box.inverseTransform,VO),0);
PO= glm::vec4(multiplyMV(box.inverseTransform,PO),1);

float T1,T2,temp;
float tnear= -500000.000;
float tfar= 500000.000;


vec4 BI= vec4(-0.5,-0.5,-0.5,1);
vec4 BH= vec4(0.5,0.5,0.5,1);

// for each pair of planes

if(VO.x ==0) // the ray is parallel to x planes
{
if (PO.x <BI.x || PO.x>BH.x)//and if ray is not between the slabs then it will not intersect the planes. Logic hai :)
{
return -1;

}
}
else // when ray is not parallel to x axis
// compute intersection distance between the planes.
{
T1= (BI.x- PO.x)/VO.x;
T2= (BH.x - PO.x)/VO.x;

if (T1>T2) // swap T1 T2
{
temp=T1;
T1=T2;
T2=temp;
}

if (T1>tnear)
{
tnear=T1; // we want the largest tnear

}
if( T2<tfar)
{
tfar=T2; // we want smallest tfar
}

if(tnear>tfar) // cube missed
{
return -1;
}

if(tfar<0)
{
return -1; // box bheind the light
}
}



// doing y planes now

if(VO.y == 0) // the ray is parallel to y planes
{
if (PO.y <BI.y || PO.y>BH.y)//and if ray is not between the slabs then it will not intersect the planes. Logic hai :)
{
return -1;

}
}
else // when ray is not parallel to y axis
// compute intersection distance between the planes.
{
T1= (BI.y- PO.y)/VO.y;
T2= (BH.y - PO.y)/VO.y;

if (T1>T2) // swap T1 T2
{
temp=T1;
T1=T2;
T2=temp;
}

if (T1>tnear)
{
tnear=T1; // we want the largest tnear

}
if( T2<tfar )
{
tfar=T2; // we want smallest tfar
}

if(tnear>tfar) // cube missed
{
return -1;
}

if(tfar<0)
{
return -1; // box bheind the light
}
}


// FOR Z PLANES NOW -----

if(VO.z == 0) // the ray is parallel to x planes
{
if (PO.z <BI.z || PO.z>BH.z)//and if ray is not between the slabs then it will not intersect the planes. Logic hai :)
{
return -1;

}
}
else // when ray is not parallel to x axis
// compute intersection distance between the planes.
{
T1= (BI.z- PO.z)/VO.z;
T2= (BH.z - PO.z)/VO.z;

if (T1>T2) // swap T1 T2
{
temp=T1;
T1=T2;
T2=temp;
}

if (T1>tnear)
{
tnear=T1; // we want the largest tnear

}
if(T2<tfar)
{
tfar=T2; // we want smallest tfar
}

if(tnear>tfar) // cube missed
{
return -1;
}

if(tfar<0)
{
return -1; // box bheind the light
}
if(tnear>0)
{
if(abs(tnear)<0.0001)
{
return -1;
}
else
{
glm::vec4 POI= PO+VO*tnear;
if(POI.x<=0.5+EPSILON && POI.x>=0.5-EPSILON)
{
normal=glm::vec3(1,0,0);
}
if(POI.x<=-0.5+EPSILON && POI.x>=-0.5-EPSILON)
{
normal=glm::vec3(-1,0,0);
}
if(POI.y<=0.5+EPSILON && POI.y>=0.5-EPSILON)
{
normal=glm::vec3(0,1,0);
}
if(POI.y<=-0.5+EPSILON && POI.y>=-0.5-EPSILON)
{
normal=glm::vec3(0,-1,0);
}
if(POI.z<=0.5+EPSILON && POI.z>=0.5-EPSILON)
{
normal=glm::vec3(0,0,1);
}
if(POI.z<=-0.5+EPSILON && POI.z>=-0.5-EPSILON)
{
normal=glm::vec3(0,0,-1);
}

vec4 Normal= vec4(normal, 0);
//cudaMat4 transposed = box.tranposeTranform);
normal= multiplyMV(box.tranposeTranform,Normal);
glm::vec3 test= normal;;

}
intersectionPoint = r.origin + r.direction*tnear;
return tnear;
}
}

if (abs(tnear) < 0.001)
return -1;
if (tnear > 0)
{
intersectionPoint = r.origin + r.direction*tnear;
return tnear;
}
if(abs(tfar) < 0.001)
return -1;
if (tfar > 0)
{
glm::vec4 POI= PO+VO*tfar;
if(POI.x<=0.5+EPSILON && POI.x>=0.5-EPSILON)
{
normal=glm::vec3(1,0,0);
}
if(POI.x<=-0.5+EPSILON && POI.x>=-0.5-EPSILON)
{
normal=glm::vec3(-1,0,0);
}
if(POI.y<=0.5+EPSILON && POI.y>=0.5-EPSILON)
{
normal=glm::vec3(0,1,0);
}
if(POI.y<=-0.5+EPSILON && POI.y>=-0.5-EPSILON)
{
normal=glm::vec3(0,-1,0);
}
if(POI.z<=0.5+EPSILON && POI.z>=0.5-EPSILON)
{
normal=glm::vec3(0,0,1);
}
if(POI.z<=-0.5+EPSILON && POI.z>=-0.5-EPSILON)
{
normal=glm::vec3(0,0,-1);
}

vec4 Normal= vec4(normal, 0);
//glm::mat4 transposed2= glm::mat4(box.tranposeTranform);
normal= multiplyMV(box.tranposeTranform,Normal);
glm::vec3 test=normal;
intersectionPoint = r.origin + r.direction*tfar;
return tfar;
}
return -1;

}

//LOOK: Here's an intersection test example from a sphere. Now you just need to figure out cube and, optionally, triangle.
Expand Down
Loading