几何着色器无法在 DirectX10 HLSL 中编译
我一直在尝试编写几何着色器代码,以便生成广告牌系统,如 Frank Luna 的《使用 DirectX 进行 3D 游戏编程简介》一书中所述。我将着色器插入到我的技术中,如下所示:
pass P3
{
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(CompileShader(gs_4_0, GS()));
SetPixelShader(CompileShader( ps_4_0, PS_NoSpecular()));
SetBlendState(SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
但是,这给出了错误 1>D3DEffectCompiler : 错误 : 在技术渲染、传递 P3 中找不到有效的 VertexShader-GeometryShader 组合。
VS 和 GS 的结构如下:
struct GS_INPUT
{
float4 PosH : SV_POSITION;
float4 PosW : POSITION;
float2 Tex : TEXCOORD;
float3 N : NORMAL;
float3 Tangent : TANGENT;
float3 Binormal : BINORMAL;
};
struct VS_INPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD;
float3 N : NORMAL;
float3 Tangent : TANGENT;
float3 Binormal : BINORMAL;
};
它们应该相同吗?
I've been trying to code a geometry shader in order to generate billboard systems as explained in Frank Luna's book Introduction to 3D Game Programming with DirectX. I insert the shader into my technique as follows:
pass P3
{
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(CompileShader(gs_4_0, GS()));
SetPixelShader(CompileShader( ps_4_0, PS_NoSpecular()));
SetBlendState(SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
However, this gives the error 1>D3DEffectCompiler : error : No valid VertexShader-GeometryShader combination could be found in Technique render, Pass P3.
The structs for both VS and GS are given below:
struct GS_INPUT
{
float4 PosH : SV_POSITION;
float4 PosW : POSITION;
float2 Tex : TEXCOORD;
float3 N : NORMAL;
float3 Tangent : TANGENT;
float3 Binormal : BINORMAL;
};
struct VS_INPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD;
float3 N : NORMAL;
float3 Tangent : TANGENT;
float3 Binormal : BINORMAL;
};
Should they be the same?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于用于从顶点着色器、几何着色器和像素着色器输入和输出的结构。如果顶点着色器输出 PS_INPUT 类型,则几何着色器需要使用该 PS_INPUT 作为其输入类型。
The problem lies with the struct used to input and output from the vertex shader, geometry shader and pixel shader. If the vertex shader outputs a PS_INPUT type, then the geometry shader needs to use that PS_INPUT as its input type.