Computer Graphics HW1 - Bezier Surface Rre

Hi everyone, I will talk about my first assignment in CENG469 course, which is Bezier Surface rendering. Firstly, I will explain how I implement the homework, then I will talk about issues that I faced during the implementation. So, let's begin!



In this assignment, we were expected to render smooth Bezier surfaces in OpenGL whose height information was given. The height information of the surfaces was given with input.txt files. Here’s the input.txt file format

input.txt file format

The very first thing that I do in this assignment is parsing the given txt file according to given information. (I will come to that point in the issue part :), because I was parsing the file in wrong order, and It took me to figure out why my shading is not working properly.). After finishing the parsing operation, I will jump to codebase that was provided to us, I start to analyze the codebase. Because, I forgot the  some functionality of OpenGL. Anyway. 

Then, I start to implement Bezier Surface equations into my program. (When I do the implementation, I get influeced by matlab codes that are provided to us). After getting the input.txt information, I can start to create Bezier Surface's control points. Once I created the control points, then I calculate normal vectors of surfaces to compute shading part of the homework. After the create whole surfaces according to the given input files, I jump to user interaction part of the homework, which are rotating the surface and extending or shrinking the surface coordinates. Hence, here's the final result of my homework.



Let's talk about issues that I face during the implementation.

Challenges - Issues

  •  The first issue is that I had a hard time to manage vertex buffer at the beginning of implementation. Because I cannot render any thing in the first place. Then, I figure out that I was giving wrong buffer size to VBO I should have also multiply vertex numbers with sizeof(float). Once I figured out the problem, I have manage to render my points to the screen.



  • After rendering vertecies as points, the next thing to do is rendering faces. This time, also, I had hard time to figure out the order of indices. 


  • Once I have managed to render my first patch, the next thing is rendering multi patches at the same time. I have managed to render all patches in the input files but I couldn't render in one piece. As you can see the below, there are gaps between patches. I had very hard time to solve this problem, because dealing with indicies in the arrays made my eyes bleed :) 


Before filling the gaps

After filling the gaps


  • When I tried to dealing with normal calculation, I get some annoying outputs like below. I figured out that my normal calculation is face normal calculation, Then, I have changed my normal calculation method, instead of getting face normals, I did calculate every vertex of each triangle normals and take average of them. Once I do it, the artifacts are gone.
Before average calculation

After average calculation



  • This is a very interesting bug for me, because It took probably 5 days to solve this problem. Once I calculate the control points and normals, I start to calculate coloring part. However, there is something going on and I couldn't see it. I couldn't get the correct color output like in the homework document. After five days, I found the problem, the problem is located in my input file parsing function. I took the rgb color information in a wrong order :\ Instead of getting color values in rgb order, I took rbg order :| 
wrong rgb order in parsing function



wrong color of output of input2.txt


In conclusion, this assignment has been a valuable learning experience that has allowed me to gain a deeper understanding of the OpenGL pipeline and the complexities of implementing a bezier surface. Hence, I feel confident that the knowledge and skills I have gained through this assignment will serve me well in my future career.







Comments

Popular posts from this blog

Leveling Up Raven: BVH, Transformations, and Instancing

Raven: The Beginning of My Ray Tracing Journey

Enhancing Raven: Multisampling and Distribution Ray Tracing