Now I can attach arbitrary shaders to sprites based on things that happen in the world.
This commit is contained in:
parent
bec8fe0a13
commit
787be78a69
6 changed files with 53 additions and 16 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <numbers>
|
||||
#include "components.hpp"
|
||||
#include "textures.hpp"
|
||||
#include "systems.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
using std::make_unique;
|
||||
|
@ -180,10 +181,9 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
// float level = sqrt(rec.first);
|
||||
float level = lights[sprite_pos.location.y][sprite_pos.location.x] * PERCENT;
|
||||
|
||||
shared_ptr<sf::Shader> effect = nullptr;
|
||||
shared_ptr<sf::Shader> effect = System::sprite_effect($level, rec.second);
|
||||
|
||||
if(rec.second == aiming_at) {
|
||||
effect = $flame;
|
||||
if(effect) {
|
||||
apply_sprite_effect(effect, sprite_width, sprite_height);
|
||||
} else {
|
||||
effect = $brightness;
|
||||
|
@ -411,7 +411,4 @@ void Raycaster::update_level(GameLevel level) {
|
|||
|
||||
void Raycaster::init_shaders() {
|
||||
$brightness = shaders::get("rayview_sprites");
|
||||
$brightness->setUniform("source", sf::Shader::CurrentTexture);
|
||||
$flame = shaders::get("flame");
|
||||
$flame->setUniform("source", sf::Shader::CurrentTexture);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue