Add support for Skybox and rendering path of background according to Zones
Showing the changes to interface/src/Application.cpp (1 of 36 files). Show all
Unified · Split
| @@ -3161,39 +3161,62 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 3160 unmodified lines | ||
| 3161 | 3161 | glTexGenfv(GL_R, GL_EYE_PLANE, (const GLfloat*)&_shadowMatrices[i][2]); |
| 3162 | 3162 | } |
| 3163 | 3163 | |
| 3164 | − if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { | |
| 3165 | − PerformanceTimer perfTimer("stars"); | |
| 3166 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3167 | − "Application::displaySide() ... stars..."); | |
| 3168 | − if (!_stars.isStarsLoaded()) { | |
| 3169 | − _stars.generate(STARFIELD_NUM_STARS, STARFIELD_SEED); | |
| 3170 | − } | |
| 3171 | − // should be the first rendering pass - w/o depth buffer / lighting | |
| 3172 | − | |
| 3173 | − // compute starfield alpha based on distance from atmosphere | |
| 3174 | − float alpha = 1.0f; | |
| 3175 | − bool hasStars = true; | |
| 3176 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 3177 | − // TODO: handle this correctly for zones | |
| 3178 | − const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition()); | |
| 3164 | + // Background rendering decision | |
| 3165 | + auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | |
| 3166 | + if (skyStage->getBackgroundMode() == model::SunSkyStage::NO_BACKGROUND) { | |
| 3167 | + } else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_DOME) { | |
| 3168 | + if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { | |
| 3169 | + PerformanceTimer perfTimer("stars"); | |
| 3170 | + PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3171 | + "Application::displaySide() ... stars..."); | |
| 3172 | + if (!_stars.isStarsLoaded()) { | |
| 3173 | + _stars.generate(STARFIELD_NUM_STARS, STARFIELD_SEED); | |
| 3174 | + } | |
| 3175 | + // should be the first rendering pass - w/o depth buffer / lighting | |
| 3176 | + | |
| 3177 | + // compute starfield alpha based on distance from atmosphere | |
| 3178 | + float alpha = 1.0f; | |
| 3179 | + bool hasStars = true; | |
| 3180 | + if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 3181 | + // TODO: handle this correctly for zones | |
| 3182 | + const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition()); | |
| 3179 | 3183 | |
| 3180 | − if (closestData.getHasStars()) { | |
| 3181 | − float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter()); | |
| 3182 | − if (height < closestData.getAtmosphereInnerRadius()) { | |
| 3183 | − alpha = 0.0f; | |
| 3184 | − | |
| 3185 | − } else if (height < closestData.getAtmosphereOuterRadius()) { | |
| 3186 | − alpha = (height - closestData.getAtmosphereInnerRadius()) / | |
| 3187 | − (closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius()); | |
| 3184 | + if (closestData.getHasStars()) { | |
| 3185 | + float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter()); | |
| 3186 | + if (height < closestData.getAtmosphereInnerRadius()) { | |
| 3187 | + alpha = 0.0f; | |
| 3188 | + | |
| 3189 | + } else if (height < closestData.getAtmosphereOuterRadius()) { | |
| 3190 | + alpha = (height - closestData.getAtmosphereInnerRadius()) / | |
| 3191 | + (closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius()); | |
| 3192 | + } | |
| 3193 | + } else { | |
| 3194 | + hasStars = false; | |
| 3188 | 3195 | } |
| 3189 | − } else { | |
| 3190 | − hasStars = false; | |
| 3191 | 3196 | } |
| 3192 | − } | |
| 3193 | 3197 | |
| 3194 | − // finally render the starfield | |
| 3195 | − if (hasStars) { | |
| 3196 | − _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha); | |
| 3198 | + // finally render the starfield | |
| 3199 | + if (hasStars) { | |
| 3200 | + _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha); | |
| 3201 | + } | |
| 3202 | + | |
| 3203 | + // draw the sky dome | |
| 3204 | + if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 3205 | + PerformanceTimer perfTimer("atmosphere"); | |
| 3206 | + PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3207 | + "Application::displaySide() ... atmosphere..."); | |
| 3208 | + _environment.renderAtmospheres(theCamera); | |
| 3209 | + } | |
| 3210 | + | |
| 3211 | + } | |
| 3212 | + } else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_BOX) { | |
| 3213 | + auto skybox = skyStage->getSkybox(); | |
| 3214 | + if (skybox) { | |
| 3215 | + gpu::Batch batch; | |
| 3216 | + model::Skybox::render(batch, _viewFrustum, *skybox); | |
| 3217 | + | |
| 3218 | + gpu::GLBackend::renderBatch(batch); | |
| 3219 | + glUseProgram(0); | |
| 3197 | 3220 | } |
| 3198 | 3221 | } |
| 3199 | 3222 | |
| @@ -3201,13 +3224,6 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 1 unmodified line | ||
| 3201 | 3224 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
| 3202 | 3225 | } |
| 3203 | 3226 | |
| 3204 | − // draw the sky dome | |
| 3205 | − if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { | |
| 3206 | − PerformanceTimer perfTimer("atmosphere"); | |
| 3207 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3208 | − "Application::displaySide() ... atmosphere..."); | |
| 3209 | − _environment.renderAtmospheres(theCamera); | |
| 3210 | − } | |
| 3211 | 3227 | glEnable(GL_LIGHTING); |
| 3212 | 3228 | glEnable(GL_DEPTH_TEST); |
| 3213 | 3229 | |