Esempio n. 1
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);
    }
Esempio n. 2
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);
    }
Esempio n. 3
0
	void VRender() override
	{
		float color[4] = { 0.5f, 1.0f, 1.0f, 1.0f };

		// Set up the input assembler
		mRenderer->VSetInputLayout(mVertexShader);
		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_TRIANGLE);

		mRenderer->VSetContextTargetWithDepth();
		mRenderer->VClearContext(color, 1.0f, 0);

		mRenderer->VSetVertexShader(mVertexShader);
		mRenderer->VSetPixelShader(mPixelShader);

		mRenderer->VUpdateShaderConstantBuffer(mShaderResource, &mMatrixBuffer, 0);
		mRenderer->VSetVertexShaderConstantBuffers(mShaderResource);

		mRenderer->VBindMesh(mCubeMesh);

		mRenderer->VDrawIndexed(0, mCubeMesh->GetIndexCount());
		mRenderer->VSwapBuffers();
	}
Esempio n. 4
0
	void VRender() override
	{
		float color[4] = { 0.2f, 0.2f, 0.2f, 1.0f };

		// Set up the input assembler
		mDeviceContext->IASetInputLayout(mInputLayout);
		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_TRIANGLE);

		mDeviceContext->RSSetViewports(1, &mRenderer->GetViewport());
		mDeviceContext->OMSetRenderTargets(1, mRenderer->GetRenderTargetView(), mRenderer->GetDepthStencilView());
		mDeviceContext->ClearRenderTargetView(*mRenderer->GetRenderTargetView(), color);
		mDeviceContext->ClearDepthStencilView(
		mRenderer->GetDepthStencilView(),
			D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL,
			1.0f,
			0);

		mDeviceContext->VSSetShader(mVertexShader, NULL, 0);
		mDeviceContext->PSSetShader(mPixelShader, NULL, 0);

		mDeviceContext->UpdateSubresource(
			mConstantBuffer,
			0,
			NULL,
			&mMatrixBuffer,
			0,
			0); 

		mDeviceContext->VSSetConstantBuffers(
			0,
			1,
			&mConstantBuffer);

		// Bezier
		mDeviceContext->UpdateSubresource(static_cast<DX11Mesh*>(mBezierMesh)->mVertexBuffer, 0, NULL, &mBezierVertices, 0, 0);

		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_LINE);
		mRenderer->VBindMesh(mBezierMesh);
		mRenderer->VDrawIndexed(0, mBezierMesh->GetIndexCount());

		// Handles
		mDeviceContext->UpdateSubresource(static_cast<DX11Mesh*>(mHandlesMesh)->mVertexBuffer, 0, NULL, &mHandlesVertices, 0, 0);

		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_LINE);
		mRenderer->VBindMesh(mHandlesMesh);
		mRenderer->VDrawIndexed(0, mHandlesMesh->GetIndexCount());

		// Circles
		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_TRIANGLE);
		for (size_t i = 0; i < 4; i++)
		{
			mMatrixBuffer.mWorld = (mat4f::scale(mCircleScale) * mat4f::translate(mBezier.p[i])).transpose();
			mDeviceContext->UpdateSubresource(mConstantBuffer, 0, NULL, &mMatrixBuffer, 0, 0);

			mRenderer->VBindMesh(mCircleMesh);
			mRenderer->VDrawIndexed(0, mCircleMesh->GetIndexCount());
		}


		mRenderer->VSwapBuffers();
	}