Jump to content
  • Advertisement
Sign in to follow this  
WinstonPennypacker

Skybox Effect

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, I'm having some trouble with a skybox effect. I'm just using a modified version of one of the DirectX SDK's skybox.fx files. It renders the skybox to a single plane in screen space so that you don't need an entire box and so it stays the same regardless of the camera's position. However, when we move the camera too far out or up, the skybox freaks out and starts stretching and bending. Here is the source-

//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
float4x4 g_mInvWorldViewProjection : WorldViewProjectionInverse;
float4 g_ColorMod : Diffuse
= { 1.0f,1.0f,1.0f,1.0f };

texture g_EnvironmentTexture
<
	string ResourceType = "Cube";
>;

samplerCUBE EnvironmentSampler = sampler_state
{ 
    Texture = (g_EnvironmentTexture);
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};


//-----------------------------------------------------------------------------
// Skybox stuff
//-----------------------------------------------------------------------------
struct SkyboxVS_Input
{
    float4 Pos : POSITION;
};

struct SkyboxVS_Output
{
    float4 Pos : POSITION;
    float3 Tex : TEXCOORD0;
};

SkyboxVS_Output SkyboxVS( SkyboxVS_Input Input )
{
    SkyboxVS_Output Output;
    
    Output.Pos = Input.Pos;
    Output.Tex = normalize( mul(Input.Pos, g_mInvWorldViewProjection) );
    
    return Output;
}

float4 SkyboxPS( SkyboxVS_Output Input ) : COLOR
{
    float4 color = texCUBE( EnvironmentSampler, Input.Tex );
    
    return ( color * g_ColorMod );
}

technique Skybox
{
    pass p0
    {
    	CullMode = None;
        VertexShader = compile vs_2_0 SkyboxVS();
        PixelShader = compile ps_2_0 SkyboxPS();
    }
}


The code is extremely simple, but does anyone see anything thats off? Thanks a lot. [Edited by - WinstonPennypacker on May 2, 2007 9:51:30 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!