effect.h 1.5 KB

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