Ejemplo n.º 1
0
	PooledTextureRef SSR::BuildHZB(const Ptr<Texture> & depthTex)
	{
		auto texDesc = depthTex->GetDesc();
		texDesc.format = RENDER_FORMAT_R16_FLOAT;
		texDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET;
		texDesc.mipLevels = 0;

		auto hzb0Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });
		auto hzb1Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });

		auto hzb0 = hzb0Ref->Get()->Cast<Texture>();
		auto hzb1 = hzb1Ref->Get()->Cast<Texture>();

		Transform(
			depthTex->GetShaderResourceView(0, 1, 0, 1, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS), 
			hzb0Ref->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1));

		auto rc = Global::GetRenderEngine()->GetRenderContext();

		auto ps = Shader::FindOrCreate<HZBBuildPS>();

		for (int32_t mipLevel = 1; mipLevel < hzb0->GetDesc().mipLevels; ++mipLevel)
		{
			auto & mipSize = hzb0->GetMipSize(mipLevel - 1);
			auto w = mipSize.x();
			auto h = mipSize.y();
			float4 screenSize = float4((float)w, (float)h, 1.0f / (float)w, 1.0f / (float)h);

			ps->SetScalar("screenSize", screenSize);
			ps->SetScalar("mipLevel", (float)(mipLevel - 1));
			ps->SetSRV("depthTex", hzb0->GetShaderResourceView());
			ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());

			ps->Flush();

			auto & targetMipSize = hzb0->GetMipSize(mipLevel);

			DrawQuad({ hzb1->GetRenderTargetView(mipLevel, 0, 1) });

			hzb1->CopyTo(hzb0, mipLevel, 0, 0, 0, 0, mipLevel, 0);
		}

		return hzb0Ref;
	}
Ejemplo n.º 2
0
	void ToneMapping::BloomBlur(const Ptr<Texture> & inTex, float blurRadius)
	{
		TextureDesc texDesc = inTex->GetDesc();
		auto tmpTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });
		auto tmpTex = tmpTexRef->Get()->Cast<Texture>();

		{
			int32_t tableSize = (int32_t)blurRadius * 2 + 1;
			auto & gaussTable = GetGaussTable(tableSize);
			int32_t sampleIndex = 0;
			float weightSum = 0.0f;
			std::vector<float2> offsets;
			std::vector<float> weights;
			for (; sampleIndex < tableSize - 1; sampleIndex += 2)
			{
				float offsetStart = (float)sampleIndex - blurRadius;

				float weight0 = gaussTable[sampleIndex];
				float weight1 = gaussTable[sampleIndex + 1];
				weights.push_back(weight0 + weight1);
				offsets.push_back(float2(1.0f, 0.0f) * (offsetStart + weight1 / weights.back()));
				weightSum += weights.back();
			}
			weights.push_back(gaussTable.back());
			offsets.push_back(float2(1.0f, 0.0f) * blurRadius);

			for (auto & w : weights)
				w /= weightSum;
			for (auto & offset : offsets)
				offset /= float2((float)inTex->GetDesc().width, (float)inTex->GetDesc().height);

			TextureFilter(inTex->GetShaderResourceView(), tmpTex->GetRenderTargetView(0, 0, 1), offsets, weights, SamplerTemplate<FILTER_MIN_MAG_MIP_LINEAR>::Get());
		}

		{
			int32_t tableSize = (int32_t)blurRadius * 2 + 1;
			auto & gaussTable = GetGaussTable(tableSize);
			int32_t sampleIndex = 0;
			float weightSum = 0.0f;
			std::vector<float2> offsets;
			std::vector<float> weights;
			for (; sampleIndex < tableSize - 1; sampleIndex += 2)
			{
				float offsetStart = (float)sampleIndex - blurRadius;

				float weight0 = gaussTable[sampleIndex];
				float weight1 = gaussTable[sampleIndex + 1];
				weights.push_back(weight0 + weight1);
				offsets.push_back(float2(0.0f, 1.0f) * (offsetStart + weight1 / weights.back()));
				weightSum += weights.back();
			}
			weights.push_back(gaussTable.back());
			offsets.push_back(float2(0.0f, 1.0f) * blurRadius);

			for (auto & w : weights)
				w /= weightSum;
			for (auto & offset : offsets)
				offset /= float2((float)inTex->GetDesc().width, (float)inTex->GetDesc().height);

			TextureFilter(tmpTex->GetShaderResourceView(), inTex->GetRenderTargetView(0, 0, 1), offsets, weights, SamplerTemplate<FILTER_MIN_MAG_MIP_LINEAR>::Get());
		}

	}
Ejemplo n.º 3
0
	void CustomDrawBox::Draw(){
		//デバイスの取得
		auto Dev = App::GetApp()->GetDeviceResources();
		auto pDx11Device = Dev->GetD3DDevice();
		auto pID3D11DeviceContext = Dev->GetD3DDeviceContext();
		//ステータスのポインタ
		auto RenderStatePtr = GetStage()->GetRenderState();

		auto PtrT = GetComponent<Transform>();
		//ステージからカメラを取り出す
		auto PtrCamera = GetStage()->GetTargetCamera();
		//カメラの取得
		Matrix4X4 View, Proj, WorldViewProj;
		View = PtrCamera->GetViewMatrix();
		Proj = PtrCamera->GetProjMatrix();


		//ストライドとオフセット
		UINT stride = sizeof(VertexPositionNormalTexture);
		UINT offset = 0;
		//頂点バッファの設定
		auto PtrMeshResource = App::GetApp()->GetResource<MeshResource>(L"DEFAULT_CUBE");
		pID3D11DeviceContext->IASetVertexBuffers(0, 1, PtrMeshResource->GetVertexBuffer().GetAddressOf(), &stride, &offset);
		//インデックスバッファのセット
		pID3D11DeviceContext->IASetIndexBuffer(PtrMeshResource->GetIndexBuffer().Get(), DXGI_FORMAT_R16_UINT, 0);
		//描画方法(3角形)
		pID3D11DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
		//ステータスのポインタ
		//テクスチャを取得
		ID3D11ShaderResourceView* pNull[1] = { 0 };
		ID3D11SamplerState* pNullSR[1] = { 0 };
		//テクスチャを設定
		auto PtrTextureResource = App::GetApp()->GetResource<TextureResource>(L"TRACE_TX");
		pID3D11DeviceContext->PSSetShaderResources(0, 1, PtrTextureResource->GetShaderResourceView().GetAddressOf());
		//リニアサンプラーを設定
		ID3D11SamplerState* samplerState = RenderStatePtr->GetLinearClamp();
		pID3D11DeviceContext->PSSetSamplers(0, 1, &samplerState);
		//半透明処理
		pID3D11DeviceContext->OMSetBlendState(RenderStatePtr->GetAlphaBlendEx(), nullptr, 0xffffffff);

		//デプスステンシルは使用する
		pID3D11DeviceContext->OMSetDepthStencilState(RenderStatePtr->GetDepthDefault(), 0);
		//シェーダの設定
		pID3D11DeviceContext->VSSetShader(m_VirtexShader->GetShader(), nullptr, 0);
		pID3D11DeviceContext->PSSetShader(m_PixelShader->GetShader(), nullptr, 0);
		//インプットレイアウトの設定
		pID3D11DeviceContext->IASetInputLayout(m_VirtexShader->GetInputLayout());



		//コンスタントバッファの設定
		ConstantBuffer cb1;
		ZeroMemory(&cb1, sizeof(cb1));
		//行列の設定(転置する)
		cb1.World = Matrix4X4EX::Transpose(PtrT->GetWorldMatrix());;
		cb1.View = Matrix4X4EX::Transpose(View);
		cb1.Projection = Matrix4X4EX::Transpose(Proj);
		//ライトの設定
		//ステージから0番目のライトを取り出す
		auto PtrLight = GetStage()->GetTargetLight(0);
		cb1.LightDir = PtrLight->GetDirectional();
		//xとzだけ逆にする
		cb1.LightDir.x *= -1.0f;
		cb1.LightDir.z *= -1.0f;
		cb1.LightDir.w = 1.0f;
		//トータルタイムをコンスタントバッファに渡す
		float ElapsedTime = App::GetApp()->GetElapsedTime();
		m_TotalTime += ElapsedTime;
		if (m_TotalTime >= 1.0f){
			m_TotalTime = 0.0f;
		}
		cb1.Param.x = m_TotalTime;
		//コンスタントバッファの更新
		pID3D11DeviceContext->UpdateSubresource(m_ConstantBuffer->GetBuffer(), 0, nullptr, &cb1, 0, 0);
		//コンスタントバッファの設定
		ID3D11Buffer* pConstantBuffer = m_ConstantBuffer->GetBuffer();
		pID3D11DeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer);
		pID3D11DeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer);

		//レンダリングステート
		pID3D11DeviceContext->RSSetState(RenderStatePtr->GetCullFront());
		//内側描画
		pID3D11DeviceContext->DrawIndexed(PtrMeshResource->GetNumIndicis(), 0, 0);

		//ライトの向きを変える
		cb1.LightDir = PtrLight->GetDirectional();
		cb1.LightDir.w = 1.0f;

		//コンスタントバッファの更新
		pID3D11DeviceContext->UpdateSubresource(m_ConstantBuffer->GetBuffer(), 0, nullptr, &cb1, 0, 0);
		//コンスタントバッファの設定
		pConstantBuffer = m_ConstantBuffer->GetBuffer();
		pID3D11DeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer);
		pID3D11DeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer);

		//レンダリングステート
		pID3D11DeviceContext->RSSetState(RenderStatePtr->GetCullBack());
		//描画(外側)
		pID3D11DeviceContext->DrawIndexed(PtrMeshResource->GetNumIndicis(), 0, 0);
		//後始末
		Dev->InitializeStates(RenderStatePtr);


	}
Ejemplo n.º 4
0
	void ImageBasedLensFlare::LensBlur(const Ptr<Texture> & setupTex, const Ptr<Texture> & target)
	{
		int32_t tileSize = 9;

		//Extract Sprite Points
		int32_t extractWidth = (setupTex->GetDesc().width + tileSize - 1) / tileSize;
		int32_t extractHeight = (setupTex->GetDesc().height + tileSize - 1) / tileSize;

		RenderBufferDesc spPointsBufDesc;
		spPointsBufDesc.bindFlag = BUFFER_BIND_SHADER_RESOURCE | BUFFER_BIND_UNORDERED_ACCESS;
		spPointsBufDesc.elementSize = sizeof(float2) + sizeof(float3);
		spPointsBufDesc.numElements = extractWidth * extractHeight;
		spPointsBufDesc.cpuAccess = 0;
		spPointsBufDesc.bStructured = true;

		auto spPointsBufRef = BufferPool::Instance().FindFree(spPointsBufDesc);
		auto spPointsBuf = spPointsBufRef->Get()->Cast<RenderBuffer>();

		{
			auto ps = Shader::FindOrCreate<ExtractSpritePointsPS>();

			ps->SetScalar("spriteThreshold", _spriteThreshold);
			ps->SetSRV("setupTex", setupTex->GetShaderResourceView());
			ps->SetUAV("spPointsBuf", spPointsBuf->GetUnorderedAccessView(0, 0, RENDER_FORMAT_UNKNOWN, BUFFER_UAV_APPEND));
			ps->Flush();

			DrawQuad({}, 0.0f, 0.0f, (float)extractWidth, (float)extractHeight);
		}

		//Render Sprites
		if (!_indirectAgsBuf)
		{
			RenderBufferDesc indirectArgsBufDesc;
			indirectArgsBufDesc.bindFlag = BUFFER_BIND_INDIRECT_ARGS;
			indirectArgsBufDesc.elementSize = 16;
			indirectArgsBufDesc.numElements = 1;
			indirectArgsBufDesc.cpuAccess = 0;
			indirectArgsBufDesc.bStructured = false;

			uint32_t initData[] = { 0, 1, 0, 0 };

			_indirectAgsBuf = Global::GetRenderEngine()->GetRenderFactory()->CreateBuffer();
			_indirectAgsBuf->SetDesc(indirectArgsBufDesc);
			_indirectAgsBuf->Init(initData);
		}

		spPointsBuf->CopyStructureCountTo(_indirectAgsBuf, 0, 0, spPointsBuf->GetDesc().numElements, RENDER_FORMAT_UNKNOWN, BUFFER_UAV_APPEND);

		{
			auto vs = Shader::FindOrCreate<LensBlurVS>();
			auto gs = Shader::FindOrCreate<LensBlurGS>();
			auto ps = Shader::FindOrCreate<LensBlurPS>();

			vs->SetScalar("texSize", target->GetTexSize());
			gs->SetScalar("texSize", target->GetTexSize());

			gs->SetScalar("flareIntensity", _flareIntensity);

			vs->SetSRV("spPointsRenderBuf", spPointsBuf->GetShaderResourceView(0, 0, RENDER_FORMAT_UNKNOWN));

			auto lensTexAsset = Asset::Find<TextureAsset>("Textures/Bokeh_Circle.dds");
			if (!lensTexAsset->IsInit())
				lensTexAsset->Init();
			auto lensTex = lensTexAsset->GetTexture();
			ps->SetSRV("lensTex", lensTex->GetShaderResourceView());

			ps->SetSampler("linearSampler", SamplerTemplate<>::Get());

			vs->Flush();
			gs->Flush();
			ps->Flush();

			auto rc = Global::GetRenderEngine()->GetRenderContext();

			rc->SetVertexBuffer({});
			rc->SetIndexBuffer(nullptr);
			rc->SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_POINTLIST);

			rc->SetViewport(GetTextureQuadViewport(target));

			rc->SetRenderTargets({ target->GetRenderTargetView(0, 0, 1) });
			rc->SetDepthStencil(nullptr);
			rc->SetDepthStencilState(DepthStencilStateTemplate<false>::Get());

			rc->SetBlendState(BlendStateTemplate<false, false, true, BLEND_PARAM_SRC_ALPHA, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get());

			rc->DrawInstancedIndirect(_indirectAgsBuf, 0);

			rc->ResetShader(SHADER_GS);
			rc->SetBlendState(nullptr);
		}
	}
Ejemplo n.º 5
0
	void SSR::Render(const Ptr<RenderView> & view)
	{
		auto sceneTex = view->GetViewRenderContext()->GetSharedTexture("RenderResult");
		auto sceneClipDepth = view->GetViewRenderContext()->GetSharedTexture("SceneClipDepth");
		auto gbuffer0 = view->GetViewRenderContext()->GetSharedTexture("GBuffer0");
		auto gbuffer1 = view->GetViewRenderContext()->GetSharedTexture("GBuffer1");

		TextureDesc ssrDesc = sceneTex->GetDesc();
		ssrDesc.format = RENDER_FORMAT_R16G16B16A16_FLOAT;
		auto ssrResultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, ssrDesc });
		auto ssrResult = ssrResultTexRef->Get()->Cast<Texture>();

		auto tmpDepthTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, sceneClipDepth->GetDesc() });
		auto tmpDepthTex = tmpDepthTexRef->Get()->Cast<Texture>();
		sceneClipDepth->CopyTo(tmpDepthTex, 0, 0, 0, 0, 0, 0, 0);

		auto ps = Shader::FindOrCreate<ScreenSpaceReflectionPS>();

		view->BindShaderParams(ps);
		ps->SetScalar("frameCount", Global::GetInfo()->frameCount);
		ps->SetScalar("ssrMaxRoughness", _ssrMaxRoughness);
		ps->SetScalar("ssrIntensity", _ssrIntensity);
		ps->SetSRV("sceneTex", sceneTex->GetShaderResourceView());
		ps->SetSRV("depthTex", tmpDepthTex->GetShaderResourceView(0, 0, 0, 0, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS));
		ps->SetSRV("gbuffer0", gbuffer0->GetShaderResourceView());
		ps->SetSRV("gbuffer1", gbuffer1->GetShaderResourceView());

		ps->SetSampler("pointClampSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());
		ps->SetSampler("linearSampler", SamplerTemplate<>::Get());

		ps->Flush();

		auto rc = Global::GetRenderEngine()->GetRenderContext();

		rc->SetDepthStencilState(
			DepthStencilStateTemplate<
			false,
			DEPTH_WRITE_ZERO,
			COMPARISON_LESS,
			true, 0xff, 0xff,
			STENCIL_OP_KEEP,
			STENCIL_OP_KEEP,
			STENCIL_OP_KEEP,
			COMPARISON_NOT_EQUAL>::Get(), 0);

		DrawQuad(
		{ ssrResult->GetRenderTargetView(0, 0, 1) }, 
			0.0f, 0.0f, 0.0f, 0.0f,
			0.0f, 0.0f, 1.0f, 1.0f,
			sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT));

		auto ssrSharedRef = SSRNeighborShare(view, ssrResult, gbuffer1, tmpDepthTex, sceneClipDepth);
		auto ssrShared = ssrSharedRef->Get()->Cast<Texture>();

		// Temporal AA for SSR
		auto ssrAAedResultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, sceneTex->GetDesc() });
		auto ssrAAedResultTex = ssrAAedResultTexRef->Get()->Cast<Texture>();
		{
			auto adaptedExposureScale = view->GetViewRenderContext()->GetSharedTexture("AdaptedExposureScale");

			float2 offsets[5] =
			{
				float2(0.0f, 0.0f),
				float2(-1.0f, 0.0f),
				float2(1.0f, 0.0f),
				float2(0.0f, -1.0f),
				float2(0.0f, 1.0f),
			};
			float filterWeights[5];
			float weightsSum = 0.0f;
			for (int i = 0; i < 5; ++i)
			{
				float2 offset = offsets[i] - float2(0.5f, -0.5f) * view->temporalAAJitter;

				//filterWeights[i] = CatmullRom(offset.x()) * CatmullRom(offset.y());
				offset.x() *= 1.0f + 0.0f * 0.5f;
				offset.y() *= 1.0f + 0.0f * 0.5f;
				filterWeights[i] = exp(-2.29f * (offset.x() * offset.x() + offset.y() * offset.y()));

				weightsSum += filterWeights[i];
			}
			for (auto & i : filterWeights)
				i /= weightsSum;

			std::map<String, String> macros;
			macros["TAA_DYNAMIC"] = "0";
			macros["TAA_HISTORY_BICUBIC"] = "0";

			auto ps = Shader::FindOrCreate<TemporalAAPS>(macros);

			view->BindShaderParams(ps);

			ps->SetScalar("texSize", ssrResult->GetTexSize());
			ps->SetScalar("neighborFilterWeights", filterWeights, (int)sizeof(float) * 5);
			ps->SetScalar("frameCount", (uint32_t)Global::GetInfo()->frameCount);
			ps->SetScalar("lerpFactor", 0.125f);
			//ps->SetSRV("linearDepth", sceneLinearClipDepth->GetShaderResourceView());
			ps->SetSRV("sceneDepth", sceneClipDepth->GetShaderResourceView(0, 0, 0, 0, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS));
			ps->SetSRV("sceneTex", ssrShared->GetShaderResourceView());
			//ps->SetSRV("velocityTex", velocityTex->GetShaderResourceView());
			//ps->SetSRV("adaptedExposureScale", adaptedExposureScale->GetShaderResourceView());
			if (_preSSRResultRef)
				ps->SetSRV("historyTex", _preSSRResultRef->Get()->Cast<Texture>()->GetShaderResourceView());
			else
				ps->SetSRV("historyTex", nullptr);
			ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());
			ps->SetSampler("linearSampler", SamplerTemplate<>::Get());

			ps->Flush();

			DrawQuad(
			{ ssrAAedResultTex->GetRenderTargetView(0, 0, 1) },
				0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 1.0f, 1.0f,
				sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT));

			_preSSRResultRef = ssrResultTexRef;
		}


		/*rc->SetBlendState(
			BlendStateTemplate<false, false, true, BLEND_PARAM_ONE, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get());


		rc->SetDepthStencil(sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT));

		Transform(
			ssrAAedResultTex->GetShaderResourceView(),
			sceneTex->GetRenderTargetView(0, 0, 1), 
			{ COLOR_WRITE_R, COLOR_WRITE_G ,COLOR_WRITE_B ,COLOR_WRITE_A }, 0.0f, 0.0f, nullptr,
			sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT));*/

		rc->SetBlendState(nullptr);
		rc->SetDepthStencilState(nullptr);

		view->GetViewRenderContext()->SetSharedResource("SSR", ssrAAedResultTexRef);
	}
Ejemplo n.º 6
0
	void SpriteBase::OnDraw() {
		auto TexPtr = App::GetApp()->GetResource<TextureResource>(m_TextureResName);
		auto Dev = App::GetApp()->GetDeviceResources();
		auto pD3D11DeviceContext = Dev->GetD3DDeviceContext();
		auto RenderState = Dev->GetRenderState();
		//ワールド行列の決定
		Mat4x4 World;
		World.affineTransformation2D(
			m_Scale,			//スケーリング
			Vec2(0, 0),		//回転の中心(重心)
			m_Rot,				//回転角度
			m_Pos				//位置
		);
		//射影行列の決定
		float w = static_cast<float>(App::GetApp()->GetGameWidth());
		float h = static_cast<float>(App::GetApp()->GetGameHeight());
		Mat4x4 Proj(XMMatrixOrthographicLH(w, h, -1.0, 1.0f));
		//行列の合成
		World *= Proj;
		//コンスタントバッファの準備
		SpriteConstantBuffer sb;
		//エミッシブ加算。
		sb.Emissive = m_Emissive;
		//行列の設定
		sb.World = World;
		//コンスタントバッファの更新
		pD3D11DeviceContext->UpdateSubresource(CBSprite::GetPtr()->GetBuffer(), 0, nullptr, &sb, 0, 0);

		//ストライドとオフセット
		UINT stride = sizeof(VertexPositionColorTexture);
		UINT offset = 0;
		//頂点バッファのセット
		pD3D11DeviceContext->IASetVertexBuffers(0, 1, m_SquareMesh->GetVertexBuffer().GetAddressOf(), &stride, &offset);
		//インデックスバッファのセット
		pD3D11DeviceContext->IASetIndexBuffer(m_SquareMesh->GetIndexBuffer().Get(), DXGI_FORMAT_R16_UINT, 0);

		//描画方法(3角形)
		pD3D11DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

		//コンスタントバッファの設定
		ID3D11Buffer* pConstantBuffer = CBSprite::GetPtr()->GetBuffer();
		ID3D11Buffer* pNullConstantBuffer = nullptr;
		//頂点シェーダに渡す
		pD3D11DeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer);
		//ピクセルシェーダに渡す
		pD3D11DeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer);
		//シェーダの設定
		pD3D11DeviceContext->VSSetShader(VSPCTSprite::GetPtr()->GetShader(), nullptr, 0);
		pD3D11DeviceContext->PSSetShader(PSPCTSprite::GetPtr()->GetShader(), nullptr, 0);
		//インプットレイアウトの設定
		pD3D11DeviceContext->IASetInputLayout(VSPCTSprite::GetPtr()->GetInputLayout());
		//ブレンドステート
		switch (m_BlendState) {
		case BlendState::Opaque:
			pD3D11DeviceContext->OMSetBlendState(RenderState->GetOpaque(), nullptr, 0xffffffff);
			break;
		case BlendState::Trace:
			pD3D11DeviceContext->OMSetBlendState(RenderState->GetAlphaBlendEx(), nullptr, 0xffffffff);
			break;
		case BlendState::Additive:
			pD3D11DeviceContext->OMSetBlendState(RenderState->GetAdditive(), nullptr, 0xffffffff);
			break;
		}
		//デプスステンシルステート
		pD3D11DeviceContext->OMSetDepthStencilState(RenderState->GetDepthNone(), 0);
		//ラスタライザステート
		pD3D11DeviceContext->RSSetState(RenderState->GetCullBack());

		//テクスチャとサンプラーの設定
		ID3D11ShaderResourceView* pNull[1] = { 0 };
		pD3D11DeviceContext->PSSetShaderResources(0, 1, TexPtr->GetShaderResourceView().GetAddressOf());
		//ラッピングサンプラー
		ID3D11SamplerState* pSampler = RenderState->GetLinearWrap();
		pD3D11DeviceContext->PSSetSamplers(0, 1, &pSampler);

		//描画
		pD3D11DeviceContext->DrawIndexed(m_SquareMesh->GetNumIndicis(), 0, 0);
		//後始末
		Dev->InitializeStates();
	}