lens_flare.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_LENS_FLARE_H
  9. #define IGL_LENS_FLARE_H
  10. #ifndef IGL_NO_OPENGL
  11. #include <igl/OpenGL_convenience.h>
  12. #include <Eigen/Core>
  13. #include <vector>
  14. namespace igl
  15. {
  16. struct Flare{
  17. int type; /* flare texture index, 0..5 */
  18. float scale;
  19. float loc; /* postion on axis */
  20. float color[3];
  21. Flare():
  22. type(-1),
  23. scale(0),
  24. loc(0)
  25. {}
  26. Flare(int type, float location, float scale, const float color[3], float colorScale) :
  27. type(type),
  28. scale(scale),
  29. loc(location)
  30. {
  31. this->color[0] = color[0] * colorScale;
  32. this->color[1] = color[1] * colorScale;
  33. this->color[2] = color[2] * colorScale;
  34. }
  35. };
  36. // Initialize shared data for lens flates
  37. //
  38. // Inputs:
  39. // start_id starting texture id location (should have at least id:id+16 free)
  40. // Outputs:
  41. // shine list of texture ids for shines
  42. // flare list of texture ids for flares
  43. void lens_flare_load_textures(
  44. std::vector<GLuint> & shine_ids,
  45. std::vector<GLuint> & flare_ids);
  46. // Create a set of lens flares
  47. //
  48. // Inputs:
  49. // A primary color
  50. // B secondary color
  51. // C secondary color
  52. // Outputs:
  53. // flares list of flare objects
  54. void lens_flare_create(
  55. const float * A,
  56. const float * B,
  57. const float * C,
  58. std::vector<Flare> & flares);
  59. // Draw lens flares
  60. //
  61. // Inputs:
  62. // flares list of Flare objects
  63. // shine_ids list of shine textures
  64. // flare_ids list of flare texture ids
  65. // light position of light
  66. // near_clip near clipping plane
  67. // shine_tic current "tic" in shine textures
  68. // Outputs:
  69. // shine_tic current "tic" in shine textures
  70. void lens_flare_draw(
  71. const std::vector<Flare> & flares,
  72. const std::vector<GLuint> & shine_ids,
  73. const std::vector<GLuint> & flare_ids,
  74. const Eigen::Vector3f & light,
  75. const float near_clip,
  76. int & shine_tic);
  77. };
  78. #ifdef IGL_HEADER_ONLY
  79. # include "lens_flare.cpp"
  80. #endif
  81. #endif
  82. #endif