Example #1
0
    void UpdateCBuffer(ID3D11DeviceContext* context)
    {
        CBuffer.Data.MSAAMode = MSAAMode;
        CBuffer.Data.ResolveFilterType = ResolveFilterType;
        CBuffer.Data.ResolveFilterDiameter = ResolveFilterDiameter;
        CBuffer.Data.GaussianSigma = GaussianSigma;
        CBuffer.Data.CubicB = CubicB;
        CBuffer.Data.CubicC = CubicC;
        CBuffer.Data.UseStandardResolve = UseStandardResolve;
        CBuffer.Data.InverseLuminanceFiltering = InverseLuminanceFiltering;
        CBuffer.Data.UseExposureFiltering = UseExposureFiltering;
        CBuffer.Data.ExposureFilterOffset = ExposureFilterOffset;
        CBuffer.Data.UseGradientMipLevel = UseGradientMipLevel;
        CBuffer.Data.EnableTemporalAA = EnableTemporalAA;
        CBuffer.Data.TemporalAABlendFactor = TemporalAABlendFactor;
        CBuffer.Data.UseTemporalColorWeighting = UseTemporalColorWeighting;
        CBuffer.Data.NeighborhoodClampMode = NeighborhoodClampMode;
        CBuffer.Data.VarianceClipGamma = VarianceClipGamma;
        CBuffer.Data.LowFreqWeight = LowFreqWeight;
        CBuffer.Data.HiFreqWeight = HiFreqWeight;
        CBuffer.Data.SharpeningAmount = SharpeningAmount;
        CBuffer.Data.DilationMode = DilationMode;
        CBuffer.Data.MipBias = MipBias;
        CBuffer.Data.ReprojectionFilter = ReprojectionFilter;
        CBuffer.Data.UseStandardReprojection = UseStandardReprojection;
        CBuffer.Data.CurrentScene = CurrentScene;
        CBuffer.Data.LightDirection = LightDirection;
        CBuffer.Data.LightColor = LightColor;
        CBuffer.Data.EnableDirectLighting = EnableDirectLighting;
        CBuffer.Data.EnableAmbientLighting = EnableAmbientLighting;
        CBuffer.Data.RenderBackground = RenderBackground;
        CBuffer.Data.EnableShadows = EnableShadows;
        CBuffer.Data.EnableNormalMaps = EnableNormalMaps;
        CBuffer.Data.NormalMapIntensity = NormalMapIntensity;
        CBuffer.Data.DiffuseIntensity = DiffuseIntensity;
        CBuffer.Data.Roughness = Roughness;
        CBuffer.Data.SpecularIntensity = SpecularIntensity;
        CBuffer.Data.ModelOrientation = ModelOrientation;
        CBuffer.Data.ModelRotationSpeed = ModelRotationSpeed;
        CBuffer.Data.DoubleSyncInterval = DoubleSyncInterval;
        CBuffer.Data.ExposureScale = ExposureScale;
        CBuffer.Data.EnableZoom = EnableZoom;
        CBuffer.Data.BloomExposure = BloomExposure;
        CBuffer.Data.BloomMagnitude = BloomMagnitude;
        CBuffer.Data.BloomBlurSigma = BloomBlurSigma;
        CBuffer.Data.ManualExposure = ManualExposure;

        CBuffer.ApplyChanges(context);
        CBuffer.SetVS(context, 7);
        CBuffer.SetHS(context, 7);
        CBuffer.SetDS(context, 7);
        CBuffer.SetGS(context, 7);
        CBuffer.SetPS(context, 7);
        CBuffer.SetCS(context, 7);
    }
    void UpdateCBuffer(ID3D11DeviceContext* context)
    {
        CBuffer.Data.EnableSun = EnableSun;
        CBuffer.Data.SunAreaLightApproximation = SunAreaLightApproximation;
        CBuffer.Data.SunTintColor = SunTintColor;
        CBuffer.Data.SunIntensityScale = SunIntensityScale;
        CBuffer.Data.SunSize = SunSize;
        CBuffer.Data.SunDirType = SunDirType;
        CBuffer.Data.SunDirection = SunDirection;
        CBuffer.Data.SunAzimuth = SunAzimuth;
        CBuffer.Data.SunElevation = SunElevation;
        CBuffer.Data.MSAAMode = MSAAMode;
        CBuffer.Data.FilterSize = FilterSize;
        CBuffer.Data.EnableAlbedoMaps = EnableAlbedoMaps;
        CBuffer.Data.EnableNormalMaps = EnableNormalMaps;
        CBuffer.Data.NormalMapIntensity = NormalMapIntensity;
        CBuffer.Data.DiffuseIntensity = DiffuseIntensity;
        CBuffer.Data.Roughness = Roughness;
        CBuffer.Data.SpecularIntensity = SpecularIntensity;
        CBuffer.Data.NumParticles = NumParticles;
        CBuffer.Data.EmitRadius = EmitRadius;
        CBuffer.Data.EmitCenterX = EmitCenterX;
        CBuffer.Data.EmitCenterY = EmitCenterY;
        CBuffer.Data.EmitCenterZ = EmitCenterZ;
        CBuffer.Data.AbsorptionScale = AbsorptionScale;
        CBuffer.Data.EnableParticleAlbedoMap = EnableParticleAlbedoMap;
        CBuffer.Data.BillboardParticles = BillboardParticles;
        CBuffer.Data.RenderLowRes = RenderLowRes;
        CBuffer.Data.LowResRenderMode = LowResRenderMode;
        CBuffer.Data.ResolveSubPixelThreshold = ResolveSubPixelThreshold;
        CBuffer.Data.CompositeSubPixelThreshold = CompositeSubPixelThreshold;
        CBuffer.Data.NearestDepthThreshold = NearestDepthThreshold;
        CBuffer.Data.BloomExposure = BloomExposure;
        CBuffer.Data.BloomMagnitude = BloomMagnitude;
        CBuffer.Data.BloomBlurSigma = BloomBlurSigma;
        CBuffer.Data.ShowMSAAEdges = ShowMSAAEdges;

        CBuffer.ApplyChanges(context);
        CBuffer.SetVS(context, 7);
        CBuffer.SetHS(context, 7);
        CBuffer.SetDS(context, 7);
        CBuffer.SetGS(context, 7);
        CBuffer.SetPS(context, 7);
        CBuffer.SetCS(context, 7);
    }
Example #3
0
void HillsApp::DrawScene()
{
	md3dImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&Colors::LightSteelBlue));
	md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0);

	md3dImmediateContext->IASetInputLayout(mInputLayout);
    md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	md3dImmediateContext->PSSetShader(mPixelShader, NULL, 0);
	md3dImmediateContext->VSSetShader(mVertexShader, NULL, 0);
 
	UINT stride = sizeof(Vertex);
    UINT offset = 0;
    md3dImmediateContext->IASetVertexBuffers(0, 1, &mVB, &stride, &offset);
	md3dImmediateContext->IASetIndexBuffer(mIB, DXGI_FORMAT_R32_UINT, 0);

	// Set constants
	
	XMMATRIX view  = XMLoadFloat4x4(&mView);
	XMMATRIX proj  = XMLoadFloat4x4(&mProj);
	XMMATRIX world = XMLoadFloat4x4(&mGridWorld);
	XMMATRIX worldViewProj = XMMatrixTranspose(world*view*proj);


	cbPerObject mPerObjectCB;


	XMStoreFloat4x4(&mPerObjectCB.mWorldViewProj, worldViewProj);
	mObjectConstantBuffer.Data = mPerObjectCB;
	mObjectConstantBuffer.ApplyChanges(md3dImmediateContext);

	auto buffer = mObjectConstantBuffer.Buffer();
	md3dImmediateContext->VSSetConstantBuffers(0, 1, &buffer);

	// Set raster state
	md3dImmediateContext->RSSetState(mRasterState);

	// Draw
	md3dImmediateContext->DrawIndexed(mGridIndexCount, 0, 0);
	HR(mSwapChain->Present(0, 0));
}
Example #4
0
void LightingApp::DrawScene()
{
	md3dImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&Colors::LightSteelBlue));
	md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

	md3dImmediateContext->IASetInputLayout(mInputLayout);
	md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	md3dImmediateContext->PSSetShader(mPixelShader, NULL, 0);
	md3dImmediateContext->VSSetShader(mVertexShader, NULL, 0);

	UINT stride = sizeof(Vertex);
	UINT offset = 0;

	XMMATRIX view = XMLoadFloat4x4(&mView);
	XMMATRIX proj = XMLoadFloat4x4(&mProj);
	XMMATRIX viewProj = view*proj;

	// Set per frame constants.
	mFrameConstantBuffer.Data.mDirLight = mDirLight;
	mFrameConstantBuffer.Data.mPointLight = mPointLight;
	mFrameConstantBuffer.Data.mSpotLight = mSpotLight;
	mFrameConstantBuffer.Data.mEyePosW = mEyePosW;

	//
	// Draw the hills.
	//
	md3dImmediateContext->IASetVertexBuffers(0, 1, &mLandVB, &stride, &offset);
	md3dImmediateContext->IASetIndexBuffer(mLandIB, DXGI_FORMAT_R32_UINT, 0);

	// Set per object constants.
	XMMATRIX world = XMLoadFloat4x4(&mLandWorld);
	XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world);
	XMMATRIX worldViewProj = XMMatrixTranspose(world*view*proj);

	mObjectConstantBuffer.Data.mWorld = mLandWorld;
	XMStoreFloat4x4(&mObjectConstantBuffer.Data.mWorldInvTranspose, worldInvTranspose);
	XMStoreFloat4x4(&mObjectConstantBuffer.Data.mWorldViewProj, worldViewProj);
	mObjectConstantBuffer.Data.mMaterial = mLandMat;

	mObjectConstantBuffer.ApplyChanges(md3dImmediateContext);
	mFrameConstantBuffer.ApplyChanges(md3dImmediateContext);

	ID3D11Buffer* buffer[2] = { mObjectConstantBuffer.Buffer(), mFrameConstantBuffer.Buffer() };
	md3dImmediateContext->VSSetConstantBuffers(0, 1, &buffer[0]);
	md3dImmediateContext->PSSetConstantBuffers(0, 2, buffer);


	md3dImmediateContext->DrawIndexed(mLandIndexCount, 0, 0);

	//
	// Draw the waves.
	//
	md3dImmediateContext->IASetVertexBuffers(0, 1, &mWavesVB, &stride, &offset);
	md3dImmediateContext->IASetIndexBuffer(mWavesIB, DXGI_FORMAT_R32_UINT, 0);

	// Set per object constants.
	world = XMLoadFloat4x4(&mWavesWorld);
	worldInvTranspose = MathHelper::InverseTranspose(world);
	worldViewProj = XMMatrixTranspose(world*view*proj);

	mObjectConstantBuffer.Data.mWorld = mWavesWorld;
	XMStoreFloat4x4(&mObjectConstantBuffer.Data.mWorldInvTranspose, worldInvTranspose);
	XMStoreFloat4x4(&mObjectConstantBuffer.Data.mWorldViewProj, worldViewProj);
	mObjectConstantBuffer.Data.mMaterial = mWavesMat;

	mObjectConstantBuffer.ApplyChanges(md3dImmediateContext);
	mFrameConstantBuffer.ApplyChanges(md3dImmediateContext);

	md3dImmediateContext->VSSetConstantBuffers(0, 1, &buffer[0]);
	md3dImmediateContext->PSSetConstantBuffers(0, 2, buffer);

	md3dImmediateContext->DrawIndexed(3 * mWaves.TriangleCount(), 0, 0);


	HR(mSwapChain->Present(0, 0));
}