本教程使用显式 OUT 结构,例如:
struct C3E1v_Output {
float4 position : POSITION;
float4 color : COLOR;
};
C3E1v_Output C3E1v_anyColor(float2 position : POSITION,
uniform float4 constantColor)
{
C3E1v_Output OUT;
OUT.position = float4(position, 0, 1);
OUT.color = constantColor; // Some RGBA color
return OUT;
}
但是看看我的一个着色器,我有明确的输入/输出参数:
float4 slice_vp(
// Vertex Inputs
in float4 position : POSITION, // Vertex position in model space
out float4 oposition : POSITION,
// Model Level Inputs
uniform float4x4 worldViewProj) : TEXCOORD6
{
// Calculate output position
float4 p = mul(worldViewProj, position);
oposition=p;
return p;
}
我在使用 HLSL2GLSL 时遇到了一些问题,我想知道我的 Cg 格式是否应该受到指责(即使它作为 Cg 脚本工作得很好)。是否有“正确”的方式,或者这两种方式是否完全不同?