reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofCubeMap.h
Go to the documentation of this file.
1//
2// ofCubeMap.h
3//
4// Created by Nick Hardeman on 10/16/22.
5//
6
7#pragma once
8
9#include "glm/mat4x4.hpp"
10
11class ofVboMesh;
12
13class ofShader;
15
16class ofCubeMap {
17public:
18
20 of::filesystem::path filePath { "" };
21 of::filesystem::path cacheDirectory { "" };
22
23 bool overwriteCache = false;
24 bool useCache = false;
25 bool useLutTex = false;
26 bool flipVertically = true;
27
28 int resolution = 512;
29#ifdef TARGET_OPENGLES
30 int irradianceRes = 16;
31 int preFilterRes = 64;
32#else
33 int irradianceRes = 32;
34 int preFilterRes = 128;
35#endif
36 };
37
38 class Data{
39 public:
40 GLuint cubeMapId = 0;
41 bool bCubeMapAllocated = false;
42 GLuint irradianceMapId = 0;
44 GLuint preFilteredMapId = 0;
46
47 int index = -1;
48 bool isEnabled = true;
49
51
52 int maxMipLevels = 5;
53 float exposure = 1.0;
54 };
55
56 static GLenum getTextureTarget();
57 static bool hasActiveCubeMap();
58 static std::shared_ptr<ofCubeMap::Data> getActiveData();
59 static void clearTextureData(std::shared_ptr<ofCubeMap::Data> adata);
60 static void regenerateAllTextures();
61 static const ofTexture& getBrdfLutTexture();
62
63 ofCubeMap();
64 ofCubeMap(const ofCubeMap & mom);
65 ofCubeMap(ofCubeMap && mom);
66
67 ~ofCubeMap();
68
73 bool load( const of::filesystem::path & apath, int aFaceResolution, bool aBFlipY=true );
80 bool load( const of::filesystem::path & apath, int aFaceResolution, bool aBFlipY, int aIrradianceRes, int aPreFilterRes );
81
82 bool load( ofCubeMapSettings aSettings );
83
87 ofCubeMap& operator=(const ofCubeMap & mom);
89
90 void clear();
91
92 void draw();
93 void drawCubeMap();
94 void drawIrradiance();
95 void drawPrefilteredCube(float aRoughness);
96
97 bool isEnabled() { return data->isEnabled;}
98 const bool isEnabled() const { return data->isEnabled;}
99 void setEnabled(bool ab) {data->isEnabled=ab;}
100
101 bool hasCubeMap();
102 bool hasPrefilteredMap();
103 bool hasIrradianceMap();
104
105 int getFaceResolution() { return data->settings.resolution; }
106 GLuint getTextureId();
107 bool isHdr();
108
109 void setExposure(float aExposure);
110 float getExposure() { return data->exposure; }
111
112 void setUseBrdfLutTexture( bool ab );
113 bool isUsingLutBrdfTexture() { return data->settings.useLutTex; }
114
115 GLuint getIrradianceMapId() { return data->irradianceMapId; }
116 GLuint getPrefilterMapId() { return data->preFilteredMapId; }
117
118protected:
119
120 std::shared_ptr<ofCubeMap::Data> data;
121
122 void _drawCubeStart(GLuint aCubeMapId);
123 void _drawCubeEnd();
124
125 void _checkSetup();
126 void _createCubeMap(ofTexture& aSrcTex);
127 GLuint _createFloatCubeMap(ofTexture& aSrcTex, int aSrcRes);
128 void _equiRectToCubeMap( GLuint& aCubeTexId, ofTexture& aSrcTex, int aSrcRes, bool aBConvertToNonFloat );
129
130 void _createIrradianceMap(GLuint aSrcCubeFid, bool aBMakeCache, const of::filesystem::path & aCachePath);
131 bool _loadIrradianceMap( const of::filesystem::path & aCachePath );
132
133 void _createPrefilteredCubeMap(GLuint aSrcCubeFid, int aSrcRes, bool aBMakeCache, const of::filesystem::path & aCachePath);
134 bool _loadPrefilterMap( const of::filesystem::path & aCachePath );
135
136 static void _createBrdfLUT();
137
138
139 void _configureCubeTextures(GLuint aCubeMapId,bool abLinearMipLinear);
140 void _initEmptyTextures(GLuint aCubeMapId, int aSize);
141 void _initEmptyTextures(GLuint aCubeMapId, GLuint aInternalFormat, int aSize, int aNumMipMaps );
142 void _allocateCubeMesh();
143 std::vector<glm::mat4> _getViewMatrices(const glm::vec3& apos);
144
145 bool _loadRenderShader();
147
148 GLuint getTexStorageFormat();
149 GLuint getTexStorageFormat( GLuint aInternalFormat );
150
152 GLuint getGlTypeFromInternalFormat(GLuint aInternalFormat);
154
155 GLuint texFormat = GL_RGB;
156
157 glm::mat4 projectionMat;
158
161 //ofMesh sCubeMesh;
167
168};
169
170std::vector<std::weak_ptr<ofCubeMap::Data> > & ofCubeMapsData();
Definition ofCubeMap.h:38
ofCubeMapSettings settings
Definition ofCubeMap.h:50
bool bPreFilteredMapAllocated
Definition ofCubeMap.h:45
bool bCubeMapAllocated
Definition ofCubeMap.h:41
int maxMipLevels
Definition ofCubeMap.h:52
int index
Definition ofCubeMap.h:47
GLuint preFilteredMapId
Definition ofCubeMap.h:44
GLuint cubeMapId
Definition ofCubeMap.h:40
float exposure
Definition ofCubeMap.h:53
GLuint irradianceMapId
Definition ofCubeMap.h:42
bool bIrradianceAllocated
Definition ofCubeMap.h:43
bool isEnabled
Definition ofCubeMap.h:48
Definition ofCubeMap.h:16
GLuint getTexStorageFormat()
Definition ofCubeMap.cpp:1261
bool _loadRenderShader()
Definition ofCubeMap.cpp:1328
GLuint texFormat
Definition ofCubeMap.h:155
bool load(const of::filesystem::path &apath, int aFaceResolution, bool aBFlipY=true)
Definition ofCubeMap.cpp:276
GLuint getIrradianceMapId()
Definition ofCubeMap.h:115
ofShader shaderRender
Definition ofCubeMap.h:163
void _createIrradianceMap(GLuint aSrcCubeFid, bool aBMakeCache, const of::filesystem::path &aCachePath)
Definition ofCubeMap.cpp:743
GLuint getTextureId()
Definition ofCubeMap.cpp:538
std::vector< glm::mat4 > _getViewMatrices(const glm::vec3 &apos)
Definition ofCubeMap.cpp:1246
ofShader shaderEquiRectToCubeMap
Definition ofCubeMap.h:162
bool isUsingLutBrdfTexture()
Definition ofCubeMap.h:113
ofCubeMap()
Definition ofCubeMap.cpp:173
const bool isEnabled() const
Definition ofCubeMap.h:98
static void _createBrdfLUT()
Definition ofCubeMap.cpp:1172
bool hasCubeMap()
Definition ofCubeMap.cpp:520
int getFaceResolution()
Definition ofCubeMap.h:105
void setEnabled(bool ab)
Definition ofCubeMap.h:99
void clear()
Definition ofCubeMap.cpp:445
static void regenerateAllTextures()
void _equiRectToCubeMap(GLuint &aCubeTexId, ofTexture &aSrcTex, int aSrcRes, bool aBConvertToNonFloat)
Definition ofCubeMap.cpp:704
void setExposure(float aExposure)
Definition ofCubeMap.cpp:35
bool hasPrefilteredMap()
Definition ofCubeMap.cpp:526
int getNumPixelChannels()
Definition ofCubeMap.cpp:1319
static std::shared_ptr< ofCubeMap::Data > getActiveData()
Definition ofCubeMap.cpp:116
ofCubeMap & operator=(const ofCubeMap &mom)
Copy a given ofCubeMap into this cube map.
Definition ofCubeMap.cpp:223
void drawPrefilteredCube(float aRoughness)
Definition ofCubeMap.cpp:485
void _configureCubeTextures(GLuint aCubeMapId, bool abLinearMipLinear)
Definition ofCubeMap.cpp:622
std::shared_ptr< ofCubeMap::Data > data
Definition ofCubeMap.h:120
bool _loadPrefilterMap(const of::filesystem::path &aCachePath)
Definition ofCubeMap.cpp:1101
static bool hasActiveCubeMap()
Definition ofCubeMap.cpp:104
static GLenum getTextureTarget()
Definition ofCubeMap.cpp:264
void drawCubeMap()
Definition ofCubeMap.cpp:455
GLuint getGlTypeFromInternalFormat()
Definition ofCubeMap.cpp:1290
GLuint getPrefilterMapId()
Definition ofCubeMap.h:116
bool isHdr()
Definition ofCubeMap.cpp:544
void _initEmptyTextures(GLuint aCubeMapId, int aSize)
Definition ofCubeMap.cpp:642
bool _loadEquiRectToCubeMapShader()
Definition ofCubeMap.cpp:1339
bool _loadIrradianceMap(const of::filesystem::path &aCachePath)
Definition ofCubeMap.cpp:884
bool hasIrradianceMap()
Definition ofCubeMap.cpp:532
static ofTexture sBrdfLutTex
Definition ofCubeMap.h:159
GLuint _createFloatCubeMap(ofTexture &aSrcTex, int aSrcRes)
Definition ofCubeMap.cpp:678
static ofVboMesh sCubeMesh
Definition ofCubeMap.h:160
void drawIrradiance()
Definition ofCubeMap.cpp:470
void _checkSetup()
Definition ofCubeMap.cpp:146
void _drawCubeEnd()
Definition ofCubeMap.cpp:513
glm::mat4 projectionMat
Definition ofCubeMap.h:157
void _drawCubeStart(GLuint aCubeMapId)
Definition ofCubeMap.cpp:500
ofShader shaderIrradianceMap
Definition ofCubeMap.h:164
void setUseBrdfLutTexture(bool ab)
Definition ofCubeMap.cpp:568
~ofCubeMap()
Definition ofCubeMap.cpp:218
void _allocateCubeMesh()
Definition ofCubeMap.cpp:1234
float getExposure()
Definition ofCubeMap.h:110
ofShader shaderPreFilterMap
Definition ofCubeMap.h:165
void draw()
Definition ofCubeMap.cpp:450
static const ofTexture & getBrdfLutTexture()
Definition ofCubeMap.cpp:168
void _createPrefilteredCubeMap(GLuint aSrcCubeFid, int aSrcRes, bool aBMakeCache, const of::filesystem::path &aCachePath)
Definition ofCubeMap.cpp:943
void _createCubeMap(ofTexture &aSrcTex)
Definition ofCubeMap.cpp:582
static void clearTextureData(std::shared_ptr< ofCubeMap::Data > adata)
Definition ofCubeMap.cpp:127
static ofShader shaderBrdfLUT
Definition ofCubeMap.h:166
bool isEnabled()
Definition ofCubeMap.h:97
Definition ofGLProgrammableRenderer.h:17
Definition ofShader.h:35
A wrapper class for an OpenGL texture.
Definition ofTexture.h:253
Definition ofVboMesh.h:6
std::vector< std::weak_ptr< ofCubeMap::Data > > & ofCubeMapsData()
Definition ofCubeMap.cpp:98
Definition ofCubeMap.h:19
of::filesystem::path filePath
Definition ofCubeMap.h:20
bool useLutTex
Definition ofCubeMap.h:25
bool overwriteCache
Definition ofCubeMap.h:23
int resolution
Definition ofCubeMap.h:28
of::filesystem::path cacheDirectory
Definition ofCubeMap.h:21
bool useCache
Definition ofCubeMap.h:24
int irradianceRes
Definition ofCubeMap.h:33
bool flipVertically
Definition ofCubeMap.h:26
int preFilterRes
Definition ofCubeMap.h:34