SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLTextureIBL.h
Go to the documentation of this file.
1 /**
2  * \file SLGLTextureIBL.h
3  * \date April 2018
4  * \authors Carlos Arauz, Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLGLTEXTUREGENERATED_H
11 #define SLGLTEXTUREGENERATED_H
12 
13 #include <CVImage.h>
14 #include <SLGLVertexArray.h>
15 #include <SLGLProgram.h>
16 #include <SLGLTexture.h>
17 #include <SLGLFrameBuffer.h>
18 
19 //-----------------------------------------------------------------------------
20 //! Texture object generated in run time from another texture
21 /*!
22  This class is mainly used to generate the textures used for reflections in the
23  Image Base Lighting (IBL) techniques. It takes a source texture and projects
24  it into a cube map with different rendering techniques to produces the
25  textures needed in IBL like the irradiance or the prefilter map.
26  This textures can be given to the SLMaterial with IBL. It uses the
27  SLGLFrameBuffer class to render the scene into a cube map. These generated
28  textures only exist on the GPU. There are no images in the SLGLTexture::_images
29  vector.
30 */
32 {
33 public:
34  //! Default constructor
36 
37  //! ctor for generated textures
39  SLstring shaderPath,
40  SLGLTexture* sourceTexture,
41  SLVec2i size,
43  SLenum target,
44  SLbool readBackPixels = true,
45  SLint min_filter = GL_LINEAR,
46  SLint mag_filter = GL_LINEAR);
47 
48  virtual ~SLGLTextureIBL();
49 
50  virtual void build(SLint texID = 0);
51  void logFramebufferStatus();
52 
53 protected:
54  // converting the hdr image file to cubemap
55  void renderCube();
56  void renderQuad();
57  void readPixels(int width,
58  int height,
59  string name,
60  bool savePNG);
61 
66 
67  SLGLTexture* _sourceTexture; //!< 2D Texture from the HDR Image
68  SLGLProgram* _shaderProgram; //!< Shader program to render the texture
69  SLMat4f _captureProjection; //!< Projection matrix for capturing the textures
70  SLVMat4f _captureViews; //!< All 6 positions of the views that represent the 6 sides of the cube map
71  SLbool _readBackPixels; //!< Flag if generated texture should be read back from GPU into cvMat
72 };
73 //-----------------------------------------------------------------------------
74 #endif
unsigned int SLenum
Definition: SL.h:176
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
Wrapper class around OpenGL Frame Buffer Objects (FBO)
SLTextureType
Texture type enumeration & their filename appendix for auto type detection.
Definition: SLGLTexture.h:76
Wrapper class around OpenGL Vertex Array Objects (VAO)
vector< SLMat4f > SLVMat4f
Definition: SLMat4.h:1585
Toplevel holder of the assets meshes, materials, textures and shaders.
Encapsulation of an OpenGL shader program object.
Definition: SLGLProgram.h:56
Texture object for OpenGL texturing.
Definition: SLGLTexture.h:110
SLTextureType texType()
Definition: SLGLTexture.h:228
SLuint height()
Definition: SLGLTexture.h:219
SLenum target() const
Definition: SLGLTexture.h:226
SLuint width()
Definition: SLGLTexture.h:218
SLuint texID() const
Definition: SLGLTexture.h:227
Texture object generated in run time from another texture.
SLGLProgram * _shaderProgram
Shader program to render the texture.
SLVMat4f _captureViews
All 6 positions of the views that represent the 6 sides of the cube map.
virtual ~SLGLTextureIBL()
SLGLTexture * _sourceTexture
2D Texture from the HDR Image
virtual void build(SLint texID=0)
void renderQuad()
Renders a 2x2 XY quad, used for rendering and capturing the BRDF integral.
SLMat4f _captureProjection
Projection matrix for capturing the textures.
SLGLTextureIBL()
Default constructor.
void logFramebufferStatus()
void renderCube()
Renders 2x2 cube, used to project a texture to a cube texture with 6 sides.
void readPixels(int width, int height, string name, bool savePNG)
Reads back the pixels into an image.
SLbool _readBackPixels
Flag if generated texture should be read back from GPU into cvMat.
const SLstring & name() const
Definition: SLObject.h:38