• Home
  • About
    • 게임 개발자 유정룡 photo

      게임 개발자 유정룡

      포트폴리오

    • Learn More
    • Email
    • Github
    • Bitbucket
  • Projects
    • All Projects
    • All Tags

DirectX11 공부 3일차(Blend State)

03 Jun 2021

Reading time ~1 minute

배운것

  1. Blend State

Blend State

렌더링 파이프라인에서 픽셀 셰이더를 거쳐 생성된 단편이 렌더 타겟에 어떻게 적용될지를 결정하는 상태값

여기서부터는 셰이더의 알파값 제거하는 부분을 제거하고 실행했다.

Execute.h (추가요소)

ID3D11BlendState* blend_state = nullptr;

늘 하던대로 blend_state를 선언

Execute.cpp (추가요소)

생성자

// Create Blend State
{
	D3D11_BLEND_DESC desc;
	ZeroMemory(&desc, sizeof(D3D11_BLEND_DESC));
	desc.AlphaToCoverageEnable = false;
	desc.IndependentBlendEnable = false;
	desc.RenderTarget[0].BlendEnable = true;

	desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;				// 원본색
	desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;			// 도착색
	desc.RenderTarget[0].BlendOp= D3D11_BLEND_OP_ADD;					// Operation 어떻게 섞을 것인가

	desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
	desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
	desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;

	desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

	HRESULT hr = graphics->GetDevice()->CreateBlendState(&desc, &blend_state);
	assert(SUCCEEDED(hr));
}

블렌드 스테이드를 GPU에 보낼 DESC를 초기화한다.

AlphaToCoverageEnable : Alpha-To-Coverage을 할지 안할지 정한다

  • Alpha-To-Coverage : 자세한 설명은 어렵지만, 안티 얼라이어싱, 반투명 테스쳐를 사용할 때 순서와 무관 한 투명도를 얻을수 있음.

IndependentBlendEnable : 각각 배열이 독립적으로 혼합할지 같이 할지 결정

D3D11_RENDER_TARGET_BLEND_DESC

BlendEnable : 블렌딩 할지

SrcBlend : 리소스의 시작 블렌드 값

DestBlend : 도착 블렌드 값

BlendOp : 어떻게 블렌드 할것인지

SrcBlendAlpha : 알파값

DestBlendAlpha : 알파값

BlendOpAlpha :어떻게 블렌드 할것인지

RenderTargetWriteMask : 쓰기 마스크 (추후 설명)

후에

Redner()
{
//OM
graphics->GetDeviceContext()->OMSetBlendState(blend_state, nullptr, 0xffffffff);
}

마지막인 OM 단계에서 설정하면

배경이 안바뀐다?

위에 보면 AlphaToCoverageEnable 을 false로 했기 때문이다.

이 값을 바꾸면,

잘 나온다.

후기

슬슬 재밌어 진다6.



DirectX Share Tweet +1