lens_flare.h 1.9 KB

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