| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #pragma once
- #include <iostream>
- #include <map>
- #include <memory>
- #include <vector>
- #include "../TextureProvider.h"
- #include "WallpaperEngine/Render/Shaders/Variables/ShaderVariable.h"
- #include "GLSLContext.h"
- #include "ShaderUnit.h"
- #include "WallpaperEngine/Data/Model/Types.h"
- namespace WallpaperEngine::Render::Shaders {
- using json = nlohmann::json;
- using namespace WallpaperEngine::Render;
- using namespace WallpaperEngine::Data::Model;
- /**
- * A basic shader loader that adds basic function definitions to every loaded shader
- */
- class Shader {
- public:
- struct ParameterSearchResult {
- Variables::ShaderVariable* vertex;
- Variables::ShaderVariable* fragment;
- };
- Shader (
- const AssetLocator& assetLocator, std::string filename, const ComboMap& combos, const ComboMap& overrideCombos,
- const TextureMap& textures, const TextureMap& overrideTextures, const ShaderConstantMap& constants
- );
- const std::string& vertex ();
- const std::string& fragment ();
- /** Empty when there is no geometry stage */
- const std::string& geometry ();
- [[nodiscard]] const ShaderUnit& getVertex () const;
- [[nodiscard]] const ShaderUnit& getFragment () const;
- [[nodiscard]] const std::map<std::string, int>& getCombos () const;
- /** Searches both the vertex and fragment shader units for a parameter with this name */
- [[nodiscard]] ParameterSearchResult findParameter (const std::string& name) const;
- private:
- ShaderUnit m_vertex;
- ShaderUnit m_fragment;
- /** GS_ENABLED shaders with a .geom, like WE's particle shaders (its renderer always sets that define) */
- std::unique_ptr<ShaderUnit> m_geometry;
- std::string m_file;
- std::vector<Variables::ShaderVariable*> m_parameters = {};
- const ComboMap& m_combos;
- const TextureMap m_passTextures;
- };
- } // namespace WallpaperEngine::Render::Shaders
|