Sunday, 7 April 2013

Post processing and GUI

This assignment was easy. It was repeating what we had learnt before. However it still confused me. How should I architect my program to draw 3D and then 2D nicely? How should the 2D pipeline look like?

I draw all my meshes in cMesh class. Drawing the 2D image here seems wrong. After discussing with Cody, I decided to do it in cScene. I was still unsure about the 2D pipeline, though. Shall I put everything I want to draw from the text file like the meshes or... Anyway, at the moment I hard coded it in my cScene. Both the post processing and the GUI using the same vertex buffer and vertex shader. To accommodate the GUI nicely, I did simple math calculation in the vertex shader to position the GUI as expected. This is the math calculation I did:
x = (i_position_world * g_size.x) + g_position.x;
y = (i_position_world * g_size.y) + g_position.y;

With vignetting post processing and the yellow flower GUI

Btw, understanding SetRenderTarget on the previous assignment is indeed help me out in doing this assignment. Without understanding the render target, I won't be able to complete this assignment by myself.

I had already added the directional light. However, I wasn't sure if it's correct.

As usual, some note from the class:
  • Ambient light doesn't take normal into count at all. Therefore when diffuse light is disabled (ONLY ambient light), the object will look flat
  • Directional light --> instead of passing position as uniform, we pass direction. No need the attenuation. Beware of the direction! Given any fragment, the direction light should be any direction pointed at it.
  • We can optimize shader by using function call to the repeated calculation for example, diffuse, specular, normal map. Thus, if a shader has diffuse + specular effect, the shader will call the respective function: diffuse(); specular();
Btw, I found this nice introduction of light sources. There are several types of light sources, the most common ones are:
  • Directional lights – defined by a direction and a light intensity, the light direction is the same at any point on any surface, this occurs when you have a light source that is infinitely far away (like the sun).
  • Point Lights – these lights have both an intensity and a position, they also exhibit attenuation (the light intensity decreases with distance). Light direction and attenuation has to be calculated before being able to perform the lighting calculations.
  • Spot Lights – These lights are point lights that only emit light in a directed cone, there are various ways to define spotlights but at the most basic level they have a position, intensity and a cone direction.

1 comment:

  1. ka astrella kapan lagi posting novelnya , aku suka banget sama novel kakak di IMAGINATIVE WONDERLAND , aku masih nunggu kakak posting novelnya kakak :) - putri -

    ReplyDelete