diff --git a/resource/NewVegasReloaded.dll.defaults.toml b/resource/NewVegasReloaded.dll.defaults.toml index bf124a2a..ddd99d2f 100644 --- a/resource/NewVegasReloaded.dll.defaults.toml +++ b/resource/NewVegasReloaded.dll.defaults.toml @@ -568,97 +568,95 @@ VerticalScale = 1.6 # Multiplier for the length of the drops/st [_Shaders.Precipitations.Status] Enabled = true # Rain effect that is blocked by objects above and refracts light. -[_Shaders.ShadowsExteriors.Far] -Activators = false # Wether to include objects with "Activator" flag when rendering ps. -Actors = true # Wether to include objects with "Actors" flag when rendering shadowmaps. -AlphaEnabled = true # Wether to take into account alpha of objects when rendering shadowmaps. -Apparatus = false # Wether to include objects with "Apparatus" flag when rendering shadowmaps. -Books = false # Wether to include objects with "Books" flag when rendering shadowmaps. -Containers = true # Wether to include objects with "Containers" flag when rendering shadowmaps. -Doors = true # Wether to include objects with "Doors" flag when rendering shadowmaps. -Furniture = true # Wether to include objects with "Furniture" flag when rendering shadowmaps. -Lod = false # Wether to include objects with "Lod" flag when rendering shadowmaps. -MinRadius = 10.0 # Wether to include objects with a radius of less than x pixels on the screen in the shadowmaps. -Misc = true # Wether to include objects with misc flags when rendering shadowmaps. -Statics = true # Wether to include objects with "Statics" flag when rendering shadowmaps. -Terrain = true # Wether to include Terrain when rendering shadowmaps. -Trees = true # Wether to include Trees when rendering shadowmaps. - -[_Shaders.ShadowsExteriors.Lod] -Activators = false # Wether to include objects with "Activator" flag when rendering shadowmaps. -Actors = false # Wether to include objects with "Actors" flag when rendering shadowmaps. -AlphaEnabled = false # Wether to take into account alpha of objects when rendering shadowmaps. -Apparatus = false # Wether to include objects with "Apparatus" flag when rendering shadowmaps. -Books = false # Wether to include objects with "Books" flag when rendering shadowmaps. -Containers = false # Wether to include objects with "Containers" flag when rendering shadowmaps. -Doors = true # Wether to include objects with "Doors" flag when rendering shadowmaps. -Furniture = false # Wether to include objects with "Furniture" flag when rendering shadowmaps. -Lod = false # Wether to include objects with "Lod" flag when rendering shadowmaps. -MinRadius = 100.0 # Wether to include objects with a radius of less than x pixels on the screen in the shadowmaps. -Misc = false # Wether to include objects with misc flags when rendering shadowmaps. -Statics = true # Wether to include objects with "Statics" flag when rendering shadowmaps. -Terrain = true # Wether to include Terrain when rendering shadowmaps. -Trees = true # Wether to include Trees when rendering shadowmaps. - [_Shaders.ShadowsExteriors.Main] -PostProcess = true # Wether to render shadows as a post process effect. Currently the only supported mode. -Darkness = 0.75 # Darkness of shadows. +Quality = 4 # Quality preset - 0: Low, 1: Medium, 2: High, 3: Full, 4: Custom Enabled = true # Enable sun shadows using rendered shadow maps. +Darkness = 0.75 # Darkness of shadows. NightMinDarkness = 0.35 # Darkness of shadows during dark moon phase. Set to 0 to disable shadows completely when there is no moon. -Quality = 2 # Not used. OrthoMapResolution = 1024 # Resolution of the texture used to store the ortho map. OrthoRadius = 8000 # Max distance for rendering of ortho map. -UsePointShadowsDay = false # Wether to cast shadows from point lights. Requires a slight darkening of the entire screen. -UsePointShadowsNight = true # Wether to cast shadows from point lights during Nights. Requires a slight darkening of the entire screen. - -[_Shaders.ShadowsExteriors.Middle] -Activators = false # Wether to include objects with "Activator" flag when rendering shadowmaps. -Actors = true # Wether to include objects with "Actors" flag when rendering shadowmaps. -AlphaEnabled = true # Wether to take into account alpha of objects when rendering shadowmaps. -Apparatus = false # Wether to include objects with "Apparatus" flag when rendering shadowmaps. -Books = false # Wether to include objects with "Books" flag when rendering shadowmaps. -Containers = true # Wether to include objects with "Containers" flag when rendering shadowmaps. -Doors = true # Wether to include objects with "Doors" flag when rendering shadowmaps. -Furniture = true # Wether to include objects with "Furniture" flag when rendering shadowmaps. -Lod = false # Wether to include objects with "Lod" flag when rendering shadowmaps. -MinRadius = 10.0 # Wether to include objects with a radius of less than x pixels on the screen in the shadowmaps. -Misc = true # Wether to include objects with misc flags when rendering shadowmaps. -Statics = true # Wether to include objects with "Statics" flag when rendering shadowmaps. -Terrain = true # Wether to include Terrain when rendering shadowmaps. -Trees = true # Wether to include Trees when rendering shadowmaps. - -[_Shaders.ShadowsExteriors.Near] -Activators = false # Wether to include objects with "Activator" flag when rendering shadowmaps. -Actors = true # Wether to include objects with "Actors" flag when rendering shadowmaps. -AlphaEnabled = true # Wether to take into account alpha of objects when rendering shadowmaps. -Apparatus = false # Wether to include objects with "Apparatus" flag when rendering shadowmaps. -Books = false # Wether to include objects with "Books" flag when rendering shadowmaps. -Containers = true # Wether to include objects with "Containers" flag when rendering shadowmaps. -Doors = true # Wether to include objects with "Doors" flag when rendering shadowmaps. -Furniture = true # Wether to include objects with "Furniture" flag when rendering shadowmaps. -Lod = false # Wether to include objects with "Lod" flag when rendering shadowmaps. -MinRadius = 10.0 # Wether to include objects with a radius of less than x pixels on the screen in the shadowmaps. -Misc = true # Wether to include objects with misc flags when rendering shadowmaps. -Statics = true # Wether to include objects with "Statics" flag when rendering shadowmaps. -Terrain = true # Wether to include Terrain when rendering shadowmaps. -Trees = true # Wether to include Trees when rendering shadowmaps. - - -[_Shaders.ShadowsExteriors.Ortho] -Activators = false # Wether to include objects with "Activator" flag when rendering ortho map. -Actors = false # Wether to include objects with "Actors" flag when rendering ortho map. -AlphaEnabled = false # Wether to take into account alpha of objects when rendering ortho map. -Apparatus = false # Wether to include objects with "Apparatus" flag when rendering ortho map. -Books = false # Wether to include objects with "Books" flag when rendering ortho map. -Containers = false # Wether to include objects with "Containers" flag when rendering ortho map. -Doors = false # Wether to include objects with "Doors" flag when rendering ortho map. -Furniture = false # Wether to include objects with "Furniture" flag when rendering ortho map. -Lod = false # Wether to include objects with "Lod" flag when rendering ortho map. -MinRadius = 100.0 # Wether to include objects with a radius of less than x pixels on the screen in the ortho map. -Misc = false # Wether to include objects with misc flags when rendering ortho map. -Statics = true # Wether to include objects with "Statics" flag when rendering ortho map. -Terrain = true # Wether to include Terrain when rendering ortho map. -Trees = true # Wether to include Trees when rendering ortho map. +UsePointShadowsDay = false # Whether to cast shadows from point lights. Requires a slight darkening of the entire screen. +UsePointShadowsNight = false # Whether to cast shadows from point lights during Nights. Requires a slight darkening of the entire screen. + +[_Shaders.ShadowsExteriors.FormsNear] +Activators = true # Whether to include objects with "Activator" flag when rendering shadowmaps. +Actors = true # Whether to include objects with "Actors" flag when rendering shadowmaps. +AlphaEnabled = true # Whether to take into account alpha of objects when rendering shadowmaps. +Apparatus = false # Whether to include objects with "Apparatus" flag when rendering shadowmaps. +Books = false # Whether to include objects with "Books" flag when rendering shadowmaps. +Containers = true # Whether to include objects with "Containers" flag when rendering shadowmaps. +Doors = true # Whether to include objects with "Doors" flag when rendering shadowmaps. +Furniture = true # Whether to include objects with "Furniture" flag when rendering shadowmaps. +Lod = false # Whether to include objects with "Lod" flag when rendering shadowmaps. +MinRadius = 1.0 # Whether to include objects with a radius of less than x pixels on the screen in the shadowmaps. +Misc = true # Whether to include objects with misc flags when rendering shadowmaps. +Statics = true # Whether to include objects with "Statics" flag when rendering shadowmaps. +Terrain = true # Whether to include Terrain when rendering shadowmaps. +Trees = true # Whether to include Trees when rendering shadowmaps. + +[_Shaders.ShadowsExteriors.FormsMiddle] +Activators = true # Whether to include objects with "Activator" flag when rendering shadowmaps. +Actors = true # Whether to include objects with "Actors" flag when rendering shadowmaps. +AlphaEnabled = true # Whether to take into account alpha of objects when rendering shadowmaps. +Apparatus = false # Whether to include objects with "Apparatus" flag when rendering shadowmaps. +Books = false # Whether to include objects with "Books" flag when rendering shadowmaps. +Containers = true # Whether to include objects with "Containers" flag when rendering shadowmaps. +Doors = true # Whether to include objects with "Doors" flag when rendering shadowmaps. +Furniture = true # Whether to include objects with "Furniture" flag when rendering shadowmaps. +Lod = false # Whether to include objects with "Lod" flag when rendering shadowmaps. +MinRadius = 1.0 # Whether to include objects with a radius of less than x pixels on the screen in the shadowmaps. +Misc = true # Whether to include objects with misc flags when rendering shadowmaps. +Statics = true # Whether to include objects with "Statics" flag when rendering shadowmaps. +Terrain = true # Whether to include Terrain when rendering shadowmaps. +Trees = true # Whether to include Trees when rendering shadowmaps. + +[_Shaders.ShadowsExteriors.FormsFar] +Activators = true # Whether to include objects with "Activator" flag when rendering shadowmaps. +Actors = true # Whether to include objects with "Actors" flag when rendering shadowmaps. +AlphaEnabled = true # Whether to take into account alpha of objects when rendering shadowmaps. +Apparatus = false # Whether to include objects with "Apparatus" flag when rendering shadowmaps. +Books = false # Whether to include objects with "Books" flag when rendering shadowmaps. +Containers = true # Whether to include objects with "Containers" flag when rendering shadowmaps. +Doors = true # Whether to include objects with "Doors" flag when rendering shadowmaps. +Furniture = true # Whether to include objects with "Furniture" flag when rendering shadowmaps. +Lod = true # Whether to include objects with "Lod" flag when rendering shadowmaps. +MinRadius = 10.0 # Whether to include objects with a radius of less than x pixels on the screen in the shadowmaps. +Misc = true # Whether to include objects with misc flags when rendering shadowmaps. +Statics = true # Whether to include objects with "Statics" flag when rendering shadowmaps. +Terrain = true # Whether to include Terrain when rendering shadowmaps. +Trees = true # Whether to include Trees when rendering shadowmaps. + +[_Shaders.ShadowsExteriors.FormsLod] +Activators = false # Whether to include objects with "Activator" flag when rendering shadowmaps. +Actors = false # Whether to include objects with "Actors" flag when rendering shadowmaps. +AlphaEnabled = true # Whether to take into account alpha of objects when rendering shadowmaps. +Apparatus = false # Whether to include objects with "Apparatus" flag when rendering shadowmaps. +Books = false # Whether to include objects with "Books" flag when rendering shadowmaps. +Containers = false # Whether to include objects with "Containers" flag when rendering shadowmaps. +Doors = true # Whether to include objects with "Doors" flag when rendering shadowmaps. +Furniture = false # Whether to include objects with "Furniture" flag when rendering shadowmaps. +Lod = true # Whether to include objects with "Lod" flag when rendering shadowmaps. +MinRadius = 100.0 # Whether to include objects with a radius of less than x pixels on the screen in the shadowmaps. +Misc = false # Whether to include objects with misc flags when rendering shadowmaps. +Statics = true # Whether to include objects with "Statics" flag when rendering shadowmaps. +Terrain = true # Whether to include Terrain when rendering shadowmaps. +Trees = true # Whether to include Trees when rendering shadowmaps. + +[_Shaders.ShadowsExteriors.FormsOrtho] +Activators = false # Whether to include objects with "Activator" flag when rendering ortho map. +Actors = false # Whether to include objects with "Actors" flag when rendering ortho map. +AlphaEnabled = false # Whether to take into account alpha of objects when rendering ortho map. +Apparatus = false # Whether to include objects with "Apparatus" flag when rendering ortho map. +Books = false # Whether to include objects with "Books" flag when rendering ortho map. +Containers = false # Whether to include objects with "Containers" flag when rendering ortho map. +Doors = false # Whether to include objects with "Doors" flag when rendering ortho map. +Furniture = false # Whether to include objects with "Furniture" flag when rendering ortho map. +Lod = false # Whether to include objects with "Lod" flag when rendering ortho map. +MinRadius = 1.0 # Whether to include objects with a radius of less than x pixels on the screen in the ortho map. +Misc = true # Whether to include objects with misc flags when rendering ortho map. +Statics = true # Whether to include objects with "Statics" flag when rendering ortho map. +Terrain = true # Whether to include Terrain when rendering ortho map. +Trees = true # Whether to include Trees when rendering ortho map. [_Shaders.ShadowsExteriors.ScreenSpace] BlurRadius = 5.0 # Blur strength for denoising screenspace shadows @@ -679,7 +677,6 @@ LimitFrequency = false # Limit the update frequency of the furthest cascade Enabled = true # Post process sun and pointlights shadows in exteriors. [_Shaders.ShadowsInteriors.Main] -PostProcess = true # Wether to render shadows as a post process effect. Currently the only supported mode. UseCastShadowFlag = false # Objects without the cast shadow flag will not be rendered to the shadow maps Activators = true # Wether to include objects with "Activator" flag when rendering shadowmaps. Actors = true # Wether to include objects with "Actors" flag when rendering shadowmaps. diff --git a/src/core/ShadowManager.cpp b/src/core/ShadowManager.cpp index 1876813c..2f3a599a 100644 --- a/src/core/ShadowManager.cpp +++ b/src/core/ShadowManager.cpp @@ -101,8 +101,6 @@ NiNode* ShadowManager::GetRefNode(TESObjectREFR* Ref, ShadowsExteriorEffect::For default: break; } - // disabled for now since it's an obscure functionality - //if (ExcludedForms->size() > 0 && std::binary_search(ExcludedForms->begin(), ExcludedForms->end(), Form->refID)) return NULL; ExtraRefractionProperty* RefractionExtraProperty = (ExtraRefractionProperty*)Ref->extraDataList.GetExtraData(BSExtraData::ExtraDataType::kExtraData_RefractionProperty); float Refraction = RefractionExtraProperty ? (1 - RefractionExtraProperty->refractionAmount) : 0.0f; diff --git a/src/effects/ShadowsExterior.cpp b/src/effects/ShadowsExterior.cpp index a5a0bc6a..095923dc 100644 --- a/src/effects/ShadowsExterior.cpp +++ b/src/effects/ShadowsExterior.cpp @@ -50,57 +50,82 @@ void ShadowsExteriorEffect::UpdateConstants() { } } -void ShadowsExteriorEffect::UpdateSettings() { - - Constants.ScreenSpaceData.x = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ScreenSpace", "Enabled") && Enabled; - Constants.ScreenSpaceData.y = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ScreenSpace", "BlurRadius"); - Constants.ScreenSpaceData.z = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ScreenSpace", "RenderDistance"); - Constants.ScreenSpaceData.w = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ScreenSpace", "Darkness"); - - // Generic exterior shadows settings - Settings.Exteriors.Enabled = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "Enabled"); - Settings.Exteriors.Quality = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "Quality"); - Settings.Exteriors.Darkness = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.Main", "Darkness"); - Settings.Exteriors.NightMinDarkness = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.Main", "NightMinDarkness"); - Settings.Exteriors.OrthoRadius = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.Main", "OrthoRadius"); - Settings.Exteriors.OrthoMapResolution = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "OrthoMapResolution"); - Settings.Exteriors.ShadowMode = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "ShadowMode"); - Settings.Exteriors.UsePointShadowsDay = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "UsePointShadowsDay"); - Settings.Exteriors.UsePointShadowsNight = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "UsePointShadowsNight"); - - // Shadow maps specific configuration. - Settings.ShadowMaps.Distance = std::clamp(TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ShadowMaps", "Distance"), 0.001f, 1.0f); - Settings.ShadowMaps.CascadeLambda = std::clamp(TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ShadowMaps", "CascadeLambda"), 0.0f, 1.0f); - Settings.ShadowMaps.LimitFrequency = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "LimitFrequency"); - +bool ShadowsExteriorEffect::UpdateSettingsFromQuality(int quality) { bool cascadeSettingsChanged = false; - + int oldCascadeResolution = Settings.ShadowMaps.CascadeResolution; - Settings.ShadowMaps.CascadeResolution = (std::clamp(TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "CascadeResolution"), 0, 2) + 2) * 512; - - if (oldCascadeResolution != 0 && oldCascadeResolution != Settings.ShadowMaps.CascadeResolution) - cascadeSettingsChanged = true; - bool oldMSAA = Settings.ShadowMaps.MSAA; - Settings.ShadowMaps.MSAA = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "MSAA"); - - if (oldMSAA != Settings.ShadowMaps.MSAA) - cascadeSettingsChanged = true; - - // Mipmaps and anisotropy are disabled due to deferred shadows - derivatives are messed up and causing artifacts. - // https://aras-p.info/blog/2010/01/07/screenspace-vs-mip-mapping/ - /*bool oldMips = Settings.ShadowMaps.Mipmaps; - Settings.ShadowMaps.Mipmaps = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "Mipmaps"); - - if (oldMips != Settings.ShadowMaps.Mipmaps) - cascadeSettingsChanged = true; - - Settings.ShadowMaps.Anisotropy = (std::clamp(TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "Anisotropy"), 0, 2)) * 8;*/ - - Settings.ShadowMaps.Prefilter = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "Prefilter"); + + // Custom settings. + if (quality < 0 || quality > 3) { + Settings.ShadowMaps.Distance = std::clamp(TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ShadowMaps", "Distance"), 0.001f, 1.0f); + Settings.ShadowMaps.CascadeLambda = std::clamp(TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ShadowMaps", "CascadeLambda"), 0.0f, 1.0f); + Settings.ShadowMaps.LimitFrequency = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "LimitFrequency"); + + Settings.ShadowMaps.CascadeResolution = (std::clamp(TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "CascadeResolution"), 0, 2) + 2) * 512; + + if (oldCascadeResolution != 0 && oldCascadeResolution != Settings.ShadowMaps.CascadeResolution) + cascadeSettingsChanged = true; + + Settings.ShadowMaps.MSAA = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "MSAA"); + + if (oldMSAA != Settings.ShadowMaps.MSAA) + cascadeSettingsChanged = true; + + // Mipmaps and anisotropy are disabled due to deferred shadows - derivatives are messed up and causing artifacts. + // https://aras-p.info/blog/2010/01/07/screenspace-vs-mip-mapping/ + /*bool oldMips = Settings.ShadowMaps.Mipmaps; + Settings.ShadowMaps.Mipmaps = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "Mipmaps"); + + if (oldMips != Settings.ShadowMaps.Mipmaps) + cascadeSettingsChanged = true; + + Settings.ShadowMaps.Anisotropy = (std::clamp(TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "Anisotropy"), 0, 2)) * 8;*/ + + Settings.ShadowMaps.Prefilter = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ShadowMaps", "Prefilter"); + + for (int shadowType = 0; shadowType <= MapOrtho; shadowType++) { + char sectionName[256] = "Shaders.ShadowsExteriors.Forms"; + switch (shadowType) { + case MapNear: + strcat(sectionName, "Near"); + break; + case MapMiddle: + strcat(sectionName, "Middle"); + break; + case MapFar: + strcat(sectionName, "Far"); + break; + case MapLod: + strcat(sectionName, "Lod"); + break; + case MapOrtho: + strcat(sectionName, "Ortho"); + break; + } + ShadowMapSettings* ShadowMap = &ShadowMaps[shadowType]; + + ShadowMap->Forms.AlphaEnabled = TheSettingManager->GetSettingI(sectionName, "AlphaEnabled"); + ShadowMap->Forms.Activators = TheSettingManager->GetSettingI(sectionName, "Activators"); + ShadowMap->Forms.Actors = TheSettingManager->GetSettingI(sectionName, "Actors"); + ShadowMap->Forms.Apparatus = TheSettingManager->GetSettingI(sectionName, "Apparatus"); + ShadowMap->Forms.Books = TheSettingManager->GetSettingI(sectionName, "Books"); + ShadowMap->Forms.Containers = TheSettingManager->GetSettingI(sectionName, "Containers"); + ShadowMap->Forms.Doors = TheSettingManager->GetSettingI(sectionName, "Doors"); + ShadowMap->Forms.Furniture = TheSettingManager->GetSettingI(sectionName, "Furniture"); + ShadowMap->Forms.Misc = TheSettingManager->GetSettingI(sectionName, "Misc"); + ShadowMap->Forms.Statics = TheSettingManager->GetSettingI(sectionName, "Statics"); + ShadowMap->Forms.Terrain = TheSettingManager->GetSettingI(sectionName, "Terrain"); + ShadowMap->Forms.Trees = TheSettingManager->GetSettingI(sectionName, "Trees"); + ShadowMap->Forms.Lod = TheSettingManager->GetSettingI(sectionName, "Lod"); + ShadowMap->Forms.MinRadius = TheSettingManager->GetSettingI(sectionName, "MinRadius"); + }; + return cascadeSettingsChanged; + } + for (int shadowType = 0; shadowType <= MapOrtho; shadowType++) { - char sectionName[256] = "Shaders.ShadowsExteriors."; + char sectionName[256] = "Shaders.ShadowsExteriors.Forms"; switch (shadowType) { case MapNear: strcat(sectionName, "Near"); @@ -120,24 +145,76 @@ void ShadowsExteriorEffect::UpdateSettings() { } ShadowMapSettings* ShadowMap = &ShadowMaps[shadowType]; - ShadowMap->Forms.AlphaEnabled = TheSettingManager->GetSettingI(sectionName, "AlphaEnabled"); - ShadowMap->Forms.Activators = TheSettingManager->GetSettingI(sectionName, "Activators"); - ShadowMap->Forms.Actors = TheSettingManager->GetSettingI(sectionName, "Actors"); - ShadowMap->Forms.Apparatus = TheSettingManager->GetSettingI(sectionName, "Apparatus"); - ShadowMap->Forms.Books = TheSettingManager->GetSettingI(sectionName, "Books"); - ShadowMap->Forms.Containers = TheSettingManager->GetSettingI(sectionName, "Containers"); - ShadowMap->Forms.Doors = TheSettingManager->GetSettingI(sectionName, "Doors"); - ShadowMap->Forms.Furniture = TheSettingManager->GetSettingI(sectionName, "Furniture"); - ShadowMap->Forms.Misc = TheSettingManager->GetSettingI(sectionName, "Misc"); - ShadowMap->Forms.Statics = TheSettingManager->GetSettingI(sectionName, "Statics"); - ShadowMap->Forms.Terrain = TheSettingManager->GetSettingI(sectionName, "Terrain"); - ShadowMap->Forms.Trees = TheSettingManager->GetSettingI(sectionName, "Trees"); - ShadowMap->Forms.Lod = TheSettingManager->GetSettingI(sectionName, "Lod"); - ShadowMap->Forms.MinRadius = TheSettingManager->GetSettingI(sectionName, "MinRadius"); + ShadowMap->Forms.AlphaEnabled = shadowType == MapOrtho ? 0 : 1; + ShadowMap->Forms.Activators = shadowType < MapLod ? 1 : 0; + ShadowMap->Forms.Actors = shadowType < MapLod ? 1 : 0; + ShadowMap->Forms.Apparatus = 0; + ShadowMap->Forms.Books = shadowType < MapFar ? 1 : 0; + ShadowMap->Forms.Containers = shadowType < MapLod ? 1 : 0; + ShadowMap->Forms.Doors = shadowType == MapOrtho ? 0 : 1; + ShadowMap->Forms.Furniture = shadowType < MapLod ? 1 : 0; + ShadowMap->Forms.Misc = 1; + ShadowMap->Forms.Statics = 1; + ShadowMap->Forms.Terrain = 1; + ShadowMap->Forms.Trees = 1; + ShadowMap->Forms.Lod = shadowType < MapFar || quality < 2 ? 0 : 1; + ShadowMap->Forms.MinRadius = MapFar <= shadowType <= MapLod ? 10.0f : 1.0f; }; - // get the list of excluded formIDs - TheSettingManager->GetFormList("Shaders.ShadowsExteriors.ExcludedFormID", &Settings.Exteriors.ExcludedForms); + Settings.ShadowMaps.CascadeLambda = 0.9f; + Settings.ShadowMaps.LimitFrequency = 1; + Settings.ShadowMaps.MSAA = 1; + Settings.ShadowMaps.Prefilter = 1; + + switch (quality) { + case 0: + Settings.ShadowMaps.Distance = 0.01f; + Settings.ShadowMaps.CascadeResolution = 1024; + Settings.ShadowMaps.MSAA = 0; + break; + case 1: + Settings.ShadowMaps.Distance = 0.01f; + Settings.ShadowMaps.CascadeResolution = 1024; + break; + case 2: + Settings.ShadowMaps.Distance = 0.015f; + Settings.ShadowMaps.CascadeResolution = 2048; + break; + case 3: + Settings.ShadowMaps.Distance = 0.02f; + Settings.ShadowMaps.CascadeResolution = 2048; + break; + } + + if (oldCascadeResolution != 0 && oldCascadeResolution != Settings.ShadowMaps.CascadeResolution) + cascadeSettingsChanged = true; + + if (oldMSAA != Settings.ShadowMaps.MSAA) + cascadeSettingsChanged = true; + + return cascadeSettingsChanged; +} + +void ShadowsExteriorEffect::UpdateSettings() { + + Constants.ScreenSpaceData.x = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.ScreenSpace", "Enabled") && Enabled; + Constants.ScreenSpaceData.y = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ScreenSpace", "BlurRadius"); + Constants.ScreenSpaceData.z = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ScreenSpace", "RenderDistance"); + Constants.ScreenSpaceData.w = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.ScreenSpace", "Darkness"); + + // Generic exterior shadows settings + Settings.Exteriors.Enabled = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "Enabled"); + Settings.Exteriors.Quality = std::clamp(TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "Quality"), 0, 4); + Settings.Exteriors.Darkness = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.Main", "Darkness"); + Settings.Exteriors.NightMinDarkness = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.Main", "NightMinDarkness"); + Settings.Exteriors.OrthoRadius = TheSettingManager->GetSettingF("Shaders.ShadowsExteriors.Main", "OrthoRadius"); + Settings.Exteriors.OrthoMapResolution = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "OrthoMapResolution"); + Settings.Exteriors.ShadowMode = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "ShadowMode"); + Settings.Exteriors.UsePointShadowsDay = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "UsePointShadowsDay"); + Settings.Exteriors.UsePointShadowsNight = TheSettingManager->GetSettingI("Shaders.ShadowsExteriors.Main", "UsePointShadowsNight"); + + // Shadow maps specific configuration. + bool cascadeSettingsChanged = UpdateSettingsFromQuality(Settings.Exteriors.Quality); Settings.Interiors.Enabled = TheSettingManager->GetSettingI("Shaders.ShadowsInteriors.Main", "Enabled"); Settings.Interiors.Forms.AlphaEnabled = TheSettingManager->GetSettingI("Shaders.ShadowsInteriors.Main", "AlphaEnabled"); @@ -162,8 +239,6 @@ void ShadowsExteriorEffect::UpdateSettings() { Settings.Interiors.PlayerShadowFirstPerson = TheSettingManager->GetSettingF("Shaders.ShadowsInteriors.Main", "PlayerShadowFirstPerson"); Settings.Interiors.PlayerShadowThirdPerson = TheSettingManager->GetSettingF("Shaders.ShadowsInteriors.Main", "PlayerShadowThirdPerson"); - TheSettingManager->GetFormList("Shaders.ShadowsInteriors.ExcludedFormID", &Settings.Interiors.ExcludedForms); - bool isExterior = TheShaderManager->GameState.isExterior; // if the effect was turned off the buffer must be cleared diff --git a/src/effects/ShadowsExterior.h b/src/effects/ShadowsExterior.h index 151e399e..82ac0846 100644 --- a/src/effects/ShadowsExterior.h +++ b/src/effects/ShadowsExterior.h @@ -41,8 +41,6 @@ class ShadowsExteriorEffect : public EffectRecord D3DXVECTOR4 ShadowMapRadius; }; - typedef std::vector ExcludedFormsList; - // Settings struct FormsStruct { bool AlphaEnabled; @@ -94,7 +92,6 @@ class ShadowsExteriorEffect : public EffectRecord UInt8 ShadowMode; bool UsePointShadowsDay; bool UsePointShadowsNight; - ExcludedFormsList ExcludedForms; }; struct InteriorsStruct { @@ -108,7 +105,6 @@ class ShadowsExteriorEffect : public EffectRecord float Darkness; float LightRadiusMult; bool UseCastShadowFlag; - ExcludedFormsList ExcludedForms; bool PlayerShadowThirdPerson; bool PlayerShadowFirstPerson; }; @@ -167,4 +163,6 @@ class ShadowsExteriorEffect : public EffectRecord private: bool texturesInitialized; + + bool UpdateSettingsFromQuality(int quality); };