Terrainer

Explanation: 

This is an individual project for 2nd year UWS Real Time 3d course work.
It is a metamorphic exploration drone rendered as a beach ball in a strange alien landscape.
This project displays a 3rd person camera to aid exploration.
While the environment is created using a fault line fractal algorithm.

Code Snippet: 

Fragment shader for ball lighting

//outputs
out vec4 vFragColor;

void main(void)
{
vFragColor = vVaryingColor;

// Add in ambient light
vFragColor += ambientColor;
vFragColor.rgb = min(vec3(1.0,1.0,1.0), vFragColor.rgb);

vFragColor *= texture(colorMap, vVaryingTexCoords.st);
}

//main algorithm loop. keep number of iterations to a power of 2.
//Actually building the numbers up. With each pass we shall reduce the height range we will work the data within
//ratio of curntIt/NoItr times the range of possible deltas subtracted through MaxDelta
iHeight = iMaxDelta - ( ( iMaxDelta - iMinDelta) * iCurntIteration ) / iIterations;

//two random points
iRndX1 = rndNumbGen.Random(m_iSize);
iRndZ1 = rndNumbGen.Random(m_iSize);

//and again. Must be different
do
{
iRndX2 = rndNumbGen.Random(m_iSize);
iRndZ2 = rndNumbGen.Random(m_iSize);
}while(iRndX1 == iRndX2 && iRndZ1 == iRndZ2);

iDirX1 = iRndX2 - iRndX1;
iDirZ1 = iRndZ2 - iRndZ1; //turn rndnumbs into vectors

for(z=0; z 0 ) //This is the 2 d cross product between current vector and line vector
fTempBuffer[( z*m_iSize) + x] += (float)iHeight;
}
}

User login