{"id":4,"date":"2025-04-11T13:51:17","date_gmt":"2025-04-11T13:51:17","guid":{"rendered":"https:\/\/blog.metu.edu.tr\/e251884\/?p=4"},"modified":"2025-04-12T14:40:47","modified_gmt":"2025-04-12T14:40:47","slug":"my-homework-journey-bezier-curves-and-surfaces-in-computer-graphics","status":"publish","type":"post","link":"https:\/\/blog.metu.edu.tr\/e251884\/2025\/04\/11\/my-homework-journey-bezier-curves-and-surfaces-in-computer-graphics\/","title":{"rendered":"My Homework Journey:  CENG 469 Homework 1"},"content":{"rendered":"\n<p>Hey everyone! I wanted to share my experience working on my computer graphics homework, where I implemented Bezier curves and surfaces. It was a fun but sometimes frustrating journey.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Starting with Bezier Curves<\/h2>\n\n\n\n<p>First, I took the given 2D Bezier Curve MATLAB program and extended it to 3D. I wrote a function to generate Bezier curve points and checked the results in Octave. The results were nice and acceptable for the homework. So, I decided to generate random Bezier curves within the scene limits with some basic tweaks. For simplicity, I used the Bezier curve equation instead of matrix calculations. I could not understand why but the matrix representation resulted in mislocated start and end points although the curves were legit Bezier curves.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Shaders and Visualization<\/h3>\n\n\n\n<p>I used separate vertex and fragment shaders for the curves:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Vertex shader<\/strong>: Just position coordinates.<\/li>\n\n\n\n<li><strong>Fragment shader<\/strong>: Only color (no shading, since that was enough for me).<\/li>\n<\/ul>\n\n\n\n<p>I drew the curve and control points to figure out a good sampling frequency and length.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-49-1024x555.png\" alt=\"\" class=\"wp-image-9\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-49-1024x555.png 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-49-300x162.png 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-49-768x416.png 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-49-1536x832.png 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-49.png 1850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-11-30-1024x555.png\" alt=\"\" class=\"wp-image-10\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-11-30-1024x555.png 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-11-30-300x162.png 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-11-30-768x416.png 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-11-30-1536x832.png 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-11-30.png 1850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"555\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-34-1024x555.png\" alt=\"\" class=\"wp-image-11\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-34-1024x555.png 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-34-300x162.png 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-34-768x416.png 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-34-1536x832.png 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-17-02-10-34.png 1850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Then, I created a point and moved it along the curve.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1002\" style=\"aspect-ratio: 1850 \/ 1002;\" width=\"1850\" controls src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/video1.mp4\"><\/video><\/figure>\n\n\n\n<p>Later, I increased the speed and added more random curves for the point to follow.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1002\" style=\"aspect-ratio: 1850 \/ 1002;\" width=\"1850\" controls src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/video2.mp4\"><\/video><\/figure>\n\n\n\n<p>At this point I realized that somehow I need to dictate that the curves are long enough to be visually pleasant by paying attention to the constraints:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Min\/max values based on the scene.<\/li>\n\n\n\n<li><strong>C1 continuity<\/strong>&nbsp;(so the curves connect smoothly).<\/li>\n<\/ul>\n\n\n\n<p>I also drew the tangent of the curve to visualize it. I calculated the tangent by subtracting the last point from the current point (With a little trick for the first point of course).<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1008\" style=\"aspect-ratio: 1838 \/ 1008;\" width=\"1838\" controls src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/video3.mp4\"><\/video><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Moving the Bunny<\/h2>\n\n\n\n<p>Next, I replaced the green point with the given bunny object. I removed all pitch and roll movements at first.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Used&nbsp;<code>(0, 1, 0)<\/code>&nbsp;as the initial up vector.<\/li>\n\n\n\n<li>Used the current tangent as the gaze vector.<\/li>\n\n\n\n<li>Created a basis for the tangent and transformed the bunny into this basis.<\/li>\n<\/ul>\n\n\n\n<p>The problem I encountered at this point was the alignment of the object because there was not a middle or center point of the object. To solve this problem I calculated the middle point by taking average of edge coordinates (highest and lowest etc) and changed the transition matrix based on the object. It worked for the bunny but I knew that this was not a good solution. However I decided to create my object by knowing the center point instead of trying to generate an algorithm or rules for the center point.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1008\" style=\"aspect-ratio: 1838 \/ 1008;\" width=\"1838\" controls src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/video4.mp4\"><\/video><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Adding Roll Motion<\/h3>\n\n\n\n<p>I introduced a quaternion to make the bunny roll 45 degrees back and forth. I reordered the transformations:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Scaling<\/li>\n\n\n\n<li>Rotating<\/li>\n\n\n\n<li>Rolling<\/li>\n\n\n\n<li>Translation<\/li>\n<\/ol>\n\n\n\n<p>This looked better. Here the initial up vector is looking down. At this stage I did not realize this mistake. But towards the end of the homework I solved the issue. It was related to the vector calculations.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1008\" style=\"aspect-ratio: 1838 \/ 1008;\" width=\"1838\" controls src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/video5.mp4\"><\/video><\/figure>\n\n\n\n<p>Problems I Noticed at This Stage<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fully random curves sometimes looked weird. The control point generator needed tuning.<\/li>\n\n\n\n<li>The object\u2019s movement speed and rolling speed needed adjustment for smoother motion.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Moving to Bezier Surfaces<\/h2>\n\n\n\n<p>I wrote an Octave script to visualize Bezier surfaces. I colored points differently to make design easier.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/single-surface-1024x514.jpg\" alt=\"\" class=\"wp-image-17\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/single-surface-1024x514.jpg 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/single-surface-300x151.jpg 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/single-surface-768x386.jpg 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/single-surface-1536x772.jpg 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/single-surface-2048x1029.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Half-Sphere Example<\/h3>\n\n\n\n<p>I created a customizable half-sphere-like Bezier surface generator with Octave. With the code half sphere like Bezier surfaces can be generated by defining the center point and some parameters based on the center point ( which I defined by experimenting with them and which I can not interpret exactly what they are doing  \ud83d\ude43.)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/bezierHalfConvex-1024x514.jpg\" alt=\"\" class=\"wp-image-18\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/bezierHalfConvex-1024x514.jpg 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/bezierHalfConvex-300x151.jpg 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/bezierHalfConvex-768x386.jpg 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/bezierHalfConvex-1536x772.jpg 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/bezierHalfConvex-2048x1029.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The Octave code:<\/p>\n\n\n\n<pre class=\"wp-block-code alignwide\"><code>function &#091;P] = bezierHalfConvex(r, s, u, k, b)\n    P = { &#091;r 0 0], &#091;r r*s 0], &#091;-r r*s 0], &#091;-r 0 0]; ...\n           &#091;(r*u) 0 b], &#091;(r*u) (r*s*u) k], &#091;(-r*u) (r*s*u) k], &#091;(-r*u) 0 b]; ...\n           &#091;(r*u) 0 b], &#091;(r*u) -(r*s*u) k], &#091;(-r*u) -(r*s*u) k], &#091;(-r*u) 0 b]; ...\n           &#091;r 0 0], &#091;r -r*s 0], &#091;-r -r*s 0], &#091;-r 0 0] \n        };\nend<\/code><\/pre>\n\n\n\n<p>I also wrote Octave functions to rotate and translate the surfaces. All Octave codes are uploaded with the homework.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating the Moving Object<\/h3>\n\n\n\n<p>With the Bezier surface calculator, half sphere generator, rotation, translation codes in my hand, I started to create an object by using Bezier Surfaces. The definitions can be found in<mark style=\"background-color:#ffe2c7\" class=\"has-inline-color has-foreground-color\"> <\/mark><mark style=\"background-color:#ffe2c7\" class=\"has-inline-color has-primary-color\">bezierScript.m<\/mark> file. I tried to draw something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"710\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/depositphotos_11234785-stock-illustration-cartoon-spaceship.jpg\" alt=\"\" class=\"wp-image-19\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/depositphotos_11234785-stock-illustration-cartoon-spaceship.jpg 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/depositphotos_11234785-stock-illustration-cartoon-spaceship-300x208.jpg 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/depositphotos_11234785-stock-illustration-cartoon-spaceship-768x533.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This is what I could before getting bored by point calculations. <\/p>\n\n\n\n<p>\ud83c\udf7d\ufe0f Ingredients are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>2 Bezier half convexes (I used my script for all half convexes) for the front and back of the plane.<\/li>\n\n\n\n<li>1 half cylinder for base of the plane<\/li>\n\n\n\n<li>2 half cylinder like shapes for the sitting area, current shape:<br><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/version-1-1024x514.jpg\" alt=\"\" class=\"wp-image-20\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/version-1-1024x514.jpg 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/version-1-300x151.jpg 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/version-1-768x386.jpg 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/version-1-1536x772.jpg 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/version-1-2048x1029.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1 to close sitting area completely<\/li>\n\n\n\n<li>2 for wings<\/li>\n\n\n\n<li>1 for the wing like shape on the upper back of the plane, up to now:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/space-shuttle-1024x514.jpg\" alt=\"\" class=\"wp-image-22\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/space-shuttle-1024x514.jpg 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/space-shuttle-300x151.jpg 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/space-shuttle-768x385.jpg 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/space-shuttle-1536x771.jpg 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/space-shuttle-2048x1028.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Adding some cosmetics:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1 half convex for the steering wheel shaft<\/li>\n\n\n\n<li>2 half convex for the sterring wheel, the end result:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/cosmetic-1024x514.jpg\" alt=\"\" class=\"wp-image-21\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/cosmetic-1024x514.jpg 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/cosmetic-300x151.jpg 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/cosmetic-768x385.jpg 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/cosmetic-1536x771.jpg 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/cosmetic-2048x1028.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Moving to C++<\/h3>\n\n\n\n<p>I transferred the points to C++ by simply outputting the calculated points from Octave script and:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Generated 30 Bezier curves.<\/li>\n\n\n\n<li>Used those points to create a 30\u00d730 resolution Bezier surface.<\/li>\n\n\n\n<li>Calculated indices using a simple triangle method (3 vertices per triangle \u2192 1682 * 3 indices).<\/li>\n\n\n\n<li>Calculated the normals by averaging the triangle normals. However, I made a mistake at this point. I realized it too late, and I had already spent a lot of time on the homework. My normal calculations are not fully appropriate for the homework specification, since I calculated them using only the current surface. Because of how I structured the code (I kept the surfaces isolated from each other), fixing this would be a laborious task. I thought about manually selecting adjacent surfaces and writing loops for those, but that feels tiring and like an ugly solution. Another option is merging the surfaces and storing them as a whole, and recalculating the normals, but that would require a good amount of refactor. So, I sadly decided to skip this requirement.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Exporting and Rendering<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Exported the generated object to an OBJ file to use the existing code for obj files.<\/li>\n\n\n\n<li>Adapted rotation, scale, and translation matrices to put the object on the curve correctly.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Problems and Fixes<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Upside-Down Object<\/strong>\n<ul class=\"wp-block-list\">\n<li>There was a mistake in the up vector calculation. It was upside down. I corrected the mistake by simply changing the sign.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Incorrect Normals<\/strong>\n<ul class=\"wp-block-list\">\n<li>Some surfaces were facing the wrong way which causes them to be ignored because of the back face culling.<\/li>\n\n\n\n<li>Quick fix: Reversed the order of Bezier curves in the points data.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Assigning the Key Presses<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Space<\/strong>: Pauses movement.<\/li>\n\n\n\n<li><strong>P<\/strong>: Stops drawing the curve and curve related things (the tangent vector, up vector etc.)<\/li>\n\n\n\n<li><strong>W<\/strong>: Enables wireframe mode (I had to modify the shader).<\/li>\n<\/ul>\n\n\n\n<p>After pressing Space and P:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"559\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-33-1024x559.png\" alt=\"\" class=\"wp-image-23\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-33-1024x559.png 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-33-300x164.png 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-33-768x419.png 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-33-1536x839.png 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-33.png 1899w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After pressing Space + P + W:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"559\" src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-40-1024x559.png\" alt=\"\" class=\"wp-image-24\" srcset=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-40-1024x559.png 1024w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-40-300x164.png 300w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-40-768x419.png 768w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-40-1536x839.png 1536w, https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/Screenshot-from-2025-03-27-04-32-40.png 1899w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Last-Minute Changes<\/h3>\n\n\n\n<p>The homework required the Bezier surface resolution (<code>s<\/code>&nbsp;and&nbsp;<code>t<\/code>) to be parametric. I initially thought they were separate but realized they were the same. Instead of reverting, I just set both to the same value. So now both of them are customizable but the program takes one argument for them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Thoughts<\/h2>\n\n\n\n<p>It was a long but rewarding homework! There are still some imperfections, but I learned a lot. You can see a resolution vs fps table at the end.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1012\" style=\"aspect-ratio: 1848 \/ 1012;\" width=\"1848\" controls src=\"https:\/\/blog.metu.edu.tr\/e251884\/files\/2025\/04\/last.mp4\"><\/video><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Bezier Surface Resolution vs FPS Table<\/h3>\n\n\n\n<p>My monitor is 144hz. There is a performance problem about wireframe mode when resolution is high (Up to 96 there is no problem). I do not know the reason. To enable wireframe mode I am<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Changing glPolygonMode from &#8220;fill&#8221; to &#8220;line&#8221;<\/li>\n\n\n\n<li>Adding an if condition into the vertex shader<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><strong>Resolution<\/strong><\/td><td class=\"has-text-align-center\" data-align=\"center\"><strong>Frame per Second<\/strong><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">3&#215;3<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">6&#215;6<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">12&#215;12<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">24&#215;24<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">48&#215;48<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">96&#215;96<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">200&#215;200<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<br>(But in the wireframe mode it fluctuates between 70 and 90)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">400&#215;400<\/td><td class=\"has-text-align-center\" data-align=\"center\">144 (constant)<br>wireframe: 26-27<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">800&#215;800<\/td><td class=\"has-text-align-center\" data-align=\"center\">64-65 (stable)<br>wireframe: 7 (constant \ud83e\udd72)<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">1600&#215;1600<\/td><td class=\"has-text-align-center\" data-align=\"center\">18-19 (stable)<br>wireframe: 2 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey everyone! I wanted to share my experience working on my computer graphics homework, where I implemented Bezier curves and surfaces. It was a fun but sometimes frustrating journey. Starting with Bezier Curves First, I took the given 2D Bezier Curve MATLAB program and extended it to 3D. I wrote a function to generate Bezier [&hellip;]<\/p>\n","protected":false},"author":8372,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-4","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/posts\/4","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/users\/8372"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":0,"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.metu.edu.tr\/e251884\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}