diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 3c102e1f02..1b5840c3c8 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -4,7 +4,7 @@ setup_hifi_project(Core Gui Network Script Quick Widgets WebSockets) # link in the shared libraries link_hifi_libraries( - audio avatars octree environment gpu model fbx entities + audio avatars octree gpu model fbx entities networking animation recording shared script-engine embedded-webserver controllers physics ) diff --git a/assignment-client/src/octree/OctreeServer.h b/assignment-client/src/octree/OctreeServer.h index 2aabb97428..f1aa9531e8 100644 --- a/assignment-client/src/octree/OctreeServer.h +++ b/assignment-client/src/octree/OctreeServer.h @@ -21,7 +21,6 @@ #include #include -#include #include "OctreePersistThread.h" #include "OctreeSendThread.h" diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 7b0545c277..b4ce53b92a 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -129,7 +129,7 @@ if (WIN32) endif() # link required hifi libraries -link_hifi_libraries(shared octree environment gpu gl procedural model render +link_hifi_libraries(shared octree gpu gl procedural model render recording fbx networking model-networking entities avatars audio audio-client animation script-engine physics render-utils entities-renderer ui auto-updater diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a6d396400e..69feec2b70 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1883,12 +1883,6 @@ void Application::keyPressEvent(QKeyEvent* event) { break; } - case Qt::Key_A: - if (isShifted) { - Menu::getInstance()->triggerOption(MenuOption::Atmosphere); - } - break; - case Qt::Key_Backslash: Menu::getInstance()->triggerOption(MenuOption::Chat); break; @@ -2696,8 +2690,6 @@ void Application::init() { // Make sure Login state is up to date DependencyManager::get()->toggleLoginDialog(); - _environment.init(); - DependencyManager::get()->init(); DependencyManager::get()->init(); @@ -3618,10 +3610,6 @@ public: typedef Payload::DataPointer Pointer; Stars _stars; - Environment* _environment; - - BackgroundRenderData(Environment* environment) : _environment(environment) { - } static render::ItemID _item; // unique WorldBoxRenderData }; @@ -3665,61 +3653,7 @@ namespace render { // compute starfield alpha based on distance from atmosphere float alpha = 1.0f; - bool hasStars = true; - - if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { - // TODO: handle this correctly for zones - const EnvironmentData& closestData = background->_environment->getClosestData(args->_viewFrustum->getPosition()); // was theCamera instead of _viewFrustum - - if (closestData.getHasStars()) { - const float APPROXIMATE_DISTANCE_FROM_HORIZON = 0.1f; - const float DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON = 0.2f; - - glm::vec3 sunDirection = (args->_viewFrustum->getPosition()/*getAvatarPosition()*/ - closestData.getSunLocation()) - / closestData.getAtmosphereOuterRadius(); - float height = glm::distance(args->_viewFrustum->getPosition()/*theCamera.getPosition()*/, closestData.getAtmosphereCenter()); - if (height < closestData.getAtmosphereInnerRadius()) { - // If we're inside the atmosphere, then determine if our keyLight is below the horizon - alpha = 0.0f; - - if (sunDirection.y > -APPROXIMATE_DISTANCE_FROM_HORIZON) { - float directionY = glm::clamp(sunDirection.y, - -APPROXIMATE_DISTANCE_FROM_HORIZON, APPROXIMATE_DISTANCE_FROM_HORIZON) - + APPROXIMATE_DISTANCE_FROM_HORIZON; - alpha = (directionY / DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON); - } - - - } else if (height < closestData.getAtmosphereOuterRadius()) { - alpha = (height - closestData.getAtmosphereInnerRadius()) / - (closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius()); - - if (sunDirection.y > -APPROXIMATE_DISTANCE_FROM_HORIZON) { - float directionY = glm::clamp(sunDirection.y, - -APPROXIMATE_DISTANCE_FROM_HORIZON, APPROXIMATE_DISTANCE_FROM_HORIZON) - + APPROXIMATE_DISTANCE_FROM_HORIZON; - alpha = (directionY / DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON); - } - } - } else { - hasStars = false; - } - } - - // finally render the starfield - if (hasStars) { - background->_stars.render(args, alpha); - } - - // draw the sky dome - if (/*!selfAvatarOnly &&*/ Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { - PerformanceTimer perfTimer("atmosphere"); - PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), - "Application::displaySide() ... atmosphere..."); - - background->_environment->renderAtmospheres(batch, *(args->_viewFrustum)); - } - + background->_stars.render(args, alpha); } } break; @@ -3759,12 +3693,10 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se // Background rendering decision if (BackgroundRenderData::_item == 0) { - auto backgroundRenderData = make_shared(&_environment); + auto backgroundRenderData = make_shared(); auto backgroundRenderPayload = make_shared(backgroundRenderData); BackgroundRenderData::_item = _main3DScene->allocateID(); pendingChanges.resetItem(BackgroundRenderData::_item, backgroundRenderPayload); - } else { - } // Assuming nothing get's rendered through that diff --git a/interface/src/Application.h b/interface/src/Application.h index efcefa0c6e..71946497d5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -44,7 +44,6 @@ #include "avatar/MyAvatar.h" #include "Bookmarks.h" #include "Camera.h" -#include "Environment.h" #include "FileLogger.h" #include "gpu/Context.h" #include "Menu.h" @@ -172,8 +171,6 @@ public: virtual QThread* getMainThread() { return thread(); } virtual PickRay computePickRay(float x, float y) const; virtual glm::vec3 getAvatarPosition() const; - virtual void overrideEnvironmentData(const EnvironmentData& newData) { _environment.override(newData); } - virtual void endOverrideEnvironmentData() { _environment.endOverride(); } virtual qreal getDevicePixelRatio(); void setActiveDisplayPlugin(const QString& pluginName); @@ -440,8 +437,6 @@ private: float _rotateMirror; float _raiseMirror; - Environment _environment; - QSet _keysPressed; bool _enableProcessOctreeThread; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 377d97bc30..591cea5731 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -323,7 +323,6 @@ Menu::Menu() { // Developer > Render >>> MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render"); - addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Atmosphere, 0, true); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::WorldAxes); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DebugAmbientOcclusion); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Antialiasing); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 6bf66f1200..84f3b90b9b 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -154,7 +154,6 @@ namespace MenuOption { const QString AnimDebugDrawPosition= "Debug Draw Position"; const QString Antialiasing = "Antialiasing"; const QString AssetMigration = "ATP Asset Migration"; - const QString Atmosphere = "Atmosphere"; const QString Attachments = "Attachments..."; const QString AudioNetworkStats = "Audio Network Stats"; const QString AudioNoiseReduction = "Audio Noise Reduction"; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index b1688b8f9e..82809cb7a5 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -43,7 +43,6 @@ #include "Application.h" #include "devices/Faceshift.h" #include "AvatarManager.h" -#include "Environment.h" #include "Menu.h" #include "MyAvatar.h" #include "Physics.h" diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index a2c1cf27c2..f3c2d83451 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -277,7 +277,6 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptrendOverrideEnvironmentData(); skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through return; // Early exit @@ -309,22 +308,6 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptrgetBackgroundMode()) { case BACKGROUND_MODE_ATMOSPHERE: { - EnvironmentData data = zone->getEnvironmentData(); - glm::vec3 keyLightDirection = sceneKeyLight->getDirection(); - glm::vec3 inverseKeyLightDirection = keyLightDirection * -1.0f; - - // NOTE: is this right? It seems like the "sun" should be based on the center of the - // atmosphere, not where the camera is. - glm::vec3 keyLightLocation = _viewState->getAvatarPosition() + - (inverseKeyLightDirection * data.getAtmosphereOuterRadius()); - - data.setSunLocation(keyLightLocation); - - const float KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO = 20.0f; - float sunBrightness = sceneKeyLight->getIntensity() * KEY_LIGHT_INTENSITY_TO_SUN_BRIGHTNESS_RATIO; - data.setSunBrightness(sunBrightness); - - _viewState->overrideEnvironmentData(data); skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); _pendingSkyboxTexture = false; _skyboxTexture.clear(); @@ -360,12 +343,10 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptrendOverrideEnvironmentData(); skyStage->setBackgroundMode(model::SunSkyStage::SKY_BOX); break; } case BACKGROUND_MODE_INHERIT: - _viewState->endOverrideEnvironmentData(); skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application atmosphere through _pendingSkyboxTexture = false; _skyboxTexture.clear(); diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index 26e90f5d41..7bea5c6088 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) -link_hifi_libraries(avatars shared audio octree gpu model fbx networking animation environment) +link_hifi_libraries(avatars shared audio octree gpu model fbx networking animation) target_bullet() diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 41f722fe36..537c8fb00f 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -41,26 +41,6 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en _backgroundMode = BACKGROUND_MODE_INHERIT; } - -EnvironmentData ZoneEntityItem::getEnvironmentData() const { - EnvironmentData result; - - result.setAtmosphereCenter(_atmosphereProperties.getCenter()); - result.setAtmosphereInnerRadius(_atmosphereProperties.getInnerRadius()); - result.setAtmosphereOuterRadius(_atmosphereProperties.getOuterRadius()); - result.setRayleighScattering(_atmosphereProperties.getRayleighScattering()); - result.setMieScattering(_atmosphereProperties.getMieScattering()); - result.setScatteringWavelengths(_atmosphereProperties.getScatteringWavelengths()); - result.setHasStars(_atmosphereProperties.getHasStars()); - - // NOTE: The sunLocation and SunBrightness will be overwritten in the EntityTreeRenderer to use the - // keyLight details from the scene interface - //result.setSunLocation(1000, 900, 1000)); - //result.setSunBrightness(20.0f); - - return result; -} - EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const { EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index bf323248c0..55cd05cb19 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -12,8 +12,6 @@ #ifndef hifi_ZoneEntityItem_h #define hifi_ZoneEntityItem_h -#include - #include "KeyLightPropertyGroup.h" #include "AtmospherePropertyGroup.h" #include "EntityItem.h" @@ -70,7 +68,6 @@ public: void setBackgroundMode(BackgroundMode value) { _backgroundMode = value; } BackgroundMode getBackgroundMode() const { return _backgroundMode; } - EnvironmentData getEnvironmentData() const; const AtmospherePropertyGroup& getAtmosphereProperties() const { return _atmosphereProperties; } const SkyboxPropertyGroup& getSkyboxProperties() const { return _skyboxProperties; } const StagePropertyGroup& getStageProperties() const { return _stageProperties; } diff --git a/libraries/environment/CMakeLists.txt b/libraries/environment/CMakeLists.txt deleted file mode 100644 index 11538a8f2b..0000000000 --- a/libraries/environment/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -set(TARGET_NAME environment) -setup_hifi_library() -link_hifi_libraries(shared networking) diff --git a/libraries/environment/src/EnvironmentData.cpp b/libraries/environment/src/EnvironmentData.cpp deleted file mode 100644 index 7a0bd29bc0..0000000000 --- a/libraries/environment/src/EnvironmentData.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// -// EnvironmentData.cpp -// libraries/environment/src -// -// Created by Andrzej Kapolka on 5/6/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include - -#include "EnvironmentData.h" - -// initial values from Sean O'Neil's GPU Gems entry (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html), -// GameEngine.cpp -EnvironmentData::EnvironmentData(int id) : - _id(id), - _flat(true), - _gravity(0.0f), - _atmosphereCenter(0, -1000, 0), - _atmosphereInnerRadius(1000.0), - _atmosphereOuterRadius(1025.0), - _rayleighScattering(0.0025f), - _mieScattering(0.0010f), - _scatteringWavelengths(0.650f, 0.570f, 0.475f), - _sunLocation(1000, 900, 1000), - _sunBrightness(20.0f), - _hasStars(true) { -} - -glm::vec3 EnvironmentData::getAtmosphereCenter(const glm::vec3& cameraPosition) const { - return _atmosphereCenter + (_flat ? glm::vec3(cameraPosition.x, 0.0f, cameraPosition.z) : glm::vec3()); -} - -glm::vec3 EnvironmentData::getSunLocation(const glm::vec3& cameraPosition) const { - return _sunLocation; -} - -size_t EnvironmentData::getBroadcastData(unsigned char* destinationBuffer) const { - unsigned char* bufferStart = destinationBuffer; - - memcpy(destinationBuffer, &_id, sizeof(_id)); - destinationBuffer += sizeof(_id); - - memcpy(destinationBuffer, &_flat, sizeof(_flat)); - destinationBuffer += sizeof(_flat); - - memcpy(destinationBuffer, &_gravity, sizeof(_gravity)); - destinationBuffer += sizeof(_gravity); - - memcpy(destinationBuffer, &_atmosphereCenter, sizeof(_atmosphereCenter)); - destinationBuffer += sizeof(_atmosphereCenter); - - memcpy(destinationBuffer, &_atmosphereInnerRadius, sizeof(_atmosphereInnerRadius)); - destinationBuffer += sizeof(_atmosphereInnerRadius); - - memcpy(destinationBuffer, &_atmosphereOuterRadius, sizeof(_atmosphereOuterRadius)); - destinationBuffer += sizeof(_atmosphereOuterRadius); - - memcpy(destinationBuffer, &_rayleighScattering, sizeof(_rayleighScattering)); - destinationBuffer += sizeof(_rayleighScattering); - - memcpy(destinationBuffer, &_mieScattering, sizeof(_mieScattering)); - destinationBuffer += sizeof(_mieScattering); - - memcpy(destinationBuffer, &_scatteringWavelengths, sizeof(_scatteringWavelengths)); - destinationBuffer += sizeof(_scatteringWavelengths); - - memcpy(destinationBuffer, &_sunLocation, sizeof(_sunLocation)); - destinationBuffer += sizeof(_sunLocation); - - memcpy(destinationBuffer, &_sunBrightness, sizeof(_sunBrightness)); - destinationBuffer += sizeof(_sunBrightness); - - return destinationBuffer - bufferStart; -} - -size_t EnvironmentData::parseData(const unsigned char* sourceBuffer, int numBytes) { - const unsigned char* startPosition = sourceBuffer; - - memcpy(&_id, sourceBuffer, sizeof(_id)); - sourceBuffer += sizeof(_id); - - memcpy(&_flat, sourceBuffer, sizeof(_flat)); - sourceBuffer += sizeof(_flat); - - memcpy(&_gravity, sourceBuffer, sizeof(_gravity)); - sourceBuffer += sizeof(_gravity); - - memcpy(&_atmosphereCenter, sourceBuffer, sizeof(_atmosphereCenter)); - sourceBuffer += sizeof(_atmosphereCenter); - - memcpy(&_atmosphereInnerRadius, sourceBuffer, sizeof(_atmosphereInnerRadius)); - sourceBuffer += sizeof(_atmosphereInnerRadius); - - memcpy(&_atmosphereOuterRadius, sourceBuffer, sizeof(_atmosphereOuterRadius)); - sourceBuffer += sizeof(_atmosphereOuterRadius); - - memcpy(&_rayleighScattering, sourceBuffer, sizeof(_rayleighScattering)); - sourceBuffer += sizeof(_rayleighScattering); - - memcpy(&_mieScattering, sourceBuffer, sizeof(_mieScattering)); - sourceBuffer += sizeof(_mieScattering); - - memcpy(&_scatteringWavelengths, sourceBuffer, sizeof(_scatteringWavelengths)); - sourceBuffer += sizeof(_scatteringWavelengths); - - memcpy(&_sunLocation, sourceBuffer, sizeof(_sunLocation)); - sourceBuffer += sizeof(_sunLocation); - - memcpy(&_sunBrightness, sourceBuffer, sizeof(_sunBrightness)); - sourceBuffer += sizeof(_sunBrightness); - - return sourceBuffer - startPosition; -} - diff --git a/libraries/environment/src/EnvironmentData.h b/libraries/environment/src/EnvironmentData.h deleted file mode 100644 index daed752d4c..0000000000 --- a/libraries/environment/src/EnvironmentData.h +++ /dev/null @@ -1,83 +0,0 @@ -// -// EnvironmentData.h -// libraries/environment/src -// -// Created by Andrzej Kapolka on 5/6/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_EnvironmentData_h -#define hifi_EnvironmentData_h - -#include - -class EnvironmentData { -public: - - EnvironmentData(int id = 0); - - void setID(int id) { _id = id; } - int getID() const { return _id; } - - void setFlat(bool flat) { _flat = flat; } - bool isFlat() const { return _flat; } - - void setGravity(float gravity) { _gravity = gravity; } - float getGravity() const { return _gravity; } - - void setHasStars(bool value) { _hasStars = value; } - bool getHasStars() const { return _hasStars; } - - void setAtmosphereCenter(const glm::vec3& center) { _atmosphereCenter = center; } - void setAtmosphereInnerRadius(float radius) { _atmosphereInnerRadius = radius; } - void setAtmosphereOuterRadius(float radius) { _atmosphereOuterRadius = radius; } - const glm::vec3& getAtmosphereCenter() const { return _atmosphereCenter; } - float getAtmosphereInnerRadius() const { return _atmosphereInnerRadius; } - float getAtmosphereOuterRadius() const { return _atmosphereOuterRadius; } - - void setRayleighScattering(float scattering) { _rayleighScattering = scattering; } - void setMieScattering(float scattering) { _mieScattering = scattering; } - float getRayleighScattering() const { return _rayleighScattering; } - float getMieScattering() const { return _mieScattering; } - - void setScatteringWavelengths(const glm::vec3& wavelengths) { _scatteringWavelengths = wavelengths; } - const glm::vec3& getScatteringWavelengths() const { return _scatteringWavelengths; } - - void setSunLocation(const glm::vec3& location) { _sunLocation = location; } - void setSunBrightness(float brightness) { _sunBrightness = brightness; } - const glm::vec3& getSunLocation() const { return _sunLocation; } - float getSunBrightness() const { return _sunBrightness; } - - glm::vec3 getAtmosphereCenter(const glm::vec3& cameraPosition) const; - glm::vec3 getSunLocation(const glm::vec3& cameraPosition) const; - - size_t getBroadcastData(unsigned char* destinationBuffer) const; - size_t parseData(const unsigned char* sourceBuffer, int numBytes); - -private: - - int _id; - - bool _flat; - - float _gravity; - - glm::vec3 _atmosphereCenter; - float _atmosphereInnerRadius; - float _atmosphereOuterRadius; - - float _rayleighScattering; - float _mieScattering; - - glm::vec3 _scatteringWavelengths; - - glm::vec3 _sunLocation; - float _sunBrightness; - - bool _hasStars; -}; - -#endif // hifi_EnvironmentData_h diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index c74089a238..c4f28aeffd 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -3,7 +3,7 @@ AUTOSCRIBE_SHADER_LIB(gpu model render) # pull in the resources.qrc file qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc") setup_hifi_library(Widgets OpenGL Network Qml Quick Script) -link_hifi_libraries(shared gpu procedural model model-networking render environment animation fbx) +link_hifi_libraries(shared gpu procedural model model-networking render animation fbx) target_nsight() target_oglplus() diff --git a/libraries/render-utils/src/AbstractViewStateInterface.h b/libraries/render-utils/src/AbstractViewStateInterface.h index 1a4cfde16f..815cb45423 100644 --- a/libraries/render-utils/src/AbstractViewStateInterface.h +++ b/libraries/render-utils/src/AbstractViewStateInterface.h @@ -24,7 +24,6 @@ class Transform; class QThread; class ViewFrustum; class PickRay; -class EnvironmentData; /// Interface provided by Application to other objects that need access to the current view state details class AbstractViewStateInterface { @@ -32,10 +31,6 @@ public: /// gets the current view frustum for rendering the view state virtual ViewFrustum* getCurrentViewFrustum() = 0; - /// overrides environment data - virtual void overrideEnvironmentData(const EnvironmentData& newData) = 0; - virtual void endOverrideEnvironmentData() = 0; - /// gets the shadow view frustum for rendering the view state virtual ViewFrustum* getShadowViewFrustum() = 0; diff --git a/libraries/render-utils/src/Environment.cpp b/libraries/render-utils/src/Environment.cpp deleted file mode 100644 index f7327a2b72..0000000000 --- a/libraries/render-utils/src/Environment.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// -// Environment.cpp -// interface/src -// -// Created by Andrzej Kapolka on 5/6/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include -#include -#include - -#include "GeometryCache.h" -#include -#include -#include -#include -#include -#include - -#include "Environment.h" - -#include "SkyFromSpace_vert.h" -#include "SkyFromSpace_frag.h" -#include "SkyFromAtmosphere_vert.h" -#include "SkyFromAtmosphere_frag.h" - -Environment::Environment() - : _initialized(false) { -} - -Environment::~Environment() { -} - -void Environment::init() { - if (_initialized) { - return; - } - - setupAtmosphereProgram(SkyFromSpace_vert, SkyFromSpace_frag, _skyFromSpaceProgram, _skyFromSpaceUniformLocations); - setupAtmosphereProgram(SkyFromAtmosphere_vert, SkyFromAtmosphere_frag, _skyFromAtmosphereProgram, _skyFromAtmosphereUniformLocations); - - // start off with a default-constructed environment data - _data[QUuid()][0]; - - _initialized = true; -} - -void Environment::setupAtmosphereProgram(const char* vertSource, const char* fragSource, gpu::PipelinePointer& pipeline, int* locations) { - - auto VS = gpu::Shader::createVertex(std::string(vertSource)); - auto PS = gpu::Shader::createPixel(std::string(fragSource)); - - gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS); - - gpu::Shader::BindingSet slotBindings; - gpu::Shader::makeProgram(*program, slotBindings); - - auto state = std::make_shared(); - - state->setCullMode(gpu::State::CULL_NONE); - state->setStencilTest(true, 0xFF, gpu::State::StencilTest(0, 0xFF, gpu::EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP)); - state->setBlendFunction(true, - gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, - gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - - pipeline = gpu::Pipeline::create(program, state); - - locations[CAMERA_POS_LOCATION] = program->getUniforms().findLocation("v3CameraPos"); - locations[LIGHT_POS_LOCATION] = program->getUniforms().findLocation("v3LightPos"); - locations[INV_WAVELENGTH_LOCATION] = program->getUniforms().findLocation("v3InvWavelength"); - locations[CAMERA_HEIGHT2_LOCATION] = program->getUniforms().findLocation("fCameraHeight2"); - locations[OUTER_RADIUS_LOCATION] = program->getUniforms().findLocation("fOuterRadius"); - locations[OUTER_RADIUS2_LOCATION] = program->getUniforms().findLocation("fOuterRadius2"); - locations[INNER_RADIUS_LOCATION] = program->getUniforms().findLocation("fInnerRadius"); - locations[KR_ESUN_LOCATION] = program->getUniforms().findLocation("fKrESun"); - locations[KM_ESUN_LOCATION] = program->getUniforms().findLocation("fKmESun"); - locations[KR_4PI_LOCATION] = program->getUniforms().findLocation("fKr4PI"); - locations[KM_4PI_LOCATION] = program->getUniforms().findLocation("fKm4PI"); - locations[SCALE_LOCATION] = program->getUniforms().findLocation("fScale"); - locations[SCALE_DEPTH_LOCATION] = program->getUniforms().findLocation("fScaleDepth"); - locations[SCALE_OVER_SCALE_DEPTH_LOCATION] = program->getUniforms().findLocation("fScaleOverScaleDepth"); - locations[G_LOCATION] = program->getUniforms().findLocation("g"); - locations[G2_LOCATION] = program->getUniforms().findLocation("g2"); -} - -void Environment::resetToDefault() { - _data.clear(); - _data[QUuid()][0]; -} - -void Environment::renderAtmospheres(gpu::Batch& batch, ViewFrustum& viewFrustum) { - // get the lock for the duration of the call - QMutexLocker locker(&_mutex); - - if (_environmentIsOverridden) { - renderAtmosphere(batch, viewFrustum, _overrideData); - } else { - foreach (const ServerData& serverData, _data) { - // TODO: do something about EnvironmentData - foreach (const EnvironmentData& environmentData, serverData) { - renderAtmosphere(batch, viewFrustum, environmentData); - } - } - } -} - -EnvironmentData Environment::getClosestData(const glm::vec3& position) { - if (_environmentIsOverridden) { - return _overrideData; - } - - // get the lock for the duration of the call - QMutexLocker locker(&_mutex); - - EnvironmentData closest; - float closestDistance = FLT_MAX; - foreach (const ServerData& serverData, _data) { - foreach (const EnvironmentData& environmentData, serverData) { - float distance = glm::distance(position, environmentData.getAtmosphereCenter(position)) - - environmentData.getAtmosphereOuterRadius(); - if (distance < closestDistance) { - closest = environmentData; - closestDistance = distance; - } - } - } - return closest; -} - - -// NOTE: Deprecated - I'm leaving this in for now, but it's not actually used. I made it private -// so that if anyone wants to start using this in the future they will consider how to make it -// work with new physics systems. -glm::vec3 Environment::getGravity (const glm::vec3& position) { - // - // 'Default' gravity pulls you downward in Y when you are near the X/Z plane - const glm::vec3 DEFAULT_GRAVITY(0.0f, -1.0f, 0.0f); - glm::vec3 gravity(DEFAULT_GRAVITY); - float DEFAULT_SURFACE_RADIUS = 30.0f; - float gravityStrength; - - // Weaken gravity with height - if (position.y > 0.0f) { - gravityStrength = 1.0f / powf((DEFAULT_SURFACE_RADIUS + position.y) / DEFAULT_SURFACE_RADIUS, 2.0f); - gravity *= gravityStrength; - } - - // get the lock for the duration of the call - QMutexLocker locker(&_mutex); - - foreach (const ServerData& serverData, _data) { - foreach (const EnvironmentData& environmentData, serverData) { - glm::vec3 vector = environmentData.getAtmosphereCenter(position) - position; - float surfaceRadius = environmentData.getAtmosphereInnerRadius(); - if (glm::length(vector) <= surfaceRadius) { - // At or inside a planet, gravity is as set for the planet - gravity += glm::normalize(vector) * environmentData.getGravity(); - } else { - // Outside a planet, the gravity falls off with distance - gravityStrength = 1.0f / powf(glm::length(vector) / surfaceRadius, 2.0f); - gravity += glm::normalize(vector) * environmentData.getGravity() * gravityStrength; - } - } - } - - return gravity; -} - -bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, - float radius, glm::vec3& penetration) { - // collide with the "floor" - bool found = findCapsulePlanePenetration(start, end, radius, glm::vec4(0.0f, 1.0f, 0.0f, 0.0f), penetration); - - glm::vec3 middle = (start + end) * 0.5f; - - // get the lock for the duration of the call - QMutexLocker locker(&_mutex); - - foreach (const ServerData& serverData, _data) { - foreach (const EnvironmentData& environmentData, serverData) { - if (environmentData.getGravity() == 0.0f) { - continue; // don't bother colliding with gravity-less environments - } - glm::vec3 environmentPenetration; - if (findCapsuleSpherePenetration(start, end, radius, environmentData.getAtmosphereCenter(middle), - environmentData.getAtmosphereInnerRadius(), environmentPenetration)) { - penetration = addPenetrations(penetration, environmentPenetration); - found = true; - } - } - } - return found; -} - -void Environment::renderAtmosphere(gpu::Batch& batch, ViewFrustum& viewFrustum, const EnvironmentData& data) { - glm::vec3 center = data.getAtmosphereCenter(); - - // transform the model transform to the center of our atmosphere - Transform transform; - transform.setTranslation(center); - batch.setModelTransform(transform); - - // Make sure our view and projection transforms are correct for our viewFrustum - Transform viewTransform; - viewFrustum.evalViewTransform(viewTransform); - batch.setViewTransform(viewTransform); - - glm::mat4 projMat; - viewFrustum.evalProjectionMatrix(projMat); - batch.setProjectionTransform(projMat); - - glm::vec3 relativeCameraPos = viewFrustum.getPosition() - center; - float height = glm::length(relativeCameraPos); - - // use the appropriate shader depending on whether we're inside or outside - int* locations; - if (height < data.getAtmosphereOuterRadius()) { - batch.setPipeline(_skyFromAtmosphereProgram); - locations = _skyFromAtmosphereUniformLocations; - } else { - batch.setPipeline(_skyFromSpaceProgram); - locations = _skyFromSpaceUniformLocations; - } - - - // the constants here are from Sean O'Neil's GPU Gems entry - // (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html), GameEngine.cpp - batch._glUniform3f(locations[CAMERA_POS_LOCATION], relativeCameraPos.x, relativeCameraPos.y, relativeCameraPos.z); - glm::vec3 lightDirection = glm::normalize(data.getSunLocation()); - batch._glUniform3f(locations[LIGHT_POS_LOCATION], lightDirection.x, lightDirection.y, lightDirection.z); - batch._glUniform3f(locations[INV_WAVELENGTH_LOCATION], - 1 / powf(data.getScatteringWavelengths().r, 4.0f), - 1 / powf(data.getScatteringWavelengths().g, 4.0f), - 1 / powf(data.getScatteringWavelengths().b, 4.0f)); - batch._glUniform1f(locations[CAMERA_HEIGHT2_LOCATION], height * height); - batch._glUniform1f(locations[OUTER_RADIUS_LOCATION], data.getAtmosphereOuterRadius()); - batch._glUniform1f(locations[OUTER_RADIUS2_LOCATION], data.getAtmosphereOuterRadius() * data.getAtmosphereOuterRadius()); - batch._glUniform1f(locations[INNER_RADIUS_LOCATION], data.getAtmosphereInnerRadius()); - batch._glUniform1f(locations[KR_ESUN_LOCATION], data.getRayleighScattering() * data.getSunBrightness()); - batch._glUniform1f(locations[KM_ESUN_LOCATION], data.getMieScattering() * data.getSunBrightness()); - batch._glUniform1f(locations[KR_4PI_LOCATION], data.getRayleighScattering() * 4.0f * PI); - batch._glUniform1f(locations[KM_4PI_LOCATION], data.getMieScattering() * 4.0f * PI); - batch._glUniform1f(locations[SCALE_LOCATION], 1.0f / (data.getAtmosphereOuterRadius() - data.getAtmosphereInnerRadius())); - batch._glUniform1f(locations[SCALE_DEPTH_LOCATION], 0.25f); - batch._glUniform1f(locations[SCALE_OVER_SCALE_DEPTH_LOCATION], - (1.0f / (data.getAtmosphereOuterRadius() - data.getAtmosphereInnerRadius())) / 0.25f); - batch._glUniform1f(locations[G_LOCATION], -0.990f); - batch._glUniform1f(locations[G2_LOCATION], -0.990f * -0.990f); - - batch._glColor4f(1.0f, 0.0f, 0.0f, 0.5f); - DependencyManager::get()->renderSphere(batch); //Draw a unit sphere -} diff --git a/libraries/render-utils/src/Environment.h b/libraries/render-utils/src/Environment.h deleted file mode 100644 index af5a3c3df5..0000000000 --- a/libraries/render-utils/src/Environment.h +++ /dev/null @@ -1,85 +0,0 @@ -// -// Environment.h -// interface/src -// -// Created by Andrzej Kapolka on 5/6/13. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_Environment_h -#define hifi_Environment_h - -#include -#include - -#include -#include - -#include - -class ViewFrustum; - -class Environment { -public: - Environment(); - ~Environment(); - - void init(); - void resetToDefault(); - void renderAtmospheres(gpu::Batch& batch, ViewFrustum& viewFrustum); - - void override(const EnvironmentData& overrideData) { _overrideData = overrideData; _environmentIsOverridden = true; } - void endOverride() { _environmentIsOverridden = false; } - - EnvironmentData getClosestData(const glm::vec3& position); - -private: - glm::vec3 getGravity (const glm::vec3& position); // NOTE: Deprecated - bool findCapsulePenetration(const glm::vec3& start, - const glm::vec3& end, float radius, glm::vec3& penetration); // NOTE: Deprecated - - void renderAtmosphere(gpu::Batch& batch, ViewFrustum& viewFrustum, const EnvironmentData& data); - - bool _initialized; - - enum { - CAMERA_POS_LOCATION, - LIGHT_POS_LOCATION, - INV_WAVELENGTH_LOCATION, - CAMERA_HEIGHT2_LOCATION, - OUTER_RADIUS_LOCATION, - OUTER_RADIUS2_LOCATION, - INNER_RADIUS_LOCATION, - KR_ESUN_LOCATION, - KM_ESUN_LOCATION, - KR_4PI_LOCATION, - KM_4PI_LOCATION, - SCALE_LOCATION, - SCALE_DEPTH_LOCATION, - SCALE_OVER_SCALE_DEPTH_LOCATION, - G_LOCATION, - G2_LOCATION, - LOCATION_COUNT - }; - - void setupAtmosphereProgram(const char* vertSource, const char* fragSource, gpu::PipelinePointer& pipelineProgram, int* locations); - - - gpu::PipelinePointer _skyFromAtmosphereProgram; - gpu::PipelinePointer _skyFromSpaceProgram; - int _skyFromAtmosphereUniformLocations[LOCATION_COUNT]; - int _skyFromSpaceUniformLocations[LOCATION_COUNT]; - - typedef QHash ServerData; - - QHash _data; - EnvironmentData _overrideData; - bool _environmentIsOverridden = false; - - QMutex _mutex; -}; - -#endif // hifi_Environment_h diff --git a/tests/entities/CMakeLists.txt b/tests/entities/CMakeLists.txt index 81b8b86368..b12771b368 100644 --- a/tests/entities/CMakeLists.txt +++ b/tests/entities/CMakeLists.txt @@ -7,6 +7,6 @@ setup_hifi_project(Network Script) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") # link in the shared libraries -link_hifi_libraries(entities avatars shared octree gpu model fbx networking animation environment) +link_hifi_libraries(entities avatars shared octree gpu model fbx networking animation) package_libraries_for_deployment() diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index 9f9315ba2b..224b97c75c 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -2,7 +2,7 @@ # Declare dependencies macro (setup_testcase_dependencies) # link in the shared libraries - link_hifi_libraries(shared octree gpu model fbx networking environment entities avatars audio animation script-engine physics) + link_hifi_libraries(shared octree gpu model fbx networking entities avatars audio animation script-engine physics) package_libraries_for_deployment() endmacro () diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt index 3ba29c5626..e95970dd53 100644 --- a/tests/shaders/CMakeLists.txt +++ b/tests/shaders/CMakeLists.txt @@ -8,7 +8,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") #include_oglplus() # link in the shared libraries -link_hifi_libraries(shared octree environment gl gpu model render fbx networking entities +link_hifi_libraries(shared octree gl gpu model render fbx networking entities script-engine physics render-utils entities-renderer)