Searc

Tuesday 28 December 2010

Multitexturing

Ok well i have managed to add water and also to multitexture my planet. The water is just a normal grid using a cube map and a wave map to produce the waves.  Using the following function in the vertex shader to convert the height and calculate the position, depending on which side of the sphere (Cube) the wave is on and which angle it should rise at.




     float4 CalculateSphereHeights(float4 v, float2 tex,float heightv)
  
     {
  
     float4 p;
  
     p = normalize(v);
  
     return v + p * heightv;
  
     }  

I have calculated the mutitexturing by getting the distance from the centre to the vertex, then passing that to the pixel shader and using 4 different textures blended at various different stages. Most of the code used is modified code from various tutorials that i have found around the web, (No point in reinventing the wheel) apart from the roam, which was adapted from a flat surface roam, and then mapped directly on to the cube which was warped to a sphere using the function i have shown in my earlier post.

No comments:

Post a Comment