22
33// --------------------------------------------------------------
44void ofApp::setup (){
5+ // ofSetLogLevel(OF_LOG_VERBOSE);
6+
57 ofSetVerticalSync (false );
68
79 camera.setNearClip (200 );
@@ -10,23 +12,43 @@ void ofApp::setup(){
1012 // loading a cube map will enable image based lighting on PBR materials.
1113 // cube map will create a prefiltered light cube map and an irradiance cube map
1214 // cube map texture from https://polyhaven.com
13- #ifdef USE_CUBE_MAP
15+ #ifdef USE_CUBE_MAP
1416 // comment out the loading of the cube map image to see added cube map lighting without image
1517 // fake environment lighting is added in the pbr shader
16- cubeMap.load (" modern_buildings_2_1k.exr" , 512 , true );
17- #endif
18+
19+ ofCubeMap::ofCubeMapSettings csettings;
20+ csettings.filePath = " modern_buildings_2_1k.exr" ;
21+ // uncomment to load from a cache or make one if it doesn't exist
22+ // csettings.useCache = true;
23+
24+ // uncomment to use the maximum precision available. OpenGL ES is float16 and OpenGL is float32;
25+ // csettings.useMaximumPrecision = true;
26+
27+ // make sure the defaults are the same for making and loading the cache
28+ // ie opengl es defaults are smaller and the file names to load are based on the resolution
29+ csettings.irradianceRes = 32 ;
30+ csettings.preFilterRes = 128 ;
31+
32+ cubeMap.load (csettings);
33+ // below is another method for loading a cube map without passing settings class
34+ // cubeMap.load("modern_buildings_2_1k.exr", 512, true );
35+ #endif
36+
37+ ofEnableArbTex ();
1838}
1939
2040// --------------------------------------------------------------
2141void ofApp::update (){
22-
42+ prefilterRoughness = ofMap ( ofGetMouseX (), 0 , ofGetWidth (), 0 . 0f , 1 . 0f , true );
2343}
2444
2545// --------------------------------------------------------------
2646void ofApp::draw (){
2747
2848 ofEnableDepthTest ();
49+
2950 camera.begin ();
51+
3052 float tradius = 50.0 ;
3153 int numCols = 5 ;
3254 int numRows = 3 ;
@@ -73,7 +95,7 @@ void ofApp::draw(){
7395 // this will allow for the benefit of depth clipping
7496 if ( cubeMapMode == 2 ) {
7597 if ( cubeMap.hasPrefilteredMap () ) {
76- cubeMap.drawPrefilteredCube (0 . 25f );
98+ cubeMap.drawPrefilteredCube (prefilterRoughness );
7799 } else {
78100 ofLogNotice (" DOES NOT HAVE PRE FILTERED CUBE MAP" ) << " " << ofGetFrameNum ();
79101 }
@@ -94,7 +116,7 @@ void ofApp::draw(){
94116 stringstream ss;
95117 string cmMode = " Cube Map" ;
96118 if ( cubeMapMode == 2 ) {
97- cmMode = " Prefiltered" ;
119+ cmMode = " Prefiltered : roughness(mouse): " + ofToString (prefilterRoughness, 2 ) ;
98120 } else if (cubeMapMode == 3 ) {
99121 cmMode = " Irradiance" ;
100122 }
0 commit comments