Showing the changes to interface/src/Application.cpp (1 of 6 files). Show all
Unified · Split
| @@ -164,13 +164,6 @@ extern "C" { · 163 unmodified lines | |||
| 164 | } | 164 | } |
| 165 | #endif | 165 | #endif |
| 166 | 166 | ||
| 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 | |||
| 174 | using namespace std; | 167 | using namespace std; |
| 175 | 168 | ||
| 176 | static QTimer locationUpdateTimer; | 169 | static QTimer locationUpdateTimer; |
| @@ -1219,8 +1212,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 1042 unmodified lines | |||
| 1219 | connect(this, &Application::applicationStateChanged, this, &Application::activeChanged); | 1212 | connect(this, &Application::applicationStateChanged, this, &Application::activeChanged); |
| 1220 | qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0); | 1213 | qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0); |
| 1221 | 1214 | ||
| 1222 | auto textureCache = DependencyManager::get<TextureCache>(); | 1215 | auto textureCache = DependencyManager::get<TextureCache>(); |
| 1223 | skyboxTexture = textureCache->getTexture(QUrl("https://hifi-public.s3.amazonaws.com/images/SkyboxTextures/FullMoon1024Compressed.jpg"), NetworkTexture::CUBE_TEXTURE); | 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 }); | ||
| 1224 | 1225 | ||
| 1225 | // After all of the constructor is completed, then set firstRun to false. | 1226 | // After all of the constructor is completed, then set firstRun to false. |
| 1226 | Setting::Handle<bool> firstRun{ Settings::firstRun, true }; | 1227 | Setting::Handle<bool> firstRun{ Settings::firstRun, true }; |
| @@ -4263,23 +4264,19 @@ namespace render { · 3036 unmodified lines | |||
| 4263 | } | 4264 | } |
| 4264 | */ | 4265 | */ |
| 4265 | 4266 | ||
| 4266 | if (!skyboxTextureLoaded && skyboxTexture && skyboxTexture->isLoaded()) { | 4267 | auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage(); |
| 4267 | skybox->setColor({ 1.0, 1.0, 1.0 }); | 4268 | auto sceneKeyLight = scene->getKeyLight(); |
| 4268 | skyboxTextureLoaded = true; | 4269 | scene->setSunModelEnable(false); |
| 4269 | auto texture = skyboxTexture->getGPUTexture(); | 4270 | sceneKeyLight->setColor(glm::vec3(255.0f / 255.0f, 220.0f / 255.0f, 194.0f / 255.0f) * 0.2f); |
| 4270 | if (texture) { | 4271 | sceneKeyLight->setIntensity(0.2f); |
| 4271 | skybox->setCubemap(texture); | 4272 | sceneKeyLight->setAmbientIntensity(3.5f); |
| 4272 | auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage(); | 4273 | sceneKeyLight->setDirection({ 0.0f, 0.0f, -1.0f }); |
| 4273 | auto sceneKeyLight = scene->getKeyLight(); | 4274 | |
| 4274 | sceneKeyLight->setAmbientSphere(texture->getIrradiance()); | 4275 | auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture(); |
| 4275 | sceneKeyLight->setAmbientMap(texture); | 4276 | sceneKeyLight->setAmbientSphere(defaultSkyboxAmbientTexture->getIrradiance()); |
| 4276 | } else { | 4277 | sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture); |
| 4277 | skybox->setCubemap(nullptr); | 4278 | |
| 4278 | } | 4279 | qApp->getDefaultSkybox()->render(batch, args->getViewFrustum()); |
| 4279 | } | ||
| 4280 | if (skyboxTextureLoaded) { | ||
| 4281 | skybox->render(batch, args->getViewFrustum()); | ||
| 4282 | } | ||
| 4283 | } | 4280 | } |
| 4284 | break; | 4281 | break; |
| 4285 | 4282 | ||