struct VS_BILLBOARD_INPUT
{
ย ย float2 size : SIZE; // x : Height, y : Width
};
struct GS_BILLBOARD_INPUT
{
ย ย float3 position_w : POSITION;
ย ย float2 size : SIZE;
};
struct GS_BILLBOARD_OUTPUT
{
ย ย float4 position : SV_POSITION;
ย ย uint p_id : SV_PrimitiveID;
ย ย float2 uv : TEXCOORD;
ย ย uint textureIndex : INDEX;
};
GS_BILLBOARD_INPUT VS_BillBoard(VS_BILLBOARD_INPUT input)
{
ย ย GS_BILLBOARD_INPUT output;
ย ย ย
ย ย output.position_w = mul(float4(0.0f, 0.0f, 0.0f, 0.0f), gmtxWorld).xyz;
ย ย output.size = input.size;
ย ย return (output);
}
[maxvertexcount(4)]
void GS_BillBoard(point GS_BILLBOARD_INPUT input[1], uint p_id : SV_PrimitiveID, inout TriangleStream<GS_BILLBOARD_OUTPUT> triStream)
{
ย ย float3 up = float3(0.0f, 1.0f, 0.0f);
ย ย float3 look = cameraPos - input[0].position_w;
ย ย ย
ย ย look.y = 0.0f;
ย ย look = normalize(look);
ย ย ย
ย ย float3 right = cross(up, look);
ย ย ย
ย ย float h_width = input[0].size.y * 0.5f;
ย ย float h_height = input[0].size.x * 0.5f;
ย ย ย
ย ย float4 vertex[4];
ย ย ย
ย ย vertex[0] = float4(input[0].position_w + h_width * right - h_height * up, 1.0f);
ย ย vertex[1] = float4(input[0].position_w + h_width * right + h_height * up, 1.0f);
ย ย vertex[2] = float4(input[0].position_w - h_width * right - h_height * up, 1.0f);
ย ย vertex[3] = float4(input[0].position_w - h_width * right + h_height * up, 1.0f);
ย ย ย
ย ย float2 uv[4] =
ย ย {
ย ย ย ย float2(0.0f, 1.0f),
ย ย ย ย float2(0.0f, 0.0f),
ย ย ย ย float2(1.0f, 1.0f),
ย ย ย ย float2(1.0f, 0.0f)
ย ย };
ย ย ย
ย ย GS_BILLBOARD_OUTPUT output;
ย ย [unroll]
ย ย for (int i = 0; i < 4; i++)
ย ย {
ย ย ย ย output.position = mul(vertex[i], gmtxViewProj);
ย ย ย ย output.uv = uv[i];
ย ย ย ย output.p_id = p_id;
ย ย ย ย ย
ย ย ย ย if (h_height > 10.0f)
ย ย ย ย ย ย output.textureIndex = 0;
ย ย ย ย ย
ย ย ย ย else
ย ย ย ย ย ย output.textureIndex = 1;
ย ย ย ย ย
ย ย ย ย triStream.Append(output);
ย ย }
}
float4 PS_BillBoard(GS_BILLBOARD_OUTPUT input) : SV_TARGET
{
ย ย float3 uvw = float3(input.uv, int(input.p_id % 4));
ย ย float4 cColor = gtxtBillBoard[input.textureIndex].Sample(gsamLinearClamp, uvw);
ย ย ย
ย ย clip(cColor.a - 0.5f);
ย ย ย
ย ย return cColor;
}
์ง์ค๋ฉํธ๋ฆฌ ์์ด๋๋ก ๋น๋ณด๋ ๋ง๋๋ ์์ด๋๊ณ ์์ฉํ๋ก๊ทธ๋จ์ชฝ์ ๋ฌธ์ ์์
๊ทผ๋ฐ ์๊พธ ๋ค๋ ์์ ์ง์ค๋ฉํธ๋ฆฌ ์์ด๋ - ํฝ์ ์์ด๋ ์ฐ๊ฒฐ์ค ๋ฌธ์ ์๊ฒผ๋ค๊ณ ์ง๋ํ๋ค
D3D12 ERROR: ID3D12Device::CreateGraphicsPipelineState: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'SV_PrimitiveID' is defined for mismatched hardware re1gisters between the output stage and input stage. [ STATE_CREATION ERROR #660: CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGI1STERINDEX]
D3D12 ERROR: ID3D12Device::CreateGraphicsPipelineState: Geometry Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'SV_PrimitiveID' of the input stage has a hardware regi1ster component mask that is not a subset of the output of the previous stage. [ STATE_CREATION ERROR #662: CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGI1STERMASK]
์๋ฐ ์์ผ๋ก
๋ณด๋๊น ์๋ฉํฑ ๊ฐ์ธ SV_PrimitiveID๊ฐ ๋ง์ง ์๋๋ค๋๊ฑฐ๊ฐ์๋ฐ ์ง์ค๋ฉํธ๋ฆฌ ์์ด๋์์ ๋ฐ์์ ํฝ์ ์์ด๋๋ก ๋๊ฒจ์ฃผ๋๊ฒ ๋ฌธ์ ๊ฐ ๋๋?
์๋ฉํฑ ๊ฐ ์ด๋ฆ ๋ฐ๊ฟ๋ ์ค๋ฅ ์ฌ์ ํ ๋จ
๋ญ๊ฐ ๋ฌธ์ ค๊น
๋๊ธ 0