Skip to the content.

Blogpost DemoGPR5300

1. Introduction

This is a blogpost about the 3D scene demo I had to do for the GPR5300 module at SAE Geneva using OpenGL. I followed some of the tutorials from LearnOpenGL to make my scene : https://learnopengl.com/

2. Cubemaps

For this scene I used the skybox given by LearnOpenGL : https://learnopengl.com/Advanced-OpenGL/Cubemaps

I first made an array of vertices for my skybox :

cubemaps

Then I generate the Vertex Array Object (VAO) and Vertex Buffer Object (VBO) and transfer the datas to the GPU :

cubemaps2

Then we take the textures with the right path from my folders and show them in the scene :

demopres

OBJ

For my obj I have a model class which takes care of loading it in the scene.

obj

obj2

And I call this function in the update. We can also change the positions of our obj.

obj3

I paid to get this model and if you’d like to have it too you can find it here :

https://www.cgtrader.com/3d-models/exterior/landscape/snowy-mountain-8k-textures

Framebuffer

For the framebuffer I first made coordinates for the quad vertices.

framebuffer

Then we generate and bind the Framebuffer Object (FBO) and the Renderbuffer Object (RBO) :

framebuffer2

framebuffer3

We also generate and bind the quad VAO and quad VBO :

framebuffer4

We also need to make our shaders, here’s the fragment shader :

fbofrag

and our vertex shader :

fbovert

Then we call the shaders and everything that we need in the update to be able to use the framebuffer in our scene :

framebuffer5

framebuffer6

framebuffer7

framebuffer8

and we know it works because if we put this line instead of the other one in our fragment shader, the scene looks like this :

framebuffer10

framebuffer9

Directional Light & Normal Map

For the directional light we don’t need any position because it lights the whole scene. Since I had shaders for both my directional light and my normal map, I decided to make a “mix” of the two in the normal map vertex and fragment shaders.

I followed LearnOpenGl tutorials to make the directional light and the normal map :

https://learnopengl.com/Lighting/Light-casters

https://learnopengl.com/Advanced-Lighting/Normal-Mapping

I had first encountered a bug where my normal map texture would show in Render Doc but the whole scene was dark as if there wasn’t any light.

normalmapbug3

normalmapbug2

The problem came from this line in the fragment shader with the diffuse light :

nmbug

Instead of TangentLightPos - TangentFragPos I only needed to change it to -TangentLightPos :

nmbug2

Here’s the normal map + directional light vertex shader :

nmvert

Here’s the normal map + directional map fragment shader :

nmfrag

nmfrag2

And then my scene had a light with some shadows and the normal texture.

finalscene

Final Look

Here’s the final look with the camera moving in the scene :

finallook2

Conclusion

To conclude, I honestly liked this module and learning about OpenGL. Unfortunately I couldn’t do as much as I wanted and work on all the other samples because I had to take care of my grandmother whose health worsened these last few months. I will probably keep on trying to work on the samples after this module to keep on learning about OpenGL and computer graphics.

My repository : https://github.com/eleonoradps/DEMOGPR5300