add 'advanced' post-effect load configuration
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -76,5 +76,4 @@ private:
|
||||
|
||||
std::vector<glm::vec3> ssaoKernel;
|
||||
uint noiseTexture;
|
||||
bool ssaoConfigured = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user