lens_flare.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef IGL_LENS_FLARE_H
  2. #define IGL_LENS_FLARE_H
  3. #include <igl/OpenGL_convenience.h>
  4. #include <Eigen/Core>
  5. #include <vector>
  6. namespace igl
  7. {
  8. struct Flare{
  9. int type; /* flare texture index, 0..5 */
  10. float scale;
  11. float loc; /* postion on axis */
  12. float color[3];
  13. Flare(){}
  14. Flare(int type, float location, float scale, const float color[3], float colorScale) :
  15. type(type),
  16. scale(scale),
  17. loc(location)
  18. {
  19. this->color[0] = color[0] * colorScale;
  20. this->color[1] = color[1] * colorScale;
  21. this->color[2] = color[2] * colorScale;
  22. }
  23. };
  24. // Initialize shared data for lens flates
  25. //
  26. // Inputs:
  27. // start_id starting texture id location (should have at least id:id+16 free)
  28. // Outputs:
  29. // shine list of texture ids for shines
  30. // flare list of texture ids for flares
  31. void lens_flare_load_textures(
  32. std::vector<GLuint> & shine_ids,
  33. std::vector<GLuint> & flare_ids);
  34. // Create a set of lens flares
  35. //
  36. // Inputs:
  37. // A primary color
  38. // B secondary color
  39. // C secondary color
  40. // Outputs:
  41. // flares list of flare objects
  42. void lens_flare_create(
  43. const float * A,
  44. const float * B,
  45. const float * C,
  46. std::vector<Flare> & flares);
  47. // Draw lens flares
  48. //
  49. // Inputs:
  50. // flares list of Flare objects
  51. // shine_ids list of shine textures
  52. // flare_ids list of flare texture ids
  53. // light position of light
  54. // near_clip near clipping plane
  55. // shine_tic current "tic" in shine textures
  56. // Outputs:
  57. // shine_tic current "tic" in shine textures
  58. void lens_flare_draw(
  59. const std::vector<Flare> & flares,
  60. const std::vector<GLuint> & shine_ids,
  61. const std::vector<GLuint> & flare_ids,
  62. const Eigen::Vector3f & light,
  63. const float near_clip,
  64. int & shine_tic);
  65. };
  66. #ifdef IGL_HEADER_ONLY
  67. # include "lens_flare.cpp"
  68. #endif
  69. #endif