V

Avatar



Tip: VBO & GLVertexPointer

The following information comes from NVidia’s article: Using VBOs. It is here for easy access for myself and anyone reading this blog and wanting to know more.

Warning: This information is to be ignored if you’re using recent GL version (3.x and above forward compatible) which most creative frameworks still don’t.

“Avoid Calling glVertexPointer() more than once per VBO
The “glVertexPointer” function does a lot of setup in VBO, so to avoid redundancy. The most efficient way to do is to bind the VBO buffer, setup various array pointers (glNormalPointer etc) and then call glVertexPointer(). glVertexPointer should be called one time for one VBO. You might think the essentials of VBO management are done in glBindBufferARB(), but it’s the opposite. VBO systems wait for the next upcoming important function (like glVertexPointer). The binding operation is cheap compared to the setup of various pointers. This advice fits any other function working in the same manner as glVertexPointer().”

From NVIDIA website.





Hemisphere Ambient Lighting

This is a very simple trick, nonetheless an interesting one.It might help make things look a bit better when you probably don’t need it to…

Objects reflect it’s environment. That’s a fact. Everything around an object influences what you see.

This trick simulates (in a very cheap way) that. Technically it just blends between two colors defined as ground and sky. It doesn’t take into account any other objects you might have in your scene. That’s a whole new topic.

How it works: The angle between the light direction vector and the normal defines the influence on a specific point:

 

vec3 N = normalize( g_WorldMatrix * normal );
vec3 L = normalize( g_LightPositionWS - PosWS );
float NdotL  = dot( N, L );
float  influence = NdotL * 0.5 + 0.5;  // = cos(angle) * 0.5 + 0.5
vec4 diffuse = mix( g_GroundColor, g_SkyColor, influence );





OpenGL 4.x Hardware Tesselllation

The following video is a first experiment with opengl’s hardware tessellation. The girl height map was taken from Kazuki Takamatsu Depthmaps work.





1d to 2d

At some point you might end up needing to convert a 1d index value to access a 2d array. Here’s how you can do it.


int x = index % xres;
int y = index / xres;

As noted by Diogo Teixeira, one way to get rid of the mod/div operations for POT buffers would be:


int precalc_a = ( xresPOT - 1 );
int precalc_b = (int)log2( xresPOT );
int x = index & precalc_a;
int y = index >> precalc_b;

.





Minivegas

Minivegas is my new home. What’s the story? Well, let me tell you.

Around April, Minivegas asked me to develop a interactive piece for Heineken that would allow people to draw light onto a mirrored screen using their body.

To work on this project i traveled to Minivegas studios in Amsterdam. Better to work on site than remotely i think. I have to say, it was a good idea but i am not used to be surrounded by people anymore while focusing on work. I did ok. We did ok. I had to do some over night time just before the client’s visit to watch our first draft of the piece. We went through a lot of reviews concerning the features to be implemented, alot were rejected and we ended up with using things like basic polylines defining a streak. Ofcourse there’s more than that, but we can say that is basically the core.
After 2 weeks things were looking better but we had some major problems with the interaction. Kinect is no miracle-maker, and we learnt that the hard way. Long story short, during my flight back to Portugal i fixed the major problems of new user entering the interaction area. Why? Well, I was alone. Don’t take me wrong, i’m not saying being a lone ranger is a good thing, but sometimes having time on your own takes you where you need to go.

“What exactly are you trying to say?” – Well, nothing really. Just telling a story.

After getting that annoying bug fixed we were able to focus on the rest of the application. Visuals, features, etc. It was awesome, but i was back home and working over skype and email. That was a bit annoying after 2 weeks with the guys over Minivegas. I missed that, but only when i got back. Yeah, i know what you’re thinking.

Anyway, the time was to travel to Milan, and what did i find? The bug that i had fixed before actually was just taking a break. He came back! And stronger. I started to panic. No, not really, but i wasn’t calm. Anyway i ended up working on the application until the doors opened while drinking some beer to release some steam. And there it was, the VIPs were flocking around the screen, really! They started playing around and having fun, i was having fun!

Maybe you’re asking yourself. What about that bug you were talking about? I want to know. Well it was there, i can tell you that, but i guess it was a nice bug and turned out it did not ruin the party, the amount of people did, but everyone was drunk and there was very little space for anyone to do anything. It was fun!

Oh yeah! Minivegas was looking for a interactive developer/creative technologist/programmer and they asked me. I said yes, and I fixed the bug later.

So, this is Goodbye to Coimbra, Hello to Amsterdam.

Let’s see what the future has for me. Hopefully, it’s dynamic.