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: Siqi Huang #2

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e8f59d9
version1
siqihuang Oct 7, 2015
a0f67d8
version 2
siqihuang Oct 9, 2015
a0bc24d
images
siqihuang Oct 9, 2015
c1b3ce9
images
siqihuang Oct 9, 2015
05c9cf9
Update README.md
siqihuang Oct 9, 2015
73d5636
Update README.md
siqihuang Oct 9, 2015
136bc1c
Update README.md
siqihuang Oct 9, 2015
d2fbfea
Update README.md
siqihuang Oct 9, 2015
b8931c3
Update README.md
siqihuang Oct 9, 2015
0e751db
Update README.md
siqihuang Oct 9, 2015
b46f30a
Update README.md
siqihuang Oct 9, 2015
f868678
Update README.md
siqihuang Oct 9, 2015
bd9fc10
screenshot
siqihuang Oct 9, 2015
be32b86
Update README.md
siqihuang Oct 9, 2015
8515f8a
Update README.md
siqihuang Oct 9, 2015
227fc2f
Update README.md
siqihuang Oct 9, 2015
b06eeec
Update README.md
siqihuang Oct 9, 2015
62dce9a
change
siqihuang Oct 9, 2015
053a656
Update README.md
siqihuang Oct 9, 2015
d672d48
Update README.md
siqihuang Oct 9, 2015
369d158
image
siqihuang Oct 9, 2015
880d68d
Update README.md
siqihuang Oct 9, 2015
be183ae
Update README.md
siqihuang Oct 9, 2015
d08f1f4
Update README.md
siqihuang Oct 9, 2015
727d8ef
Update README.md
siqihuang Oct 9, 2015
7de052a
Update README.md
siqihuang Oct 9, 2015
28e5d91
Update README.md
siqihuang Oct 9, 2015
2f82e30
Update README.md
siqihuang Oct 9, 2015
fbabf47
Update README.md
siqihuang Oct 9, 2015
3fdb8df
Update README.md
siqihuang Oct 9, 2015
fce7543
Update README.md
siqihuang Oct 9, 2015
f75d986
ana_images
siqihuang Oct 9, 2015
52d070e
bug fix
siqihuang Oct 9, 2015
951029f
Update README.md
siqihuang Oct 9, 2015
4684223
Update README.md
siqihuang Oct 9, 2015
adaf7d1
name change
siqihuang Oct 9, 2015
e9182cb
new image
siqihuang Oct 9, 2015
a901d7b
Update README.md
siqihuang Oct 9, 2015
d1161b8
name change
siqihuang Oct 9, 2015
3ec8a30
renew image
siqihuang Oct 9, 2015
aa89eba
Update README.md
siqihuang Oct 9, 2015
41fd9d3
Update README.md
siqihuang Oct 9, 2015
025b45f
Update README.md
siqihuang Oct 9, 2015
80227d6
Update README.md
siqihuang Oct 9, 2015
58fe19a
Update README.md
siqihuang Oct 9, 2015
87057f4
Update README.md
siqihuang Oct 9, 2015
396b0b5
Update README.md
siqihuang Oct 9, 2015
a3e7038
Update README.md
siqihuang Oct 9, 2015
f4918bb
Update README.md
siqihuang Oct 9, 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
Prev Previous commit
Next Next commit
ana_images
siqihuang committed Oct 9, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit f75d98685c9cd5c937a89595599b8c38beaf31ea
Binary file added image/ana_crossobject2.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 image/ana_crossobjects1.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 output/Sample114.bmp
Binary file not shown.
Binary file added output/Sample142.bmp
Binary file not shown.
Binary file added output/Sample143.bmp
Binary file not shown.
7 changes: 5 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ int main(int argc, char **argv) {
cin>>usAnti;
if(usAnti=='y') anti=4;

for(int i=0;i<5;++i) Gtime[i]=0;

obj *mesh = new obj();

{
@@ -53,7 +55,7 @@ int main(int argc, char **argv) {
// GLFW main loop
mainLoop();
}

for(int i=0;i<5;++i) cout<<Gtime[i]<<endl;
return 0;
}

@@ -82,6 +84,7 @@ void mainLoop() {
// VAO, shader program, and texture already bound
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
glfwSwapBuffers(window);
if(frame==100) break;
}
glfwDestroyWindow(window);
glfwTerminate();
@@ -97,7 +100,7 @@ void runCuda() {
dptr = NULL;

cudaGLMapBufferObject((void **)&dptr, pbo);
rasterize(dptr,lightPos,cameraUp,cameraFront,fov,cameraDis,rotation,outputImage,fog,anti,frame);
rasterize(dptr,lightPos,cameraUp,cameraFront,fov,cameraDis,rotation,outputImage,fog,anti,frame,Gtime);
//outputImage=false;
cudaGLUnmapBufferObject(pbo);

1 change: 1 addition & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ GLfloat rotation=0.0f;
bool firstMouse=true;
bool outputImage=false;
bool fog=false;
float *Gtime=new float[5];
int anti=1;
string texture;
glm::vec3 lightPos = glm::vec3(-2.0f, 0.0f, -5.0f);
40 changes: 36 additions & 4 deletions src/rasterize.cu
Original file line number Diff line number Diff line change
@@ -150,6 +150,7 @@ __global__ void rasterization(Triangle *primitives,Fragment *fg_out,int *depth,g
if(isBarycentricCoordInBounds(tmp)){
int currentDepth=(int)(1e6*getZAtCoordinate(tmp,tri));
atomicMin(&depth[i*Len+j],currentDepth);
//continue;
if(currentDepth==depth[i*Len+j]){
glm::vec3 n1=primitives[index].v[0].nor;
glm::vec3 n2=primitives[index].v[1].nor;
@@ -348,20 +349,35 @@ void imageOutput(glm::vec3 *frameBuffer,int num){
* Perform rasterization.
*/
void rasterize(uchar4 *pbo,glm::vec3 lightPos,glm::vec3 cameraUp,glm::vec3 cameraFront,
float fovy,float cameraDis,float rotation,bool outputImage,bool fog,int anti,int frame) {
float fovy,float cameraDis,float rotation,bool outputImage,bool fog,int anti,int frame,float *time) {
int sideLength2d = 8;
dim3 blockSize2d(sideLength2d, sideLength2d);
dim3 blockCount2d((width - 1) / blockSize2d.x + 1,
(height - 1) / blockSize2d.y + 1);

cudaEvent_t start, stop;
float milliseconds = 0;
cudaEventCreate(&start);
cudaEventCreate(&stop);
// TODO: Execute your rasterization pipeline here
// (See README for rasterization pipeline outline.)

cudaEventRecord(start);
vertexShading<<<(vertCount+127)/128,128>>>(dev_bufVertex,dev_vertexOut,cameraUp,cameraFront,fovy,cameraDis,rotation,vertCount);
cudaEventCreate(&stop);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&milliseconds, start, stop);
time[0]+=milliseconds;

cudaEventRecord(start);
primitiveAssemblyTest<<<(bufIdxSize/3+127)/128,128>>>(dev_vertexOut,dev_bufIdx,dev_primitives,bufIdxSize/3);
setColorToBlue<<<(width*height+127)/128,128>>>(dev_depthbuffer,fog,width*height);

setDepthMax<<<(width*height+127)/128,128>>>(dev_depth,width*height);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&milliseconds, start, stop);
time[1]+=milliseconds;

cudaEventRecord(start);
float dx=0,dy=0;
glm::vec3 *dev_tmp;
cudaMalloc(&dev_tmp, width*height*sizeof(glm::vec3));
@@ -375,12 +391,28 @@ void rasterize(uchar4 *pbo,glm::vec3 lightPos,glm::vec3 cameraUp,glm::vec3 camer
}
copyBack<<<(width*height+127)/128,128>>>(dev_tmp,dev_depthbuffer,width*height);
cudaFree(dev_tmp);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&milliseconds, start, stop);
time[2]+=milliseconds;

cudaEventRecord(start);
if(fog) blending<<<(width*height+127)/128,128>>>(dev_depthbuffer,dev_depth,width*height);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&milliseconds, start, stop);
time[3]+=milliseconds;

cudaEventRecord(start);
// Copy depthbuffer colors into framebuffer
render<<<blockCount2d, blockSize2d>>>(width, height, dev_depthbuffer, dev_framebuffer);
// Copy framebuffer into OpenGL buffer for OpenGL previewing
sendImageToPBO<<<blockCount2d, blockSize2d>>>(pbo, width, height, dev_framebuffer);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
cudaEventElapsedTime(&milliseconds, start, stop);
time[4]+=milliseconds;


if(outputImage&&frame%5==0) imageOutput(dev_framebuffer,frame/5);

2 changes: 1 addition & 1 deletion src/rasterize.h
Original file line number Diff line number Diff line change
@@ -18,6 +18,6 @@ void initTexture(std::string fileName);
void rasterizeSetBuffers(
int bufIdxSize, int *bufIdx,
int vertCount, float *bufPos, float *bufNor, float *bufCol, float *bufTex, int *texIdx);
void rasterize(uchar4 *pbo,glm::vec3 lightPos,glm::vec3 cameraUp,glm::vec3 cameraFront,float fovy,float cameraDis,float rotation,bool outputImage,bool fog,int anti,int frame);
void rasterize(uchar4 *pbo,glm::vec3 lightPos,glm::vec3 cameraUp,glm::vec3 cameraFront,float fovy,float cameraDis,float rotation,bool outputImage,bool fog,int anti,int frame,float *time);
void rasterizeFree();
//void imageOutput(glm::vec3 *frameBuffer);
2 changes: 1 addition & 1 deletion util/obj.cpp
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ void obj::buildBufPoss() {
if (faces.size() != (int) facenormals.size()||facenormals[0].size()==0) {
genNormals = true;
}
cout<<genNormals<<endl;
//cout<<genNormals<<endl;
for (int k = 0; k < (int) faces.size(); k++) {

if (isConvex(faces[k]) == true) {