我正在尝试使用几何着色器扩展渲染器(用于 TressFX),因此我正在采取措施以确保一切正常。因此,我创建了一个简单的传递几何着色器,它适用于三角形,但由于某种原因不适用于线或点(将三角形转换为线和点),因为我看不到输出。结果链接
如果有人能指出为什么它不适用于线条和点,我会很高兴。
代码
ASetPrimitiveTopology 设置为 D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
顶点着色器
struct PS_INPUT_HAIR_AA
{
float4 Position : SV_POSITION;
float4 Tangent : Tangent;
float4 p0p1 : TEXCOORD0;
};
PS_INPUT_HAIR_AA VS_RenderHair( uint vertexId : SV_VertexID )
{
PS_INPUT_HAIR_AA Output = (PS_INPUT_HAIR_AA)0;
Calculate position etc...
Output.Position = mul(float4(v, 1), g_mViewProj);
Output.Tangent = float4(t, ratio);
Output.p0p1 = float4( v.xy, g_HairVertexPositions[vertexId+1].xy );
return Output;
}
三角形的几何着色器(有效)
[maxvertexcount(64)] // more than enough
void GS_RenderHairPassThrough( triangle PS_INPUT_HAIR_AA input[3], inout TriangleStream<PS_INPUT_HAIR_AA> OutputStream )
{
PS_INPUT_HAIR_AA output = (PS_INPUT_HAIR_AA)0;
for(uint i = 0; i < 3; ++i) {
output.Position = input[i].Position;
output.Tangent = input[i].Tangent;
output.p0p1 = input[i].p0p1;
OutputStream.Append( output );
}
OutputStream.RestartStrip();
}
点和线的几何着色器(不起作用)
[maxvertexcount(64)] // more than enough
void GS_RenderHairPassThrough( triangle PS_INPUT_HAIR_AA input[3], inout PointStream<PS_INPUT_HAIR_AA> OutputStream )
{
PS_INPUT_HAIR_AA output = (PS_INPUT_HAIR_AA)0;
for(uint i = 0; i < 3; ++i) {
output.Position = input[i].Position;
output.Tangent = input[i].Tangent;
output.p0p1 = input[i].p0p1;
OutputStream.Append( output );
OutputStream.RestartStrip(); // Not sure if I need this
}
}
[maxvertexcount(64)] // more than enough
void GS_RenderHairPassThrough( triangle PS_INPUT_HAIR_AA input[3], inout LineStream<PS_INPUT_HAIR_AA> OutputStream )
{
PS_INPUT_HAIR_AA output = (PS_INPUT_HAIR_AA)0;
for(uint i = 0; i < 3; ++i) {
output.Position = input[i].Position;
output.Tangent = input[i].Tangent;
output.p0p1 = input[i].p0p1;
OutputStream.Append( output );
}
OutputStream.RestartStrip();
}
但是,如果我在点/线传递几何着色器中对 output.Position 进行硬编码,我可以设法获得可以在屏幕上看到的输出。