Compiler construction HLSL编译器错误?
这是我的像素着色器的一部分。为什么会出现编译器错误? 我正在Compiler construction HLSL编译器错误?,compiler-construction,directx,direct3d,hlsl,Compiler Construction,Directx,Direct3d,Hlsl,这是我的像素着色器的一部分。为什么会出现编译器错误? 我正在ps\u 3\u 0中编译它。 没有mul()它就可以编译。啊,我想这是有道理的。由于w组件未初始化,因此mul()函数将失败 为了避免这种情况,可以按如下方式初始化向量: float4x4 matInvViewProj; float4 GetPointPosition(float2 Tex0) { float4 PosImageSpace; PosImageSpace.xy = float2(Tex0*2-1);
ps\u 3\u 0中编译它。
没有
mul()
它就可以编译。啊,我想这是有道理的。由于w组件未初始化,因此mul()函数将失败
为了避免这种情况,可以按如下方式初始化向量:
float4x4 matInvViewProj;
float4 GetPointPosition(float2 Tex0)
{
float4 PosImageSpace;
PosImageSpace.xy = float2(Tex0*2-1);
PosImageSpace.z = tex2D(DepthTextureSampler,Tex0).r;
return mul(PosImageSpace,matInvViewProj);
}
我仍然建议您尝试在调试模式下使用fxc编译着色器,因为这样可以获得更好的错误描述。您甚至可以设置自定义构建步骤,让您右键单击.fx文件并进行编译,而无需编译整个解决方案/项目
要在调试配置中使用fxc编译着色器,请执行以下操作:
float4 PosImageSpace = (float4)0;
您可以在C:\Program Files\Microsoft DirectX SDK\Utilities\bin中找到fxc
在Visual Studio中设置自定义生成步骤,以及
还要检查一下如何使用fxc。啊,我想这是有道理的。由于w组件未初始化,因此mul()函数将失败 为了避免这种情况,可以按如下方式初始化向量:
float4x4 matInvViewProj;
float4 GetPointPosition(float2 Tex0)
{
float4 PosImageSpace;
PosImageSpace.xy = float2(Tex0*2-1);
PosImageSpace.z = tex2D(DepthTextureSampler,Tex0).r;
return mul(PosImageSpace,matInvViewProj);
}
我仍然建议您尝试在调试模式下使用fxc编译着色器,因为这样可以获得更好的错误描述。您甚至可以设置自定义构建步骤,让您右键单击.fx文件并进行编译,而无需编译整个解决方案/项目
要在调试配置中使用fxc编译着色器,请执行以下操作:
float4 PosImageSpace = (float4)0;
您可以在C:\Program Files\Microsoft DirectX SDK\Utilities\bin中找到fxc
在Visual Studio中设置自定义生成步骤,以及
还要检查一下如何使用fxc。这很奇怪:
我加了一行:
fxc /Od /Zi /T fx_3_0 /Fo Directional_Lighting_Shader_Defaul.fxo Directional_Lighting_Shader_Defaul.fx
现在它编译得很好。
这就是它现在的样子:
PosImageSpace.w = 0.0f;
真奇怪:
我加了一行:
fxc /Od /Zi /T fx_3_0 /Fo Directional_Lighting_Shader_Defaul.fxo Directional_Lighting_Shader_Defaul.fx
现在它编译得很好。
这就是它现在的样子:
PosImageSpace.w = 0.0f;
你犯了什么错误?它在这里编译得很好。C:\Dokumente und Einstellungen\Administrator\Desktop\program\3d\Litte3DEngine2\bin\Release\Shader\Directional\u Lighting\u Shader\u Default.fx(91):ID3DXEffectCompiler::CompileEffect:编译表达式ID3DXEffectCompiler:compiled失败行91:PixelShader=compile ps\u 3\u 0 ps();你犯了什么错误?它在这里编译得很好。C:\Dokumente und Einstellungen\Administrator\Desktop\program\3d\Litte3DEngine2\bin\Release\Shader\Directional\u Lighting\u Shader\u Default.fx(91):ID3DXEffectCompiler::CompileEffect:编译表达式ID3DXEffectCompiler:compiled失败行91:PixelShader=compile ps\u 3\u 0 ps();我用更多的信息更新了我的答案。这比写在评论里要简单:)我用更多的信息更新了我的答案。这比在评论中写出来要容易得多:)