by gamedboy | Jun 26, 2008 | gamedboy, Programming

Dot product is a cheap and useful function in many situations. It calculate the cosAngle to two unit vectors which is 1 when acute, 0 to -1 for obtuse angle. These are some applications which I found very useful. Gameplay Check if two unit are facing each other by dot...
by gamedboy | Jun 2, 2008 | gamedboy, Programming

Not A Number NaN is an insidious bug that often plague games and shader programs during development. If you are lucky, you would probably never encounter it before, but the first time would often be very painful. It began with a single unit disappearing from the map,...
by gamedboy | Jun 1, 2008 | Blog, gamedboy, Programming

Linear Interpolation It would commonly take in 3 scalar or 2 vector and a scalar, and return the result of the formula x + s(y-x). Gameplay I often find this function useful for cheap generation of points along a relatively straight line. It is also very useful to...
by gamedboy | May 25, 2008 | gamedboy, Programming

I am using HLSL shader model 3, but this article should apply to other languages and shader models. It is Good to MAD One of the most basic optimisation is to use mad operation, which is to multiply 2 values and add a third value to the result. This is two...
by gamedboy | May 12, 2008 | gamedboy, Programming

Combining tangent space normal map is different from combining normal images. Here are some ways to combine two normal map together. The general idea is the identity normal, float3(0, 0, 1), will use the vertex default normal. Adding Adding two normals and preserving...
by gamedboy | May 4, 2008 | Blog, gamedboy, Programming

A Power function raised x to specific power. It has an interesting property when x is between 0 – 1, the result will be always between 0 – 1. Do take note Power function will not preserve the sign of x, it may be necessary to calculate the sign beforehand. What Power...