effect.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef WALLENGINE_EFFECT_H
  2. #define WALLENGINE_EFFECT_H
  3. #include <nlohmann/json.hpp>
  4. #include <irrlicht/irrlicht.h>
  5. #include "texture.h"
  6. #include "shaders/compiler.h"
  7. namespace wp
  8. {
  9. using json = nlohmann::json;
  10. class effect : public irr::video::IShaderConstantSetCallBack
  11. {
  12. public:
  13. effect (json json_data);
  14. virtual void OnSetConstants (irr::video::IMaterialRendererServices* services, int32_t userData);
  15. std::vector <wp::texture*>& getTextureList ();
  16. irr::s32 getMaterialType ();
  17. private:
  18. enum ParameterType
  19. {
  20. TYPE_VEC4,
  21. TYPE_VEC3,
  22. TYPE_VEC2,
  23. TYPE_FLOAT,
  24. TYPE_INT
  25. };
  26. struct ShaderParameter
  27. {
  28. void* value;
  29. ParameterType type;
  30. };
  31. void parseConstantValues (json data);
  32. wp::shaders::compiler* m_fragShader;
  33. wp::shaders::compiler* m_vertShader;
  34. std::map <std::string, ShaderParameter*> m_vertexVariables;
  35. std::map <std::string, ShaderParameter*> m_pixelVariables;
  36. std::map <std::string, void*> m_constants;
  37. std::vector <wp::texture*> m_textures;
  38. std::string m_content;
  39. json m_json;
  40. irr::io::path m_file;
  41. irr::s32 m_materialType;
  42. std::vector<void*> m_passes;
  43. };
  44. }
  45. #endif //WALLENGINE_EFFECT_H