3D Graphics

8 Articles

The Bumblebee Project

What is the Bumblebee project?

The Ubuntu Wiki has a better explanation:

“Bumblebee aims to provide support for NVIDIA Optimus laptops for GNU/Linux distributions. Using Bumblebee, you can use your NVIDIA card for rendering graphics which will be displayed using the Intel card.Bumblebee is officially supported by Ubuntu in 14.04 newer. However, all releases are supported by the Bumblebee Project community from Ubuntu version 12.04 up to 14.04.”

I came across this while searching a driver for my graphics card.  I’m using a DELL laptop with a hybrid graphics card – NVIDIA GeForce GT 525M.  I found no satisfactory drivers in the linux(Ubuntu) platform that works perfectly.  Even though I tried configuring with different versions of NVIDIA Drivers for Ubuntu, the libGL.so module was always crashing when the application loads.  I setup bumblebee, and it worked.

Click here for the instructions to setup graphics cards for your NVIDIA Optimus laptops with Linux(Ubuntu distribution)

After configuration, use the optirun command to run the application with the NVIDIA card,

optirun ./myapp

To test it, install glmark2 which is a benchmarking tool for Opengl.

sudo apt-get install glmark2

After successful installation, run the command in the terminal,

optirun glmark2

It will show up the details of the graphics card and performs various tests along with preview.

screenshot-from-2016-12-20-234012 screenshot-from-2016-12-20-234134

Blender Coordinate System to OpenGL

Some simple transformations may require when we import a 3d model from a modeling package which uses different coordinate system than the 3D engine we use.   Though both Blender and OpenGL use right handed coordinate system,  Blender is designed to have its z axis point upwards.  So if we import a 3d model which is created in Blender with its height along Z axis, the model seem to aligned with the view direction if we try to draw it in OpenGL with the default model, projection transformations.  We need to apply some rotations, translations as well as some vertex reordering to make the geometry visually appear similar to where we have created it.

I hope Blender has its coordinate system pretty hard coded into this.  And I found this question in a few game development forums asking for a solution.

Coordinate System

Differences in Axis orientations in both Blender and OpenGL.



Read More →

Writing a scene exporter addon for Blender

This tutorial will explain how to pull the scene data(meshes, lights, cameras, animations) from Blender and dump them into a desired file format for our use.  This is what every addon in the Blender does.  This article emphasize more on how to read the required data from blender scene, not how exactly the procedures to put them into an addon.

Blender Exporter Menu

First of all, Blender is a 3D modeling/animation platform is built using C++ and Python.  Python is used for extending its existing functionalities and is released as the Blender-Python API.  It can be found here.

Read More →

Blender Animation Timeline Units

Couple of days ago, I received some mail from a friend asking some doubts regarding the Blender Timeline and its time units.    He was trying to relate between the numbers in the Timeline and the time units in the exported animation file(in Collada format).  After listening to his query, I was glad that I solved that long time back itself, it was to import skeletel animation from a collada file exported from Blender.  If you don’t know that the Blender timeline has frame numbers, it can be a little bit confusing and misleading.  The exported Collada file has them in seconds represented by floating point numbers.  The question of how to convert the frame numbers to time has a simple and straight forward answer.

The Blkender timeline

Blender timeline

Read More →

Backface Culling

It is a test using which we can avoid drawing some faces of the geometry which the user not likely to see, thus improving the performance of rendering.  Using this test, the renderer module can efficiently skip the faces while drawing, using the following way.

We can imagine that every polygon has two sides.  We need to draw the polygon only if it is facing the viewer, and we just skip drawing the polygons which are not facing the user.  To determine whether a polygon is facing the user or not, just calculate the polygon’s Normal vector and calculate the angle between the viewer’s view direction and the normal vector.


In the above figure, the blue lines represent the normal corresponding to each of those planes.  you can see there are normals facing away from the viewer.

Read More →

Triangle Rasterization

This functionality is the heart of any 3D APIs such as Direct3D or OpenGL.

It addresses the problem, how fast you can render a triangle?

in 3D graphics, all the geometry entities are composed of polygons, where a single polygon can be represented by the help of one or more triangles.


In general, any complex geometry can be divided into a number of triangles and we can solve them individually. Thus, to draw a geometry, we have to provide these 3D APIs with a collection of polygons or triangles. And they’ll draw the triangles on the screen using their version of Triangle Rasterization function. Read More →

3D Projection using lens formula

This is how I re-invented the wheel 🙂

This is an alternate approach to do projection in computer graphics using a lens formula. As it is a technique which is derived from lens formula, the focal length of the lens is the major parameter. The traditional projection techniques uses the ‘field of view’ value – which is an angle expressed in degrees or radians.

Anyways, if you are a person who didn’t even experienced the 3D graphics programming, you may ask these following questions to yourself before you get started.

1. How to draw 3D objects on a 2D Plane?

2. How can we plot a 3D vertex(x, y, z) into a 2D plane which has only 2 axes.

I asked this questions to myself long time back before attending some 3D graphics lessons. As a result, after some days of deep thought, I landed up with an idea to go through my Physics book. I flipped through the pages and stopped at the chapter Ray Optics. Finally, after some days, I ended up with some clues to solve the above problems. The final outcome of this was an equation by which we can accomplish projection. Later when I covered computer graphics I came to know that this is called the “Projection” operation in 3D Graphics. Yeah. The moment I came to know that I re-invented the wheel.

Here we start,

\frac{1}{v} - \frac{1}{u} = \frac{1}{f}

Read More →

Stepping into the 3rd Dimension

teapot_shadedThis is an old story. Almost 8 years ago I reinvented the projection technique of computer graphics.  Being a computer graphics lover, I and had an urge to switch into 3D graphics as it was almost bored working with the existing 2D graphics APIs in C.  The dilemma was that I haven’t covered any computer graphics topics since then, it was really doubtful to make it possible under dos.  However, I achieved this by putting my attention back to the old physics textbook. Flipped the pages and stopped right at the ray-optics chapter.  After some days, the R&D activity ended up with the derivation of an own projection method using the concave mirror formula. It had a mathematical proof too, but not published here or anywhere, I just left in my shelf itself.

This a small trick illustrating how to create a 3d version of your 2d graphics functions such as DrawLine(x1, y1, x2, y2) , SetPixel(x, y, color).  Let the above two functions, have 3d version DrawLine(x1, y1, z1, x2, y2, z2) and SetPixel(x, y, z, color).  Obviously the 3d version has z coordinate.  It is a genuine question for a beginner what to do with the z value. Read More →

print ''; /** lol **/