void BloomFilter::render() { // draw RT1 using bloom shader to RT2 // RT1 = original source // RT2 = bloom ID3D11ShaderResourceView* srv1 = gfx::getRenderTargetSRV(_rt1); gfx::setRenderTarget(_rt2); gfx::clearRenderTarget(_rt2, Color(0, 0, 0)); _quad.render(_bloomShader, srv1); // RT3 - horizontal blur ID3D11ShaderResourceView* srv2 = gfx::getRenderTargetSRV(_rt2); gfx::setRenderTarget(_rt3); gfx::clearRenderTarget(_rt3, Color(0, 0, 0)); _quad.render(_hBlurShader, srv2); // RT2 vertical blur ID3D11ShaderResourceView* srv3 = gfx::getRenderTargetSRV(_rt3); gfx::setRenderTarget(_rt2); gfx::clearRenderTarget(_rt2, Color(0, 0, 0)); _quad.render(_vBlurShader, srv3); // draw RT1 and RT4 using combine shader gfx::restoreBackBuffer(); gfx::beginRendering(Color(0, 0, 0)); BloomSettings settings; settings.intensity = 1.0f; settings.originalIntensity = 0.7f; settings.saturation = 0.8f; settings.originalSaturation = 1.0f; ConstantBuffer* cb = gfx::getConstantBuffer(_blCB); cb->setData(gfx::getDeviceContext(), settings); cb->setPSBuffer(gfx::getDeviceContext(), 0); _quad.render(_combineShader, srv1,srv2); //gfx::drawRenderTarget(_rt2); }
int createConstantBuffer(int elementSize) { // FIXME: elementsize must be multiple of 16!!!! ConstantBuffer* buffer = new ConstantBuffer; buffer->create(ctx->device,elementSize); ctx->constantBuffers.push_back(buffer); return ctx->constantBuffers.size() - 1; }
HRESULT ShaderBase::processLoadedShaderBlob( ID3DBlob *shaderSource ) { HRESULT res = build( shaderSource ); if ( FAILED(res) ) { std::cout << "Error (ShaderBase::processLoadedShaderBlob): Error creating shader" << std::endl; return res; } // setup buffers using the shader reflection ID3D11ShaderReflection *reflector; res = D3DReflect( shaderSource->GetBufferPointer(), shaderSource->GetBufferSize(), IID_ID3D11ShaderReflection, (void**)&reflector ); if ( FAILED( res ) ) { std::cout << "Error (ShaderBase::processLoadedShaderBlob): Error creating shader reflection" << std::endl; return res; } D3D11_SHADER_DESC shaderDesc; ZeroMemory( &shaderDesc, sizeof( D3D11_SHADER_DESC ) ); res = reflector->GetDesc( &shaderDesc ); if ( FAILED( res ) ) { std::cout << "Error (ShaderBase::processLoadedShaderBlob): Error creating shader reflection description" << std::endl; reflector->Release(); return res; } for ( UINT i = 0U; i < shaderDesc.ConstantBuffers; ++i ) { ID3D11ShaderReflectionConstantBuffer *constBuffReflection = reflector->GetConstantBufferByIndex( i ); D3D11_SHADER_BUFFER_DESC shaderBuffDesc; constBuffReflection->GetDesc( &shaderBuffDesc ); //TODO: these can be put on the stack ConstantBuffer *cBuff = new ConstantBuffer( m_dxDev, i, shaderBuffDesc.Name ); cBuff->create( shaderBuffDesc.Size ); for ( UINT j = 0U; j < shaderBuffDesc.Variables; ++j ) { ID3D11ShaderReflectionVariable *variableRefl = constBuffReflection->GetVariableByIndex( j ); D3D11_SHADER_VARIABLE_DESC shaderVarDesc; variableRefl->GetDesc( &shaderVarDesc ); cBuff->addVariableDefinition( shaderVarDesc.Name, shaderVarDesc.StartOffset, shaderVarDesc.Size ); } m_constBuffers.push_back( cBuff ); m_dxConstBuffers.push_back( cBuff->getDxBufferPtr() ); } reflector->Release(); return S_OK; }
bool LightingApp::Init() { if(!D3DApp::Init()) return false; mWaves.Init(160, 160, 1.0f, 0.03f, 3.25f, 0.4f); BuildLandGeometryBuffers(); BuildWaveGeometryBuffers(); BuildFX(); BuildVertexLayout(); mObjectConstantBuffer.Initialize(md3dDevice); mFrameConstantBuffer.Initialize(md3dDevice); return true; }
void ParticleSystemEffectBinder::Init(DeviceDependableFactory * factory) { colorTexture = TexturePtr(true); dataBuffer = factory->CreateConstantBuffer(); ConstantBuffer * b = dataBuffer.Get(); b->InitBuffer(sizeof(ParticleGPUData) * MAX_PARTICLES_IN_SYSTEM); cameraVectorsBuffer = factory->CreateConstantBuffer(); b = cameraVectorsBuffer.Get(); b->InitBuffer(sizeof(CameraVectorsChunck)); camVectorsChunck.padding1 = 0; camVectorsChunck.padding2 = 0; }
void ComputeShader::SetConstantBuffer( int _BufferSlot, ConstantBuffer& _Buffer ) { if ( !Lock() ) return; // Someone else is locking it ! ID3D11Buffer* pBuffer = _Buffer.GetBuffer(); m_Device.DXContext().CSSetConstantBuffers( _BufferSlot, 1, &pBuffer ); Unlock(); }
void AnimatedEntity::Init(ModelHandler model,SkeletonHandler skeleton,ResourceManager * resMgr, DeviceDependableFactory * factory) { EntityBase::Init(model,resMgr, factory); this->skeletonHandler = skeleton; palleteBuffer = factory->CreateConstantBuffer(); ConstantBuffer * buffer = palleteBuffer.Get(); buffer->InitBuffer(sizeof(DirectX::XMFLOAT4X4) * MAX_BONES); currentAnimController = nullptr; DirectX::XMFLOAT4X4 id; DirectX::XMStoreFloat4x4(&id,DirectX::XMMatrixIdentity()); FillBindPosePallete(0,id); EffectMaskUtil::Bind(effectMask,SKINNING); }
bool HillsApp::Init() { if(!D3DApp::Init()) return false; BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); BuildRasterState(); mObjectConstantBuffer.Initialize(md3dDevice); return true; }
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 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)); }
bool ComputeShader::SetConstantBuffer( const char* _pBufferName, ConstantBuffer& _Buffer ) { if ( !Lock() ) return true; // Someone else is locking it ! bool bUsed = false; ID3D11Buffer* pBuffer = _Buffer.GetBuffer(); { int SlotIndex = m_CSConstants.GetConstantBufferIndex( _pBufferName ); if ( SlotIndex != -1 ) m_Device.DXContext().CSSetConstantBuffers( SlotIndex, 1, &pBuffer ); bUsed |= SlotIndex != -1; } Unlock(); return bUsed; }
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); }
void SceneShaderData::Init(DeviceDependableFactory * factory) { cameraPtr = factory->CreateConstantBuffer(); globalAmbiantPtr = factory->CreateConstantBuffer(); illuminationInfoPtr = factory->CreateConstantBuffer(); directionLightsPtr = factory->CreateConstantBuffer(); pointLightsPtr = factory->CreateConstantBuffer(); ConstantBuffer * buffer = cameraPtr.Get(); buffer->InitBuffer(sizeof(CameraData)); buffer = globalAmbiantPtr.Get(); buffer->InitBuffer(sizeof(Vector4)); buffer = illuminationInfoPtr.Get(); buffer->InitBuffer(sizeof(IlluminationInfo)); buffer = directionLightsPtr.Get(); buffer->InitBuffer(sizeof(DLData) * MAX_DIRECTIONAL_LIGHTS); buffer = pointLightsPtr.Get(); buffer->InitBuffer(sizeof(PLData) * MAX_POINT_LIGHTS); }
namespace AppSettings { MSAAModesSetting MSAAMode; FilterTypesSetting ResolveFilterType; FloatSetting ResolveFilterDiameter; FloatSetting GaussianSigma; FloatSetting CubicB; FloatSetting CubicC; BoolSetting UseStandardResolve; BoolSetting InverseLuminanceFiltering; BoolSetting UseExposureFiltering; FloatSetting ExposureFilterOffset; BoolSetting UseGradientMipLevel; BoolSetting CentroidSampling; BoolSetting EnableTemporalAA; FloatSetting TemporalAABlendFactor; BoolSetting UseTemporalColorWeighting; ClampModesSetting NeighborhoodClampMode; FloatSetting VarianceClipGamma; JitterModesSetting JitterMode; FloatSetting JitterScale; FloatSetting LowFreqWeight; FloatSetting HiFreqWeight; FloatSetting SharpeningAmount; DilationModesSetting DilationMode; FloatSetting MipBias; FilterTypesSetting ReprojectionFilter; BoolSetting UseStandardReprojection; ScenesSetting CurrentScene; DirectionSetting LightDirection; ColorSetting LightColor; BoolSetting EnableDirectLighting; BoolSetting EnableAmbientLighting; BoolSetting RenderBackground; BoolSetting EnableShadows; BoolSetting EnableNormalMaps; FloatSetting NormalMapIntensity; FloatSetting DiffuseIntensity; FloatSetting Roughness; FloatSetting SpecularIntensity; OrientationSetting ModelOrientation; FloatSetting ModelRotationSpeed; BoolSetting DoubleSyncInterval; FloatSetting ExposureScale; BoolSetting EnableZoom; FloatSetting BloomExposure; FloatSetting BloomMagnitude; FloatSetting BloomBlurSigma; FloatSetting ManualExposure; ConstantBuffer<AppSettingsCBuffer> CBuffer; void Initialize(ID3D11Device* device) { TwBar* tweakBar = Settings.TweakBar(); MSAAMode.Initialize(tweakBar, "MSAAMode", "Anti Aliasing", "MSAAMode", "", MSAAModes::MSAA4x, 4, MSAAModesLabels); Settings.AddSetting(&MSAAMode); ResolveFilterType.Initialize(tweakBar, "ResolveFilterType", "Anti Aliasing", "Resolve Filter Type", "", FilterTypes::BSpline, 10, FilterTypesLabels); Settings.AddSetting(&ResolveFilterType); ResolveFilterDiameter.Initialize(tweakBar, "ResolveFilterDiameter", "Anti Aliasing", "Resolve Filter Diameter", "", 2.0000f, 0.0000f, 6.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ResolveFilterDiameter); GaussianSigma.Initialize(tweakBar, "GaussianSigma", "Anti Aliasing", "Gaussian Sigma", "", 0.5000f, 0.0100f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&GaussianSigma); CubicB.Initialize(tweakBar, "CubicB", "Anti Aliasing", "Cubic B", "", 0.3300f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&CubicB); CubicC.Initialize(tweakBar, "CubicC", "Anti Aliasing", "Cubic C", "", 0.3300f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&CubicC); UseStandardResolve.Initialize(tweakBar, "UseStandardResolve", "Anti Aliasing", "Use Standard Resolve", "", false); Settings.AddSetting(&UseStandardResolve); InverseLuminanceFiltering.Initialize(tweakBar, "InverseLuminanceFiltering", "Anti Aliasing", "Inverse Luminance Filtering", "", true); Settings.AddSetting(&InverseLuminanceFiltering); UseExposureFiltering.Initialize(tweakBar, "UseExposureFiltering", "Anti Aliasing", "Use Exposure Filtering", "", true); Settings.AddSetting(&UseExposureFiltering); ExposureFilterOffset.Initialize(tweakBar, "ExposureFilterOffset", "Anti Aliasing", "Exposure Filter Offset", "", 2.0000f, -16.0000f, 16.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ExposureFilterOffset); UseGradientMipLevel.Initialize(tweakBar, "UseGradientMipLevel", "Anti Aliasing", "Use Gradient Mip Level", "", false); Settings.AddSetting(&UseGradientMipLevel); CentroidSampling.Initialize(tweakBar, "CentroidSampling", "Anti Aliasing", "Centroid Sampling", "", true); Settings.AddSetting(&CentroidSampling); EnableTemporalAA.Initialize(tweakBar, "EnableTemporalAA", "Anti Aliasing", "Enable Temporal AA", "", true); Settings.AddSetting(&EnableTemporalAA); TemporalAABlendFactor.Initialize(tweakBar, "TemporalAABlendFactor", "Anti Aliasing", "Temporal AABlend Factor", "", 0.9000f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&TemporalAABlendFactor); UseTemporalColorWeighting.Initialize(tweakBar, "UseTemporalColorWeighting", "Anti Aliasing", "Use Temporal Color Weighting", "", false); Settings.AddSetting(&UseTemporalColorWeighting); NeighborhoodClampMode.Initialize(tweakBar, "NeighborhoodClampMode", "Anti Aliasing", "Neighborhood Clamp Mode", "", ClampModes::Variance_Clip, 4, ClampModesLabels); Settings.AddSetting(&NeighborhoodClampMode); VarianceClipGamma.Initialize(tweakBar, "VarianceClipGamma", "Anti Aliasing", "Variance Clip Gamma", "", 1.5000f, 0.0000f, 2.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&VarianceClipGamma); JitterMode.Initialize(tweakBar, "JitterMode", "Anti Aliasing", "Jitter Mode", "", JitterModes::Hammersley4x, 5, JitterModesLabels); Settings.AddSetting(&JitterMode); JitterScale.Initialize(tweakBar, "JitterScale", "Anti Aliasing", "Jitter Scale", "", 1.0000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&JitterScale); LowFreqWeight.Initialize(tweakBar, "LowFreqWeight", "Anti Aliasing", "Low Freq Weight", "", 0.2500f, 0.0000f, 100.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&LowFreqWeight); HiFreqWeight.Initialize(tweakBar, "HiFreqWeight", "Anti Aliasing", "Hi Freq Weight", "", 0.8500f, 0.0000f, 100.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&HiFreqWeight); SharpeningAmount.Initialize(tweakBar, "SharpeningAmount", "Anti Aliasing", "Sharpening Amount", "", 0.0000f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SharpeningAmount); DilationMode.Initialize(tweakBar, "DilationMode", "Anti Aliasing", "Dilation Mode", "", DilationModes::DilateNearestDepth, 3, DilationModesLabels); Settings.AddSetting(&DilationMode); MipBias.Initialize(tweakBar, "MipBias", "Anti Aliasing", "Mip Bias", "", 0.0000f, -340282300000000000000000000000000000000.0000f, 0.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&MipBias); ReprojectionFilter.Initialize(tweakBar, "ReprojectionFilter", "Anti Aliasing", "Reprojection Filter", "", FilterTypes::CatmullRom, 10, FilterTypesLabels); Settings.AddSetting(&ReprojectionFilter); UseStandardReprojection.Initialize(tweakBar, "UseStandardReprojection", "Anti Aliasing", "Use Standard Reprojection", "", false); Settings.AddSetting(&UseStandardReprojection); CurrentScene.Initialize(tweakBar, "CurrentScene", "Scene Controls", "Current Scene", "", Scenes::RoboHand, 5, ScenesLabels); Settings.AddSetting(&CurrentScene); LightDirection.Initialize(tweakBar, "LightDirection", "Scene Controls", "Light Direction", "The direction of the light", Float3(-0.7500f, 0.9770f, -0.4000f)); Settings.AddSetting(&LightDirection); LightColor.Initialize(tweakBar, "LightColor", "Scene Controls", "Light Color", "The color of the light", Float3(20.0000f, 16.0000f, 10.0000f), true, 0.0000f, 20.0000f, 0.1000f, ColorUnit::None); Settings.AddSetting(&LightColor); EnableDirectLighting.Initialize(tweakBar, "EnableDirectLighting", "Scene Controls", "Enable Direct Lighting", "Enables direct lighting", true); Settings.AddSetting(&EnableDirectLighting); EnableAmbientLighting.Initialize(tweakBar, "EnableAmbientLighting", "Scene Controls", "Enable Ambient Lighting", "Enables ambient lighting from the environment", true); Settings.AddSetting(&EnableAmbientLighting); RenderBackground.Initialize(tweakBar, "RenderBackground", "Scene Controls", "Render Background", "", true); Settings.AddSetting(&RenderBackground); EnableShadows.Initialize(tweakBar, "EnableShadows", "Scene Controls", "Enable Shadows", "", true); Settings.AddSetting(&EnableShadows); EnableNormalMaps.Initialize(tweakBar, "EnableNormalMaps", "Scene Controls", "Enable Normal Maps", "", true); Settings.AddSetting(&EnableNormalMaps); NormalMapIntensity.Initialize(tweakBar, "NormalMapIntensity", "Scene Controls", "Normal Map Intensity", "", 1.0000f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&NormalMapIntensity); DiffuseIntensity.Initialize(tweakBar, "DiffuseIntensity", "Scene Controls", "Diffuse Intensity", "Diffuse albedo intensity parameter for the material", 0.5000f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&DiffuseIntensity); Roughness.Initialize(tweakBar, "Roughness", "Scene Controls", "Roughness", "Specular roughness parameter for the material", 0.1000f, 0.0010f, 1.0000f, 0.0010f, ConversionMode::Square, 1.0000f); Settings.AddSetting(&Roughness); SpecularIntensity.Initialize(tweakBar, "SpecularIntensity", "Scene Controls", "Specular Intensity", "Specular intensity parameter for the material", 0.0500f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SpecularIntensity); ModelOrientation.Initialize(tweakBar, "ModelOrientation", "Scene Controls", "Model Orientation", "", Quaternion(0.4100f, -0.5500f, -0.2900f, 0.6700f)); Settings.AddSetting(&ModelOrientation); ModelRotationSpeed.Initialize(tweakBar, "ModelRotationSpeed", "Scene Controls", "Model Rotation Speed", "", 0.0000f, 0.0000f, 10.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ModelRotationSpeed); DoubleSyncInterval.Initialize(tweakBar, "DoubleSyncInterval", "Scene Controls", "Double Sync Interval", "", false); Settings.AddSetting(&DoubleSyncInterval); ExposureScale.Initialize(tweakBar, "ExposureScale", "Scene Controls", "Exposure Scale", "", 0.0000f, -16.0000f, 16.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ExposureScale); EnableZoom.Initialize(tweakBar, "EnableZoom", "Scene Controls", "Enable Zoom", "", false); Settings.AddSetting(&EnableZoom); BloomExposure.Initialize(tweakBar, "BloomExposure", "Post Processing", "Bloom Exposure Offset", "Exposure offset applied to generate the input of the bloom pass", -4.0000f, -10.0000f, 0.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomExposure); BloomMagnitude.Initialize(tweakBar, "BloomMagnitude", "Post Processing", "Bloom Magnitude", "Scale factor applied to the bloom results when combined with tone-mapped result", 1.0000f, 0.0000f, 2.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomMagnitude); BloomBlurSigma.Initialize(tweakBar, "BloomBlurSigma", "Post Processing", "Bloom Blur Sigma", "Sigma parameter of the Gaussian filter used in the bloom pass", 5.0000f, 0.5000f, 5.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomBlurSigma); ManualExposure.Initialize(tweakBar, "ManualExposure", "Post Processing", "Manual Exposure", "Manual exposure value when auto-exposure is disabled", -2.5000f, -10.0000f, 10.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ManualExposure); TwHelper::SetOpened(tweakBar, "Anti Aliasing", true); TwHelper::SetOpened(tweakBar, "Scene Controls", true); TwHelper::SetOpened(tweakBar, "Post Processing", true); CBuffer.Initialize(device); } void Update() { } 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 Initialize(ID3D11Device* device) { TwBar* tweakBar = Settings.TweakBar(); MSAAMode.Initialize(tweakBar, "MSAAMode", "Anti Aliasing", "MSAAMode", "", MSAAModes::MSAA4x, 4, MSAAModesLabels); Settings.AddSetting(&MSAAMode); ResolveFilterType.Initialize(tweakBar, "ResolveFilterType", "Anti Aliasing", "Resolve Filter Type", "", FilterTypes::BSpline, 10, FilterTypesLabels); Settings.AddSetting(&ResolveFilterType); ResolveFilterDiameter.Initialize(tweakBar, "ResolveFilterDiameter", "Anti Aliasing", "Resolve Filter Diameter", "", 2.0000f, 0.0000f, 6.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ResolveFilterDiameter); GaussianSigma.Initialize(tweakBar, "GaussianSigma", "Anti Aliasing", "Gaussian Sigma", "", 0.5000f, 0.0100f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&GaussianSigma); CubicB.Initialize(tweakBar, "CubicB", "Anti Aliasing", "Cubic B", "", 0.3300f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&CubicB); CubicC.Initialize(tweakBar, "CubicC", "Anti Aliasing", "Cubic C", "", 0.3300f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&CubicC); UseStandardResolve.Initialize(tweakBar, "UseStandardResolve", "Anti Aliasing", "Use Standard Resolve", "", false); Settings.AddSetting(&UseStandardResolve); InverseLuminanceFiltering.Initialize(tweakBar, "InverseLuminanceFiltering", "Anti Aliasing", "Inverse Luminance Filtering", "", true); Settings.AddSetting(&InverseLuminanceFiltering); UseExposureFiltering.Initialize(tweakBar, "UseExposureFiltering", "Anti Aliasing", "Use Exposure Filtering", "", true); Settings.AddSetting(&UseExposureFiltering); ExposureFilterOffset.Initialize(tweakBar, "ExposureFilterOffset", "Anti Aliasing", "Exposure Filter Offset", "", 2.0000f, -16.0000f, 16.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ExposureFilterOffset); UseGradientMipLevel.Initialize(tweakBar, "UseGradientMipLevel", "Anti Aliasing", "Use Gradient Mip Level", "", false); Settings.AddSetting(&UseGradientMipLevel); CentroidSampling.Initialize(tweakBar, "CentroidSampling", "Anti Aliasing", "Centroid Sampling", "", true); Settings.AddSetting(&CentroidSampling); EnableTemporalAA.Initialize(tweakBar, "EnableTemporalAA", "Anti Aliasing", "Enable Temporal AA", "", true); Settings.AddSetting(&EnableTemporalAA); TemporalAABlendFactor.Initialize(tweakBar, "TemporalAABlendFactor", "Anti Aliasing", "Temporal AABlend Factor", "", 0.9000f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&TemporalAABlendFactor); UseTemporalColorWeighting.Initialize(tweakBar, "UseTemporalColorWeighting", "Anti Aliasing", "Use Temporal Color Weighting", "", false); Settings.AddSetting(&UseTemporalColorWeighting); NeighborhoodClampMode.Initialize(tweakBar, "NeighborhoodClampMode", "Anti Aliasing", "Neighborhood Clamp Mode", "", ClampModes::Variance_Clip, 4, ClampModesLabels); Settings.AddSetting(&NeighborhoodClampMode); VarianceClipGamma.Initialize(tweakBar, "VarianceClipGamma", "Anti Aliasing", "Variance Clip Gamma", "", 1.5000f, 0.0000f, 2.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&VarianceClipGamma); JitterMode.Initialize(tweakBar, "JitterMode", "Anti Aliasing", "Jitter Mode", "", JitterModes::Hammersley4x, 5, JitterModesLabels); Settings.AddSetting(&JitterMode); JitterScale.Initialize(tweakBar, "JitterScale", "Anti Aliasing", "Jitter Scale", "", 1.0000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&JitterScale); LowFreqWeight.Initialize(tweakBar, "LowFreqWeight", "Anti Aliasing", "Low Freq Weight", "", 0.2500f, 0.0000f, 100.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&LowFreqWeight); HiFreqWeight.Initialize(tweakBar, "HiFreqWeight", "Anti Aliasing", "Hi Freq Weight", "", 0.8500f, 0.0000f, 100.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&HiFreqWeight); SharpeningAmount.Initialize(tweakBar, "SharpeningAmount", "Anti Aliasing", "Sharpening Amount", "", 0.0000f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SharpeningAmount); DilationMode.Initialize(tweakBar, "DilationMode", "Anti Aliasing", "Dilation Mode", "", DilationModes::DilateNearestDepth, 3, DilationModesLabels); Settings.AddSetting(&DilationMode); MipBias.Initialize(tweakBar, "MipBias", "Anti Aliasing", "Mip Bias", "", 0.0000f, -340282300000000000000000000000000000000.0000f, 0.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&MipBias); ReprojectionFilter.Initialize(tweakBar, "ReprojectionFilter", "Anti Aliasing", "Reprojection Filter", "", FilterTypes::CatmullRom, 10, FilterTypesLabels); Settings.AddSetting(&ReprojectionFilter); UseStandardReprojection.Initialize(tweakBar, "UseStandardReprojection", "Anti Aliasing", "Use Standard Reprojection", "", false); Settings.AddSetting(&UseStandardReprojection); CurrentScene.Initialize(tweakBar, "CurrentScene", "Scene Controls", "Current Scene", "", Scenes::RoboHand, 5, ScenesLabels); Settings.AddSetting(&CurrentScene); LightDirection.Initialize(tweakBar, "LightDirection", "Scene Controls", "Light Direction", "The direction of the light", Float3(-0.7500f, 0.9770f, -0.4000f)); Settings.AddSetting(&LightDirection); LightColor.Initialize(tweakBar, "LightColor", "Scene Controls", "Light Color", "The color of the light", Float3(20.0000f, 16.0000f, 10.0000f), true, 0.0000f, 20.0000f, 0.1000f, ColorUnit::None); Settings.AddSetting(&LightColor); EnableDirectLighting.Initialize(tweakBar, "EnableDirectLighting", "Scene Controls", "Enable Direct Lighting", "Enables direct lighting", true); Settings.AddSetting(&EnableDirectLighting); EnableAmbientLighting.Initialize(tweakBar, "EnableAmbientLighting", "Scene Controls", "Enable Ambient Lighting", "Enables ambient lighting from the environment", true); Settings.AddSetting(&EnableAmbientLighting); RenderBackground.Initialize(tweakBar, "RenderBackground", "Scene Controls", "Render Background", "", true); Settings.AddSetting(&RenderBackground); EnableShadows.Initialize(tweakBar, "EnableShadows", "Scene Controls", "Enable Shadows", "", true); Settings.AddSetting(&EnableShadows); EnableNormalMaps.Initialize(tweakBar, "EnableNormalMaps", "Scene Controls", "Enable Normal Maps", "", true); Settings.AddSetting(&EnableNormalMaps); NormalMapIntensity.Initialize(tweakBar, "NormalMapIntensity", "Scene Controls", "Normal Map Intensity", "", 1.0000f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&NormalMapIntensity); DiffuseIntensity.Initialize(tweakBar, "DiffuseIntensity", "Scene Controls", "Diffuse Intensity", "Diffuse albedo intensity parameter for the material", 0.5000f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&DiffuseIntensity); Roughness.Initialize(tweakBar, "Roughness", "Scene Controls", "Roughness", "Specular roughness parameter for the material", 0.1000f, 0.0010f, 1.0000f, 0.0010f, ConversionMode::Square, 1.0000f); Settings.AddSetting(&Roughness); SpecularIntensity.Initialize(tweakBar, "SpecularIntensity", "Scene Controls", "Specular Intensity", "Specular intensity parameter for the material", 0.0500f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SpecularIntensity); ModelOrientation.Initialize(tweakBar, "ModelOrientation", "Scene Controls", "Model Orientation", "", Quaternion(0.4100f, -0.5500f, -0.2900f, 0.6700f)); Settings.AddSetting(&ModelOrientation); ModelRotationSpeed.Initialize(tweakBar, "ModelRotationSpeed", "Scene Controls", "Model Rotation Speed", "", 0.0000f, 0.0000f, 10.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ModelRotationSpeed); DoubleSyncInterval.Initialize(tweakBar, "DoubleSyncInterval", "Scene Controls", "Double Sync Interval", "", false); Settings.AddSetting(&DoubleSyncInterval); ExposureScale.Initialize(tweakBar, "ExposureScale", "Scene Controls", "Exposure Scale", "", 0.0000f, -16.0000f, 16.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ExposureScale); EnableZoom.Initialize(tweakBar, "EnableZoom", "Scene Controls", "Enable Zoom", "", false); Settings.AddSetting(&EnableZoom); BloomExposure.Initialize(tweakBar, "BloomExposure", "Post Processing", "Bloom Exposure Offset", "Exposure offset applied to generate the input of the bloom pass", -4.0000f, -10.0000f, 0.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomExposure); BloomMagnitude.Initialize(tweakBar, "BloomMagnitude", "Post Processing", "Bloom Magnitude", "Scale factor applied to the bloom results when combined with tone-mapped result", 1.0000f, 0.0000f, 2.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomMagnitude); BloomBlurSigma.Initialize(tweakBar, "BloomBlurSigma", "Post Processing", "Bloom Blur Sigma", "Sigma parameter of the Gaussian filter used in the bloom pass", 5.0000f, 0.5000f, 5.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomBlurSigma); ManualExposure.Initialize(tweakBar, "ManualExposure", "Post Processing", "Manual Exposure", "Manual exposure value when auto-exposure is disabled", -2.5000f, -10.0000f, 10.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ManualExposure); TwHelper::SetOpened(tweakBar, "Anti Aliasing", true); TwHelper::SetOpened(tweakBar, "Scene Controls", true); TwHelper::SetOpened(tweakBar, "Post Processing", true); CBuffer.Initialize(device); }
AEResult BuildCBFPRLights(GraphicDevice* graphicDevice, ConstantBuffer** cb) { AEAssert(graphicDevice != nullptr); if (graphicDevice == nullptr) { return AEResult::GraphicDeviceNull; } AEAssert(cb != nullptr); if (cb == nullptr) { return AEResult::NullParameter; } AEResult ret = AEResult::Ok; uint32_t offset = 0; ///////////////////////////////////////////////////// //Create Constant Buffer _AE_CB_FPR_LightCulling // // cbuffer _AE_CB_FPR_Lights : register(b0) // { // float3 _AE_CameraPos : packoffset(c0); // uint _AE_WindowWidth : packoffset(c0.w); // }; // /**************************************************************************** *Constant Buffer: _AE_CB_HalfPixel ****************************************************************************/ ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_FPR_LIGHTS_NAME); /************************************** *Add Var 1: _AE_CameraPos ***************************************/ ShaderCustomVariable* scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_CAMERA_POS_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 3; scv->m_Rows = 1; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::vec3); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::vec3); scv->m_ShaderVariableClass = ShaderVariableClass::Vector; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 2: _AE_WindowWidth ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_WINDOW_WIDTH_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 1; scv->m_Rows = 1; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(uint32_t); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(uint32_t); scv->m_ShaderVariableClass = ShaderVariableClass::Scalar; scv->m_ShaderVariableType = ShaderVariableType::UInt; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Initialize ***************************************/ ret = tempCB->Initialize(); if (ret != AEResult::Ok) { DeleteMem(cb); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Finish ***************************************/ *cb = tempCB; return AEResult::Ok; }
AEResult GameLightsUpdate::ShadowLightRenderGameObject(GameObject* gameObject, const glm::mat4& lightView, const glm::mat4& lightProj) { AEAssert(gameObject != nullptr); if (gameObject == nullptr) { return AEResult::NullParameter; } if (gameObject->HasMeshGOC() && gameObject->HasMaterialGOCs()) { Mesh* mesh = gameObject->GetMeshGOC()->GetMeshResource(); if (mesh != nullptr) { ConstantBuffer* cb = nullptr; Material* mat = nullptr; bool hasAnimation = gameObject->HasMeshAnimationGOC(); if (hasAnimation) { mat = m_VarianceSkinningShadowMaterial; ShaderProperties* vsProps = m_VarianceSkinningShadowMaterial->GetVSProps(); cb = vsProps->GetConstantBuffer(AE_CB_WORLD_VIEW_PROJ_NAME); ConstantBuffer* cbBones = vsProps->GetConstantBuffer(AE_CB_BONES_NAME); if (cbBones != nullptr) { AnimationPlayer* player = gameObject->GetMeshAnimationGOC()->GetAnimationPlayer(); cbBones->SetValue(AE_CB_BONE_TRANSFORMS_VAR_NAME, player->GetBoneTransforms(), sizeof(glm::mat4) * AE_MAX_BONES); } } else { mat = m_VarianceShadowMaterial; ShaderProperties* vsProps = m_VarianceShadowMaterial->GetVSProps(); cb = vsProps->GetConstantBuffer(AE_CB_WORLD_VIEW_PROJ_NAME); } cb->SetValueT<glm::mat4>(AE_CB_WORLD_VAR_NAME, gameObject->GetWorldTransform()); cb->SetValueT<glm::mat4>(AE_CB_VIEW_VAR_NAME, lightView); cb->SetValueT<glm::mat4>(AE_CB_PROJECTION_VAR_NAME, lightProj); AETODO("check return"); mat->Apply(); for (uint32_t i = 0; i < mesh->GetNumberMeshParts(); i++) { MeshPart* meshPart = mesh->GetMeshPart(i); m_GraphicDevice->SetVertexBuffer(meshPart->GetVertexBuffer()); m_GraphicDevice->SetIndexBuffer(meshPart->GetIndexBuffer()); m_GraphicDevice->SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_GraphicDevice->DrawIndexed(0, 0, meshPart->GetIndexBuffer()->GetSize()); } AETODO("check return"); mat->UnApply(); } } for (auto goIt : *gameObject) { ShadowLightRenderGameObject(goIt.second, lightView, lightProj); } return AEResult::Ok; }
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)); }
AEResult BuildCBBones(GraphicDevice* graphicDevice, ConstantBuffer** cb) { AEAssert(graphicDevice != nullptr); if (graphicDevice == nullptr) { return AEResult::GraphicDeviceNull; } AEAssert(cb != nullptr); if (cb == nullptr) { return AEResult::NullParameter; } AEResult ret = AEResult::Ok; uint32_t offset = 0; ///////////////////////////////////////////////////// //Create Constant Buffer _AE_CB_Bones // // cbuffer _AE_CB_Bones : register(b1) // { // matrix _AE_BoneTransforms[MAX_BONES] : packoffset(c0); // }; // /**************************************************************************** *Constant Buffer: _AE_CB_Bones ****************************************************************************/ ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 1, AE_CB_BONES_NAME); /************************************** *Add Var 1: _AE_World ***************************************/ ShaderCustomVariable* scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_BONE_TRANSFORMS_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 4; scv->m_Rows = 4; scv->m_Elements = AE_MAX_BONES; scv->m_IsArray = true; scv->m_ElementSize = sizeof(glm::mat4); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::mat4) * AE_MAX_BONES; scv->m_ShaderVariableClass = ShaderVariableClass::Matrix; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Initialize ***************************************/ ret = tempCB->Initialize(); if (ret != AEResult::Ok) { DeleteMem(cb); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Finish ***************************************/ *cb = tempCB; return AEResult::Ok; }
inline void SetConstant(ShaderStage stage, uint32 slot, const ConstantBuffer<Type>& buffer) { SetConstant(stage, slot, buffer.base(), buffer.getPtr(), sizeof(Type) / sizeof(__m128)); }
AEResult BuildCBHalfPixel(GraphicDevice* graphicDevice, ConstantBuffer** cb) { AEAssert(graphicDevice != nullptr); if (graphicDevice == nullptr) { return AEResult::GraphicDeviceNull; } AEAssert(cb != nullptr); if (cb == nullptr) { return AEResult::NullParameter; } AEResult ret = AEResult::Ok; uint32_t offset = 0; ///////////////////////////////////////////////////// //Create Constant Buffer _AE_CB_HalfPixel // // cbuffer _AE_CB_HalfPixel : register(b0) // { // float2 _AE_HalfPixel : packoffset(c0); // }; // /**************************************************************************** *Constant Buffer: _AE_CB_HalfPixel ****************************************************************************/ ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_HALF_PIXEL_NAME); /************************************** *Add Var 1: _AE_HalfPixel ***************************************/ ShaderCustomVariable* scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_HALF_PIXEL_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 2; scv->m_Rows = 1; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::vec2); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::vec2); scv->m_ShaderVariableClass = ShaderVariableClass::Vector; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Initialize ***************************************/ ret = tempCB->Initialize(); if (ret != AEResult::Ok) { DeleteMem(cb); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Finish ***************************************/ *cb = tempCB; return AEResult::Ok; }
AEResult BuildCBFPRLightCulling(GraphicDevice* graphicDevice, ConstantBuffer** cb) { AEAssert(graphicDevice != nullptr); if (graphicDevice == nullptr) { return AEResult::GraphicDeviceNull; } AEAssert(cb != nullptr); if (cb == nullptr) { return AEResult::NullParameter; } AEResult ret = AEResult::Ok; uint32_t offset = 0; ///////////////////////////////////////////////////// //Create Constant Buffer _AE_CB_FPR_LightCulling // // cbuffer _AE_CB_FPR_LightCulling : register(b0) // { // matrix _AE_View : packoffset(c0); // matrix _AE_InvProjection : packoffset(c4); // // uint _AE_WindowHeight : packoffset(c8.x); // uint _AE_WindowWidth : packoffset(c8.y); // uint _AE_NumLights : packoffset(c8.z); // }; // /**************************************************************************** *Constant Buffer: _AE_CB_FPR_LightCulling ****************************************************************************/ ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_FPR_LIGHT_CULLING_NAME); /************************************** *Add Var 1: _AE_View ***************************************/ ShaderCustomVariable* scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_VIEW_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 4; scv->m_Rows = 4; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::mat4); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::mat4); scv->m_ShaderVariableClass = ShaderVariableClass::Matrix; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 2: _AE_InvProjection ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_INV_PROJECTION_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 4; scv->m_Rows = 4; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::mat4); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::mat4); scv->m_ShaderVariableClass = ShaderVariableClass::Matrix; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 3: _AE_WindowHeight ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_WINDOW_HEIGHT_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 1; scv->m_Rows = 1; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(uint32_t); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(uint32_t); scv->m_ShaderVariableClass = ShaderVariableClass::Scalar; scv->m_ShaderVariableType = ShaderVariableType::UInt; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 4: _AE_WindowWidth ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_WINDOW_WIDTH_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 1; scv->m_Rows = 1; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(uint32_t); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(uint32_t); scv->m_ShaderVariableClass = ShaderVariableClass::Scalar; scv->m_ShaderVariableType = ShaderVariableType::UInt; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 5: _AE_NumLights ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_NUM_LIGHTS_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 1; scv->m_Rows = 1; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(uint32_t); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(uint32_t); scv->m_ShaderVariableClass = ShaderVariableClass::Scalar; scv->m_ShaderVariableType = ShaderVariableType::UInt; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Initialize ***************************************/ ret = tempCB->Initialize(); if (ret != AEResult::Ok) { DeleteMem(cb); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Finish ***************************************/ *cb = tempCB; return AEResult::Ok; }
AEResult BuildCBWVP(GraphicDevice* graphicDevice, ConstantBuffer** cb) { AEAssert(graphicDevice != nullptr); if (graphicDevice == nullptr) { return AEResult::GraphicDeviceNull; } AEAssert(cb != nullptr); if (cb == nullptr) { return AEResult::NullParameter; } AEResult ret = AEResult::Ok; uint32_t offset = 0; ///////////////////////////////////////////////////// //Create Constant Buffer _AE_CB_World_View_Proj // // cbuffer _AE_CB_World_View_Proj : register(b0) // { // matrix _AE_World : packoffset(c0); // matrix _AE_View : packoffset(c4); // matrix _AE_PROJection : packoffset(c8); // }; // /**************************************************************************** *Constant Buffer: _AE_CB_World_View_Proj ****************************************************************************/ ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_WORLD_VIEW_PROJ_NAME); /************************************** *Add Var 1: _AE_World ***************************************/ ShaderCustomVariable* scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_WORLD_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 4; scv->m_Rows = 4; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::mat4); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::mat4); scv->m_ShaderVariableClass = ShaderVariableClass::Matrix; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 2: _AE_View ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_VIEW_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 4; scv->m_Rows = 4; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::mat4); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::mat4); scv->m_ShaderVariableClass = ShaderVariableClass::Matrix; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Add Var 3: _AE_PROJection ***************************************/ scv = new ShaderCustomVariable(); scv->m_Name = AE_CB_PROJECTION_VAR_NAME; scv->m_StartOffset = offset; scv->m_Columns = 4; scv->m_Rows = 4; scv->m_Elements = 0; scv->m_IsArray = false; scv->m_ElementSize = sizeof(glm::mat4); scv->m_Offset = 0; scv->m_UserVariable = false; scv->m_Size = sizeof(glm::mat4); scv->m_ShaderVariableClass = ShaderVariableClass::Matrix; scv->m_ShaderVariableType = ShaderVariableType::Float; ret = tempCB->AddVariable(scv); offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size); if (ret != AEResult::Ok) { DeleteMem(tempCB); DeleteMem(scv); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Initialize ***************************************/ ret = tempCB->Initialize(); if (ret != AEResult::Ok) { DeleteMem(tempCB); return AEResult::ConstantBufferInitFailed; } /************************************** *Constant Buffer Finish ***************************************/ *cb = tempCB; return AEResult::Ok; }
void Initialize(ID3D11Device* device) { TwBar* tweakBar = Settings.TweakBar(); EnableSun.Initialize(tweakBar, "EnableSun", "Sun Light", "Enable Sun", "Enables the sun light", true); Settings.AddSetting(&EnableSun); SunAreaLightApproximation.Initialize(tweakBar, "SunAreaLightApproximation", "Sun Light", "Sun Area Light Approximation", "Controls whether the sun is treated as a disc area light in the real-time shader", true); Settings.AddSetting(&SunAreaLightApproximation); SunTintColor.Initialize(tweakBar, "SunTintColor", "Sun Light", "Sun Tint Color", "The color of the sun", Float3(1.0000f, 1.0000f, 1.0000f), false, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ColorUnit::None); Settings.AddSetting(&SunTintColor); SunIntensityScale.Initialize(tweakBar, "SunIntensityScale", "Sun Light", "Sun Intensity Scale", "Scale the intensity of the sun", 1.0000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunIntensityScale); SunSize.Initialize(tweakBar, "SunSize", "Sun Light", "Sun Size", "Angular radius of the sun in degrees", 0.2700f, 0.0100f, 340282300000000000000000000000000000000.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunSize); NormalizeSunIntensity.Initialize(tweakBar, "NormalizeSunIntensity", "Sun Light", "Normalize Sun Intensity", "", false); Settings.AddSetting(&NormalizeSunIntensity); SunDirType.Initialize(tweakBar, "SunDirType", "Sun Light", "Sun Dir Type", "Input direction type for the sun", SunDirectionTypes::UnitVector, 2, SunDirectionTypesLabels); Settings.AddSetting(&SunDirType); SunDirection.Initialize(tweakBar, "SunDirection", "Sun Light", "Sun Direction", "Director of the sun", Float3(-0.7500f, 0.9770f, -0.4000f)); Settings.AddSetting(&SunDirection); SunAzimuth.Initialize(tweakBar, "SunAzimuth", "Sun Light", "Sun Azimuth", "Angle around the horizon", 0.0000f, 0.0000f, 360.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunAzimuth); SunElevation.Initialize(tweakBar, "SunElevation", "Sun Light", "Sun Elevation", "Elevation of sun from ground. 0 degrees is aligned on the horizon while 90 degrees is directly overhead", 0.0000f, 0.0000f, 90.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SunElevation); Turbidity.Initialize(tweakBar, "Turbidity", "Sky", "Turbidity", "Atmospheric turbidity (thickness) uses for procedural sun and sky model", 2.0000f, 1.0000f, 10.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&Turbidity); GroundAlbedo.Initialize(tweakBar, "GroundAlbedo", "Sky", "Ground Albedo", "Ground albedo color used for procedural sun and sky model", Float3(0.5000f, 0.5000f, 0.5000f), false, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ColorUnit::None); Settings.AddSetting(&GroundAlbedo); MSAAMode.Initialize(tweakBar, "MSAAMode", "Anti Aliasing", "MSAAMode", "MSAA mode to use for full-resolution rendering", MSAAModes::MSAANone, 2, MSAAModesLabels); Settings.AddSetting(&MSAAMode); FilterSize.Initialize(tweakBar, "FilterSize", "Anti Aliasing", "Filter Size", "Filter radius for MSAA resolve", 2.0000f, 0.0000f, 6.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&FilterSize); EnableAlbedoMaps.Initialize(tweakBar, "EnableAlbedoMaps", "Scene", "Enable Albedo Maps", "Enables albedo maps", true); Settings.AddSetting(&EnableAlbedoMaps); EnableNormalMaps.Initialize(tweakBar, "EnableNormalMaps", "Scene", "Enable Normal Maps", "Enables normal maps", true); Settings.AddSetting(&EnableNormalMaps); NormalMapIntensity.Initialize(tweakBar, "NormalMapIntensity", "Scene", "Normal Map Intensity", "Intensity of the normal map", 0.5000f, 0.0000f, 1.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&NormalMapIntensity); DiffuseIntensity.Initialize(tweakBar, "DiffuseIntensity", "Scene", "Diffuse Intensity", "Diffuse albedo intensity parameter for the material", 0.7500f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&DiffuseIntensity); Roughness.Initialize(tweakBar, "Roughness", "Scene", "Specular Roughness", "Specular roughness parameter for the material", 0.2500f, 0.0010f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&Roughness); SpecularIntensity.Initialize(tweakBar, "SpecularIntensity", "Scene", "Specular Intensity", "Specular intensity parameter for the material", 0.0400f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&SpecularIntensity); NumParticles.Initialize(tweakBar, "NumParticles", "Particles", "Num Particles (x1024)", "The number of particles to render, in increments of 1024", 8, 0, 32); Settings.AddSetting(&NumParticles); EmitRadius.Initialize(tweakBar, "EmitRadius", "Particles", "Emit Radius", "The radius in which to emit particles", 2.0000f, 0.0100f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitRadius); EmitCenterX.Initialize(tweakBar, "EmitCenterX", "Particles", "Emit Center X", "The X coordinate of the point from which to emit particles", 0.0000f, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitCenterX); EmitCenterY.Initialize(tweakBar, "EmitCenterY", "Particles", "Emit Center Y", "The Y coordinate of the point from which to emit particles", 2.5000f, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitCenterY); EmitCenterZ.Initialize(tweakBar, "EmitCenterZ", "Particles", "Emit Center Z", "The Z coordinate of the point from which to emit particles", 0.0000f, -340282300000000000000000000000000000000.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&EmitCenterZ); RotationSpeed.Initialize(tweakBar, "RotationSpeed", "Particles", "Rotation Speed", "Controls how fast to rotate the particles around the emitter center", 0.5000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&RotationSpeed); AbsorptionScale.Initialize(tweakBar, "AbsorptionScale", "Particles", "Absorption Scale", "Scaled the absorption coefficient used for particle self-shadowing", 1.0000f, 0.0000f, 340282300000000000000000000000000000000.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&AbsorptionScale); SortParticles.Initialize(tweakBar, "SortParticles", "Particles", "Sort Particles", "Enables sorting each particle by their depth", true); Settings.AddSetting(&SortParticles); EnableParticleAlbedoMap.Initialize(tweakBar, "EnableParticleAlbedoMap", "Particles", "Enable Particle Albedo Map", "Enables or disables sampling an albedo map in the particle pixel shader", true); Settings.AddSetting(&EnableParticleAlbedoMap); BillboardParticles.Initialize(tweakBar, "BillboardParticles", "Particles", "Billboard Particles", "Enables or disabled billboarding of particles towards the camera", true); Settings.AddSetting(&BillboardParticles); RenderLowRes.Initialize(tweakBar, "RenderLowRes", "Particles", "Render Low-Res", "Renders the particles at half resolution", true); Settings.AddSetting(&RenderLowRes); LowResRenderMode.Initialize(tweakBar, "LowResRenderMode", "Particles", "Low-Res Render Mode", "Specifies the technique to use for upscaling particles from half resolution", LowResRenderModes::MSAA, 2, LowResRenderModesLabels); Settings.AddSetting(&LowResRenderMode); ResolveSubPixelThreshold.Initialize(tweakBar, "ResolveSubPixelThreshold", "Particles", "Resolve Sub-Pixel Threshold", "Threshold used during low-resolution resolve for determining pixels containing sub-pixel edges", 0.0250f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&ResolveSubPixelThreshold); CompositeSubPixelThreshold.Initialize(tweakBar, "CompositeSubPixelThreshold", "Particles", "Composite Sub-Pixel Threshold", "Threshold used during low-resolution composite for determining pixels containing sub-pixel edges", 0.1000f, 0.0000f, 1.0000f, 0.0010f, ConversionMode::None, 1.0000f); Settings.AddSetting(&CompositeSubPixelThreshold); ProgrammableSamplePoints.Initialize(tweakBar, "ProgrammableSamplePoints", "Particles", "Programmable Sample Points", "Use programmable sample positions when rendering low-resolution particles with 'MSAA' mode", true); Settings.AddSetting(&ProgrammableSamplePoints); ProgrammableSamplePoints.SetVisible(false); NearestDepthThreshold.Initialize(tweakBar, "NearestDepthThreshold", "Particles", "Nearest-Depth Threshold", "Depth threshold to use for nearest-depth upsampling", 0.2500f, 0.0000f, 100.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&NearestDepthThreshold); BloomExposure.Initialize(tweakBar, "BloomExposure", "Post Processing", "Bloom Exposure Offset", "Exposure offset applied to generate the input of the bloom pass", -4.0000f, -10.0000f, 0.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomExposure); BloomMagnitude.Initialize(tweakBar, "BloomMagnitude", "Post Processing", "Bloom Magnitude", "Scale factor applied to the bloom results when combined with tone-mapped result", 1.0000f, 0.0000f, 2.0000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomMagnitude); BloomBlurSigma.Initialize(tweakBar, "BloomBlurSigma", "Post Processing", "Bloom Blur Sigma", "Sigma parameter of the Gaussian filter used in the bloom pass", 2.5000f, 0.5000f, 2.5000f, 0.0100f, ConversionMode::None, 1.0000f); Settings.AddSetting(&BloomBlurSigma); EnableVSync.Initialize(tweakBar, "EnableVSync", "Debug", "Enable VSync", "Enables or disables vertical sync during Present", true); Settings.AddSetting(&EnableVSync); TakeScreenshot.Initialize(tweakBar, "TakeScreenshot", "Debug", "Take Screenshot", "Captures the screen output (before HUD rendering), and saves it to a file"); Settings.AddSetting(&TakeScreenshot); ShowMSAAEdges.Initialize(tweakBar, "ShowMSAAEdges", "Debug", "Show MSAAEdges", "When using MSAA low-res render mode, shows pixels that use subpixel data", false); Settings.AddSetting(&ShowMSAAEdges); TwHelper::SetOpened(tweakBar, "Sun Light", false); TwHelper::SetOpened(tweakBar, "Sky", false); TwHelper::SetOpened(tweakBar, "Anti Aliasing", false); TwHelper::SetOpened(tweakBar, "Scene", false); TwHelper::SetOpened(tweakBar, "Particles", true); TwHelper::SetOpened(tweakBar, "Post Processing", false); TwHelper::SetOpened(tweakBar, "Debug", true); CBuffer.Initialize(device); }