monogame - 在 MCGP 之后在 GLSL 中缺少声明
问题描述
我在 HLSL 中制作了一个基本的着色器,它在 DX 中运行良好,但在 OpenGL 中引发编译错误:
ERROR: 0:47: 'ps_v4' : undeclared identifier
ERROR: 0:47: 'xyz' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:48: 'ps_v3' : undeclared identifier
ERROR: 0:48: 'xyz' : field selection requires structure, vector, or matrix on left hand side
ERROR: 0:70: 'ps_v5' : undeclared identifier
ERROR: 0:70: 'xxxx' : field selection requires structure, vector, or matrix on left hand side
我对 GLSL 了解不多,但我确实查看了生成的 .xnb 文件,确实缺少声明:
...
...
uniform sampler2D ps_s0;
uniform sampler2D ps_s1;
varying vec4 vTexCoord0;
#define ps_v0 vTexCoord0
#define ps_oC0 gl_FragColor
varying vec4 vTexCoord1;
#define ps_v1 vTexCoord1
varying vec4 vFrontColor;
#define ps_v2 vFrontColor
void main()
...
...
ps_r1 = (ps_r1.xyzx * ps_c12.wwwz) + ps_c12.zzzw;
ps_r0 = clamp(ps_r0 * ps_r1, vec4(0.0), vec4(1.0));
ps_oC0 = mix(ps_c12.zzzw, ps_r0, ps_v5.xxxx);
...
但它们在同一个文件中使用。
有人可以帮我找出问题所在,所以 MGCP 错误地构建了该文件吗?MGCP 中没有错误,只是有关隐式向量截断的警告。
整个着色器代码可能有点错误,但它并没有那么不寻常,而是使用 Tangent/Binormal 进行凹凸贴图:
struct VSI
{
float4 Position : POSITION0;
float4 Normal : NORMAL0;
float2 UV : TEXCOORD0;
float4 Color : COLOR0;
float3 Tangent : TANGENT;
float3 Binormal : BINORMAL;
};
有任何想法吗?
解决方案
我实际上也在 VS-Output 中使用了 TANGENT 和 BINORMAL 寄存器,无论出于何种原因,这都不起作用。
我用 TEXCOORD2/3 替换了 VS 输出结构中的 TANGENT0 和 BINORMAL0 寄存器,这解决了错误
到目前为止,屏幕上的输出看起来不错,但我会做进一步的测试。
推荐阅读
- keycloak - 我们如何在 Keycloak 授权服务策略中为所有用户分配权限?
- perl - Perl DBD :: JDBC 模块问题 找不到适合 jdbc:hsqldb 的驱动程序
- python - 密码验证不适用于 Flask 表单
- c++ - 设置 Qt::FramelessWindowHint 时 QMessageBox 中的触摸坐标偏移
- node.js - 纱线在构建中找不到模块'logform'winston
- microsoft-teams - 如何使用逻辑应用发起 MS Teams 呼叫
- django - 覆盖默认电子邮件时,Djoser 不发送电子邮件
- php - 具有以下状态之一的 PaymentIntent:requires_payment_method、requires_confirmation、requires_action
- tkinter - pyinstaller 输出文件正在运行但未按预期正常工作
- javascript - 如何将新字符串放在前面?