Skip to content

Commit

Permalink
Merge pull request doodlum#4 from FlayaN/TruePBR-PR
Browse files Browse the repository at this point in the history
refactor: move TruePBR to it's own feature
  • Loading branch information
Jonahex authored Jul 26, 2024
2 parents 055d835 + df2fc68 commit a24313c
Show file tree
Hide file tree
Showing 12 changed files with 1,638 additions and 1,578 deletions.
4 changes: 3 additions & 1 deletion src/FeatureBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Features/TerrainOcclusion.h"
#include "Features/WetnessEffects.h"

#include "TruePBR.h"

template <class... Ts>
std::pair<unsigned char*, size_t> _GetFeatureBufferData(Ts... feat_datas)
{
Expand All @@ -34,5 +36,5 @@ std::pair<unsigned char*, size_t> GetFeatureBufferData()
WetnessEffects::GetSingleton()->GetCommonBufferData(),
LightLimitFix::GetSingleton()->GetCommonBufferData(),
Skylighting::GetSingleton()->cbData,
State::GetSingleton()->pbrSettings);
TruePBR::GetSingleton()->settings);
}
1,125 changes: 6 additions & 1,119 deletions src/Hooks.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

namespace Hooks
{
bool hk_BSShader_BeginTechnique(RE::BSShader* shader, uint32_t vertexDescriptor, uint32_t pixelDescriptor, bool skipPixelShader);
void Install();
}
60 changes: 2 additions & 58 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Features/LightLimitFix/ParticleLights.h"

#include "Deferred.h"
#include "TruePBR.h"

#include "VariableRateShading.h"

Expand Down Expand Up @@ -408,64 +409,7 @@ void Menu::DrawSettings()
ImGui::TreePop();
}
ImGui::Checkbox("Extended Frame Annotations", &State::GetSingleton()->extendedFrameAnnotations);
if (ImGui::TreeNodeEx("PBR", ImGuiTreeNodeFlags_DefaultOpen)) {
auto* state = State::GetSingleton();

if (const auto* player = RE::PlayerCharacter::GetSingleton()) {
if (const auto* currentCell = player->GetParentCell()) {
if (currentCell->IsInteriorCell()) {
if (const auto* lightingTemplate = currentCell->GetRuntimeData().lightingTemplate) {
if (ImGui::TreeNodeEx("Lighting Template Settings", ImGuiTreeNodeFlags_DefaultOpen)) {
const auto* editorId = lightingTemplate->GetFormEditorID();
ImGui::Text(std::format("Current Lighting Template : {}", editorId).c_str());

auto& pbrData = state->pbrLightingTemplates[editorId];

ImGui::SliderFloat("Directional Light Scale", &pbrData.directionalLightColorScale, 0.f, 5.f);
ImGui::SliderFloat("Directional Ambient Light Scale", &pbrData.directionalAmbientLightColorScale, 0.f, 5.f);

if (ImGui::Button("Save")) {
state->SavePBRLightingTemplateData(editorId);
}

ImGui::TreePop();
}
}
} else if (RE::Sky* sky = RE::Sky::GetSingleton()) {
if (const auto* weather = sky->currentWeather) {
if (ImGui::TreeNodeEx("Weather Settings", ImGuiTreeNodeFlags_DefaultOpen)) {
const auto* editorId = weather->GetFormEditorID();
ImGui::Text(std::format("Current Weather : {}", editorId).c_str());

auto& pbrData = state->pbrWeathers[editorId];

ImGui::SliderFloat("Directional Light Scale", &pbrData.directionalLightColorScale, 0.f, 5.f);
ImGui::SliderFloat("Directional Ambient Light Scale", &pbrData.directionalAmbientLightColorScale, 0.f, 5.f);

if (ImGui::Button("Save")) {
state->SavePBRWeatherData(editorId);
}

ImGui::TreePop();
}
}
}
}
}

bool useMultipleScattering = state->pbrSettings.useMultipleScattering;
bool useMultiBounceAO = state->pbrSettings.useMultiBounceAO;
if (ImGui::Checkbox("Use Multiple Scattering", &useMultipleScattering)) {
state->pbrSettings.useMultipleScattering = useMultipleScattering;
}
if (ImGui::Checkbox("Use Multi-bounce AO", &useMultiBounceAO)) {
state->pbrSettings.useMultiBounceAO = useMultiBounceAO;
}

ImGui::SliderFloat("Direct Light Color Multiplier", &state->globalPBRDirectLightColorMultiplier, 1e-3f, 1e2f, "%.3f", ImGuiSliderFlags_Logarithmic);
ImGui::SliderFloat("Ambient Light Color Multiplier", &state->globalPBRAmbientLightColorMultiplier, 1e-3f, 1e2f, "%.3f", ImGuiSliderFlags_Logarithmic);
ImGui::TreePop();
}
TruePBR::GetSingleton()->DrawSettings();
}

if (ImGui::CollapsingHeader("Replace Original Shaders", ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) {
Expand Down
Loading

0 comments on commit a24313c

Please sign in to comment.