Showing posts with label OpenGL. Show all posts
Showing posts with label OpenGL. Show all posts

Friday, 14 March 2014

OpenGL Sandbox - My first shader

Here it is the rendering of the Utah Teapot and the Stanford Dragon rendered with my first shader. 



It's a very simple shader and it does not create any light source in the scene. The depth perception is given by the coloration of the triangles. As you can see in the teapot image, each triangle is colored using a blend of the axes color given by the triangle's normal vector.

The shader's code is straightforward:


Here below the code which passes the vertex attributes to the shader is presented. Qt helper classes are a good choice in order to write quickly a more readable code. For this reason I will use this approach whenever it's possible

Monday, 10 March 2014

OpenGL Sandbox - New data and camera handling


I am working quite hard on the OpenGL Sandbox: you can find the repository on GitHub.


I've included some data of the Standord Scannin Repository's into the list of the available 3D models,
the "Stanford bunny" is rather important in the field of computer graphics and deserves a special mention: If you are intrested in it's history, here you can read something about it.


Furthermore, I have also included a very flexible logging system which grants me the possibility to know exactly what happening inside my program.

The other important thing that I've done is to create my own camera handling framework. The original idea was to implement an FPS like camera, although this set up turned out to be rather unconfortable.Therefore, I redesigned to work in the following way.


The camera points at a fixed point $\bar{C_l}$ in the space, and it can rotate on a sphere centered in $\bar{C_l}$ with a radius $C_r$.
You can move the camera on that sphere with a left-click and drag of your mouse. The radius $C_r$ can be modified with the mouse wheel.

You can also move the point $\bar{C_l}$ around and you might use your keyboard to do that. With W/S keys you can shift $\bar{C_l}$ on the Z-axis, A/S keys you can shift on the X-axis and with R/F on the Y-axis. I'm sorry to disappoint you but the R key does not involve any reload operation ;)

At the moment I'm striving to start to work on the shading, I need to add just a few modification in the application and then I can start working on it.

Tuesday, 25 February 2014

My first OpenGL application

After a 2-years work in the field of 3D reconstruction, computational geometry and 3D modeling I've realized that I need to learn also a little bit of rendering as well. During my free time I have watched several online video lectures and started the online course "Interactive 3D Graphics" on Udacity.

I've decided to use OpenGL as rendering API, because it is multiplatform and easily extendable to the Web application thanks to WebGL and Three.js

The first thing to do is to buy the Red Book of OpenGl.Another useful way to start is the video lecture, available in the SIGGRAPH University program, called "An Introduction to OpenGL Programming".

After some reading and watching I've created my first application. Although I just started from the "hellogl" test I alredy reorganized the code in order to make it easier to add new tests and so on.



The next step is to create the "Hello world" test that could only be the rendering of the Utah Teapot!


PS: for the lazy people here's the video lecture that I mentioned before