History

Move default skybox out of global and make irradiance gen optional

Ryan Huffman committed 10 years ago

Commit 5b69ca01 parent 35ea9906 files · +48 −31Browse files

Showing the changes to interface/src/Application.cpp (1 of 6 files). Show all

Unified · Split

interface/src/Application.cpp+23−26
@@ -164,13 +164,6 @@ extern "C" { · 163 unmodified lines
164164 }
165165 #endif
166166
167−#include <procedural/ProceduralSkybox.h>
168−#include <model/Skybox.h>
169−
170−static model::Skybox* skybox{ new ProceduralSkybox() } ;
171−static NetworkTexturePointer skyboxTexture;
172−static bool skyboxTextureLoaded = false;
173−
174167 using namespace std;
175168
176169 static QTimer locationUpdateTimer;
@@ -1219,8 +1212,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 1042 unmodified lines
12191212 connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
12201213 qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
12211214
1222− auto textureCache = DependencyManager::get<TextureCache>();
1223− skyboxTexture = textureCache->getTexture(QUrl("https://hifi-public.s3.amazonaws.com/images/SkyboxTextures/FullMoon1024Compressed.jpg"), NetworkTexture::CUBE_TEXTURE);
1215+ auto textureCache = DependencyManager::get<TextureCache>();
1216+
1217+ QString skyboxUrl { PathUtils::resourcesPath() + "images/Default-Sky-9-cubemap.jpg" };
1218+ QString skyboxAmbientUrl { PathUtils::resourcesPath() + "images/Default-Sky-9-ambient.jpg" };
1219+
1220+ _defaultSkyboxTexture = textureCache->getImageTexture(skyboxUrl, NetworkTexture::CUBE_TEXTURE, { { "generateIrradiance", false } });
1221+ _defaultSkyboxAmbientTexture = textureCache->getImageTexture(skyboxAmbientUrl, NetworkTexture::CUBE_TEXTURE, { { "generateIrradiance", true } });
1222+
1223+ _defaultSkybox->setCubemap(_defaultSkyboxTexture);
1224+ _defaultSkybox->setColor({ 1.0, 1.0, 1.0 });
12241225
12251226 // After all of the constructor is completed, then set firstRun to false.
12261227 Setting::Handle<bool> firstRun{ Settings::firstRun, true };
@@ -4263,23 +4264,19 @@ namespace render { · 3036 unmodified lines
42634264 }
42644265 */
42654266
4266− if (!skyboxTextureLoaded && skyboxTexture && skyboxTexture->isLoaded()) {
4267− skybox->setColor({ 1.0, 1.0, 1.0 });
4268− skyboxTextureLoaded = true;
4269− auto texture = skyboxTexture->getGPUTexture();
4270− if (texture) {
4271− skybox->setCubemap(texture);
4272− auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
4273− auto sceneKeyLight = scene->getKeyLight();
4274− sceneKeyLight->setAmbientSphere(texture->getIrradiance());
4275− sceneKeyLight->setAmbientMap(texture);
4276− } else {
4277− skybox->setCubemap(nullptr);
4278− }
4279− }
4280− if (skyboxTextureLoaded) {
4281− skybox->render(batch, args->getViewFrustum());
4282− }
4267+ auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
4268+ auto sceneKeyLight = scene->getKeyLight();
4269+ scene->setSunModelEnable(false);
4270+ sceneKeyLight->setColor(glm::vec3(255.0f / 255.0f, 220.0f / 255.0f, 194.0f / 255.0f) * 0.2f);
4271+ sceneKeyLight->setIntensity(0.2f);
4272+ sceneKeyLight->setAmbientIntensity(3.5f);
4273+ sceneKeyLight->setDirection({ 0.0f, 0.0f, -1.0f });
4274+
4275+ auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture();
4276+ sceneKeyLight->setAmbientSphere(defaultSkyboxAmbientTexture->getIrradiance());
4277+ sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture);
4278+
4279+ qApp->getDefaultSkybox()->render(batch, args->getViewFrustum());
42834280 }
42844281 break;
42854282