DX10 Skybox Shader

3.1k views Asked by At

I'm trying to write a skybox shader in DX10 using the following HLSL code:

//////////////////////////////////////////////////////////////////////////
// world matrix for each rendered object
float4x4 g_mWorld;

// single cubemap texture
Texture2D g_tCubeMap;

// basic mirror texture sampler
SamplerState g_sSamplerMirror
{
    Filter = MIN_MAG_MIP_POINT;
    AddressU = MIRROR;
    AddressV = MIRROR;
};

//////////////////////////////////////////////////////////////////////////
// pre-defined vertex formats for vertex input layouts
struct VS_INPUT
{
    float3 Position     : POSITION;
};

struct PS_INPUT
{
    float4 SPosition    : SV_POSITION;
    float3 UV           : TEXCOORD;
};

//////////////////////////////////////////////////////////////////////////
PS_INPUT VS_Default( VS_INPUT Input )
{
    PS_INPUT Output = (PS_INPUT)0;

    Output.SPosition = float4(Input.Position,1.0f);
    Output.UV = normalize( mul( Output.SPosition, g_mWorld ) ).xyz;

    return Output;
}

//////////////////////////////////////////////////////////////////////////
float4 PS_Default( PS_INPUT Input ) : SV_TARGET0
{
    return float4( texCUBE( g_sSamplerMirror, Input.UV ) );
}

//////////////////////////////////////////////////////////////////////////
technique10 TECH_Default
{
    pass
    {
        SetVertexShader( CompileShader( vs_4_0, VS_Default() ) );
        SetPixelShader( CompileShader( ps_4_0, PS_Default() ) );
        SetGeometryShader( 0 );
    }
}

Which gives the error "DX-9 style intrinsics are disabled when not in dx9 compatibility mode." on line 46:

return float4( texCUBE( g_sSamplerMirror, Input.UV ) );

Is there an alternative to texCUBE? How can I fix this without enabling dx9 compatibility mode?

1

There are 1 answers

2
AudioBubble On

Since you are using Shader Model 4 you should be able to create a TextureCube object and then call the Sample method.