誰でもこのエラーが発生する理由を知ることができます:
現在の頂点宣言には、現在の頂点シェーダーに必要なすべての要素が含まれていません。TextureCoordinate0 がありません。
標準の Vertex Shader を使用すると、すべて問題ありません。
ここに私のシェーダーファイルがあります:
float4x4 World;
float4x4 View;
float4x4 Projection;
float4 color;
float seaLevel;
texture myTexture;
float maxHeight = 128;
float height;
sampler2D mySampler = sampler_state
{
Texture = <myTexture>;
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertexShaderInput
{
float4 Position : POSITION0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
};
struct VS_INPUT
{
float4 position : POSITION;
float4 uv : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 position : POSITION;
float4 uv : TEXCOORD0;
float4 worldPos : TEXCOORD1;
};
VS_OUTPUT Transform(VS_INPUT In)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
float4x4 viewProj = mul(View, Projection);
float4x4 worldViewProj= mul(World, viewProj);
float height = tex2Dlod ( mySampler, float4(In.uv.xy , 0 , 0 ) );
In.position.y = height * maxHeight;
Out.worldPos = mul(In.position, World);
Out.position = mul( In.position , worldViewProj);
Out.uv = In.uv;
return Out;
}
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(input.Position, World);
worldPosition = float4(normalize(worldPosition.xyz) * seaLevel, 1);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
return color;
}
technique Technique1
{
pass Pass1
{
VertexShader = compile vs_3_0 Transform();
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}