Problem loading shaders with slimdx

Posted by Levi on Game Development See other posts from Game Development or by Levi
Published on 2012-06-19T15:42:33Z Indexed on 2012/06/19 21:25 UTC
Read the original article Hit count: 628

Filed under:
|
|

I'm attempting to load an FX file in slimdx, I've got this exact FX file loading and compiling fine with XNA 4.0 but I'm getting errors with slimdx, here's my code to load it.

    using SlimDX.Direct3D11;
    using SlimDX.D3DCompiler;

    public static Effect LoadFXShader(string path)
    {
        Effect shader;
        using (var bytecode = ShaderBytecode.CompileFromFile(path, null, "fx_2_0", ShaderFlags.None, EffectFlags.None))
            shader = new Effect(Devices.GPU.GraphicsDevice, bytecode);

        return shader;
    }

Here's the shader:

#define TEXTURE_TILE_SIZE 16

struct VertexToPixel
{
    float4 Position     : POSITION;    
    float2 TextureCoords: TEXCOORD1;
};

struct PixelToFrame
{
    float4 Color : COLOR0;
};

//------- Constants --------
float4x4 xView;
float4x4 xProjection;
float4x4 xWorld;
float4x4 preViewProjection;
//float random;

//------- Texture Samplers --------

Texture TextureAtlas;
sampler TextureSampler = sampler_state { texture = <TextureAtlas>; magfilter = Point; minfilter = point; mipfilter=linear; AddressU = mirror; AddressV = mirror;};

//------- Technique: Textured --------

VertexToPixel TexturedVS( byte4 inPos : POSITION, float2 inTexCoords: TEXCOORD0)
{   
    inPos.w = 1;
    VertexToPixel Output = (VertexToPixel)0;
    float4x4 preViewProjection = mul (xView, xProjection);
    float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);

    Output.Position = mul(inPos, preWorldViewProjection);

    Output.TextureCoords = inTexCoords / TEXTURE_TILE_SIZE;

    return Output;
}

PixelToFrame TexturedPS(VertexToPixel PSIn) 
{
    PixelToFrame Output = (PixelToFrame)0;

    Output.Color = tex2D(TextureSampler, PSIn.TextureCoords);

    if(Output.Color.a != 1)
        clip(-1);

    return Output;
}

technique Textured
{
    pass Pass0
    {   
        VertexShader = compile vs_2_0 TexturedVS();
        PixelShader  = compile ps_2_0 TexturedPS();
    }
}

Now this exact shader works fine in XNA, but in slimdx I get the error

ChunkDefault.fx(28,27): error X3000: unrecognized identifier 'byte4'

© Game Development or respective owner

Related posts about c#

Related posts about shaders