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; }
bool HillsApp::Init() { if(!D3DApp::Init()) return false; BuildGeometryBuffers(); BuildFX(); BuildVertexLayout(); BuildRasterState(); mObjectConstantBuffer.Initialize(md3dDevice); return true; }
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 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 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 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; }
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; }
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); }