add 'advanced' post-effect load configuration

This commit is contained in:
MihailRis 2025-06-13 23:28:16 +03:00
parent 9cc59c8848
commit 02a91e0b72
10 changed files with 49 additions and 21 deletions

View file

@ -10,10 +10,11 @@ PostEffect::Param::Param(Type type, Value defValue)
}
PostEffect::PostEffect(
bool advanced,
std::shared_ptr<Shader> shader,
std::unordered_map<std::string, Param> params
)
: shader(std::move(shader)), params(std::move(params)) {
: advanced(advanced), shader(std::move(shader)), params(std::move(params)) {
}
Shader& PostEffect::use() {

View file

@ -35,6 +35,7 @@ public:
};
PostEffect(
bool advanced,
std::shared_ptr<Shader> shader,
std::unordered_map<std::string, Param> params
);
@ -48,10 +49,15 @@ public:
void setParam(const std::string& name, const dv::value& value);
bool isAdvanced() const {
return advanced;
}
bool isActive() {
return intensity > 1e-4f;
}
private:
bool advanced = false;
std::shared_ptr<Shader> shader;
std::unordered_map<std::string, Param> params;
float intensity = 0.0f;

View file

@ -97,6 +97,7 @@ void PostProcessing::configureEffect(
) {
const auto& viewport = context.getViewport();
bool ssaoConfigured = false;
if (!ssaoConfigured) {
for (unsigned int i = 0; i < 64; ++i) {
auto name = "u_ssaoSamples["+ std::to_string(i) + "]";
@ -129,7 +130,9 @@ void PostProcessing::render(
}
int totalPasses = 0;
for (const auto& effect : effectSlots) {
totalPasses += (effect != nullptr && effect->isActive());
totalPasses +=
(effect != nullptr && effect->isActive() &&
!(effect->isAdvanced() && gbuffer == nullptr));
}
const auto& vp = context.getViewport();
@ -163,6 +166,9 @@ void PostProcessing::render(
if (effect == nullptr || !effect->isActive()) {
continue;
}
if (effect->isAdvanced() && gbuffer == nullptr) {
continue;
}
auto& shader = effect->use();
configureEffect(context, shader, timer, camera, shadowMap);

View file

@ -76,5 +76,4 @@ private:
std::vector<glm::vec3> ssaoKernel;
uint noiseTexture;
bool ssaoConfigured = false;
};