It’s nice and easy to upgrade your environment with a SkyBox. Generate a nice 6 sided cubemap. Use a simple centered Box as Geometry. Translate the box to camera position. Apply the ViewProjection. Set pos.z = pos.w to fit allways to farplane. Use the ModelVertexPosition to sample the cubemap.
That’s it…

Some Problems to fix
• you have to change the cullmode, because you are in the box
• you have to set the DepthComparison to LessEqual, because it’s equal

Some Improvements
• draw the box allways as last opaque object
• adjust the Y position
• use a wider field of view for the box
• draw a sun spot for directional light
• draw the sun spot to glow target for BloomEffect
• the sun spot only works if you use averaged model normals


VS_OUT VShader(float4 pos : POSITION,
               float3 nrm : NORMAL)
 VS_OUT Out;

 float3 cpos = CamPosition;
        cpos.y += YAdjustment;
 float4 wpos = float4(cpos, 0) + pos;

 Out.pos = mul(wpos,SkyCubeViewProjection);
 Out.pos.z = Out.pos.w;
 Out.vpos =;
 Out.nrm = nrm;
 return Out;


PS_OUT PShader(	float4 pos  : SV_POSITION,
                float3 vpos : POSITION,
                float3 nrm  : NORMAL)
 PS_OUT Out;

 nrm = normalize(nrm);

 //Sun Dot
 float sunDot = dot(nrm, DirLight.direction);
       sunDot = saturate(pow (sunDot,SunDistance * 2000)) * SunSharpness   * 30;

 float3 sun = SunColor *sunDot; 

 //Sample RGBA
 float4 RGBA = TextureColor.Sample(Sampler, vpos).rgba; 

 Out.color.rgb = float4(RGBA.rgb +sun,0);  //Out FinalColor
 Out.glow      = float4(sun,0);
 return Out;

SkyBox in Action


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s