• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

SV_Position과 Position의 차이는 이건가요?

22.02.22 16:45 작성 조회수 1.27k

0

위 사진처럼 되었을 때, 빨간색이 화면이고 검정색이 물체이며 초록색에서 현재 픽셀 셰이더가 돌아간다고 했을 때

Position은 저 초록색 픽셀의 동차 좌표를 나타내며,

SV_Position은 저 초록색 픽셀의 픽셀 좌표를 나타내는건가요?

코드는 다음과 같습니다

struct VS_IN
{
    float3 pos : POSITION;
};

struct VS_OUT
{
    float4 pos : SV_Position;
    float4 clipPos : POSITION;
};

VS_OUT VS_Main(VS_IN input)
{
    VS_OUT output = (VS_OUT)0.f;

    output.pos = mul(float4(input.pos, 1.f), g_matWVP);
    output.clipPos = output.pos;

    return output;
}

float4 PS_Main(VS_OUT input) : SV_Target
{
    return float4(input.clipPos.z / input.clipPos.w, 0.f, 0.f, 0.f);
}

답변 1

답변을 작성해보세요.

1

SV_POSITION의 SV는 SystemValue의 약자입니다.
HLSL상에서 이미 예약되어 있는 이름이고
렌더링 파이프라인 상에서의 의미가 정해져 있습니다.
아래 내용 참고 바랍니다.

Semantics with the SV prefix are "system value" semantics. This means that they have a specific meaning to the pipeline. In the case of SV_Position, if it's attached to a vertex shader output that means that the output will contain he final transformed vertex position used for rasterization. Or if you use it for a pixel shader input, it will contain the screenspace position of the pixel. All of these SV semantics are described in the SDK documentation, in the HLSL section. Just search for "semantics".

https://www.gamedev.net/forums/topic/579610-hlsl-semantics-position-vs-sv_position/