Friday 29 June 2012

Sky Sphere Clouds Source



I have altered the shader a bit since my last post. I now only use a single cloud texture, sample that three times and rotate each sample over the other and add the result to the sky color. I have done this as passing more was having an impact on FPS.

So I have added two new functions to the shader to do the rotation of the textures.SwirlHoriz and SwirlVert.


SwirlHoriz: This function is used to rotate the cloud texture horizontaly around the sky sphere, either clockwise or anti-clockwise.
float2 SwirlHoriz(float2 coord,bool clockwise)
{
    if(clockwise)
    {
        coord.x += cloudTimer;
        if(coord.x > 1)
            coord.x = coord.x-1;
    }
    else
    {
        coord.x -= cloudTimer;
        if(coord.x < 0)
            coord.x = coord.x+1;
    }
    return coord;
}


SwirlVert: This function is used to rotate the cloud texture verticaly around the sky sphere, either up or down.
float2 SwirlVert(float2 coord,bool up)
{
     if(up)
     {
         coord.y -= cloudTimer;
         if(coord.y < 0)
             coord.y = coord.y+1;
     }
     else
     {
         coord.y += cloudTimer;
         if(coord.y > 1)
             coord.y = coord.y-1;
     }
     return coord;
}

I have named this source Cloud I as I have just got a new book on HLSL and so I feel I will re work this at some point, in the mean time, here is what I have done.

GenericXNAExampleSkyBox2CloudsI.zip

No comments:

Post a Comment