Example #1
0
//==================================================================================================================================
void HDR::ToneMapWithBloom(ID3D11ShaderResourceView* pInput, ID3D11ShaderResourceView* pBloom, ID3D11RenderTargetView* pOutput)
{
	ID3D11DeviceContext* context = mD3DSystem->GetDeviceContext();
	ID3D11ShaderResourceView* ppSRV[] = { pInput, luminance->SRView, pBloom };
	context->PSSetShaderResources(0, 3, ppSRV);
	
	PostProcessManager::mShader->SwitchTo("ToneMapWithBloom", ZShadeSandboxShader::EShaderTypes::ST_PIXEL);

	//mD3DSystem->TurnOnAdditiveBlending();
	mD3DSystem->TurnOnAlphaBlending();
	{
		// Set all IA stage inputs to NULL, since we're not using it at all.
		ID3D11Buffer* vertexBuffers[1] = { NULL };
		UINT strides[1] = { 0 };
		UINT offsets[1] = { 0 };
		mD3DSystem->GetDeviceContext()->IASetVertexBuffers(0, 1, vertexBuffers, strides, offsets);
		mD3DSystem->GetDeviceContext()->IASetInputLayout(NULL);
		mD3DSystem->GetDeviceContext()->IASetIndexBuffer(NULL, DXGI_FORMAT_UNKNOWN, 0);
		
		// Set the vertex shader for the fullscreen quad
		PostProcessManager::mShader->SetVertexShader();
		
		// Set the pixel shader being used for the post process
		PostProcessManager::mShader->SetPixelShader();
		
		// Bind a NULL Input Layout for the fullscreen quad and draw with 4 points
		PostProcessManager::mShader->RenderDraw11(4);
		
		ppSRV[0] = NULL; ppSRV[1] = NULL;
		context->PSSetShaderResources(0, 2, ppSRV);
	}
	mD3DSystem->TurnOffAlphaBlending();
	//mD3DSystem->TurnOffAdditiveBlending();
}
Example #2
0
void TgcDX11Effect::setTexture(string name, const TgcTexture* texture)
{
	ID3D11DeviceContext* deviceContext = ((TgcDX11Renderer*)GuiController::Instance->renderer)->deviceContext;

	TgcEffectValues::Sampler sampler = this->samplers[name];
	ID3D11SamplerState* dxSampler = this->dxSampleStates[name];
	TgcDX11Texture* dxTexture = (TgcDX11Texture*)texture;

	//Set the sampler and texture for pixel shader
	if(sampler.shaderType == TgcEffectValues::PS)
	{
		deviceContext->PSSetSamplers(sampler.slot, 1, &dxSampler);
		deviceContext->PSSetShaderResources(sampler.slot, 1, &(dxTexture->dxTexture));
	}
	//Set the sampler and texture for vertex shader
	else if(sampler.shaderType == TgcEffectValues::VS)
	{
		deviceContext->VSSetSamplers(sampler.slot, 1, &dxSampler);
		deviceContext->VSSetShaderResources(sampler.slot, 1, &(dxTexture->dxTexture));
	}
	else if(sampler.shaderType == TgcEffectValues::VS_AND_PS)
	{
		deviceContext->VSSetSamplers(sampler.slot, 1, &dxSampler);
		deviceContext->PSSetSamplers(sampler.slot, 1, &dxSampler);

		deviceContext->VSSetShaderResources(sampler.slot, 1, &(dxTexture->dxTexture));
		deviceContext->PSSetShaderResources(sampler.slot, 1, &(dxTexture->dxTexture));
	}
	
}
Example #3
0
void Sample::Internal(ID3D11ShaderResourceView * src,ID3D11RenderTargetView * dst)
{
	ID3D11DeviceContext * context;
	device->GetImmediateContext(&context);

	ps.Get()->Bind();

	context->OMSetRenderTargets(1,&dst,nullptr);
	Color c = Color::White();
	context->ClearRenderTargetView(dst,(float*)&c);
	

	context->PSSetShaderResources(0,1,&src);
	FullScreenQuad::BindVS();

	FullScreenQuad::Draw();

	FullScreenQuad::UnbindVS();

	ID3D11RenderTargetView * rtvNull = nullptr;
	ID3D11ShaderResourceView * srvNull = nullptr;

	context->OMSetRenderTargets(1,&rtvNull,nullptr);
	context->PSSetShaderResources(0,1,&srvNull);
}
Example #4
0
void MSAAFilter::RenderAA()
{
    PIXEvent pixEvent(L"MSAA Resolve + Temporal AA");
    ProfileBlock profileBlock(L"MSAA Resolve + Temporal AA");

    ID3D11DeviceContext* context = deviceManager.ImmediateContext();

    ID3D11RenderTargetView* rtvs[1] = { resolveTarget.RTView };

    context->OMSetRenderTargets(1, rtvs, nullptr);

    if(AppSettings::UseStandardResolve)
    {
        if(AppSettings::MSAAMode == 0)
            context->CopyResource(resolveTarget.Texture, colorTarget.Texture);
        else
            context->ResolveSubresource(resolveTarget.Texture, 0, colorTarget.Texture, 0, colorTarget.Format);
        return;
    }

    const uint32 SampleRadius = static_cast<uint32>((AppSettings::ResolveFilterDiameter / 2.0f) + 0.499f);
    ID3D11PixelShader* pixelShader = resolvePS[AppSettings::MSAAMode];
    context->PSSetShader(pixelShader, nullptr, 0);
    context->VSSetShader(resolveVS, nullptr, 0);

    resolveConstants.Data.TextureSize = Float2(static_cast<float>(colorTarget.Width), static_cast<float>(colorTarget.Height));
    resolveConstants.Data.SampleRadius = SampleRadius;;
    resolveConstants.ApplyChanges(context);
    resolveConstants.SetPS(context, 0);

    ID3D11ShaderResourceView* srvs[] = { colorTarget.SRView, velocityTarget.SRView, depthBuffer.SRView, prevFrameTarget.SRView};
    context->PSSetShaderResources(0, ArraySize_(srvs), srvs);

    ID3D11SamplerState* samplers[] = { samplerStates.LinearClamp(), samplerStates.Point() };
    context->PSSetSamplers(0, ArraySize_(samplers), samplers);

    ID3D11Buffer* vbs[1] = { nullptr };
    UINT strides[1] = { 0 };
    UINT offsets[1] = { 0 };
    context->IASetVertexBuffers(0, 1, vbs, strides, offsets);
    context->IASetInputLayout(nullptr);
    context->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
    context->Draw(3, 0);

    rtvs[0] = nullptr;
    context->OMSetRenderTargets(1, rtvs, nullptr);

    srvs[0] = srvs[1] = srvs[2] = nullptr;
    context->PSSetShaderResources(0, 3, srvs);

    context->CopyResource(prevFrameTarget.Texture, resolveTarget.Texture);
}
//-----------------------------------------------
void CPUTRenderTargetDepth::SetRenderTarget(
    CPUTRenderParameters   &renderParams,
    DWORD                   renderTargetIndex,
    float                   zClearVal,
    bool                    clear
)
{
    // ****************************
    // Save the current render target "state" so we can restore it later.
    // ****************************
    mSavedWidth   = CPUTRenderTargetDepth::GetActiveWidth();
    mSavedHeight  = CPUTRenderTargetDepth::GetActiveHeight();

    CPUTRenderTargetColor::SetActiveWidthHeight( mWidth, mHeight );
    CPUTRenderTargetDepth::SetActiveWidthHeight( mWidth, mHeight );

    // TODO: support multiple render target views (i.e., MRT)
    ID3D11DeviceContext *pContext = CPUT_DX11::GetContext();

    // Make sure this render target isn't currently bound as a texture.
    static ID3D11ShaderResourceView *pSRV[16] = {0};
    pContext->PSSetShaderResources( 0, 16, pSRV );

    // Save the color and depth views so we can restore them later.
    mpSavedColorRenderTargetView = CPUTRenderTargetColor::GetActiveRenderTargetView();
    mpSavedDepthStencilView      = CPUTRenderTargetDepth::GetActiveDepthStencilView();

    // Clear the shader resources to avoid a hazard warning
    ID3D11ShaderResourceView *pNullResources[16] = {0};
    pContext->PSSetShaderResources(0, 16, pNullResources );
    pContext->VSSetShaderResources(0, 16, pNullResources );

    // ****************************
    // Set the new render target states
    // ****************************
    ID3D11RenderTargetView *pView[1] = {NULL};
    pContext->OMSetRenderTargets( 1, pView, mpDepthStencilView );

    CPUTRenderTargetColor::SetActiveRenderTargetView( NULL );
    CPUTRenderTargetDepth::SetActiveDepthStencilView( mpDepthStencilView );

    if( clear )
    {
        pContext->ClearDepthStencilView( mpDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, zClearVal, 0 );
    }
    D3D11_VIEWPORT viewport  = { 0.0f, 0.0f, (float)mWidth, (float)mHeight, 0.0f, 1.0f };
    pContext->RSSetViewports( 1, &viewport );

    mRenderTargetSet = true;
} // CPUTRenderTargetDepth::SetRenderTarget()
Example #6
0
	/** Sets a texture on the current shader instance. */
	void Shader::SetTexture(u32 index, std::shared_ptr<Texture> texture)
	{
		ID3D11ShaderResourceView* resourceView = texture != nullptr ? texture->GetShaderResourceView() : nullptr;
		ID3D11DeviceContext* context = GetParent()->GetDeviceContext();
		switch(GetType())
		{
		case ShaderType::Compute:
			context->CSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Domain:
			context->DSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Geometry:
			context->GSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Hull:
			context->HSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Pixel:
			context->PSSetShaderResources(index, 1, &resourceView);
			break;
		case ShaderType::Vertex:
			context->VSSetShaderResources(index, 1, &resourceView);
			break;
		}
	}
    void CFullscreenTriangleDrawer::DrawDX11( ID3D11ShaderResourceView* pTextureSRV )
    {
        ID3D11Device* pDevice = static_cast<ID3D11Device*>( gD3DDevice );
        ID3D11DeviceContext* pContext = NULL;
        pDevice->GetImmediateContext( &pContext );

        CDX11StateGuard stateGuard;

        pContext->IASetInputLayout( NULL );
        pContext->IASetIndexBuffer( NULL, DXGI_FORMAT_UNKNOWN, 0 );
        pContext->IASetVertexBuffers( 0, 0, NULL, NULL, NULL );
        pContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

        pContext->VSSetShader( m_pVertexShader11, NULL, 0 );
        pContext->PSSetShader( m_pPixelShader11, NULL, 0 );
        ID3D11SamplerState* pNullSampler[] = { NULL };
        pContext->PSSetSamplers( 0, 1, pNullSampler );

        pContext->PSSetShaderResources( 0, 1, &pTextureSRV );

        pContext->OMSetBlendState( m_pBlendState11, NULL, 0xFFFFFFFF );

        // Draw
        pContext->Draw( 3, 0 );
    }
void TextureFragmentShader::setParameters( ID3D11DeviceContext& deviceContext, const Texture2DSpecBind< TexBind::ShaderResource, float >& texture, int mipmapLevel )
{
	ID3D11ShaderResourceView* textureResource = texture.getShaderResourceView( mipmapLevel );

	deviceContext.PSSetShaderResources( 0, 1, &textureResource );
	deviceContext.PSSetSamplers( 0, 1, m_samplerState.GetAddressOf() );
}
Example #9
0
    void RenderMotionBlur()
    {
        mRenderer->VSetRenderContextTargetWithDepth(mRenderContext, 0);
        mRenderer->VClearContext(mRenderContext, reinterpret_cast<const float*>(&mClearColor), 1.0f, 0);

        mRenderer->VSetInputLayout(mVertexShader);
        mRenderer->VSetVertexShader(mVertexShader);
        //	mRenderer->VSetPixelShader(mPixelShader);
        mRenderer->VSetPixelShader(mSCPixelShader);

        DrawScene();

        mRenderer->VSetContextTargetWithDepth();
        mRenderer->VClearContext(reinterpret_cast<const float*>(&mClearColor), 1.0f, 0);

        mRenderer->VSetInputLayout(mQuadVertexShader);
        mRenderer->VSetVertexShader(mQuadVertexShader);
        mRenderer->VSetPixelShader(mMotionBlurPixelShader);

        mRenderer->VUpdateShaderConstantBuffer(mBlurShaderResource, &mMBMatrixBuffer, 0);
        mRenderer->VSetPixelShaderConstantBuffer(mBlurShaderResource, 0, 0);

        mRenderer->VSetPixelShaderResourceView(mRenderContext, 0, 0);
        mRenderer->VSetPixelShaderDepthResourceView(mRenderContext, 1);
        mRenderer->VSetPixelShaderSamplerStates(mBlurShaderResource);

        mRenderer->VBindMesh(mQuadMesh);
        mRenderer->VDrawIndexed(0, mQuadMesh->GetIndexCount());

        ID3D11DeviceContext* deviceContext = mRenderer->GetDeviceContext();
        ID3D11ShaderResourceView* nullSRV[2] = { 0, 0 };
        deviceContext->PSSetShaderResources(0, 2, nullSRV);
    }
void TextureFragmentShader::unsetParameters( ID3D11DeviceContext& deviceContext )
{
	ID3D11ShaderResourceView* nullResource = nullptr;
	ID3D11SamplerState*       nullSampler = nullptr;

	deviceContext.PSSetShaderResources( 0, 1, &nullResource );
	deviceContext.PSSetSamplers( 0, 1, &nullSampler );
}
void SkeletonModelFragmentShader::unsetParameters( ID3D11DeviceContext& deviceContext )
{
	ID3D11ShaderResourceView* nullResources[] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
	ID3D11SamplerState*       nullSampler = nullptr;

	deviceContext.PSSetShaderResources( 0, 7, nullResources );
	deviceContext.PSSetSamplers( 0, 1, &nullSampler );
}
void ParticleSystemEffectBinder::Bind()
{
	ID3D11DeviceContext * context = GetContext();
	ID3D11ShaderResourceView * textureSRV = colorTexture.Get()->GetShaderResourcePointer();
	ID3D11Buffer * buffers[3] = {cameraBuffer.Get()->GetBufferPointer(),cameraVectorsBuffer.Get()->GetBufferPointer(),dataBuffer.Get()->GetBufferPointer()};

	context->VSSetConstantBuffers(0,3,buffers);
	context->PSSetShaderResources(0,1,&textureSRV);
}
Example #13
0
    void graphics_extensions::UnbindAll() {
        ID3D11DeviceContext* context = GraphicsManager::Get()->GetImmidiateContext();

        ID3D11RenderTargetView* rtViews[4];
        memset(rtViews, 0, sizeof(ID3D11RenderTargetView*) * _countof(rtViews));
        context->OMSetRenderTargets(_countof(rtViews), rtViews, nullptr);

        ID3D11ShaderResourceView* srViews[6];
        memset(srViews, 0, sizeof(ID3D11ShaderResourceView*) * _countof(srViews));
        context->PSSetShaderResources(0, _countof(srViews), srViews);
    }
//-----------------------------------------------
void CPUTRenderTargetColor::SetRenderTarget(
    CPUTRenderParameters   &renderParams,
    CPUTRenderTargetDepth  *pDepthBuffer,
    DWORD                   renderTargetIndex,
    const float            *pClearColor,
    bool                    clear,
    float                   zClearVal
)
{
    // ****************************
    // Save the current render target "state" so we can restore it later.
    // ****************************
    mSavedWidth   = CPUTRenderTargetColor::sCurrentWidth;
    mSavedHeight  = CPUTRenderTargetColor::sCurrentHeight;

    // Save the render target view so we can restore it later.
    mpSavedColorRenderTargetView = CPUTRenderTargetColor::GetActiveRenderTargetView();
    mpSavedDepthStencilView      = CPUTRenderTargetDepth::GetActiveDepthStencilView();

    CPUTRenderTargetColor::SetActiveWidthHeight( mWidth, mHeight );
    CPUTRenderTargetDepth::SetActiveWidthHeight( mWidth, mHeight );

    // TODO: support multiple render target views (i.e., MRT)
    ID3D11DeviceContext *pContext = CPUT_DX11::GetContext();

    // Clear the shader resources to avoid a hazard warning
    ID3D11ShaderResourceView *pNullResources[16] = {0};
    pContext->PSSetShaderResources(0, 16, pNullResources );
    pContext->VSSetShaderResources(0, 16, pNullResources );

    // ****************************
    // Set the new render target states
    // ****************************
    ID3D11DepthStencilView *pDepthStencilView = pDepthBuffer ? pDepthBuffer->GetDepthBufferView() : NULL;
    pContext->OMSetRenderTargets( 1, &mpColorRenderTargetView, pDepthStencilView );

    CPUTRenderTargetColor::SetActiveRenderTargetView(mpColorRenderTargetView);
    CPUTRenderTargetDepth::SetActiveDepthStencilView(pDepthStencilView);

    if( clear )
    {
        pContext->ClearRenderTargetView( mpColorRenderTargetView, pClearColor );
        if( pDepthStencilView )
        {
            pContext->ClearDepthStencilView( pDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, zClearVal, 0 );
        }
    }
    D3D11_VIEWPORT viewport  = { 0.0f, 0.0f, (float)mWidth, (float)mHeight, 0.0f, 1.0f };
    pContext->RSSetViewports(1, &viewport);

    mRenderTargetSet = true;
	mSoftwareTextureDirty = true;

} // CPUTRenderTargetColor::SetRenderTarget()
            ~CDX11StateGuard()
            {
                ID3D11Device* pDevice = static_cast<ID3D11Device*>( gD3DDevice );
                ID3D11DeviceContext* pContext = NULL;
                pDevice->GetImmediateContext( &pContext );

                // Apply saved state
                pContext->OMSetBlendState( m_pBlendState, m_BlendFactor, m_SampleMask );
                pContext->RSSetState( m_pRasterizerState );
                pContext->IASetPrimitiveTopology( m_PrimitiveTopology );
                pContext->IASetIndexBuffer( m_pIndexBuffer, m_IndexBufferFormat, m_IndexBufferOffset );
                pContext->IASetInputLayout( m_pInputLayout );
                pContext->IASetVertexBuffers( 0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, m_pVertexBuffers, m_pVertexBufferStrides, m_pVertexBufferOffsets );
                pContext->VSSetShader( m_pVertexShader, m_ppVertexShaderClassInstances, m_VertexShaderClassInstancesCount );
                pContext->PSSetShader( m_pPixelShader, m_ppPixelShaderClassInstances, m_PixelShaderClassInstancesCount );
                pContext->PSSetSamplers( 0, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, m_ppPixelShaderSamplers );
                pContext->PSSetShaderResources( 0, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, m_ppPixelShaderResources );

                // Release references
                SAFE_RELEASE( m_pBlendState );
                SAFE_RELEASE( m_pRasterizerState );
                SAFE_RELEASE( m_pIndexBuffer );
                SAFE_RELEASE( m_pInputLayout );

                for ( UINT i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i )
                {
                    SAFE_RELEASE( m_pVertexBuffers[i] );
                }

                SAFE_RELEASE( m_pVertexShader );

                for ( UINT i = 0; i < m_VertexShaderClassInstancesCount; ++i )
                {
                    SAFE_RELEASE( m_ppVertexShaderClassInstances[i] );
                }

                SAFE_RELEASE( m_pPixelShader );

                for ( UINT i = 0; i < m_PixelShaderClassInstancesCount; ++i )
                {
                    SAFE_RELEASE( m_ppPixelShaderClassInstances[i] );
                }

                for ( UINT i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i )
                {
                    SAFE_RELEASE( m_ppPixelShaderSamplers[i] );
                }

                for ( UINT i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i )
                {
                    SAFE_RELEASE( m_ppPixelShaderResources[i] );
                }
            }
Example #16
0
void D11State::draw() {
	clock_t t = clock();
	float elapsed = static_cast<float>(t - timeT) / CLOCKS_PER_SEC;
	++frameCount;
	if (elapsed > OVERLAY_FPS_INTERVAL) {
		OverlayMsg om;
		om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
		om.omh.uiType = OVERLAY_MSGTYPE_FPS;
		om.omh.iLength = sizeof(OverlayMsgFps);
		om.omf.fps = frameCount / elapsed;

		sendMessage(om);

		frameCount = 0;
		timeT = t;
	}

	checkMessage(static_cast<unsigned int>(vp.Width), static_cast<unsigned int>(vp.Height));

	if (a_ucTexture && pSRView && (uiLeft != uiRight)) {
		if (!bDeferredContext) {
			pOrigStateBlock->Capture();
			pMyStateBlock->Apply();
		}

		// Set vertex buffer
		UINT stride = sizeof(SimpleVertex);
		UINT offset = 0;
		pDeviceContext->IASetVertexBuffers(0, 1, &pVertexBuffer, &stride, &offset);

		pDeviceContext->VSSetShader(pVertexShader, NULL, 0);
		pDeviceContext->GSSetShader(NULL, NULL, 0);
		pDeviceContext->PSSetShaderResources(0, 1, &pSRView);
		pDeviceContext->PSSetShader(pPixelShader, NULL, 0);
		pDeviceContext->DrawIndexed(6, 0, 0);

		if (bDeferredContext) {
			ID3D11CommandList *pCommandList;
			pDeviceContext->FinishCommandList(TRUE, &pCommandList);
			ID3D11DeviceContext *ctx = NULL;
			pDevice->GetImmediateContext(&ctx);
			ctx->ExecuteCommandList(pCommandList, TRUE);
			ctx->Release();
			pCommandList->Release();
		} else {
			pDeviceContext->Flush();
			pMyStateBlock->Capture();
			pOrigStateBlock->Apply();
		}
	}
}
//---------------------------------------------------------------------------
void TexturedShader::DrawRenderable(const RenderableNode& r)
{

    // update per draw cb.
    ID3D11DeviceContext*  dc = m_rc->Context();
    ID3D11ShaderResourceView* textures[] = {NULL, NULL, NULL};
           
    ConstantBufferPerDraw constBuff;

    Matrix::Transpose(r.WorldXform, constBuff.cb_world );
    constBuff.cb_hasDiffuseMap = 0;
    constBuff.cb_hasNormalMap = 0;
    constBuff.cb_hasSpecularMap = 0;
    constBuff.cb_lighting =  r.lighting;

    Matrix w = r.WorldXform;        
    w.M41 = w.M42 = w.M43 = 0; w.M44 = 1;
    Matrix::Invert(w,constBuff.cb_worldInvTrans);
    Matrix::Transpose(r.TextureXForm, constBuff.cb_textureTrans);
    constBuff.cb_matDiffuse     = r.diffuse;
    constBuff.cb_matEmissive    = r.emissive;
    constBuff.cb_matSpecular    = float4(r.specular.x,r.specular.y, r.specular.z, r.specPower);

    if(r.textures[TextureType::DIFFUSE])
    {
        constBuff.cb_hasDiffuseMap = 1;
        textures[0] = r.textures[TextureType::DIFFUSE]->GetView();
    }

    if(r.textures[TextureType::NORMAL])
    {
        constBuff.cb_hasNormalMap = 1;
        textures[1] = r.textures[TextureType::NORMAL]->GetView();
    }
        
    UpdateConstantBuffer(dc,m_pConstantBufferPerDraw,&constBuff, sizeof(constBuff));    
    dc->PSSetShaderResources( 0, ARRAY_SIZE(textures), textures );
            
    uint32_t stride = r.mesh->vertexBuffer->GetStride();
    uint32_t offset = 0;
    uint32_t startIndex  = 0;
    uint32_t startVertex = 0;    
    uint32_t indexCount = r.mesh->indexBuffer->GetCount();        
    ID3D11Buffer* d3dvb = r.mesh->vertexBuffer->GetBuffer();
    ID3D11Buffer* d3dib = r.mesh->indexBuffer->GetBuffer();
    dc->IASetPrimitiveTopology( (D3D11_PRIMITIVE_TOPOLOGY)r.mesh->primitiveType );    
    dc->IASetVertexBuffers( 0, 1, &d3dvb, &stride, &offset );
    dc->IASetIndexBuffer(d3dib, DXGI_FORMAT_R32_UINT, 0);
    dc->DrawIndexed(indexCount, startIndex, startVertex);
}
Example #18
0
void ToneMapper::IntRun(ID3D11ShaderResourceView * src,ID3D11RenderTargetView * dst)
{
	ID3D11DeviceContext * context;
	device->GetImmediateContext(&context);

	ID3D11ShaderResourceView * srvNull[2] = {nullptr,nullptr};
	ID3D11RenderTargetView * rtvNull = nullptr;

	shader.Get()->Bind();
	FullScreenQuad::BindVS();

	ID3D11ShaderResourceView * srcSrv[2] = {src,bloomTexture.Get()->GetShaderResourcePointer()};


	context->PSSetShaderResources(0,2,srcSrv);
	context->OMSetRenderTargets(1,&dst,nullptr);

	FullScreenQuad::Draw();

	context->PSSetShaderResources(0,2,srvNull);
	context->OMSetRenderTargets(1,&rtvNull,nullptr);

}
Example #19
0
void D3D11Mesh::Render()
{
	ID3D11DeviceContext* pContext = m_shader->GetContext();
	ID3D11ShaderResourceView* ptexRv = dynamic_cast<D3D11Texture*>(m_tex)->m_textureRV;

	unsigned int stride = sizeof(Vertex);
	unsigned int offset = 0;

	pContext->IASetInputLayout(m_vertexLayout);
	pContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);
	pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	pContext->PSSetShaderResources(0, 1, &ptexRv);

	pContext->Draw(m_numtriangles*3, 0);
}
Example #20
0
    void RenderGuassianBlur()
    {
        mRenderer->VSetRenderContextTargetWithDepth(mRenderContext, 0);
        mRenderer->VClearContext(mRenderContext, reinterpret_cast<const float*>(&mClearColor), 1.0f, 0);

        mRenderer->VSetInputLayout(mVertexShader);
        mRenderer->VSetVertexShader(mVertexShader);
        //	mRenderer->VSetPixelShader(mPixelShader);
        mRenderer->VSetPixelShader(mSCPixelShader);

        DrawScene();

        // Horizontal Pass
        // Only clear rtv here leave depth alone
        mRenderer->VSetRenderContextTarget(mRenderContext, 1);
        mRenderer->VClearContextTarget(mRenderContext, 1, reinterpret_cast<const float*>(&mClearColor));

        mRenderer->VSetInputLayout(mQuadVertexShader);
        mRenderer->VSetVertexShader(mQuadVertexShader);
        mRenderer->VSetPixelShader(mQuadBlurPixelShader);

        mRenderer->VUpdateShaderConstantBuffer(mBlurShaderResource, &mBlurH, 1);
        mRenderer->VSetPixelShaderConstantBuffer(mBlurShaderResource, 1, 0);

        mRenderer->VSetPixelShaderResourceView(mRenderContext, 0, 0);
        mRenderer->VSetPixelShaderDepthResourceView(mRenderContext, 1);
        mRenderer->VSetPixelShaderSamplerStates(mBlurShaderResource);

        mRenderer->VBindMesh(mQuadMesh);
        mRenderer->VDrawIndexed(0, mQuadMesh->GetIndexCount());

        // Final Pass
        mRenderer->VSetContextTargetWithDepth();
        mRenderer->VClearContext(reinterpret_cast<const float*>(&mClearColor), 1.0f, 0);

        mRenderer->VUpdateShaderConstantBuffer(mBlurShaderResource, &mBlurV, 1);
        mRenderer->VSetPixelShaderConstantBuffer(mBlurShaderResource, 1, 0);

        mRenderer->VSetPixelShaderResourceView(mRenderContext, 1, 0);
        mRenderer->VSetPixelShaderDepthResourceView(mRenderContext, 1);

        mRenderer->VDrawIndexed(0, mQuadMesh->GetIndexCount());

        ID3D11DeviceContext* deviceContext = mRenderer->GetDeviceContext();
        ID3D11ShaderResourceView* nullSRV[2] = { 0, 0 };
        deviceContext->PSSetShaderResources(0, 2, nullSRV);
    }
	void MultiTextureShader::SetShaderParameters(Graphics* graphics)
	{
		unsigned int bufferNumber;
		ID3D11DeviceContext* deviceContext = graphics->GetImmediateContex();;

		m_matrixBuffer.Data.World = m_worldMatrix.Transpose();
		m_matrixBuffer.Data.View = m_viewMatrix.Transpose();
		m_matrixBuffer.Data.Projection = m_projectionMatrix.Transpose();
		m_matrixBuffer.ApplyChanges(deviceContext);

		bufferNumber = 0;
		ID3D11Buffer* constBuffer[] = { m_matrixBuffer.Buffer() };
		deviceContext->VSSetConstantBuffers(bufferNumber,1,constBuffer);

		deviceContext->PSSetShaderResources(0,2,m_textures->GetTextures());

	}
	void AlphaMapShader::SetShaderParameters(Graphics* graphics)
	{
		unsigned int bufferNumber = 0;
		ID3D11DeviceContext* context = graphics->GetImmediateContex();

		Matrix world = m_worldMatrix.Transpose();
		Matrix view = m_viewMatrix.Transpose();
		Matrix proj = m_projectionMatrix.Transpose();

		m_matrixBuffer.Data.World = world;
		m_matrixBuffer.Data.View = view;
		m_matrixBuffer.Data.Projection = proj;
		m_matrixBuffer.ApplyChanges(context);

		ID3D11Buffer* buffer = m_matrixBuffer.Buffer();
		context->VSSetConstantBuffers(bufferNumber,1,&buffer);
		context->PSSetShaderResources(0,3,m_textures->GetTextures());
	}
/*
	Renders entity
*/
void CEntity::Render(unsigned int &prevMeshID) const 
{
	if (mRenderEntity)
	{
		CRenderManager* rm = CRenderManager::GetInstance();
		ID3D11DeviceContext* deviceContext = rm->GetDeviceContext();
		geom::CMesh* mesh = mTemplate->mMesh;

		if (mesh != NULL)
		{
			if (mesh->GetUID() != prevMeshID)
			{		
				/* Sets the buffers */
				ID3D11Buffer* vertexBuffer = mesh->GetVertexBuffer();
				ID3D11Buffer* indexBuffer = mesh->GetIndexBuffer();

				UINT stride = mesh->GetVertexSize();
				UINT offset = 0;

				deviceContext->IASetVertexBuffers( 0, 1, &vertexBuffer, &stride, &offset );
				deviceContext->IASetIndexBuffer( indexBuffer, DXGI_FORMAT_R16_UINT, 0 );

				deviceContext->IASetPrimitiveTopology( mesh->GetTopology() );

				/* Sets texture */
				ID3D11ShaderResourceView* texture = mesh->GetTexture();
				if (texture != NULL)
				{
					ID3D11SamplerState* sample = mesh->GetSample();
					int startSlot = mesh->GetStartSlot();

					deviceContext->PSSetShaderResources( startSlot, 1, &texture );
					deviceContext->PSSetSamplers( startSlot, 1, &sample );

					deviceContext->RSSetState( mTemplate->mRasterState );
				}
			}

			deviceContext->DrawIndexed( mesh->GetNumberOfIndices(), 0, 0 );

			prevMeshID = mesh->GetUID();
		}
	}
}
void SkeletonModelFragmentShader::setParameters( ID3D11DeviceContext& deviceContext,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, unsigned char >& alphaTexture,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, uchar4 >& emissiveTexture,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, uchar4 >& albedoTexture,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, uchar4 >& normalTexture,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, unsigned char >& metalnessTexture,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, unsigned char >& roughnessTexture,
                                                 const Texture2DSpecBind< TexBind::ShaderResource, unsigned char >& indexOfRefractionTexture,
                                                 const float4& extraEmissive )
{
	const int resourceCount = 7;
	ID3D11ShaderResourceView* textureResource[ resourceCount ] = 
    {
        alphaTexture.getShaderResourceView(),
        emissiveTexture.getShaderResourceView(),
        albedoTexture.getShaderResourceView(),
        normalTexture.getShaderResourceView(),
        metalnessTexture.getShaderResourceView(),
        roughnessTexture.getShaderResourceView(),
        indexOfRefractionTexture.getShaderResourceView()
    };

	deviceContext.PSSetShaderResources( 0, resourceCount, textureResource );
	deviceContext.PSSetSamplers( 0, 1, m_samplerState.GetAddressOf() );

    D3D11_MAPPED_SUBRESOURCE mappedResource;
    ConstantBuffer* dataPtr;

    HRESULT result = deviceContext.Map( m_constantInputBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource );
    if ( result < 0 ) throw std::exception( "BlockModelVertexShader::setParameters - mapping constant buffer to CPU memory failed" );

    dataPtr = (ConstantBuffer*)mappedResource.pData;

    dataPtr->extraEmissive = extraEmissive;

    deviceContext.Unmap( m_constantInputBuffer.Get(), 0 );

    deviceContext.PSSetConstantBuffers( 0, 1, m_constantInputBuffer.GetAddressOf() );
}
Example #25
0
void Model::Paint(const XMMATRIX &world, Camera *camera, XMFLOAT3 lightPos)
{
  unsigned int stride = mSizeOfVertexDesc;
	unsigned int offset = 0;

  XMMATRIX view = camera->GetViewMatrix();
  XMMATRIX proj = camera->GetProjectionMatrix();

  MatrixBuffer buffer;
  buffer.world = XMMatrixTranspose(world);
  buffer.view = XMMatrixTranspose(view);
  buffer.proj = XMMatrixTranspose(proj);
  buffer.wvp = XMMatrixTranspose(world * view * proj);
  buffer.cameraPos = camera->GetPosition();

  ID3D11DeviceContext *dc = GameEngine::GetInstance()->GetGraphicsManager()->GetGraphicsDeviceContext();

	dc->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &offset);
	dc->IASetInputLayout(mInputLayout);
	dc->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	dc->VSSetShader(mVertexShader, 0, 0);
	dc->PSSetShader(mFragmentShader, 0, 0);
  dc->PSSetShaderResources(0, 1, &mTextureView);
  dc->PSSetSamplers(0, 1, &mTextureSamplerState);

  dc->UpdateSubresource(mMatrixBuffer, 0, 0, &buffer, 0, 0);
  dc->VSSetConstantBuffers(0, 1, &mMatrixBuffer);

  dc->UpdateSubresource(mLightBuffer, 0, 0, &lightPos, 0, 0);
  dc->VSSetConstantBuffers(1, 1, &mLightBuffer);

  if (mAnimation)
  {
    mAnimation->SetAnimationProperties(dc);
  }

	dc->Draw(mNumberOfVertices, 0);
}
Example #26
0
	//----------------------------------------------------------------------------------------------------
	bool EECylinder::Render()
	{
		if (!EEObject::Render())
			return false;

		MapObjectBuffer();

		ID3D11DeviceContext *deviceConstext = EECore::s_EECore->GetDeviceContext();
		deviceConstext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
		deviceConstext->IASetInputLayout(s_objectIL);
		UINT stride = sizeof(EECylinderVertex);
		UINT offset = 0;
		deviceConstext->IASetVertexBuffers(0, 1, &m_objectVB, &stride, &offset);
		deviceConstext->IASetIndexBuffer(m_objectIB, DXGI_FORMAT_R32_UINT, 0);
		deviceConstext->VSSetShader(s_objectVS, NULL, 0);
		ID3D11ShaderResourceView *texture = m_tex.GetTexture();
		deviceConstext->PSSetShaderResources(0, 1, &texture);
		deviceConstext->PSSetShader(s_objectPS, NULL, 0);
		deviceConstext->DrawIndexed(m_indexCount, 0, 0);

		return true;
	}
Example #27
0
	//----------------------------------------------------------------------------------------------------
	bool EECurve2D::Render()
	{
		if (!EEObject::Render())
			return false;

		MapObjectBuffer();

		ID3D11DeviceContext *deviceContext = EECore::s_EECore->GetDeviceContext();
		deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
		deviceContext->IASetInputLayout(s_curveIL);
		UINT stride = sizeof(EECurve2DVertex);
		UINT offset = 0;
		deviceContext->IASetVertexBuffers(0, 1, &m_curveVB, &stride, &offset);
		deviceContext->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0);
		deviceContext->VSSetShader(s_curveVS, NULL, 0);
		ID3D11ShaderResourceView *texture = m_tex.GetTexture();
		deviceContext->PSSetShaderResources(0, 1, &texture);
		deviceContext->PSSetShader(s_curvePS, NULL, 0);
		deviceContext->Draw(m_curve.size() << 1, 0);

		return true;
	}
Example #28
0
void SpriteShader::SetParameters()
{
	D3D11_MAPPED_SUBRESOURCE ms0, ms1;
	ID3D11DeviceContext* devcon = (ID3D11DeviceContext*)EngineCore::GetGraphicsAPI()->GetDeviceContext();

	// Set buffer 0
	devcon->Map(
		gpu_vs_buffer0,
		0,
		D3D11_MAP_WRITE_DISCARD,
		0,
		&ms0
	);

	memcpy(ms0.pData, &cpu_vs_buffer0, sizeof(cpu_vs_buffer0));
	devcon->Unmap(gpu_vs_buffer0, 0);
	devcon->VSSetConstantBuffers(0, 1, &gpu_vs_buffer0);

	// Set buffer 1
	devcon->Map(
		gpu_vs_buffer1,
		0,
		D3D11_MAP_WRITE_DISCARD,
		0,
		&ms1
	);

	memcpy(ms1.pData, &cpu_vs_buffer1, sizeof(cpu_vs_buffer1));
	devcon->Unmap(gpu_vs_buffer1, 0);
	devcon->VSSetConstantBuffers(1, 1, &gpu_vs_buffer1);

	PNG_Texture* png_tex = (PNG_Texture*)texture;
	ID3D11ShaderResourceView* srv = png_tex->GetShaderResourceView();
	devcon->PSSetShaderResources(0, 1, &srv);

	devcon->PSSetSamplers(0, 1, &samplerState);
}
void D3D11CanvasWindowGraphics::Render()
{
	RECT clientRc;
	GetClientRect(m_hWnd, &clientRc);
	RectF clientRcf((float)clientRc.left, (float)clientRc.top,
		(float)clientRc.right, (float)clientRc.bottom);
	D2D1_RECT_F clientRectf = D2D1::RectF((FLOAT)clientRc.left, (FLOAT)clientRc.top,
		(FLOAT)clientRc.right, (FLOAT)clientRc.bottom);

	ID3D11DeviceContext* pContext = m_driver->GetD3D11Context();

	// Clear to black
	static const float BG_COLOR[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
	pContext->ClearRenderTargetView(m_backBufferRTV, BG_COLOR);

	// TODO: CLEAN UP THIS MESS!!!

	if (m_image)
	{
		// Set up rasterizer
		RECT clientRc;
		GetClientRect(m_hWnd, &clientRc);
		RectF clientRcf((float)clientRc.left, (float)clientRc.top,
			(float)clientRc.right, (float)clientRc.bottom);
		D3D11_VIEWPORT vp = CD3D11_VIEWPORT(
			clientRcf.left,
			clientRcf.top,
			clientRcf.right - clientRcf.left,
			clientRcf.bottom - clientRcf.top);
		pContext->RSSetViewports(1, &vp);

		// Set up output merger
		ID3D11RenderTargetView* rtv = m_backBufferRTV;
		pContext->OMSetRenderTargets(1, &rtv, NULL);
		pContext->OMSetBlendState(m_driver->GetOverBlend(), NULL, 0xFFFFFFFF);

		D3D11ImagePtr d3d11Image = std::static_pointer_cast<D3D11Image, DriverImage>(
			m_image->GetDriverImage());
		ID3D11ShaderResourceView* srv = d3d11Image->GetSRV();
		ID3D11SamplerState* ss = m_driver->GetBilinearSampler();

		// Set up pixel shader
		pContext->PSSetShader(m_driver->GetTexturedPixelShader(), NULL, 0);
		pContext->PSSetShaderResources(0, 1, &srv);
		pContext->PSSetSamplers(0, 1, &ss);

		m_driver->RenderQuad(m_camera->GetCanvasToClip(clientRcf),
			m_image->GetCanvasRect());

		srv = NULL;
		pContext->PSSetShaderResources(0, 1, &srv);
	}

	// Render something into Direct2D target

	ComPtr<ID2D1RenderTarget> pD2DTarget = m_d2dTarget->AcquireTarget();

	pD2DTarget->BeginDraw();

	// Clear to transparent black
	pD2DTarget->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f));

	// Create brush for drawing stuff
	ID2D1SolidColorBrush* brush;
	pD2DTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Blue), &brush);
	
	Matrix3x2f canvasToViewport = m_camera->GetCanvasToViewport(clientRcf);

	// Draw the extensible image's tile structure
	const ExtensibleImage::TileMap& tiles = m_extensibleImage->GetTileMap();
	for (ExtensibleImage::TileMap::const_iterator it = tiles.begin();
		it != tiles.end(); ++it)
	{
		const RectF& canvasRect = it->second->GetCanvasRect();

		ID2D1Factory* d2dFactory;
		pD2DTarget->GetFactory(&d2dFactory);

		ID2D1RectangleGeometry* rectGeom;
		d2dFactory->CreateRectangleGeometry(
			D2D1::RectF(canvasRect.left, canvasRect.top, canvasRect.right, canvasRect.bottom),
			&rectGeom);

		ID2D1TransformedGeometry* transGeom;
		d2dFactory->CreateTransformedGeometry(rectGeom,
			D2D1::Matrix3x2F(canvasToViewport.m11, canvasToViewport.m12,
			canvasToViewport.m21, canvasToViewport.m22,
			canvasToViewport.m31, canvasToViewport.m32),
			&transGeom);

		rectGeom->Release();

		pD2DTarget->DrawGeometry(transGeom, brush);

		transGeom->Release();

		d2dFactory->Release();
	}

	// Draw some text
	RenderPrintf(pD2DTarget, m_textFormat, clientRectf, brush,
		L"Welcome to Paint Sandbox!");

	brush->Release();

	pD2DTarget->EndDraw();

	m_d2dTarget->ReleaseTarget();

	// Transfer Direct2D target to display
	//m_driver->RenderD2DTarget(m_d2dTarget);

	// Set up rasterizer
	D3D11_VIEWPORT vp = CD3D11_VIEWPORT(
		clientRcf.left,
		clientRcf.top,
		clientRcf.right - clientRcf.left,
		clientRcf.bottom - clientRcf.top);
	pContext->RSSetViewports(1, &vp);

	// Set up output merger
	ID3D11RenderTargetView* rtv = m_backBufferRTV;
	pContext->OMSetRenderTargets(1, &rtv, NULL);
	pContext->OMSetBlendState(m_driver->GetOverBlend(), NULL, 0xFFFFFFFF);

	ID3D11ShaderResourceView* srv = m_d2dTarget->AcquireSRV();
	ID3D11SamplerState* ss = m_driver->GetBilinearSampler();

	// Set up pixel shader
	pContext->PSSetShader(m_driver->GetTexturedPixelShader(), NULL, 0);
	pContext->PSSetShaderResources(0, 1, &srv);
	pContext->PSSetSamplers(0, 1, &ss);

	m_driver->RenderQuad(Matrix3x2f::IDENTITY, RectF(-1.0f, 1.0f, 1.0f, -1.0f));

	srv = NULL;
	pContext->PSSetShaderResources(0, 1, &srv);

	m_d2dTarget->ReleaseSRV();
}
Example #30
0
void BaseShader::PreRender(void)
{
	ID3D11DeviceContext* deviceContext = Application::GetInstance().GetGraphicsDevice()->GetDXSystem()->GetDeviceContext();
	HRESULT result;
	D3D11_MAPPED_SUBRESOURCE mappedResource;
	D3DXMATRIX world;
	D3DXMATRIX proj;
	D3DXMATRIX view;
	unsigned int pixelBufferNum = 0;
	unsigned int vertexBufferNum = 0;

	Application::GetInstance().GetGraphicsDevice()->GetDXSystem()->GetWorldMatrix(world);
	Application::GetInstance().GetGraphicsDevice()->GetDXSystem()->GetProjectionMatrix(proj);
	Application::GetInstance().GetGraphicsDevice()->m_debugCamera->GetViewMatrix(view);

	D3DXMatrixTranspose(&world, &world);
	D3DXMatrixTranspose(&view, &view);
	D3DXMatrixTranspose(&proj, &proj);

	for (auto it = m_buffers.begin(); it != m_buffers.end(); it++)
	{
		eBufferType buffType = (*it).first;

		if (buffType > eBufferType_Vertex && buffType < eBufferType_Pixel)
		{
			result = deviceContext->Map((*it).second, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
			if (FAILED(result))
			{
				LogManager::GetInstance().Error("Shader::Render-> could not lock a buffer");
				return;
			}

			//Specific
			switch (buffType)
			{
			case eBufferType_Vertex_Matrix:
			{
				MatrixBufferType* dataPtr = (MatrixBufferType*)mappedResource.pData;
				dataPtr->world = world;
				dataPtr->projection = proj;
				dataPtr->view = view;
			}
				break;
			case eBufferType_Vertex_Camera:
			{
				CameraBufferType* dataPtr = (CameraBufferType*)mappedResource.pData;
				dataPtr->cameraPosition = Application::GetInstance().GetGraphicsDevice()->m_debugCamera->GetPosition();
				dataPtr->padding = 0.0f;
			}
				break;
			case eBufferType_Vertex_Light:
			{
				LightBufferType* dataPtr = (LightBufferType*)mappedResource.pData;
				dataPtr->ambientColour = D3DXVECTOR4(0.15f, 0.15f, 0.15f, 1.0f);
				dataPtr->diffuseColour = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
				dataPtr->specularColour = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
				dataPtr->direction = D3DXVECTOR3(0.0f, -1.0f, 0.0f);
				dataPtr->specularPower = 1024.0f;
			}
				break;
			default:
				assert(false && "It's pretty impossible to get here, re-evaluate your life");
				break;
			}

			deviceContext->Unmap((*it).second, 0);
			deviceContext->VSSetConstantBuffers(vertexBufferNum, 1, &(*it).second);
			vertexBufferNum++;
		}
		else if (buffType > eBufferType_Pixel)
		{
			result = deviceContext->Map((*it).second, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
			if (FAILED(result))
			{
				LogManager::GetInstance().Error("Shader::Render-> could not lock a buffer");
				return;
			}

			//Specific
			switch (buffType)
			{
			case eBufferType_Pixel_Matrix:
			{
				MatrixBufferType* dataPtr = (MatrixBufferType*)mappedResource.pData;
				dataPtr->world = world;
				dataPtr->projection = proj;
				dataPtr->view = view;
			}
				break;
			case eBufferType_Pixel_Camera:
			{
				CameraBufferType* dataPtr = (CameraBufferType*)mappedResource.pData;
				dataPtr->cameraPosition = Application::GetInstance().GetGraphicsDevice()->m_debugCamera->GetPosition();
				dataPtr->padding = 0.0f;
			}
				break;
			case eBufferType_Pixel_Light:
			{
				LightBufferType* dataPtr = (LightBufferType*)mappedResource.pData;
				dataPtr->ambientColour = D3DXVECTOR4(0.15f, 0.15f, 0.15f, 1.0f);
				dataPtr->diffuseColour = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
				dataPtr->specularColour = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f);
				dataPtr->direction = D3DXVECTOR3(0.0f, -1.0f, 0.0f);
				dataPtr->specularPower = 1024.0f;
			}
				break;
			default:
				assert(false && "It's pretty impossible to get here, re-evaluate your life");
				break;
			}

			deviceContext->Unmap((*it).second, 0);
			deviceContext->PSSetConstantBuffers(pixelBufferNum, 1, &(*it).second);
			pixelBufferNum++;
		}
		else
		{
			assert(false && "You dun goofed");
		}
	}

	std::vector<ID3D11ShaderResourceView> texturesToSend;
	for (auto it = m_textures.begin(); it != m_textures.end(); it++)
	{
		if (m_supportedTextures.count((*it).first) > 0)
		{
			ID3D11ShaderResourceView* temp = (*it).second->GetTexture();
			deviceContext->PSSetShaderResources((*it).first, 1, &temp);
		}
	}

	deviceContext->IASetInputLayout(m_layout);
	deviceContext->VSSetShader(m_vertexShader, nullptr, 0);
	deviceContext->PSSetShader(m_pixelShader, nullptr, 0);
	deviceContext->PSSetSamplers(0, 1, &m_sampleState);
}