我正在尝试在 slimdx 中加载 FX 文件,我已经使用 XNA 4.0 加载和编译了这个精确的 FX 文件,但是我遇到了 slimdx 错误,这是我加载它的代码。
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;
}
这是着色器:
#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();
}
}
现在这个精确的着色器在 XNA 中工作正常,但在 slimdx 中我得到了错误
ChunkDefault.fx(28,27): error X3000: unrecognized identifier 'byte4'