3
This tutorial使用顯式OUT結構,例如:構建Cg程序的正確方法是什麼?
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腳本)。有沒有「正確」的方式,還是兩種截然不同的方式來達到同一目標?