The shader effects now work correctly on the scene actors, but the application of shaders should be on the animation class.

This commit is contained in:
Zed A. Shaw 2026-01-02 23:23:05 -05:00
parent 22db12f5e4
commit 05fc9062a7
11 changed files with 33 additions and 16 deletions

View file

@ -76,6 +76,7 @@ namespace scene {
void Engine::apply_effect(const std::string& actor, const std::string& shader) {
auto& element = actor_config(actor);
element.effect = shaders::get(shader);
}
void Engine::attach_text(const std::string& actor, const std::string& text) {
@ -100,8 +101,12 @@ namespace scene {
}
for(auto& actor : $actors) {
view.draw(*actor.st.sprite, actor.effect.get());
if(actor.anim.playing) view.draw(actor.text);
if(actor.effect != nullptr) {
dbc::log(fmt::format("ACTOR {} SHADER {}", actor.name, (void*)actor.effect.get()));
}
view.draw(*actor.st.sprite, actor.effect.get());
if(actor.anim.playing) view.draw(actor.text);
}
$camera.render(view);
@ -139,7 +144,8 @@ namespace scene {
actor.anim.apply(actor.text, actor.pos);
if(actor.effect) {
actor.effect->setUniform("u_time", actor.anim.subframe);
actor.effect->setUniform("u_duration", 1000);
sf::Vector2f u_resolution{float(actor.anim.frame_width), float(actor.anim.frame_height)};
actor.effect->setUniform("u_resolution", u_resolution);
}
} else {
actor.effect = nullptr;
@ -159,7 +165,8 @@ namespace scene {
return pos;
}
void Engine::zoom(float mid_x, float mid_y, float scale) {
void Engine::zoom(float mid_x, float mid_y, const std::string& style, float scale) {
$camera.style(style);
$camera.scale(scale);
$camera.move(mid_x, mid_y);
$camera.play();
@ -188,13 +195,13 @@ namespace scene {
}
}
void Engine::zoom(const std::string &actor, float scale) {
void Engine::zoom(const std::string &actor, const std::string& style, float scale) {
auto& config = actor_config(actor);
auto bounds = config.st.sprite->getGlobalBounds();
float mid_x = config.pos.x + bounds.size.x / 2.0f;
float mid_y = config.pos.y + bounds.size.y / 2.0f;
zoom(mid_x, mid_y, scale);
zoom(mid_x, mid_y, style, scale);
}
void Engine::reset(sf::RenderTexture& view) {