diff --git a/cmake/macros/AutoScribeShader.cmake b/cmake/macros/AutoScribeShader.cmake index f5a497962c..20aa334134 100755 --- a/cmake/macros/AutoScribeShader.cmake +++ b/cmake/macros/AutoScribeShader.cmake @@ -268,6 +268,7 @@ macro(AUTOSCRIBE_SHADER_LIB) set(PROGRAM_ENUMS "namespace program { enum {\n") foreach(PROGRAM_FILE ${SHADER_PROGRAM_FILES}) get_filename_component(PROGRAM_NAME ${PROGRAM_FILE} NAME_WE) + get_filename_component(PROGRAM_FOLDER ${PROGRAM_FILE} DIRECTORY) file(READ ${PROGRAM_FILE} PROGRAM_CONFIG) set(AUTOSCRIBE_PROGRAM_VERTEX ${PROGRAM_NAME}) set(AUTOSCRIBE_PROGRAM_FRAGMENT ${PROGRAM_NAME}) @@ -315,7 +316,11 @@ macro(AUTOSCRIBE_SHADER_LIB) if (HAS_FRAGMENT EQUAL -1) set(DEFINES "${VERTEX_DEFINES}") set(SHADER_LIST "") - set(SHADER_FILE "${SRC_FOLDER}/${VERTEX_NAME}.slv") + set(SHADER_FILE "${PROGRAM_FOLDER}/${VERTEX_NAME}.slv") + if (NOT EXISTS "${SHADER_FILE}") + set(SHADER_FILE "${PROGRAM_FOLDER}/../${VERTEX_NAME}.slv") + endif() + find_file(SHADER_FILE "" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES ".." NO_DEFAULT_PATH) AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}") else() @@ -331,7 +336,10 @@ macro(AUTOSCRIBE_SHADER_LIB) if (HAS_VERTEX EQUAL -1) set(DEFINES "${FRAGMENT_DEFINES}") set(SHADER_LIST "") - set(SHADER_FILE "${SRC_FOLDER}/${FRAGMENT_NAME}.slf") + set(SHADER_FILE "${PROGRAM_FOLDER}/${FRAGMENT_NAME}.slf") + if (NOT EXISTS "${SHADER_FILE}") + set(SHADER_FILE "${PROGRAM_FOLDER}/../${FRAGMENT_NAME}.slf") + endif() AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}") else() diff --git a/cmake/macros/SetupQt.cmake b/cmake/macros/SetupQt.cmake index 3ef0f9cde8..c09c2b0f6b 100644 --- a/cmake/macros/SetupQt.cmake +++ b/cmake/macros/SetupQt.cmake @@ -52,14 +52,8 @@ macro(setup_qt) message(FATAL_ERROR "VCPKG_QT_CMAKE_PREFIX_PATH should have been set by hifi_vcpkg.py") endif() if (NOT DEV_BUILD) - if (UNIX AND DEFINED ENV{QT_CMAKE_PREFIX_PATH} AND NOT APPLE) - # HACK: obey QT_CMAKE_PREFIX_PATH to allow UNIX to use older QT libs - message("HACK: obey QT_CMAKE_PREFIX_PATH on UNIX") - set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) - else() - message("override QT_CMAKE_PREFIX_PATH with VCPKG_QT_CMAKE_PREFIX_PATH") - set(QT_CMAKE_PREFIX_PATH ${VCPKG_QT_CMAKE_PREFIX_PATH}) - endif() + message("override QT_CMAKE_PREFIX_PATH with VCPKG_QT_CMAKE_PREFIX_PATH") + set(QT_CMAKE_PREFIX_PATH ${VCPKG_QT_CMAKE_PREFIX_PATH}) else() # DEV_BUILD if (DEFINED ENV{QT_CMAKE_PREFIX_PATH}) diff --git a/hifi_vcpkg.py b/hifi_vcpkg.py index 686ccfcfc7..764a6270bd 100644 --- a/hifi_vcpkg.py +++ b/hifi_vcpkg.py @@ -259,7 +259,7 @@ endif() url = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/qt5-install-5.12.3-macos3.tar.gz' elif platform.system() == 'Linux': if platform.linux_distribution()[1][:3] == '16.': - url = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04.tar.gz' + url = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' elif platform.linux_distribution()[1][:3] == '18.': url = 'https://hifi-public.s3.amazonaws.com/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-18.04.tar.gz' else: diff --git a/interface/resources/avatar/animations/teleport.fbx b/interface/resources/avatar/animations/teleport.fbx new file mode 100644 index 0000000000..99c950ced6 Binary files /dev/null and b/interface/resources/avatar/animations/teleport.fbx differ diff --git a/interface/resources/qml/InteractiveWindow.qml b/interface/resources/qml/InteractiveWindow.qml index 9136de9dcf..b27668f70c 100644 --- a/interface/resources/qml/InteractiveWindow.qml +++ b/interface/resources/qml/InteractiveWindow.qml @@ -30,7 +30,6 @@ Windows.Window { signal selfDestruct(); - property var flags: 0; property var additionalFlags: 0; property var overrideFlags: 0; @@ -158,8 +157,7 @@ Windows.Window { if (Qt.platform.os !== "windows" && (root.additionalFlags & Desktop.ALWAYS_ON_TOP)) { nativeWindowFlags |= Qt.WindowStaysOnTopHint; } - root.flags = root.overrideFlags || nativeWindowFlags; - nativeWindow.flags = root.flags; + nativeWindow.flags = root.overrideFlags || nativeWindowFlags; nativeWindow.x = interactiveWindowPosition.x; nativeWindow.y = interactiveWindowPosition.y; @@ -317,7 +315,7 @@ Windows.Window { // set invisible on close, to make it not re-appear unintended after switching PresentationMode interactiveWindowVisible = false; - if ((root.flags & Desktop.CLOSE_BUTTON_HIDES) !== Desktop.CLOSE_BUTTON_HIDES) { + if ((root.additionalFlags & Desktop.CLOSE_BUTTON_HIDES) !== Desktop.CLOSE_BUTTON_HIDES) { selfDestruct(); } } diff --git a/interface/resources/qml/controlsUit/ComboBox.qml b/interface/resources/qml/controlsUit/ComboBox.qml index 8d1d7a5262..1a904df89d 100644 --- a/interface/resources/qml/controlsUit/ComboBox.qml +++ b/interface/resources/qml/controlsUit/ComboBox.qml @@ -22,6 +22,7 @@ FocusScope { property alias editable: comboBox.editable property alias comboBox: comboBox readonly property alias currentText: comboBox.currentText; + property alias displayText: comboBox.displayText; property alias currentIndex: comboBox.currentIndex; property int currentHighLightedIndex: comboBox.currentIndex; diff --git a/interface/resources/qml/hifi/dialogs/graphics/GraphicsSettings.qml b/interface/resources/qml/hifi/dialogs/graphics/GraphicsSettings.qml new file mode 100644 index 0000000000..8634648d17 --- /dev/null +++ b/interface/resources/qml/hifi/dialogs/graphics/GraphicsSettings.qml @@ -0,0 +1,379 @@ +// +// GraphicsSettings.qml +// qml\hifi\dialogs\graphics +// +// Created by Zach Fox on 2019-07-10 +// Copyright 2019 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 +// + +import Hifi 1.0 as Hifi +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.12 +import stylesUit 1.0 as HifiStylesUit +import controlsUit 1.0 as HifiControlsUit +import "qrc:////qml//controls" as HifiControls +import PerformanceEnums 1.0 + +Item { + HifiStylesUit.HifiConstants { id: hifi; } + + id: root; + anchors.fill: parent + + ColumnLayout { + id: graphicsSettingsColumnLayout + anchors.left: parent.left + anchors.leftMargin: 26 + anchors.right: parent.right + anchors.rightMargin: 26 + anchors.top: parent.top + anchors.topMargin: HMD.active ? 80 : 0 + spacing: 8 + + ColumnLayout { + Layout.preferredWidth: parent.width + Layout.topMargin: 18 + spacing: 0 + + HifiStylesUit.RalewayRegular { + text: "GRAPHICS SETTINGS" + Layout.maximumWidth: parent.width + height: 30 + size: 16 + color: "#FFFFFF" + } + + ColumnLayout { + Layout.topMargin: 10 + Layout.preferredWidth: parent.width + spacing: 0 + + HifiControlsUit.RadioButton { + id: performanceLow + colorScheme: hifi.colorSchemes.dark + height: 18 + fontSize: 16 + leftPadding: 0 + text: "Low" + checked: Performance.getPerformancePreset() === PerformanceEnums.LOW + onClicked: { + Performance.setPerformancePreset(PerformanceEnums.LOW); + root.refreshAllDropdowns(); + } + } + + HifiControlsUit.RadioButton { + id: performanceMedium + colorScheme: hifi.colorSchemes.dark + height: 18 + fontSize: 16 + leftPadding: 0 + text: "Medium" + checked: Performance.getPerformancePreset() === PerformanceEnums.MID + onClicked: { + Performance.setPerformancePreset(PerformanceEnums.MID); + root.refreshAllDropdowns(); + } + } + + HifiControlsUit.RadioButton { + id: performanceHigh + colorScheme: hifi.colorSchemes.dark + height: 18 + fontSize: 16 + leftPadding: 0 + text: "High" + checked: Performance.getPerformancePreset() === PerformanceEnums.HIGH + onClicked: { + Performance.setPerformancePreset(PerformanceEnums.HIGH); + root.refreshAllDropdowns(); + } + } + + HifiControlsUit.RadioButton { + id: performanceCustom + colorScheme: hifi.colorSchemes.dark + height: 18 + fontSize: 16 + leftPadding: 0 + text: "Custom" + checked: Performance.getPerformancePreset() === PerformanceEnums.UNKNOWN + onClicked: { + Performance.setPerformancePreset(PerformanceEnums.UNKNOWN); + } + } + } + + ColumnLayout { + Layout.topMargin: 10 + Layout.preferredWidth: parent.width + spacing: 0 + + Item { + Layout.preferredWidth: parent.width + Layout.preferredHeight: 35 + + HifiStylesUit.RalewayRegular { + id: worldDetailHeader + text: "World Detail" + anchors.left: parent.left + anchors.top: parent.top + width: 130 + height: parent.height + size: 16 + color: "#FFFFFF" + } + + ListModel { + id: worldDetailModel + + ListElement { + text: "Low World Detail" + worldDetailQualityValue: 0.25 + } + ListElement { + text: "Medium World Detail" + worldDetailQualityValue: 0.5 + } + ListElement { + text: "Full World Detail" + worldDetailQualityValue: 0.75 + } + } + + HifiControlsUit.ComboBox { + id: worldDetailDropdown + enabled: performanceCustom.checked + anchors.left: worldDetailHeader.right + anchors.leftMargin: 20 + anchors.top: parent.top + width: 280 + height: parent.height + colorScheme: hifi.colorSchemes.dark + model: worldDetailModel + currentIndex: -1 + + function refreshWorldDetailDropdown() { + var currentWorldDetailQuality = LODManager.worldDetailQuality; + if (currentWorldDetailQuality <= 0.25) { + worldDetailDropdown.currentIndex = 0; + } else if (currentWorldDetailQuality <= 0.5) { + worldDetailDropdown.currentIndex = 1; + } else { + worldDetailDropdown.currentIndex = 2; + } + } + + Component.onCompleted: { + worldDetailDropdown.refreshWorldDetailDropdown(); + } + + onCurrentIndexChanged: { + LODManager.worldDetailQuality = model.get(currentIndex).worldDetailQualityValue; + worldDetailDropdown.displayText = model.get(currentIndex).text; + } + } + } + + Item { + Layout.preferredWidth: parent.width + Layout.preferredHeight: 35 + Layout.topMargin: 20 + + HifiStylesUit.RalewayRegular { + id: renderingEffectsHeader + text: "Rendering Effects" + anchors.left: parent.left + anchors.top: parent.top + width: 130 + height: parent.height + size: 16 + color: "#FFFFFF" + } + + ListModel { + id: renderingEffectsModel + + ListElement { + text: "No Rendering Effects" + preferredRenderMethod: 1 // "FORWARD" + shadowsEnabled: false + } + ListElement { + text: "Local Lights, Fog, Bloom" + preferredRenderMethod: 0 // "DEFERRED" + shadowsEnabled: false + } + ListElement { + text: "Local Lights, Fog, Bloom, Shadows" + preferredRenderMethod: 0 // "DEFERRED" + shadowsEnabled: true + } + } + + HifiControlsUit.ComboBox { + id: renderingEffectsDropdown + enabled: performanceCustom.checked + anchors.left: renderingEffectsHeader.right + anchors.leftMargin: 20 + anchors.top: parent.top + width: 280 + height: parent.height + colorScheme: hifi.colorSchemes.dark + model: renderingEffectsModel + currentIndex: -1 + + function refreshRenderingEffectsDropdownDisplay() { + if (Render.shadowsEnabled) { + renderingEffectsDropdown.currentIndex = 2; + } else if (Render.renderMethod === 0) { + renderingEffectsDropdown.currentIndex = 1; + } else { + renderingEffectsDropdown.currentIndex = 0; + } + } + + Component.onCompleted: { + renderingEffectsDropdown.refreshRenderingEffectsDropdownDisplay(); + } + + onCurrentIndexChanged: { + var renderMethodToSet = 1; + if (model.get(currentIndex).preferredRenderMethod === 0 && + PlatformInfo.isRenderMethodDeferredCapable()) { + renderMethodToSet = 0; + } + Render.renderMethod = renderMethodToSet; + Render.shadowsEnabled = model.get(currentIndex).shadowsEnabled; + renderingEffectsDropdown.displayText = model.get(currentIndex).text; + } + } + } + + Item { + Layout.preferredWidth: parent.width + Layout.preferredHeight: 35 + Layout.topMargin: 20 + + HifiStylesUit.RalewayRegular { + id: refreshRateHeader + text: "Refresh Rate" + anchors.left: parent.left + anchors.top: parent.top + width: 130 + height: parent.height + size: 16 + color: "#FFFFFF" + } + + ListModel { + id: refreshRateModel + + ListElement { + text: "Economical" + refreshRatePreset: 0 // RefreshRateProfile::ECO + } + ListElement { + text: "Interactive" + refreshRatePreset: 1 // RefreshRateProfile::INTERACTIVE + } + ListElement { + text: "Real-Time" + refreshRatePreset: 2 // RefreshRateProfile::REALTIME + } + } + + HifiControlsUit.ComboBox { + id: refreshRateDropdown + enabled: performanceCustom.checked + anchors.left: refreshRateHeader.right + anchors.leftMargin: 20 + anchors.top: parent.top + width: 280 + height: parent.height + colorScheme: hifi.colorSchemes.dark + model: refreshRateModel + currentIndex: -1 + + function refreshRefreshRateDropdownDisplay() { + if (Performance.getRefreshRateProfile() === 0) { + refreshRateDropdown.currentIndex = 0; + } else if (Performance.getRefreshRateProfile() === 1) { + refreshRateDropdown.currentIndex = 1; + } else { + refreshRateDropdown.currentIndex = 2; + } + } + + Component.onCompleted: { + refreshRateDropdown.refreshRefreshRateDropdownDisplay(); + } + + onCurrentIndexChanged: { + Performance.setRefreshRateProfile(model.get(currentIndex).refreshRatePreset); + refreshRateDropdown.displayText = model.get(currentIndex).text; + } + } + } + + Item { + Layout.preferredWidth: parent.width + Layout.preferredHeight: 35 + Layout.topMargin: 16 + + HifiStylesUit.RalewayRegular { + id: resolutionHeader + text: "Resolution Scale (" + Number.parseFloat(Render.viewportResolutionScale).toPrecision(3) + ")" + anchors.left: parent.left + anchors.top: parent.top + width: 130 + height: parent.height + size: 16 + color: "#FFFFFF" + } + + HifiControlsUit.Slider { + id: resolutionScaleSlider + enabled: performanceCustom.checked + anchors.left: resolutionHeader.right + anchors.leftMargin: 57 + anchors.top: parent.top + width: 150 + height: parent.height + colorScheme: hifi.colorSchemes.dark + minimumValue: 0.25 + maximumValue: 1.0 + stepSize: 0.02 + value: Render.viewportResolutionScale + live: true + + function updateResolutionScale(sliderValue) { + if (Render.viewportResolutionScale !== sliderValue) { + Render.viewportResolutionScale = sliderValue; + } + } + + onValueChanged: { + updateResolutionScale(value); + } + onPressedChanged: { + if (!pressed) { + updateResolutionScale(value); + } + } + } + } + } + } + } + + function refreshAllDropdowns() { + worldDetailDropdown.refreshWorldDetailDropdown(); + renderingEffectsDropdown.refreshRenderingEffectsDropdownDisplay(); + refreshRateDropdown.refreshRefreshRateDropdownDisplay(); + } +} diff --git a/interface/resources/qml/hifi/simplifiedUI/avatarApp/components/DisplayNameHeader.qml b/interface/resources/qml/hifi/simplifiedUI/avatarApp/components/DisplayNameHeader.qml index becbd8ca61..8938fb9b0b 100644 --- a/interface/resources/qml/hifi/simplifiedUI/avatarApp/components/DisplayNameHeader.qml +++ b/interface/resources/qml/hifi/simplifiedUI/avatarApp/components/DisplayNameHeader.qml @@ -91,7 +91,7 @@ Item { SimplifiedControls.TextField { id: myDisplayNameText - text: MyAvatar.sessionDisplayName === "" ? MyAvatar.displayName : MyAvatar.sessionDisplayName + text: MyAvatar.displayName maximumLength: 256 clip: true selectByMouse: true diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b59fd223ba..ad38599dcf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -257,6 +257,10 @@ extern "C" { } #endif +#ifdef Q_OS_MAC +#include "MacHelper.h" +#endif + #if defined(Q_OS_ANDROID) #include #include "AndroidHelper.h" @@ -960,6 +964,9 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); +#ifdef Q_OS_MAC + DependencyManager::set(); +#endif QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark"); if (!setBookmarkValue.isEmpty()) { @@ -1187,6 +1194,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo } auto accountManager = DependencyManager::get(); + // set the account manager's root URL and trigger a login request if we don't have the access token + accountManager->setIsAgent(true); + accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + if (!accountManager->hasKeyPair()) { + accountManager->generateNewUserKeypair(); + } + #ifndef Q_OS_ANDROID _logger->setSessionID(accountManager->getSessionID()); #endif @@ -1334,10 +1348,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo #endif connect(accountManager.data(), &AccountManager::usernameChanged, this, &Application::updateWindowTitle); - // set the account manager's root URL and trigger a login request if we don't have the access token - accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); - // use our MyAvatar position and quat for address manager path addressManager->setPositionGetter([] { auto avatarManager = DependencyManager::get(); @@ -2807,7 +2817,7 @@ void Application::cleanupBeforeQuit() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - + DependencyManager::destroy(); _snapshotSoundInjector = nullptr; @@ -2853,6 +2863,9 @@ Application::~Application() { _gameWorkload.shutdown(); DependencyManager::destroy(); +#ifdef Q_OS_MAC + DependencyManager::destroy(); +#endif _entityClipboard->eraseAllOctreeElements(); _entityClipboard.reset(); @@ -4429,27 +4442,6 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; - case Qt::Key_P: { - if (!isShifted && !isMeta && !isOption && !event->isAutoRepeat()) { - AudioInjectorOptions options; - options.localOnly = true; - options.positionSet = false; // system sound - options.stereo = true; - - Setting::Handle notificationSounds{ MenuOption::NotificationSounds, true }; - Setting::Handle notificationSoundSnapshot{ MenuOption::NotificationSoundsSnapshot, true }; - if (notificationSounds.get() && notificationSoundSnapshot.get()) { - if (_snapshotSoundInjector) { - DependencyManager::get()->setOptionsAndRestart(_snapshotSoundInjector, options); - } else { - _snapshotSoundInjector = DependencyManager::get()->playSound(_snapshotSound, options); - } - } - takeSnapshot(true); - } - break; - } - case Qt::Key_Apostrophe: { if (isMeta) { auto cursor = Cursor::Manager::instance().getCursor(); @@ -5994,6 +5986,7 @@ void Application::resetPhysicsReadyInformation() { _gpuTextureMemSizeStabilityCount = 0; _gpuTextureMemSizeAtLastCheck = 0; _physicsEnabled = false; + _octreeProcessor.stopSafeLanding(); } void Application::reloadResourceCaches() { @@ -6253,6 +6246,7 @@ void Application::tryToEnablePhysics() { // We keep physics disabled until we've received a full scene and everything near the avatar in that // scene is ready to compute its collision shape. if (getMyAvatar()->isReadyForPhysics()) { + _octreeProcessor.resetSafeLanding(); _physicsEnabled = true; setIsInterstitialMode(false); getMyAvatar()->updateMotionBehaviorFromMenu(); @@ -6776,6 +6770,12 @@ void Application::update(float deltaTime) { if (!getActiveDisplayPlugin()->isActive()) { getMain3DScene()->processTransactionQueue(); } + + // decide if the sensorToWorldMatrix is changing in a way that warrents squeezing the edges of the view down + if (getActiveDisplayPlugin()->isHmd()) { + PerformanceTimer perfTimer("squeezeVision"); + _visionSqueeze.updateVisionSqueeze(myAvatar->getSensorToWorldMatrix(), deltaTime); + } } void Application::updateRenderArgs(float deltaTime) { @@ -6982,13 +6982,16 @@ int Application::sendNackPackets() { } void Application::queryOctree(NodeType_t serverType, PacketType packetType) { - if (!_settingsLoaded) { return; // bail early if settings are not loaded } const bool isModifiedQuery = !_physicsEnabled; if (isModifiedQuery) { + if (!_octreeProcessor.safeLandingIsActive()) { + // don't send the octreeQuery until SafeLanding knows it has started + return; + } // Create modified view that is a simple sphere. bool interstitialModeEnabled = DependencyManager::get()->getDomainHandler().getInterstitialModeEnabled(); @@ -7211,7 +7214,6 @@ void Application::clearDomainOctreeDetails(bool clearAll) { void Application::domainURLChanged(QUrl domainURL) { // disable physics until we have enough information about our new location to not cause craziness. - resetPhysicsReadyInformation(); setIsServerlessMode(domainURL.scheme() != URL_SCHEME_HIFI); if (isServerlessMode()) { loadServerlessDomain(domainURL); @@ -7221,7 +7223,6 @@ void Application::domainURLChanged(QUrl domainURL) { void Application::goToErrorDomainURL(QUrl errorDomainURL) { // disable physics until we have enough information about our new location to not cause craziness. - resetPhysicsReadyInformation(); setIsServerlessMode(errorDomainURL.scheme() != URL_SCHEME_HIFI); if (isServerlessMode()) { loadErrorDomain(errorDomainURL); @@ -7238,12 +7239,12 @@ void Application::resettingDomain() { void Application::nodeAdded(SharedNodePointer node) { if (node->getType() == NodeType::EntityServer) { if (_failedToConnectToEntityServer && !_entityServerConnectionTimer.isActive()) { - _failedToConnectToEntityServer = false; _octreeProcessor.stopSafeLanding(); - _octreeProcessor.startSafeLanding(); + _failedToConnectToEntityServer = false; } else if (_entityServerConnectionTimer.isActive()) { _entityServerConnectionTimer.stop(); } + _octreeProcessor.startSafeLanding(); _entityServerConnectionTimer.setInterval(ENTITY_SERVER_CONNECTION_TIMEOUT); _entityServerConnectionTimer.start(); } @@ -7318,7 +7319,7 @@ void Application::nodeKilled(SharedNodePointer node) { _octreeProcessor.nodeKilled(node); _entityEditSender.nodeKilled(node); - + if (node->getType() == NodeType::AudioMixer) { QMetaObject::invokeMethod(DependencyManager::get().data(), "audioMixerKilled"); } else if (node->getType() == NodeType::EntityServer) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 2d6821bbd9..1e7180e203 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -78,6 +78,7 @@ #include #include "Sound.h" +#include "VisionSqueeze.h" class GLCanvas; class FaceTracker; @@ -364,6 +365,9 @@ public: void forceLoginWithTokens(const QString& tokens); void setConfigFileURL(const QString& fileUrl); + // used by preferences and HMDScriptingInterface... + VisionSqueeze& getVisionSqueeze() { return _visionSqueeze; } + signals: void svoImportRequested(const QString& url); @@ -731,6 +735,7 @@ private: bool _loginDialogPoppedUp{ false }; bool _desktopRootItemCreated{ false }; + bool _developerMenuVisible{ false }; QString _previousAvatarSkeletonModel; float _previousAvatarTargetScale; @@ -837,5 +842,7 @@ private: bool _resumeAfterLoginDialogActionTaken_SafeToRun { false }; bool _startUpFinished { false }; bool _overrideEntry { false }; + + VisionSqueeze _visionSqueeze; }; #endif // hifi_Application_h diff --git a/interface/src/MacHelper.cpp b/interface/src/MacHelper.cpp new file mode 100755 index 0000000000..8527f02918 --- /dev/null +++ b/interface/src/MacHelper.cpp @@ -0,0 +1,58 @@ +// +// MacHelper.h +// interface/src +// +// Created by Howard Stearns +// Copyright 2019 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 "InterfaceLogging.h" +#include "MacHelper.h" +#include + +#ifdef Q_OS_MAC +#include +#include + +// The type definitions in these variables come from IOKit, which includes a definition of Duration that conflicts with ours. +// So... we include these definitions here rather than in the .h, as the .h is included in Application.cpp which +// uses Duration. +static io_connect_t root_port; +static IONotificationPortRef notifyPortRef; +static io_object_t notifierObject; +static void* refCon; + +static void sleepHandler(void* refCon, io_service_t service, natural_t messageType, void* messageArgument) { + if (messageType == kIOMessageSystemHasPoweredOn) { + qCInfo(interfaceapp) << "Waking up from sleep or hybernation."; + QMetaObject::invokeMethod(DependencyManager::get().data(), "noteAwakening", Qt::QueuedConnection); + } +} +#endif + +MacHelper::MacHelper() { +#ifdef Q_OS_MAC + root_port = IORegisterForSystemPower(refCon, ¬ifyPortRef, sleepHandler, ¬ifierObject); + if (root_port == 0) { + qCWarning(interfaceapp) << "IORegisterForSystemPower failed"; + return; + } + CFRunLoopAddSource(CFRunLoopGetCurrent(), + IONotificationPortGetRunLoopSource(notifyPortRef), + kCFRunLoopCommonModes); +#endif +} + +MacHelper::~MacHelper() { +#ifdef Q_OS_MAC + CFRunLoopRemoveSource(CFRunLoopGetCurrent(), + IONotificationPortGetRunLoopSource(notifyPortRef), + kCFRunLoopCommonModes); + IODeregisterForSystemPower(¬ifierObject); + IOServiceClose(root_port); + IONotificationPortDestroy(notifyPortRef); +#endif +} diff --git a/interface/src/MacHelper.h b/interface/src/MacHelper.h new file mode 100755 index 0000000000..52ad4d3e55 --- /dev/null +++ b/interface/src/MacHelper.h @@ -0,0 +1,21 @@ +// +// MacHelper.h +// interface/src +// +// Created by Howard Stearns +// Copyright 2019 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 +// + +#pragma once + +#include "DependencyManager.h" + +class MacHelper : public Dependency { +public: + MacHelper(); + ~MacHelper(); +}; + diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 8bee8de8c3..4cf78c23ee 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -266,8 +266,13 @@ Menu::Menu() { // Settings > Graphics... action = addActionToQMenuAndActionHash(settingsMenu, "Graphics..."); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/GraphicsPreferencesDialog.qml"), - QString("hifi/tablet/TabletGraphicsPreferences.qml"), "GraphicsPreferencesDialog"); + auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); + auto hmd = DependencyManager::get(); + tablet->pushOntoStack("hifi/dialogs/graphics/GraphicsSettings.qml"); + + if (!hmd->getShouldShowTablet()) { + hmd->toggleShouldShowTablet(); + } }); // Settings > Security... diff --git a/interface/src/PerformanceManager.cpp b/interface/src/PerformanceManager.cpp index ec12ab0404..80c09e3fec 100644 --- a/interface/src/PerformanceManager.cpp +++ b/interface/src/PerformanceManager.cpp @@ -92,7 +92,7 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP RenderScriptingInterface::getInstance()->setShadowsEnabled(true); qApp->getRefreshRateManager().setRefreshRateProfile(RefreshRateManager::RefreshRateProfile::REALTIME); - DependencyManager::get()->setWorldDetailQuality(0.5f); + DependencyManager::get()->setWorldDetailQuality(0.75f); break; case PerformancePreset::MID: @@ -114,7 +114,7 @@ void PerformanceManager::applyPerformancePreset(PerformanceManager::PerformanceP RenderScriptingInterface::getInstance()->setViewportResolutionScale(recommandedPpiScale); - DependencyManager::get()->setWorldDetailQuality(0.75f); + DependencyManager::get()->setWorldDetailQuality(0.25f); break; case PerformancePreset::UNKNOWN: diff --git a/interface/src/VisionSqueeze.cpp b/interface/src/VisionSqueeze.cpp new file mode 100644 index 0000000000..cb895cc74f --- /dev/null +++ b/interface/src/VisionSqueeze.cpp @@ -0,0 +1,213 @@ +// +// VisionSqueeze.cpp +// interface/src +// +// Created by Seth Alves on 2019-3-13. +// Copyright 2019 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 "VisionSqueeze.h" + +#include +#include + +#include + +#include "Application.h" + +VisionSqueeze::VisionSqueeze() : + _visionSqueezeEnabled(_visionSqueezeEnabledSetting.get()), + _visionSqueezeRatioX(_visionSqueezeRatioXSetting.get()), + _visionSqueezeRatioY(_visionSqueezeRatioYSetting.get()), + _visionSqueezeUnSqueezeDelay(_visionSqueezeUnSqueezeDelaySetting.get()), + _visionSqueezeUnSqueezeSpeed(_visionSqueezeUnSqueezeSpeedSetting.get()), + _visionSqueezeTransition(_visionSqueezeTransitionSetting.get()), + _visionSqueezePerEye(_visionSqueezePerEyeSetting.get()), + _visionSqueezeGroundPlaneY(_visionSqueezeGroundPlaneYSetting.get()), + _visionSqueezeSpotlightSize(_visionSqueezeSpotlightSizeSetting.get()), + _visionSqueezeTurningXFactor(_visionSqueezeTurningXFactorSetting.get()), + _visionSqueezeTurningYFactor(_visionSqueezeTurningYFactorSetting.get()) { +} + +void VisionSqueeze::setVisionSqueezeEnabled(bool value) { + if (value != _visionSqueezeEnabled) { + _visionSqueezeEnabled = value; + _visionSqueezeEnabledSetting.set(_visionSqueezeEnabled); + } +} + +void VisionSqueeze::setVisionSqueezeRatioX(float value) { + if (value != _visionSqueezeRatioX) { + _visionSqueezeRatioX = value; + _visionSqueezeRatioXSetting.set(_visionSqueezeRatioX); + } +} + +void VisionSqueeze::setVisionSqueezeRatioY(float value) { + if (value != _visionSqueezeRatioY) { + _visionSqueezeRatioY = value; + _visionSqueezeRatioYSetting.set(_visionSqueezeRatioY); + } +} + +void VisionSqueeze::setVisionSqueezeUnSqueezeDelay(float value) { + if (value != _visionSqueezeUnSqueezeDelay) { + _visionSqueezeUnSqueezeDelay = value; + _visionSqueezeUnSqueezeDelaySetting.set(_visionSqueezeUnSqueezeDelay); + } +} + +void VisionSqueeze::setVisionSqueezeUnSqueezeSpeed(float value) { + if (value != _visionSqueezeUnSqueezeSpeed) { + _visionSqueezeUnSqueezeSpeed = value; + _visionSqueezeUnSqueezeSpeedSetting.set(_visionSqueezeUnSqueezeSpeed); + } +} + +void VisionSqueeze::setVisionSqueezeTransition(float value) { + if (value != _visionSqueezeTransition) { + _visionSqueezeTransition = value; + _visionSqueezeTransitionSetting.set(_visionSqueezeTransition); + } +} + +void VisionSqueeze::setVisionSqueezePerEye(int value) { + if (value != _visionSqueezePerEye) { + _visionSqueezePerEye = value; + _visionSqueezePerEyeSetting.set(_visionSqueezePerEye); + } +} + +void VisionSqueeze::setVisionSqueezeGroundPlaneY(float value) { + if (value != _visionSqueezeGroundPlaneY) { + _visionSqueezeGroundPlaneY = value; + _visionSqueezeGroundPlaneYSetting.set(_visionSqueezeGroundPlaneY); + } +} + +void VisionSqueeze::setVisionSqueezeSpotlightSize(float value) { + if (value != _visionSqueezeSpotlightSize) { + _visionSqueezeSpotlightSize = value; + _visionSqueezeSpotlightSizeSetting.set(_visionSqueezeSpotlightSize); + } +} + +void VisionSqueeze::setVisionSqueezeTurningXFactor(float value) { + if (value != _visionSqueezeTurningXFactor) { + _visionSqueezeTurningXFactor = value; + _visionSqueezeTurningXFactorSetting.set(_visionSqueezeTurningXFactor); + } +} + +void VisionSqueeze::setVisionSqueezeTurningYFactor(float value) { + if (value != _visionSqueezeTurningYFactor) { + _visionSqueezeTurningYFactor = value; + _visionSqueezeTurningYFactorSetting.set(_visionSqueezeTurningYFactor); + } +} + +void VisionSqueeze::updateVisionSqueeze(const glm::mat4& sensorToWorldMatrix, float deltaTime) { + + const float SENSOR_TO_WORLD_TRANS_EPSILON = 0.0001f; + const float SENSOR_TO_WORLD_TRANS_Y_EPSILON = 0.01f; + const float SENSOR_TO_WORLD_TRANS_ITS_A_TELEPORT_SQUARED = 2.0f; + const float SENSOR_TO_WORLD_ROT_EPSILON = 0.000005f; + const float SENSOR_TO_WORLD_ROT_ITS_A_SNAP_TURN = 0.99f; + const float VISION_SQUEEZE_TP_LOCKOUT = 0.1f; // seconds + + glm::vec3 scale; + glm::quat rotation; + glm::vec3 translation; + glm::vec3 skew; + glm::vec4 perspective; + glm::decompose(sensorToWorldMatrix, scale, rotation, translation, skew, perspective); + + if (!_visionSqueezeEnabled) { + _squeezeVision = false; + _squeezeVisionTurning = false; + } else if (_visionSqueezeLockout > 0.0f) { + _visionSqueezeLockout -= deltaTime; + } else { + _squeezeVision = false; + _squeezeVisionTurning = false; + glm::vec3 absTransDelta = glm::abs(translation - _prevTranslation); + float rotDot = fabsf(glm::dot(rotation, _prevRotation)); + + // if the avatar has just teleported or snap-turned, briefly disable triggering of vision-squeeze + if (glm::length2(translation - _prevTranslation) > SENSOR_TO_WORLD_TRANS_ITS_A_TELEPORT_SQUARED || + rotDot < SENSOR_TO_WORLD_ROT_ITS_A_SNAP_TURN) { + _visionSqueezeLockout = VISION_SQUEEZE_TP_LOCKOUT; + _squeezeVision = true; + _squeezeVisionTurning = true; + } else if (rotDot < 1.0f - SENSOR_TO_WORLD_ROT_EPSILON) { + _squeezeVision = true; + _squeezeVisionTurning = true; + } else if (absTransDelta.x > SENSOR_TO_WORLD_TRANS_EPSILON || + absTransDelta.y > SENSOR_TO_WORLD_TRANS_Y_EPSILON || + absTransDelta.z > SENSOR_TO_WORLD_TRANS_EPSILON) { + _squeezeVision = true; + _squeezeVisionTurning = false; + } + } + + _prevTranslation = translation; + _prevRotation = rotation; + + static quint64 lastSqueezeTime = 0; + quint64 now = usecTimestampNow(); + static float visionSqueezeX = 0.0f; // 0.0 -- unobstructed, 1.0 -- fully blocked + static float visionSqueezeY = 0.0f; // 0.0 -- unobstructed, 1.0 -- fully blocked + + if (_squeezeVision) { + float ratioX = getVisionSqueezeRatioX(); + float ratioY = getVisionSqueezeRatioY(); + + if (ratioX >= 0.0f) { + if (_squeezeVisionTurning) { + ratioX += (1.0f - ratioX) * getVisionSqueezeTurningXFactor(); + } + float newVisionSqueezeX = ratioX; + if (newVisionSqueezeX >= visionSqueezeX) { + lastSqueezeTime = now; + visionSqueezeX = newVisionSqueezeX; + } + } else { + visionSqueezeX = -1.0f; + } + + if (ratioY >= 0.0f) { + float newVisionSqueezeY = ratioY; + if (newVisionSqueezeY >= visionSqueezeY) { + lastSqueezeTime = now; + visionSqueezeY = newVisionSqueezeY; + } + } else { + visionSqueezeY = -1.0f; + } + } + + float unsqueezeAmount = deltaTime * getVisionSqueezeUnSqueezeSpeed(); + if (now - lastSqueezeTime > getVisionSqueezeUnSqueezeDelay() * USECS_PER_SECOND) { + visionSqueezeX -= unsqueezeAmount; + if (visionSqueezeX < 0.0f) { + visionSqueezeX = -1.0f; + } + visionSqueezeY -= unsqueezeAmount; + if (visionSqueezeY < 0.0f) { + visionSqueezeY = -1.0f; + } + } + + std::shared_ptr hmdDisplayPlugin = + std::dynamic_pointer_cast(qApp->getActiveDisplayPlugin()); + if (hmdDisplayPlugin) { + hmdDisplayPlugin->updateVisionSqueezeParameters(visionSqueezeX, visionSqueezeY, + getVisionSqueezeTransition(), + getVisionSqueezePerEye(), + getVisionSqueezeGroundPlaneY(), + getVisionSqueezeSpotlightSize()); + } +} diff --git a/interface/src/VisionSqueeze.h b/interface/src/VisionSqueeze.h new file mode 100644 index 0000000000..d32f608ed0 --- /dev/null +++ b/interface/src/VisionSqueeze.h @@ -0,0 +1,108 @@ +// +// VisionSqueeze.h +// interface/src +// +// Created by Seth Alves on 2019-3-13. +// Copyright 2019 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_VisionSqueeze_h +#define hifi_VisionSqueeze_h + +#include +#include + +#include + +static const float DEFAULT_VISION_SQUEEZE_TURNING_X_FACTOR = 0.51f; +static const float DEFAULT_VISION_SQUEEZE_TURNING_Y_FACTOR = 0.36f; +static const float DEFAULT_VISION_SQUEEZE_UNSQUEEZE_DELAY = 0.2f; // seconds +static const float DEFAULT_VISION_SQUEEZE_UNSQUEEZE_SPEED = 3.0f; +static const float DEFAULT_VISION_SQUEEZE_TRANSITION = 0.25f; +static const int DEFAULT_VISION_SQUEEZE_PER_EYE = 1; +static const float DEFAULT_VISION_SQUEEZE_GROUND_PLANE_Y = 0.0f; +static const float DEFAULT_VISION_SQUEEZE_SPOTLIGHT_SIZE = 6.0f; + + +class VisionSqueeze { + +public: + + VisionSqueeze(); + + bool getVisionSqueezeEnabled() const { return _visionSqueezeEnabled; } + void setVisionSqueezeEnabled(bool value); + float getVisionSqueezeRatioX() const { return _visionSqueezeRatioX; } + float getVisionSqueezeRatioY() const { return _visionSqueezeRatioY; } + void setVisionSqueezeRatioX(float value); + void setVisionSqueezeRatioY(float value); + float getVisionSqueezeUnSqueezeDelay() const { return _visionSqueezeUnSqueezeDelay; } + void setVisionSqueezeUnSqueezeDelay(float value); + float getVisionSqueezeUnSqueezeSpeed() const { return _visionSqueezeUnSqueezeSpeed; } + void setVisionSqueezeUnSqueezeSpeed(float value); + float getVisionSqueezeTransition() const { return _visionSqueezeTransition; } + void setVisionSqueezeTransition(float value); + int getVisionSqueezePerEye() const { return _visionSqueezePerEye; } + void setVisionSqueezePerEye(int value); + float getVisionSqueezeGroundPlaneY() const { return _visionSqueezeGroundPlaneY; } + void setVisionSqueezeGroundPlaneY(float value); + float getVisionSqueezeSpotlightSize() const { return _visionSqueezeSpotlightSize; } + void setVisionSqueezeSpotlightSize(float value); + float getVisionSqueezeTurningXFactor() const { return _visionSqueezeTurningXFactor; } + void setVisionSqueezeTurningXFactor(float value); + float getVisionSqueezeTurningYFactor() const { return _visionSqueezeTurningYFactor; } + void setVisionSqueezeTurningYFactor(float value); + + void updateVisionSqueeze(const glm::mat4& sensorToWorldMatrix, float deltaTime); + + // state variable accessors used by Application.cpp... + bool getSqueezeVision() const { return _squeezeVision; } + void setSqueezeVision(bool value) { _squeezeVision = value; } + bool getSqueezeVisionTurning() const { return _squeezeVisionTurning; } + void setSqueezeVisionTurning(bool value) { _squeezeVisionTurning = value; } + +private: + Setting::Handle _visionSqueezeEnabledSetting {"visionSqueezeEnabled", false}; + Setting::Handle _visionSqueezeRatioXSetting {"visionSqueezeRatioX", 0.0f}; + Setting::Handle _visionSqueezeRatioYSetting {"visionSqueezeRatioY", 0.0f}; + Setting::Handle _visionSqueezeUnSqueezeDelaySetting {"visionSqueezeUnSqueezeDelay", + DEFAULT_VISION_SQUEEZE_UNSQUEEZE_DELAY}; + Setting::Handle _visionSqueezeUnSqueezeSpeedSetting {"visionSqueezeUnSqueezeSpeed", + DEFAULT_VISION_SQUEEZE_UNSQUEEZE_SPEED}; + Setting::Handle _visionSqueezeTransitionSetting {"visionSqueezeTransition", DEFAULT_VISION_SQUEEZE_TRANSITION}; + Setting::Handle _visionSqueezePerEyeSetting {"visionSqueezePerEye", DEFAULT_VISION_SQUEEZE_PER_EYE}; + Setting::Handle _visionSqueezeGroundPlaneYSetting {"visionSqueezeGroundPlaneY", + DEFAULT_VISION_SQUEEZE_GROUND_PLANE_Y}; + Setting::Handle _visionSqueezeSpotlightSizeSetting {"visionSqueezeSpotlightSize", + DEFAULT_VISION_SQUEEZE_SPOTLIGHT_SIZE}; + Setting::Handle _visionSqueezeTurningXFactorSetting {"visionSqueezeTurningXFactor", + DEFAULT_VISION_SQUEEZE_TURNING_X_FACTOR}; + Setting::Handle _visionSqueezeTurningYFactorSetting {"visionSqueezeTurningYFactor", + DEFAULT_VISION_SQUEEZE_TURNING_Y_FACTOR}; + + + // these are readable and writable from the scripting interface (on a different thread), so make them atomic + std::atomic _visionSqueezeEnabled { false }; + std::atomic _visionSqueezeRatioX { 0.0f }; + std::atomic _visionSqueezeRatioY { 0.0f }; + std::atomic _visionSqueezeUnSqueezeDelay { DEFAULT_VISION_SQUEEZE_UNSQUEEZE_DELAY }; // seconds + std::atomic _visionSqueezeUnSqueezeSpeed { DEFAULT_VISION_SQUEEZE_UNSQUEEZE_SPEED }; + std::atomic _visionSqueezeTransition { DEFAULT_VISION_SQUEEZE_TRANSITION }; + std::atomic _visionSqueezePerEye { DEFAULT_VISION_SQUEEZE_PER_EYE }; + std::atomic _visionSqueezeGroundPlaneY { DEFAULT_VISION_SQUEEZE_GROUND_PLANE_Y }; + std::atomic _visionSqueezeSpotlightSize { DEFAULT_VISION_SQUEEZE_SPOTLIGHT_SIZE }; + std::atomic _visionSqueezeTurningXFactor { DEFAULT_VISION_SQUEEZE_TURNING_X_FACTOR }; + std::atomic _visionSqueezeTurningYFactor { DEFAULT_VISION_SQUEEZE_TURNING_Y_FACTOR }; + + bool _squeezeVision { false }; + bool _squeezeVisionTurning { false }; + + float _visionSqueezeLockout { 0.0 }; + glm::vec3 _prevTranslation; + glm::quat _prevRotation; +}; + +#endif // hifi_VisionSqueeze_h diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index c88a934acf..553033f394 100755 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -574,6 +574,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar avatar->die(); queuePhysicsChange(avatar); + avatar->removeOrb(); // remove this avatar's entities from the tree now, if we wait (as we did previously) for this Avatar's destructor // it might not fire until after we create a new instance for the same remote avatar, which creates a race diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index cce2af466d..acb199bb97 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -6144,4 +6144,3 @@ void MyAvatar::sendPacket(const QUuid& entityID) const { }); } } - diff --git a/interface/src/avatar/OtherAvatar.cpp b/interface/src/avatar/OtherAvatar.cpp index a6e2d6a998..8c8c42679b 100755 --- a/interface/src/avatar/OtherAvatar.cpp +++ b/interface/src/avatar/OtherAvatar.cpp @@ -75,6 +75,7 @@ void OtherAvatar::createOrb() { properties.setType(EntityTypes::Sphere); properties.setAlpha(1.0f); properties.setColor(getLoadingOrbColor(_loadingStatus)); + properties.setName("Loading Avatar " + getID().toString()); properties.setPrimitiveMode(PrimitiveMode::LINES); properties.getPulse().setMin(0.5f); properties.getPulse().setMax(1.0f); @@ -201,6 +202,7 @@ void OtherAvatar::computeShapeLOD() { break; case workload::Region::UNKNOWN: case workload::Region::INVALID: + case workload::Region::R4: case workload::Region::R3: default: newLOD = BodyLOD::Sphere; diff --git a/interface/src/graphics/GraphicsEngine.cpp b/interface/src/graphics/GraphicsEngine.cpp index 7f9a612697..284118a52a 100644 --- a/interface/src/graphics/GraphicsEngine.cpp +++ b/interface/src/graphics/GraphicsEngine.cpp @@ -259,7 +259,7 @@ void GraphicsEngine::render_performFrame() { batch.enableSkybox(true); batch.enableStereo(isStereo); batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); - _splashScreen->render(batch, viewFrustum); + _splashScreen->render(batch, viewFrustum, renderArgs._renderMethod == RenderArgs::RenderMethod::FORWARD); }); } else { { diff --git a/interface/src/octree/OctreePacketProcessor.cpp b/interface/src/octree/OctreePacketProcessor.cpp index c6f908e039..bc3c1afdd5 100644 --- a/interface/src/octree/OctreePacketProcessor.cpp +++ b/interface/src/octree/OctreePacketProcessor.cpp @@ -114,7 +114,11 @@ void OctreePacketProcessor::processPacket(QSharedPointer messag if (renderer) { renderer->processDatagram(*message, sendingNode); if (_safeLanding && _safeLanding->isTracking()) { - _safeLanding->addToSequence(renderer->getLastOctreeMessageSequence()); + OCTREE_PACKET_SEQUENCE thisSequence = renderer->getLastOctreeMessageSequence(); + _safeLanding->addToSequence(thisSequence); + if (_safeLandingSequenceStart == SafeLanding::INVALID_SEQUENCE) { + _safeLandingSequenceStart = thisSequence; + } } } } @@ -124,8 +128,8 @@ void OctreePacketProcessor::processPacket(QSharedPointer messag // Read sequence # OCTREE_PACKET_SEQUENCE completionNumber; message->readPrimitive(&completionNumber); - if (_safeLanding) { - _safeLanding->finishSequence(0, completionNumber); + if (_safeLanding && _safeLanding->isTracking()) { + _safeLanding->finishSequence(_safeLandingSequenceStart, completionNumber); } } break; @@ -153,6 +157,13 @@ void OctreePacketProcessor::stopSafeLanding() { } } +void OctreePacketProcessor::resetSafeLanding() { + if (_safeLanding) { + _safeLanding->reset(); + } + _safeLandingSequenceStart = SafeLanding::INVALID_SEQUENCE; +} + bool OctreePacketProcessor::safeLandingIsActive() const { return _safeLanding && _safeLanding->isTracking(); } diff --git a/interface/src/octree/OctreePacketProcessor.h b/interface/src/octree/OctreePacketProcessor.h index eacc15f62d..d56b7e0e35 100644 --- a/interface/src/octree/OctreePacketProcessor.h +++ b/interface/src/octree/OctreePacketProcessor.h @@ -28,6 +28,7 @@ public: void startSafeLanding(); void updateSafeLanding(); void stopSafeLanding(); + void resetSafeLanding(); bool safeLandingIsActive() const; bool safeLandingIsComplete() const; @@ -43,6 +44,7 @@ private slots: void handleOctreePacket(QSharedPointer message, SharedNodePointer senderNode); private: + OCTREE_PACKET_SEQUENCE _safeLandingSequenceStart { SafeLanding::INVALID_SEQUENCE }; std::unique_ptr _safeLanding; }; #endif // hifi_OctreePacketProcessor_h diff --git a/interface/src/octree/SafeLanding.cpp b/interface/src/octree/SafeLanding.cpp index 75e512232b..ed779787c9 100644 --- a/interface/src/octree/SafeLanding.cpp +++ b/interface/src/octree/SafeLanding.cpp @@ -17,7 +17,6 @@ #include "InterfaceLogging.h" #include "Application.h" -const int SafeLanding::SEQUENCE_MODULO = std::numeric_limits::max() + 1; CalculateEntityLoadingPriority SafeLanding::entityLoadingOperatorElevateCollidables = [](const EntityItem& entityItem) { const int COLLIDABLE_ENTITY_PRIORITY = 10.0f; @@ -25,8 +24,8 @@ CalculateEntityLoadingPriority SafeLanding::entityLoadingOperatorElevateCollidab }; namespace { - template bool lessThanWraparound(int a, int b) { - constexpr int MAX_T_VALUE = std::numeric_limits::max(); + template bool lessThanWraparound(int32_t a, int32_t b) { + constexpr int32_t MAX_T_VALUE = std::numeric_limits::max(); if (b <= a) { b += MAX_T_VALUE; } @@ -34,7 +33,7 @@ namespace { } } -bool SafeLanding::SequenceLessThan::operator()(const int& a, const int& b) const { +bool SafeLanding::SequenceLessThan::operator()(const OCTREE_PACKET_SEQUENCE& a, const OCTREE_PACKET_SEQUENCE& b) const { return lessThanWraparound(a, b); } @@ -46,8 +45,8 @@ void SafeLanding::startTracking(QSharedPointer entityTreeRen _entityTreeRenderer = entityTreeRenderer; _trackedEntities.clear(); _maxTrackedEntityCount = 0; - _initialStart = INVALID_SEQUENCE; - _initialEnd = INVALID_SEQUENCE; + _sequenceStart = SafeLanding::INVALID_SEQUENCE; + _sequenceEnd = SafeLanding::INVALID_SEQUENCE; _sequenceNumbers.clear(); _trackingEntities = true; _startTime = usecTimestampNow(); @@ -72,7 +71,7 @@ void SafeLanding::addTrackedEntity(const EntityItemID& entityID) { if (entity && !entity->isLocalEntity() && entity->getCreated() < _startTime) { _trackedEntities.emplace(entityID, entity); - int trackedEntityCount = (int)_trackedEntities.size(); + int32_t trackedEntityCount = (int32_t)_trackedEntities.size(); if (trackedEntityCount > _maxTrackedEntityCount) { _maxTrackedEntityCount = trackedEntityCount; _trackedEntityStabilityCount = 0; @@ -87,15 +86,15 @@ void SafeLanding::deleteTrackedEntity(const EntityItemID& entityID) { _trackedEntities.erase(entityID); } -void SafeLanding::finishSequence(int first, int last) { +void SafeLanding::finishSequence(OCTREE_PACKET_SEQUENCE first, OCTREE_PACKET_SEQUENCE last) { Locker lock(_lock); if (_trackingEntities) { - _initialStart = first; - _initialEnd = last; + _sequenceStart = first; + _sequenceEnd = last; } } -void SafeLanding::addToSequence(int sequenceNumber) { +void SafeLanding::addToSequence(OCTREE_PACKET_SEQUENCE sequenceNumber) { Locker lock(_lock); _sequenceNumbers.insert(sequenceNumber); } @@ -135,14 +134,13 @@ void SafeLanding::updateTracking() { if (_trackedEntities.empty()) { // no more tracked entities --> check sequenceNumbers - if (_initialStart != INVALID_SEQUENCE) { + if (_sequenceStart != SafeLanding::INVALID_SEQUENCE) { bool shouldStop = false; { Locker lock(_lock); - int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart: - _initialEnd + SEQUENCE_MODULO - _initialStart; - auto startIter = _sequenceNumbers.find(_initialStart); - auto endIter = _sequenceNumbers.find(_initialEnd - 1); + auto sequenceSize = _sequenceEnd - _sequenceStart; // this works even in rollover case + auto startIter = _sequenceNumbers.find(_sequenceStart); + auto endIter = _sequenceNumbers.find(_sequenceEnd - 1); bool missingSequenceNumbers = qApp->isMissingSequenceNumbers(); shouldStop = (sequenceSize == 0 || @@ -159,31 +157,41 @@ void SafeLanding::updateTracking() { void SafeLanding::stopTracking() { Locker lock(_lock); - _trackingEntities = false; - if (_entityTreeRenderer) { - auto entityTree = _entityTreeRenderer->getTree(); - disconnect(std::const_pointer_cast(entityTree).get(), - &EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity); - disconnect(std::const_pointer_cast(entityTree).get(), - &EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity); - _entityTreeRenderer.reset(); + if (_trackingEntities) { + _trackingEntities = false; + if (_entityTreeRenderer) { + auto entityTree = _entityTreeRenderer->getTree(); + disconnect(std::const_pointer_cast(entityTree).get(), + &EntityTree::addingEntity, this, &SafeLanding::addTrackedEntity); + disconnect(std::const_pointer_cast(entityTree).get(), + &EntityTree::deletingEntity, this, &SafeLanding::deleteTrackedEntity); + _entityTreeRenderer.reset(); + } + EntityTreeRenderer::setEntityLoadingPriorityFunction(_prevEntityLoadingPriorityOperator); } - EntityTreeRenderer::setEntityLoadingPriorityFunction(_prevEntityLoadingPriorityOperator); +} + +void SafeLanding::reset() { + _trackingEntities = false; + _trackedEntities.clear(); + _maxTrackedEntityCount = 0; + _sequenceStart = SafeLanding::INVALID_SEQUENCE; + _sequenceEnd = SafeLanding::INVALID_SEQUENCE; } bool SafeLanding::trackingIsComplete() const { - return !_trackingEntities && (_initialStart != INVALID_SEQUENCE); + return !_trackingEntities && (_sequenceStart != SafeLanding::INVALID_SEQUENCE); } float SafeLanding::loadingProgressPercentage() { Locker lock(_lock); - static const int MINIMUM_TRACKED_ENTITY_STABILITY_COUNT = 15; float entityReadyPercentage = 0.0f; if (_maxTrackedEntityCount > 0) { entityReadyPercentage = ((_maxTrackedEntityCount - _trackedEntities.size()) / (float)_maxTrackedEntityCount); } + constexpr int32_t MINIMUM_TRACKED_ENTITY_STABILITY_COUNT = 15; if (_trackedEntityStabilityCount < MINIMUM_TRACKED_ENTITY_STABILITY_COUNT) { entityReadyPercentage *= 0.20f; } @@ -203,8 +211,22 @@ bool SafeLanding::isEntityPhysicsReady(const EntityItemPointer& entity) { if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) { auto space = _entityTreeRenderer->getWorkloadSpace(); uint8_t region = space ? space->getRegion(entity->getSpaceIndex()) : (uint8_t)workload::Region::INVALID; - bool shouldBePhysical = region < workload::Region::R3 && entity->shouldBePhysical(); - return (!shouldBePhysical || entity->isInPhysicsSimulation() || modelEntity->computeShapeFailedToLoad()); + + // Note: the meanings of the workload regions are: + // R1 = in physics simulation and willing to own simulation + // R2 = in physics simulation but does NOT want to own simulation + // R3 = not in physics simulation but kinematically animated when velocities are non-zero + // R4 = sorted by workload and found to be outside R3 + // UNKNOWN = known to workload but not yet sorted + // INVALID = not known to workload + // So any entity sorted into R3 or R4 is definitelyNotPhysical + + bool definitelyNotPhysical = region == workload::Region::R3 || + region == workload::Region::R4 || + !entity->shouldBePhysical() || + modelEntity->unableToLoadCollisionShape(); + bool definitelyPhysical = entity->isInPhysicsSimulation(); + return definitelyNotPhysical || definitelyPhysical; } } } @@ -212,20 +234,24 @@ bool SafeLanding::isEntityPhysicsReady(const EntityItemPointer& entity) { } void SafeLanding::debugDumpSequenceIDs() const { - int p = -1; qCDebug(interfaceapp) << "Sequence set size:" << _sequenceNumbers.size(); - for (auto s: _sequenceNumbers) { - if (p == -1) { - p = s; - qCDebug(interfaceapp) << "First:" << s; - } else { + + auto itr = _sequenceNumbers.begin(); + OCTREE_PACKET_SEQUENCE p = SafeLanding::INVALID_SEQUENCE; + if (itr != _sequenceNumbers.end()) { + p = (*itr); + qCDebug(interfaceapp) << "First:" << (int32_t)p; + ++itr; + while (itr != _sequenceNumbers.end()) { + OCTREE_PACKET_SEQUENCE s = *itr; if (s != p + 1) { - qCDebug(interfaceapp) << "Gap from" << p << "to" << s << "(exclusive)"; + qCDebug(interfaceapp) << "Gap from" << (int32_t)p << "to" << (int32_t)s << "(exclusive)"; p = s; } + ++itr; + } + if (p != SafeLanding::INVALID_SEQUENCE) { + qCDebug(interfaceapp) << "Last:" << p; } } - if (p != -1) { - qCDebug(interfaceapp) << "Last:" << p; - } } diff --git a/interface/src/octree/SafeLanding.h b/interface/src/octree/SafeLanding.h index 87dac16ba3..00473f6fc8 100644 --- a/interface/src/octree/SafeLanding.h +++ b/interface/src/octree/SafeLanding.h @@ -17,6 +17,8 @@ #include #include +#include + #include "EntityItem.h" #include "EntityDynamicInterface.h" @@ -27,14 +29,18 @@ class EntityItemID; class SafeLanding : public QObject { public: + static constexpr OCTREE_PACKET_SEQUENCE MAX_SEQUENCE = std::numeric_limits::max(); + static constexpr OCTREE_PACKET_SEQUENCE INVALID_SEQUENCE = MAX_SEQUENCE; // not technically invalid, but close enough + void startTracking(QSharedPointer entityTreeRenderer); void updateTracking(); void stopTracking(); + void reset(); bool isTracking() const { return _trackingEntities; } bool trackingIsComplete() const; - void finishSequence(int first, int last); // 'last' exclusive. - void addToSequence(int sequenceNumber); + void finishSequence(OCTREE_PACKET_SEQUENCE first, OCTREE_PACKET_SEQUENCE last); // 'last' exclusive. + void addToSequence(OCTREE_PACKET_SEQUENCE sequenceNumber); float loadingProgressPercentage(); private slots: @@ -52,24 +58,22 @@ private: using EntityMap = std::map; EntityMap _trackedEntities; - static constexpr int INVALID_SEQUENCE = -1; - int _initialStart { INVALID_SEQUENCE }; - int _initialEnd { INVALID_SEQUENCE }; - int _maxTrackedEntityCount { 0 }; - int _trackedEntityStabilityCount { 0 }; + OCTREE_PACKET_SEQUENCE _sequenceStart { INVALID_SEQUENCE }; + OCTREE_PACKET_SEQUENCE _sequenceEnd { INVALID_SEQUENCE }; + int32_t _maxTrackedEntityCount { 0 }; + int32_t _trackedEntityStabilityCount { 0 }; quint64 _startTime { 0 }; struct SequenceLessThan { - bool operator()(const int& a, const int& b) const; + bool operator()(const OCTREE_PACKET_SEQUENCE& a, const OCTREE_PACKET_SEQUENCE& b) const; }; - std::set _sequenceNumbers; + using SequenceSet = std::set; + SequenceSet _sequenceNumbers; static CalculateEntityLoadingPriority entityLoadingOperatorElevateCollidables; CalculateEntityLoadingPriority _prevEntityLoadingPriorityOperator { nullptr }; - - static const int SEQUENCE_MODULO; }; #endif // hifi_SafeLanding_h diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index 23fc1cb4bd..0589124db8 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -405,7 +405,8 @@ gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabo using namespace shader::render_utils::program; static const std::vector> keys = { - std::make_tuple(false, false, parabola), std::make_tuple(false, true, forward_parabola), std::make_tuple(true, false, parabola_translucent)/*, std::make_tuple(true, true, forward_parabola_translucent)*/ + std::make_tuple(false, false, parabola), std::make_tuple(false, true, parabola_forward), + std::make_tuple(true, false, parabola_translucent), std::make_tuple(true, true, parabola_forward) // The forward opaque/translucent pipelines are the same for now }; for (auto& key : keys) { @@ -423,9 +424,6 @@ gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabo _parabolaPipelines[{std::get<0>(key), std::get<1>(key)}] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state); } - - // The forward opaque/translucent pipelines are the same for now - _parabolaPipelines[{ true, true }] = _parabolaPipelines[{ false, true}]; } return _parabolaPipelines[{ _parabolaData.color.a < 1.0f, forward }]; } diff --git a/interface/src/scripting/DesktopScriptingInterface.cpp b/interface/src/scripting/DesktopScriptingInterface.cpp index ef5bd7abb9..a1c8e4fc6c 100644 --- a/interface/src/scripting/DesktopScriptingInterface.cpp +++ b/interface/src/scripting/DesktopScriptingInterface.cpp @@ -111,10 +111,11 @@ void DesktopScriptingInterface::show(const QString& path, const QString& title) InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) { if (QThread::currentThread() != thread()) { InteractiveWindowPointer interactiveWindow = nullptr; - BLOCKING_INVOKE_METHOD(this, "createWindow", + BLOCKING_INVOKE_METHOD(this, "createWindowOnThread", Q_RETURN_ARG(InteractiveWindowPointer, interactiveWindow), Q_ARG(QString, sourceUrl), - Q_ARG(QVariantMap, properties)); + Q_ARG(QVariantMap, properties), + Q_ARG(QThread*, QThread::currentThread())); return interactiveWindow; } @@ -129,3 +130,16 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& return new InteractiveWindow(sourceUrl, properties); } + +InteractiveWindowPointer DesktopScriptingInterface::createWindowOnThread(const QString& sourceUrl, const QVariantMap& properties, QThread* targetThread) { + // The offscreen surface already validates against non-local QML sources, but we also need to ensure that + // if we create top level QML, like dock widgets or other types of QQuickView containing desktop windows + // that the source URL is permitted + const auto& urlValidator = OffscreenQmlSurface::getUrlValidator(); + if (!urlValidator(sourceUrl)) { + return nullptr; + } + InteractiveWindowPointer window = new InteractiveWindow(sourceUrl, properties); + window->moveToThread(targetThread); + return window; +} diff --git a/interface/src/scripting/DesktopScriptingInterface.h b/interface/src/scripting/DesktopScriptingInterface.h index b4ff159176..525fd7c803 100644 --- a/interface/src/scripting/DesktopScriptingInterface.h +++ b/interface/src/scripting/DesktopScriptingInterface.h @@ -101,6 +101,8 @@ private: static int flagAlwaysOnTop() { return AlwaysOnTop; } static int flagCloseButtonHides() { return CloseButtonHides; } + Q_INVOKABLE InteractiveWindowPointer createWindowOnThread(const QString& sourceUrl, const QVariantMap& properties, QThread* targetThread); + static QVariantMap getDockArea(); Q_INVOKABLE static QVariantMap getPresentationMode(); diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index baca6250d2..8f7ae7c4dc 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -236,3 +236,83 @@ QVariant HMDScriptingInterface::getPlayAreaRect() { QVector HMDScriptingInterface::getSensorPositions() { return qApp->getActiveDisplayPlugin()->getSensorPositions(); } + +float HMDScriptingInterface::getVisionSqueezeRatioX() const { + return qApp->getVisionSqueeze().getVisionSqueezeRatioX(); +} + +float HMDScriptingInterface::getVisionSqueezeRatioY() const { + return qApp->getVisionSqueeze().getVisionSqueezeRatioY(); +} + +void HMDScriptingInterface::setVisionSqueezeRatioX(float value) { + qApp->getVisionSqueeze().setVisionSqueezeRatioX(value); +} + +void HMDScriptingInterface::setVisionSqueezeRatioY(float value) { + qApp->getVisionSqueeze().setVisionSqueezeRatioY(value); +} + +float HMDScriptingInterface::getVisionSqueezeUnSqueezeDelay() const { + return qApp->getVisionSqueeze().getVisionSqueezeUnSqueezeDelay(); +} + +void HMDScriptingInterface::setVisionSqueezeUnSqueezeDelay(float value) { + qApp->getVisionSqueeze().setVisionSqueezeUnSqueezeDelay(value); +} + +float HMDScriptingInterface::getVisionSqueezeUnSqueezeSpeed() const { + return qApp->getVisionSqueeze().getVisionSqueezeUnSqueezeSpeed(); +} + +void HMDScriptingInterface::setVisionSqueezeUnSqueezeSpeed(float value) { + qApp->getVisionSqueeze().setVisionSqueezeUnSqueezeSpeed(value); +} + +float HMDScriptingInterface::getVisionSqueezeTransition() const { + return qApp->getVisionSqueeze().getVisionSqueezeTransition(); +} + +void HMDScriptingInterface::setVisionSqueezeTransition(float value) { + qApp->getVisionSqueeze().setVisionSqueezeTransition(value); +} + +int HMDScriptingInterface::getVisionSqueezePerEye() const { + return qApp->getVisionSqueeze().getVisionSqueezePerEye(); +} + +void HMDScriptingInterface::setVisionSqueezePerEye(int value) { + qApp->getVisionSqueeze().setVisionSqueezePerEye(value); +} + +float HMDScriptingInterface::getVisionSqueezeGroundPlaneY() const { + return qApp->getVisionSqueeze().getVisionSqueezeGroundPlaneY(); +} + +void HMDScriptingInterface::setVisionSqueezeGroundPlaneY(float value) { + qApp->getVisionSqueeze().setVisionSqueezeGroundPlaneY(value); +} + +float HMDScriptingInterface::getVisionSqueezeSpotlightSize() const { + return qApp->getVisionSqueeze().getVisionSqueezeSpotlightSize(); +} + +void HMDScriptingInterface::setVisionSqueezeSpotlightSize(float value) { + qApp->getVisionSqueeze().setVisionSqueezeSpotlightSize(value); +} + +float HMDScriptingInterface::getVisionSqueezeTurningXFactor() const { + return qApp->getVisionSqueeze().getVisionSqueezeTurningXFactor(); +} + +void HMDScriptingInterface::setVisionSqueezeTurningXFactor(float value) { + qApp->getVisionSqueeze().setVisionSqueezeTurningXFactor(value); +} + +float HMDScriptingInterface::getVisionSqueezeTurningYFactor() const { + return qApp->getVisionSqueeze().getVisionSqueezeTurningYFactor(); +} + +void HMDScriptingInterface::setVisionSqueezeTurningYFactor(float value) { + qApp->getVisionSqueeze().setVisionSqueezeTurningYFactor(value); +} diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 0f636a388b..2e90ecdec1 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -84,6 +84,17 @@ class HMDScriptingInterface : public AbstractHMDScriptingInterface, public Depen Q_PROPERTY(QVariant playArea READ getPlayAreaRect); Q_PROPERTY(QVector sensorPositions READ getSensorPositions); + Q_PROPERTY(float visionSqueezeRatioX READ getVisionSqueezeRatioX WRITE setVisionSqueezeRatioX); + Q_PROPERTY(float visionSqueezeRatioY READ getVisionSqueezeRatioY WRITE setVisionSqueezeRatioY); + Q_PROPERTY(float visionSqueezeUnSqueezeDelay READ getVisionSqueezeUnSqueezeDelay WRITE setVisionSqueezeUnSqueezeDelay); + Q_PROPERTY(float visionSqueezeUnSqueezeSpeed READ getVisionSqueezeUnSqueezeSpeed WRITE setVisionSqueezeUnSqueezeSpeed); + Q_PROPERTY(float visionSqueezeTransition READ getVisionSqueezeTransition WRITE setVisionSqueezeTransition); + Q_PROPERTY(int visionSqueezePerEye READ getVisionSqueezePerEye WRITE setVisionSqueezePerEye); + Q_PROPERTY(float visionSqueezeGroundPlaneY READ getVisionSqueezeGroundPlaneY WRITE setVisionSqueezeGroundPlaneY); + Q_PROPERTY(float visionSqueezeSpotlightSize READ getVisionSqueezeSpotlightSize WRITE setVisionSqueezeSpotlightSize); + Q_PROPERTY(float visionSqueezeTurningXFactor READ getVisionSqueezeTurningXFactor WRITE setVisionSqueezeTurningXFactor); + Q_PROPERTY(float visionSqueezeTurningYFactor READ getVisionSqueezeTurningYFactor WRITE setVisionSqueezeTurningYFactor); + public: /**jsdoc @@ -339,6 +350,27 @@ public: */ Q_INVOKABLE void openTablet(bool contextualMode = false); + float getVisionSqueezeRatioX() const; + float getVisionSqueezeRatioY() const; + void setVisionSqueezeRatioX(float value); + void setVisionSqueezeRatioY(float value); + float getVisionSqueezeUnSqueezeDelay() const; + void setVisionSqueezeUnSqueezeDelay(float value); + float getVisionSqueezeUnSqueezeSpeed() const; + void setVisionSqueezeUnSqueezeSpeed(float value); + float getVisionSqueezeTransition() const; + void setVisionSqueezeTransition(float value); + int getVisionSqueezePerEye() const; + void setVisionSqueezePerEye(int value); + float getVisionSqueezeGroundPlaneY() const; + void setVisionSqueezeGroundPlaneY(float value); + float getVisionSqueezeSpotlightSize() const; + void setVisionSqueezeSpotlightSize(float value); + float getVisionSqueezeTurningXFactor() const; + void setVisionSqueezeTurningXFactor(float value); + float getVisionSqueezeTurningYFactor() const; + void setVisionSqueezeTurningYFactor(float value); + signals: /**jsdoc * Triggered when a request to show or hide models of the HMD hand controllers is made using diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.cpp b/interface/src/scripting/PlatformInfoScriptingInterface.cpp index cbd94b3dd5..9adf514718 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.cpp +++ b/interface/src/scripting/PlatformInfoScriptingInterface.cpp @@ -221,4 +221,6 @@ QStringList PlatformInfoScriptingInterface::getPlatformTierNames() { return platformTierNames; } - +bool PlatformInfoScriptingInterface::isRenderMethodDeferredCapable() { + return platform::Profiler::isRenderMethodDeferredCapable(); +} diff --git a/interface/src/scripting/PlatformInfoScriptingInterface.h b/interface/src/scripting/PlatformInfoScriptingInterface.h index 9ac67ec0bd..f59d476f0c 100644 --- a/interface/src/scripting/PlatformInfoScriptingInterface.h +++ b/interface/src/scripting/PlatformInfoScriptingInterface.h @@ -245,7 +245,12 @@ public slots: */ QStringList getPlatformTierNames(); - + /**jsdoc + * Gets whether the current hardware can render using the Deferred method. + * @function PlatformInfo.isRenderMethodDeferredCapable + * @returns {bool} true if the current hardware can render using the Deferred method; false otherwise. + */ + bool isRenderMethodDeferredCapable(); }; #endif // hifi_PlatformInfoScriptingInterface_h diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index bae6621fb2..b9a1fc441f 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -94,7 +94,7 @@ void AvatarInputs::setShowBubbleTools(bool showBubbleTools) { return; _showBubbleTools = showBubbleTools; - showBubbleToolsSetting.set(_showAudioTools); + showBubbleToolsSetting.set(_showBubbleTools); emit showBubbleToolsChanged(_showBubbleTools); } diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index dfef16b536..fc2d8c56bf 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -51,6 +51,28 @@ static const QStringList KNOWN_SCHEMES = QStringList() << "http" << "https" << " static const int DEFAULT_HEIGHT = 60; +QmlWindowProxy::QmlWindowProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(qmlObject, parent) { + _qmlWindow = qmlObject; +} + +void QmlWindowProxy::parentNativeWindowToMainWindow() { +#ifdef Q_OS_WIN + if (!_qmlWindow) { + return; + } + const auto nativeWindowProperty = _qmlWindow->property("nativeWindow"); + if (nativeWindowProperty.isNull() || !nativeWindowProperty.isValid()) { + return; + } + const auto nativeWindow = qvariant_cast(nativeWindowProperty); + SetWindowLongPtr((HWND)nativeWindow->winId(), GWLP_HWNDPARENT, (LONG)MainWindow::findMainWindow()->winId()); +#endif +} + +static void qmlWindowProxyDeleter(QmlWindowProxy* qmlWindowProxy) { + qmlWindowProxy->deleteLater(); +} + static void dockWidgetDeleter(DockWidget* dockWidget) { dockWidget->deleteLater(); } @@ -85,13 +107,13 @@ void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) { * @property {string} [title="InteractiveWindow] - The title of the window. * @property {Vec2} [position] - The initial position of the window, in pixels. * @property {Vec2} [size] - The initial size of the window, in pixels - * @property {boolean} [visible=true] - true to make the window visible when created, false to make + * @property {boolean} [visible=true] - true to make the window visible when created, false to make * it invisible. - * @property {InteractiveWindow.PresentationMode} [presentationMode=Desktop.PresentationMode.VIRTUAL] - - * Desktop.PresentationMode.VIRTUAL to display the window inside Interface, .NATIVE to display it + * @property {InteractiveWindow.PresentationMode} [presentationMode=Desktop.PresentationMode.VIRTUAL] - + * Desktop.PresentationMode.VIRTUAL to display the window inside Interface, .NATIVE to display it * as its own separate window. - * @property {InteractiveWindow.PresentationWindowInfo} [presentationWindowInfo] - Controls how a NATIVE window is - * displayed. If used, the window is docked to the specified edge of the Interface window, otherwise the window is + * @property {InteractiveWindow.PresentationWindowInfo} [presentationWindowInfo] - Controls how a NATIVE window is + * displayed. If used, the window is docked to the specified edge of the Interface window, otherwise the window is * displayed as its own separate window. * @property {InteractiveWindow.AdditionalFlags} [additionalFlags=0] - Window behavior flags in addition to "native window flags" (minimize/maximize/close), * set at window creation. Possible flag values are provided as {@link Desktop|Desktop.ALWAYS_ON_TOP} and {@link Desktop|Desktop.CLOSE_BUTTON_HIDES}. @@ -124,7 +146,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap auto mainWindow = qApp->getWindow(); _dockWidget = std::shared_ptr(new DockWidget(title, mainWindow), dockWidgetDeleter); auto quickView = _dockWidget->getQuickView(); - + Application::setupQmlSurface(quickView->rootContext() , true); //add any whitelisted callbacks @@ -176,13 +198,12 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap }); _dockWidget->setSource(QUrl(sourceUrl)); - mainWindow->addDockWidget(dockArea, _dockWidget.get()); } else { auto offscreenUi = DependencyManager::get(); // Build the event bridge and wrapper on the main thread offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&](QQmlContext* context, QObject* object) { - _qmlWindow = object; + _qmlWindowProxy = std::shared_ptr(new QmlWindowProxy(object, nullptr), qmlWindowProxyDeleter); context->setContextProperty(EVENT_BRIDGE_PROPERTY, this); if (properties.contains(ADDITIONAL_FLAGS_PROPERTY)) { object->setProperty(ADDITIONAL_FLAGS_PROPERTY, properties[ADDITIONAL_FLAGS_PROPERTY].toUInt()); @@ -249,60 +270,48 @@ void InteractiveWindow::sendToQml(const QVariant& message) { QMetaObject::invokeMethod(rootItem, "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message)); } } else { - QMetaObject::invokeMethod(_qmlWindow, "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message)); + QMetaObject::invokeMethod(_qmlWindowProxy->getQmlWindow(), "fromScript", Qt::QueuedConnection, Q_ARG(QVariant, message)); } } void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "emitScriptEvent", Qt::QueuedConnection, Q_ARG(QVariant, scriptMessage)); - } else { - emit scriptEventReceived(scriptMessage); - } + emit scriptEventReceived(scriptMessage); } void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "emitWebEvent", Qt::QueuedConnection, Q_ARG(QVariant, webMessage)); - } else { - emit webEventReceived(webMessage); - } + emit webEventReceived(webMessage); } void InteractiveWindow::close() { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "close"); - return; + if (_qmlWindowProxy) { + QObject* qmlWindow = _qmlWindowProxy->getQmlWindow(); + if (qmlWindow) { + qmlWindow->deleteLater(); + } + _qmlWindowProxy->deleteLater(); } - if (_qmlWindow) { - _qmlWindow->deleteLater(); + if (_dockWidget) { + auto window = qApp->getWindow(); + if (QThread::currentThread() != window->thread()) { + BLOCKING_INVOKE_METHOD(window, "removeDockWidget", Q_ARG(QDockWidget*, _dockWidget.get())); + } else { + window->removeDockWidget(_dockWidget.get()); + } } - - qApp->getWindow()->removeDockWidget(_dockWidget.get()); _dockWidget = nullptr; - _qmlWindow = nullptr; + _qmlWindowProxy = nullptr; } void InteractiveWindow::show() { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "show"); - return; - } - - if (_qmlWindow) { - QMetaObject::invokeMethod(_qmlWindow, "show", Qt::DirectConnection); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy->getQmlWindow(), "show"); } } void InteractiveWindow::raise() { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "raise"); - return; - } - - if (_qmlWindow) { - QMetaObject::invokeMethod(_qmlWindow, "raiseWindow", Qt::DirectConnection); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy->getQmlWindow(), "raiseWindow"); } } @@ -317,144 +326,84 @@ void InteractiveWindow::qmlToScript(const QVariant& message) { } void InteractiveWindow::setVisible(bool visible) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setVisible", Q_ARG(bool, visible)); - return; - } - - if (!_qmlWindow.isNull()) { - _qmlWindow->setProperty(INTERACTIVE_WINDOW_VISIBLE_PROPERTY, visible); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy.get(), "writeProperty", Q_ARG(QString, INTERACTIVE_WINDOW_VISIBLE_PROPERTY), + Q_ARG(QVariant, visible)); } } bool InteractiveWindow::isVisible() const { - if (QThread::currentThread() != thread()) { - bool result = false; - BLOCKING_INVOKE_METHOD(const_cast(this), "isVisible", Q_RETURN_ARG(bool, result)); - return result; - } - - if (_qmlWindow.isNull()) { + if (!_qmlWindowProxy) { return false; } - return _qmlWindow->property(INTERACTIVE_WINDOW_VISIBLE_PROPERTY).toBool(); + return _qmlWindowProxy->readProperty(INTERACTIVE_WINDOW_VISIBLE_PROPERTY).toBool(); } glm::vec2 InteractiveWindow::getPosition() const { - if (QThread::currentThread() != thread()) { - glm::vec2 result; - BLOCKING_INVOKE_METHOD(const_cast(this), "getPosition", Q_RETURN_ARG(glm::vec2, result)); - return result; - } - - if (_qmlWindow.isNull()) { + if (!_qmlWindowProxy) { return {}; } - return toGlm(_qmlWindow->property(INTERACTIVE_WINDOW_POSITION_PROPERTY).toPointF()); + return toGlm(_qmlWindowProxy->readProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY).toPointF()); } void InteractiveWindow::setPosition(const glm::vec2& position) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setPosition", Q_ARG(const glm::vec2&, position)); - return; - } - - if (!_qmlWindow.isNull()) { - _qmlWindow->setProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY, QPointF(position.x, position.y)); - QMetaObject::invokeMethod(_qmlWindow, "updateInteractiveWindowPositionForMode", Qt::DirectConnection); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy.get(), "writeProperty", Q_ARG(QString, INTERACTIVE_WINDOW_POSITION_PROPERTY), + Q_ARG(QVariant, QPointF(position.x, position.y))); + QMetaObject::invokeMethod(_qmlWindowProxy->getQmlWindow(), "updateInteractiveWindowPositionForMode"); } } glm::vec2 InteractiveWindow::getSize() const { - if (QThread::currentThread() != thread()) { - glm::vec2 result; - BLOCKING_INVOKE_METHOD(const_cast(this), "getSize", Q_RETURN_ARG(glm::vec2, result)); - return result; - } - - if (_qmlWindow.isNull()) { + if (!_qmlWindowProxy) { return {}; } - return toGlm(_qmlWindow->property(INTERACTIVE_WINDOW_SIZE_PROPERTY).toSize()); + + return toGlm(_qmlWindowProxy->readProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY).toSize()); } void InteractiveWindow::setSize(const glm::vec2& size) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setSize", Q_ARG(const glm::vec2&, size)); - return; - } - - if (!_qmlWindow.isNull()) { - _qmlWindow->setProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY, QSize(size.x, size.y)); - QMetaObject::invokeMethod(_qmlWindow, "updateInteractiveWindowSizeForMode", Qt::DirectConnection); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy.get(), "writeProperty", Q_ARG(QString, INTERACTIVE_WINDOW_SIZE_PROPERTY), + Q_ARG(QVariant, QSize(size.x, size.y))); + QMetaObject::invokeMethod(_qmlWindowProxy->getQmlWindow(), "updateInteractiveWindowSizeForMode"); } } QString InteractiveWindow::getTitle() const { - if (QThread::currentThread() != thread()) { - QString result; - BLOCKING_INVOKE_METHOD(const_cast(this), "getTitle", Q_RETURN_ARG(QString, result)); - return result; - } - - if (_qmlWindow.isNull()) { + if (!_qmlWindowProxy) { return QString(); } - return _qmlWindow->property(TITLE_PROPERTY).toString(); + + return _qmlWindowProxy->readProperty(TITLE_PROPERTY).toString(); } void InteractiveWindow::setTitle(const QString& title) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setTitle", Q_ARG(const QString&, title)); - return; - } - - if (!_qmlWindow.isNull()) { - _qmlWindow->setProperty(TITLE_PROPERTY, title); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy.get(), "writeProperty", Q_ARG(QString, TITLE_PROPERTY), + Q_ARG(QVariant, title)); } } int InteractiveWindow::getPresentationMode() const { - if (QThread::currentThread() != thread()) { - int result; - BLOCKING_INVOKE_METHOD(const_cast(this), "getPresentationMode", - Q_RETURN_ARG(int, result)); - return result; - } - - if (_qmlWindow.isNull()) { + if (!_qmlWindowProxy) { return Virtual; } - return _qmlWindow->property(PRESENTATION_MODE_PROPERTY).toInt(); + + return _qmlWindowProxy->readProperty(PRESENTATION_MODE_PROPERTY).toInt(); } void InteractiveWindow::parentNativeWindowToMainWindow() { -#ifdef Q_OS_WIN - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "parentNativeWindowToMainWindow"); - return; + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy.get(), "parentNativeWindowToMainWindow"); } - if (_qmlWindow.isNull()) { - return; - } - const auto nativeWindowProperty = _qmlWindow->property("nativeWindow"); - if (nativeWindowProperty.isNull() || !nativeWindowProperty.isValid()) { - return; - } - const auto nativeWindow = qvariant_cast(nativeWindowProperty); - SetWindowLongPtr((HWND)nativeWindow->winId(), GWLP_HWNDPARENT, (LONG)MainWindow::findMainWindow()->winId()); -#endif } void InteractiveWindow::setPresentationMode(int presentationMode) { - if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setPresentationMode", Q_ARG(int, presentationMode)); - return; - } - - if (!_qmlWindow.isNull()) { - _qmlWindow->setProperty(PRESENTATION_MODE_PROPERTY, presentationMode); + if (_qmlWindowProxy) { + QMetaObject::invokeMethod(_qmlWindowProxy.get(), "writeProperty", Q_ARG(QString, PRESENTATION_MODE_PROPERTY), + Q_ARG(QVariant, presentationMode)); } } diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index c7b3631dde..0098658c16 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -18,10 +18,26 @@ #include #include #include +#include #include #include +class QmlWindowProxy : public QmlWrapper { + Q_OBJECT + +public: + QmlWindowProxy(QObject* qmlObject, QObject* parent = nullptr); + + Q_INVOKABLE void parentNativeWindowToMainWindow(); + + QObject* getQmlWindow() const { return _qmlWindow; } +private: + QObject* _qmlWindow; + +}; + + namespace InteractiveWindowEnums { Q_NAMESPACE @@ -291,7 +307,7 @@ protected slots: void forwardKeyReleaseEvent(int key, int modifiers); private: - QPointer _qmlWindow; + std::shared_ptr _qmlWindowProxy; std::shared_ptr _dockWidget { nullptr }; }; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index ce70e91128..ec15dd8111 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "scripting/RenderScriptingInterface.h" #include "Application.h" #include "DialogsManager.h" @@ -377,6 +378,33 @@ void setupPreferences() { preference->setDecimals(2); preferences->addPreference(preference); } + { + auto getter = []()->bool { + return qApp->getVisionSqueeze().getVisionSqueezeEnabled(); + }; + auto setter = [](bool value) { + qApp->getVisionSqueeze().setVisionSqueezeEnabled(value); + }; + auto preference = new CheckPreference(VR_MOVEMENT, "Enable HMD Comfort Mode", getter, setter); + preferences->addPreference(preference); + } + { + const float sliderPositions = 5.0f; + auto getter = [sliderPositions]()->float { + return roundf(sliderPositions * qApp->getVisionSqueeze().getVisionSqueezeRatioX()); + }; + auto setter = [sliderPositions](float value) { + float ratio = value / sliderPositions; + qApp->getVisionSqueeze().setVisionSqueezeRatioX(ratio); + qApp->getVisionSqueeze().setVisionSqueezeRatioY(ratio); + }; + auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Comfort Mode", getter, setter); + preference->setMin(0.0f); + preference->setMax(sliderPositions); + preference->setStep(1.0f); + preference->setDecimals(0); + preferences->addPreference(preference); + } { auto getter = [myAvatar]()->bool { return myAvatar->getShowPlayArea(); }; auto setter = [myAvatar](bool value) { myAvatar->setShowPlayArea(value); }; diff --git a/launchers/darwin/src/Launcher.m b/launchers/darwin/src/Launcher.m index 71eb7828e9..1a84e9143d 100644 --- a/launchers/darwin/src/Launcher.m +++ b/launchers/darwin/src/Launcher.m @@ -442,7 +442,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; NSString* contentPath = [[self getDownloadPathForContentAndScripts] stringByAppendingString:@"content"]; NSString* displayName = [ self displayName]; - NSString* scriptsPath = [[self getAppPath] stringByAppendingString:@"interface.app/Contents/Resources/scripts/simplifiedUI/"]; + NSString* scriptsPath = [[self getAppPath] stringByAppendingString:@"interface.app/Contents/Resources/scripts/simplifiedUIBootstrapper.js"]; NSString* domainUrl = [[Settings sharedSettings] getDomainUrl]; NSString* userToken = [[Launcher sharedLauncher] getTokenString]; NSString* homeBookmark = [[NSString stringWithFormat:@"hqhome="] stringByAppendingString:domainUrl]; @@ -453,7 +453,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; @"--tokens", userToken, @"--cache", contentPath, @"--displayName", displayName, - @"--scripts", scriptsPath, + @"--defaultScriptsOverride", scriptsPath, @"--setBookmark", homeBookmark, @"--no-updater", @"--no-launcher", nil]; @@ -461,7 +461,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE; arguments = [NSArray arrayWithObjects: @"--url" , domainUrl, @"--cache", contentPath, - @"--scripts", scriptsPath, + @"--defaultScriptsOverride", scriptsPath, @"--setBookmark", homeBookmark, @"--no-updater", @"--no-launcher", nil]; diff --git a/launchers/win32/LauncherDlg.cpp b/launchers/win32/LauncherDlg.cpp index 704a2f3050..2e5d568839 100644 --- a/launchers/win32/LauncherDlg.cpp +++ b/launchers/win32/LauncherDlg.cpp @@ -672,7 +672,7 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) { theApp._manager.addToLog(_T("Start splash screen")); setDrawDialog(DrawStep::DrawLogo); } - } else if (_splashStep > 100) { + } else if (_splashStep > 100 && !theApp._manager.needsToWait()) { _showSplash = false; if (theApp._manager.shouldShutDown()) { if (_applicationWND != NULL) { diff --git a/launchers/win32/LauncherManager.cpp b/launchers/win32/LauncherManager.cpp index e56e0e71fc..294c9742f5 100644 --- a/launchers/win32/LauncherManager.cpp +++ b/launchers/win32/LauncherManager.cpp @@ -24,35 +24,7 @@ LauncherManager::~LauncherManager() { void LauncherManager::init() { initLog(); addToLog(_T("Getting most recent build")); - CString response; - LauncherUtils::ResponseError error = getMostRecentBuild(_latestApplicationURL, _latestVersion, response); - if (error == LauncherUtils::ResponseError::NoError) { - addToLog(_T("Latest version: ") + _latestVersion); - CString currentVersion; - if (isApplicationInstalled(currentVersion, _domainURL, _contentURL, _loggedIn) && _loggedIn) { - addToLog(_T("Installed version: ") + currentVersion); - if (_latestVersion.Compare(currentVersion) == 0) { - addToLog(_T("Already running most recent build. Launching interface.exe")); - _shouldLaunch = TRUE; - _shouldShutdown = TRUE; - } else { - addToLog(_T("New build found. Updating")); - _shouldUpdate = TRUE; - } - } else if (_loggedIn) { - addToLog(_T("Interface not found but logged in. Reinstalling")); - _shouldUpdate = TRUE; - } else { - _shouldInstall = TRUE; - } - } else { - _hasFailed = true; - CString msg; - msg.Format(_T("Getting most recent build has failed with error: %d"), error); - addToLog(msg); - msg.Format(_T("Response: %s"), response); - addToLog(msg); - } + getMostRecentBuild(_latestApplicationURL, _latestVersion); } BOOL LauncherManager::initLog() { @@ -387,39 +359,71 @@ LauncherUtils::ResponseError LauncherManager::readOrganizationJSON(const CString return LauncherUtils::ResponseError::ParsingJSON; } -LauncherUtils::ResponseError LauncherManager::getMostRecentBuild(CString& urlOut, CString& versionOut, - CString& response) { +void LauncherManager::getMostRecentBuild(CString& urlOut, CString& versionOut) { CString contentTypeJson = L"content-type:application/json"; - LauncherUtils::ResponseError error = LauncherUtils::makeHTTPCall(L"HQ Launcher", - L"thunder.highfidelity.com", - L"/builds/api/tags/latest?format=json", - contentTypeJson, CStringA(), - response, false); - if (error != LauncherUtils::ResponseError::NoError) { - return error; - } - Json::Value json; - if (LauncherUtils::parseJSON(response, json)) { - int count = json["count"].isInt() ? json["count"].asInt() : 0; - if (count > 0 && json["results"].isArray()) { - for (int i = 0; i < count; i++) { - if (json["results"][i].isObject()) { - Json::Value result = json["results"][i]; - if (result["latest_version"].isInt()) { - std::string version = std::to_string(result["latest_version"].asInt()); - versionOut = CString(version.c_str()); - } - if (result["installers"].isObject() && - result["installers"]["windows"].isObject() && - result["installers"]["windows"]["zip_url"].isString()) { - urlOut = result["installers"]["windows"]["zip_url"].asCString(); - return LauncherUtils::ResponseError::NoError; + std::function httpCallback = [&](CString response, int err) { + LauncherUtils::ResponseError error = LauncherUtils::ResponseError(err); + if (error == LauncherUtils::ResponseError::NoError) { + Json::Value json; + error = LauncherUtils::ResponseError::ParsingJSON; + if (LauncherUtils::parseJSON(response, json)) { + int count = json["count"].isInt() ? json["count"].asInt() : 0; + if (count > 0 && json["results"].isArray()) { + for (int i = 0; i < count; i++) { + if (json["results"][i].isObject()) { + Json::Value result = json["results"][i]; + if (result["latest_version"].isInt()) { + std::string version = std::to_string(result["latest_version"].asInt()); + versionOut = CString(version.c_str()); + } + if (result["installers"].isObject() && + result["installers"]["windows"].isObject() && + result["installers"]["windows"]["zip_url"].isString()) { + urlOut = result["installers"]["windows"]["zip_url"].asCString(); + error = LauncherUtils::ResponseError::NoError; + } + } } } } + onMostRecentBuildReceived(response, error); } + }; + LauncherUtils::httpCallOnThread(L"HQ Launcher", + L"thunder.highfidelity.com", + L"/builds/api/tags/latest?format=json", + contentTypeJson, CStringA(), false, httpCallback); +} + +void LauncherManager::onMostRecentBuildReceived(const CString& response, LauncherUtils::ResponseError error) { + if (error == LauncherUtils::ResponseError::NoError) { + addToLog(_T("Latest version: ") + _latestVersion); + CString currentVersion; + if (isApplicationInstalled(currentVersion, _domainURL, _contentURL, _loggedIn) && _loggedIn) { + addToLog(_T("Installed version: ") + currentVersion); + if (_latestVersion.Compare(currentVersion) == 0) { + addToLog(_T("Already running most recent build. Launching interface.exe")); + _shouldLaunch = TRUE; + _shouldShutdown = TRUE; + } else { + addToLog(_T("New build found. Updating")); + _shouldUpdate = TRUE; + } + } else if (_loggedIn) { + addToLog(_T("Interface not found but logged in. Reinstalling")); + _shouldUpdate = TRUE; + } else { + _shouldInstall = TRUE; + } + _shouldWait = FALSE; + } else { + _hasFailed = true; + CString msg; + msg.Format(_T("Getting most recent build has failed with error: %d"), error); + addToLog(msg); + msg.Format(_T("Response: %s"), response); + addToLog(msg); } - return LauncherUtils::ResponseError::ParsingJSON; } LauncherUtils::ResponseError LauncherManager::getAccessTokenForCredentials(const CString& username, @@ -603,12 +607,10 @@ BOOL LauncherManager::downloadFile(ProcessType type, const CString& url, CString std::function onDownloadFinished = [&](int type, bool error) { if (!error) { onFileDownloaded((ProcessType)type); - } - else { + } else { if (type == ProcessType::DownloadApplication) { addToLog(_T("Error downloading content.")); - } - else { + } else { addToLog(_T("Error downloading application.")); } _hasFailed = true; diff --git a/launchers/win32/LauncherManager.h b/launchers/win32/LauncherManager.h index cb707e0a14..6ebebc5fc3 100644 --- a/launchers/win32/LauncherManager.h +++ b/launchers/win32/LauncherManager.h @@ -67,7 +67,7 @@ public: BOOL isApplicationInstalled(CString& version, CString& domain, CString& content, bool& loggedIn); LauncherUtils::ResponseError getAccessTokenForCredentials(const CString& username, const CString& password); - LauncherUtils::ResponseError getMostRecentBuild(CString& urlOut, CString& versionOut, CString& response); + void getMostRecentBuild(CString& urlOut, CString& versionOut); LauncherUtils::ResponseError readOrganizationJSON(const CString& hash); LauncherUtils::ResponseError readConfigJSON(CString& version, CString& domain, CString& content, bool& loggedIn); @@ -90,12 +90,13 @@ public: BOOL needsUpdate() { return _shouldUpdate; } BOOL needsUninstall() { return _shouldUninstall; } BOOL needsInstall() { return _shouldInstall; } + BOOL needsToWait() { return _shouldWait; } void setDisplayName(const CString& displayName) { _displayName = displayName; } bool isLoggedIn() { return _loggedIn; } bool hasFailed() { return _hasFailed; } void setFailed(bool hasFailed) { _hasFailed = hasFailed; } const CString& getLatestInterfaceURL() const { return _latestApplicationURL; } - void uninstall() { _shouldUninstall = true; }; + void uninstall() { _shouldUninstall = true; _shouldWait = false; }; BOOL downloadFile(ProcessType type, const CString& url, CString& localPath); BOOL downloadContent(); @@ -110,6 +111,7 @@ public: private: ProcessType _currentProcess { ProcessType::DownloadApplication }; + void onMostRecentBuildReceived(const CString& response, LauncherUtils::ResponseError error); CString _latestApplicationURL; CString _latestVersion; CString _contentURL; @@ -126,6 +128,7 @@ private: BOOL _shouldInstall { FALSE }; BOOL _shouldShutdown { FALSE }; BOOL _shouldLaunch { FALSE }; + BOOL _shouldWait { TRUE }; float _progress { 0.0f }; CStdioFile _logFile; }; diff --git a/launchers/win32/LauncherUtils.cpp b/launchers/win32/LauncherUtils.cpp index 3ba4b26901..e0a85302f0 100644 --- a/launchers/win32/LauncherUtils.cpp +++ b/launchers/win32/LauncherUtils.cpp @@ -470,9 +470,9 @@ BOOL LauncherUtils::hMac256(const CString& cmessage, const char* keystr, CString DWORD WINAPI LauncherUtils::unzipThread(LPVOID lpParameter) { UnzipThreadData& data = *((UnzipThreadData*)lpParameter); - uint64_t size = LauncherUtils::extractZip(data._zipFile, data._path, std::vector(), data.progressCallback); + uint64_t size = LauncherUtils::extractZip(data._zipFile, data._path, std::vector(), data._progressCallback); int mb_size = (int)(size * 0.001f); - data.callback(data._type, mb_size); + data._callback(data._type, mb_size); delete &data; return 0; } @@ -480,17 +480,26 @@ DWORD WINAPI LauncherUtils::unzipThread(LPVOID lpParameter) { DWORD WINAPI LauncherUtils::downloadThread(LPVOID lpParameter) { DownloadThreadData& data = *((DownloadThreadData*)lpParameter); ProgressCallback progressCallback; - progressCallback.setProgressCallback(data.progressCallback); + progressCallback.setProgressCallback(data._progressCallback); auto hr = URLDownloadToFile(0, data._url, data._file, 0, static_cast(&progressCallback)); - data.callback(data._type, hr != S_OK); + data._callback(data._type, hr != S_OK); return 0; } DWORD WINAPI LauncherUtils::deleteDirectoryThread(LPVOID lpParameter) { DeleteThreadData& data = *((DeleteThreadData*)lpParameter); BOOL success = LauncherUtils::deleteFileOrDirectory(data._dirPath); - data.callback(!success); + data._callback(!success); + return 0; +} + +DWORD WINAPI LauncherUtils::httpThread(LPVOID lpParameter) { + HttpThreadData& data = *((HttpThreadData*)lpParameter); + CString response; + auto error = LauncherUtils::makeHTTPCall(data._callerName, data._mainUrl, data._dirUrl, + data._contentType, data._postData, response, data._isPost); + data._callback(response, error); return 0; } @@ -543,6 +552,26 @@ BOOL LauncherUtils::deleteDirectoryOnThread(const CString& dirPath, std::functio return FALSE; } +BOOL LauncherUtils::httpCallOnThread(const CString& callerName, const CString& mainUrl, const CString& dirUrl, + const CString& contentType, CStringA& postData, bool isPost, + std::function callback) { + DWORD myThreadID; + HttpThreadData* httpThreadData = new HttpThreadData(); + httpThreadData->_callerName = callerName; + httpThreadData->_mainUrl = mainUrl; + httpThreadData->_dirUrl = dirUrl; + httpThreadData->_contentType = contentType; + httpThreadData->_postData = postData; + httpThreadData->_isPost = isPost; + httpThreadData->setCallback(callback); + HANDLE myHandle = CreateThread(0, 0, httpThread, httpThreadData, 0, &myThreadID); + if (myHandle) { + CloseHandle(myHandle); + return TRUE; + } + return FALSE; +} + HWND LauncherUtils::executeOnForeground(const CString& path, const CString& params) { SHELLEXECUTEINFO info; info.cbSize = sizeof(SHELLEXECUTEINFO); diff --git a/launchers/win32/LauncherUtils.h b/launchers/win32/LauncherUtils.h index 3e07d2af05..32cd5031b4 100644 --- a/launchers/win32/LauncherUtils.h +++ b/launchers/win32/LauncherUtils.h @@ -55,15 +55,15 @@ public: ULONG ulStatusCode, LPCWSTR szStatusText) { float progress = (float)ulProgress / ulProgressMax; if (!isnan(progress)) { - onProgressCallback(progress); + _onProgressCallback(progress); } return S_OK; } void setProgressCallback(std::function fn) { - onProgressCallback = std::bind(fn, std::placeholders::_1); + _onProgressCallback = std::bind(fn, std::placeholders::_1); } private: - std::function onProgressCallback; + std::function _onProgressCallback; }; enum ResponseError { @@ -82,14 +82,14 @@ public: int _type; CString _url; CString _file; - std::function callback; - std::function progressCallback; + std::function _callback; + std::function _progressCallback; // function(type, errorType) void setCallback(std::function fn) { - callback = std::bind(fn, std::placeholders::_1, std::placeholders::_2); + _callback = std::bind(fn, std::placeholders::_1, std::placeholders::_2); } void setProgressCallback(std::function fn) { - progressCallback = std::bind(fn, std::placeholders::_1); + _progressCallback = std::bind(fn, std::placeholders::_1); } }; @@ -98,23 +98,36 @@ public: std::string _zipFile; std::string _path; // function(type, size) - std::function callback; - std::function progressCallback; + std::function _callback; + std::function _progressCallback; void setCallback(std::function fn) { - callback = std::bind(fn, std::placeholders::_1, std::placeholders::_2); + _callback = std::bind(fn, std::placeholders::_1, std::placeholders::_2); } void setProgressCallback(std::function fn) { - progressCallback = std::bind(fn, std::placeholders::_1); + _progressCallback = std::bind(fn, std::placeholders::_1); } }; struct DeleteThreadData { CString _dirPath; - std::function callback; - std::function progressCallback; - void setCallback(std::function fn) { callback = std::bind(fn, std::placeholders::_1); } + std::function _callback; + std::function _progressCallback; + void setCallback(std::function fn) { _callback = std::bind(fn, std::placeholders::_1); } void setProgressCallback(std::function fn) { - progressCallback = std::bind(fn, std::placeholders::_1); + _progressCallback = std::bind(fn, std::placeholders::_1); + } + }; + + struct HttpThreadData { + CString _callerName; + CString _mainUrl; + CString _dirUrl; + CString _contentType; + CStringA _postData; + bool _isPost { false }; + std::function _callback; + void setCallback(std::function fn) { + _callback = std::bind(fn, std::placeholders::_1, std::placeholders::_2); } }; @@ -150,6 +163,9 @@ public: std::function callback, std::function progressCallback); static BOOL deleteDirectoryOnThread(const CString& dirPath, std::function callback); + static BOOL httpCallOnThread(const CString& callerName, const CString& mainUrl, const CString& dirUrl, + const CString& contentType, CStringA& postData, bool isPost, + std::function callback); static CString urlEncodeString(const CString& url); static HWND executeOnForeground(const CString& path, const CString& params); @@ -159,4 +175,5 @@ private: static DWORD WINAPI unzipThread(LPVOID lpParameter); static DWORD WINAPI downloadThread(LPVOID lpParameter); static DWORD WINAPI deleteDirectoryThread(LPVOID lpParameter); -}; \ No newline at end of file + static DWORD WINAPI httpThread(LPVOID lpParameter); +}; diff --git a/libraries/animation/src/AnimInverseKinematics.cpp b/libraries/animation/src/AnimInverseKinematics.cpp index ed3d5d67d6..8d98f9c775 100644 --- a/libraries/animation/src/AnimInverseKinematics.cpp +++ b/libraries/animation/src/AnimInverseKinematics.cpp @@ -431,7 +431,6 @@ void AnimInverseKinematics::solveTargetWithCCD(const AnimContext& context, const constrained = constraint->apply(tipRelativeRotation); if (constrained) { tipOrientation = tipParentOrientation * tipRelativeRotation; - tipRelativeRotation = tipRelativeRotation; } } diff --git a/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.cpp b/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.cpp index d068bef3b0..4515a28997 100644 --- a/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.cpp +++ b/libraries/display-plugins/src/display-plugins/AbstractHMDScriptingInterface.cpp @@ -47,5 +47,9 @@ void AbstractHMDScriptingInterface::setIPDScale(float IPDScale) { } bool AbstractHMDScriptingInterface::isHMDMode() const { - return PluginContainer::getInstance().getActiveDisplayPlugin()->isHmd(); -} + auto displayPlugin = PluginContainer::getInstance().getActiveDisplayPlugin(); + if (displayPlugin) { + return displayPlugin->isHmd(); + } + return false; +} \ No newline at end of file diff --git a/libraries/display-plugins/src/display-plugins/DrawTextureWithVisionSqueeze.slf b/libraries/display-plugins/src/display-plugins/DrawTextureWithVisionSqueeze.slf new file mode 100644 index 0000000000..1092608421 --- /dev/null +++ b/libraries/display-plugins/src/display-plugins/DrawTextureWithVisionSqueeze.slf @@ -0,0 +1,104 @@ +<@include gpu/Config.slh@> +<$VERSION_HEADER$> +// Generated on <$_SCRIBE_DATE$> +// +// DrawTextureWithVisionSqueeze.frag +// +// Draw texture 0 fetched at texcoord.xy +// +// Created by Seth Alves on 2019-2-15 +// Copyright 2019 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 display-plugins/VisionSqueeze.slh@> + +struct DrawTextureWithVisionSqueezeParams { + float _visionSqueezeX; + float _visionSqueezeY; + float _spareA; + float _spareB; + mat4 _leftProjection; + mat4 _rightProjection; + mat4 _hmdSensorMatrix; + float _visionSqueezeTransition; + int _visionSqueezePerEye; + float _visionSqueezeGroundPlaneY; + float _visionSqueezeSpotlightSize; +}; + + +LAYOUT(binding=0) uniform sampler2D colorMap; + +// binding=1 must match drawTextureWithSqueezeParamsSlot in OpenGLDisplayPlugin.h +LAYOUT(binding=1) uniform drawTextureWithSqueezeMappingParamsBuffer { + DrawTextureWithVisionSqueezeParams params; +}; + +layout(location=0) in vec2 varTexCoord0; +layout(location=0) out vec4 outFragColor; + + +float getVisionSqueezeX() { + return params._visionSqueezeX; +} +float getVisionSqueezeY() { + return params._visionSqueezeY; +} +float getVisionSqueezeTransitionRatio() { + return params._visionSqueezeTransition; +} +int getVisionSqueezePerEye() { + return params._visionSqueezePerEye; +} +float getVisionSqueezeGroundPlaneY() { + return params._visionSqueezeGroundPlaneY; +} +float getVisionSqueezeSpotlightSize() { + return params._visionSqueezeSpotlightSize; +} +mat4 getProjectionMatrix(float eye) { + if (eye == 0.0) { + return params._leftProjection; + } else { + return params._rightProjection; + } +} +mat4 getHMDSensorMatrix() { + return params._hmdSensorMatrix; +} + + +void main(void) { + + float side = float(varTexCoord0.x > 0.5); + mat4 leftProjectionMatrix = getProjectionMatrix(0.0); + vec4 fovTan = extractFovTan(leftProjectionMatrix); + vec2 focalPointNDC = extractFocalPoint(fovTan); + focalPointNDC.x -= 2.0 * focalPointNDC.x * (1.0 - side); + vec2 focalPointUV = 0.5 * (focalPointNDC + vec2(1.0)); + + // block edges of vision to avoid sickness + vec2 visionSqueezeRatios = vec2(getVisionSqueezeX(), getVisionSqueezeY()); + bool perEye = getVisionSqueezePerEye() > 0; + float frac = squeezeVision(perEye, varTexCoord0, visionSqueezeRatios, getVisionSqueezeTransitionRatio(), focalPointUV); + + if (frac == 0.0) { + // world only + outFragColor = texture(colorMap, varTexCoord0); + } else { + // grid on the floor only or mixed + mat4 hmdSensorMatrix = getHMDSensorMatrix(); + mat4 projectionMatrix = getProjectionMatrix(side); + mat4 projectionInverse = inverse(projectionMatrix); + float groundPlaneY = getVisionSqueezeGroundPlaneY(); + float spotLightSize = getVisionSqueezeSpotlightSize(); + vec4 gridColor = vec4(gridFloor(varTexCoord0, hmdSensorMatrix, projectionInverse, groundPlaneY, spotLightSize), 1.0); + + vec4 preSqueezeColor = texture(colorMap, varTexCoord0); + // mix between grid and world + outFragColor = mix(preSqueezeColor, gridColor, frac); + } +} diff --git a/libraries/display-plugins/src/display-plugins/DrawTextureWithVisionSqueeze.slp b/libraries/display-plugins/src/display-plugins/DrawTextureWithVisionSqueeze.slp new file mode 100644 index 0000000000..c2c4bfbebd --- /dev/null +++ b/libraries/display-plugins/src/display-plugins/DrawTextureWithVisionSqueeze.slp @@ -0,0 +1 @@ +VERTEX gpu::vertex::DrawUnitQuadTexcoord diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index ebbf888e83..1d0fc5a128 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -392,6 +392,9 @@ void OpenGLDisplayPlugin::customizeContext() { _drawTexturePipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTexture), scissorState); + _drawTextureSqueezePipeline = + gpu::Pipeline::create(gpu::Shader::createProgram(shader::display_plugins::program::DrawTextureWithVisionSqueeze), scissorState); + _linearToSRGBPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureLinearToSRGB), scissorState); _SRGBToLinearPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureSRGBToLinear), scissorState); @@ -407,6 +410,7 @@ void OpenGLDisplayPlugin::customizeContext() { void OpenGLDisplayPlugin::uncustomizeContext() { _drawTexturePipeline.reset(); + _drawTextureSqueezePipeline.reset(); _linearToSRGBPipeline.reset(); _SRGBToLinearPipeline.reset(); _cursorPipeline.reset(); @@ -629,6 +633,10 @@ void OpenGLDisplayPlugin::compositePointer() { }); } +void OpenGLDisplayPlugin::setupCompositeScenePipeline(gpu::Batch& batch) { + batch.setPipeline(_drawTexturePipeline); +} + void OpenGLDisplayPlugin::compositeScene() { render([&](gpu::Batch& batch) { batch.enableStereo(false); @@ -637,8 +645,8 @@ void OpenGLDisplayPlugin::compositeScene() { batch.setStateScissorRect(ivec4(uvec2(), _compositeFramebuffer->getSize())); batch.resetViewTransform(); batch.setProjectionTransform(mat4()); - batch.setPipeline(_drawTexturePipeline); batch.setResourceTexture(0, _currentFrame->framebuffer->getRenderBuffer(0)); + setupCompositeScenePipeline(batch); batch.draw(gpu::TRIANGLE_STRIP, 4); }); } @@ -958,4 +966,3 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne gpu::PipelinePointer OpenGLDisplayPlugin::getRenderTexturePipeline() { return _drawTexturePipeline; } - diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index 6fb36bff90..5eebd92fba 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -100,6 +100,7 @@ protected: virtual QThread::Priority getPresentPriority() { return QThread::HighPriority; } virtual void compositeLayers(); + virtual void setupCompositeScenePipeline(gpu::Batch& batch); virtual void compositeScene(); virtual void compositePointer(); virtual void compositeExtra(){}; @@ -155,6 +156,7 @@ protected: gpu::PipelinePointer _mirrorHUDPipeline; gpu::ShaderPointer _mirrorHUDPS; gpu::PipelinePointer _drawTexturePipeline; + gpu::PipelinePointer _drawTextureSqueezePipeline; gpu::PipelinePointer _linearToSRGBPipeline; gpu::PipelinePointer _SRGBToLinearPipeline; gpu::PipelinePointer _cursorPipeline; diff --git a/libraries/display-plugins/src/display-plugins/VisionSqueeze.slh b/libraries/display-plugins/src/display-plugins/VisionSqueeze.slh new file mode 100644 index 0000000000..28e5f12337 --- /dev/null +++ b/libraries/display-plugins/src/display-plugins/VisionSqueeze.slh @@ -0,0 +1,106 @@ +// Generated on <$_SCRIBE_DATE$> +// +// Created by Seth Alves on 2019-2-13. +// Copyright 2019 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 +// + +<@if not VISION_SQUEEZE_SLH@> +<@def VISION_SQUEEZE_SLH@> + + +float ellipse(vec2 coord, vec2 centerUV, vec2 semiAxis) { + return pow(coord.x - centerUV.x, 2.0) / semiAxis.x + pow(coord.y - centerUV.y, 2.0) / semiAxis.y; +} + +vec4 extractFovTan(mat4 m) { + mat4 mt = transpose(m); + vec4 v; + vec4 result; + + // x -- Left + v = mt * vec4(1.0, 0.0, 0.0, 1.0); + result.x = -(v.z / v.x); + // y -- Right + v = mt * vec4(-1.0, 0.0, 0.0, 1.0); + result.y = (v.z / v.x); + // z -- Down + v = mt * vec4(0.0, 1.0, 0.0, 1.0); + result.z = -(v.z / v.y); + // w -- Up + v = mt * vec4(0.0, -1.0, 0.0, 1.0); + result.w = v.z / v.y; + return result; +} + +// takes left-side projection matrix, returns NDC for right eye. to get left, invert sign on x coord of result. +vec2 extractFocalPoint(vec4 fovTan) { + float fovwidth = fovTan.x + fovTan.y; + float fovheight = fovTan.z + fovTan.w; + vec2 focalPoint = vec2(fovTan.y / fovwidth, (fovTan.z / fovheight) - 0.5f); + return focalPoint; +} + +float squeezeVision(bool perEye, vec2 varTexCoord0, vec2 visionSqueezeRatios, float transitionRatio, vec2 focalPointUV) { + if (visionSqueezeRatios.x == 0.0 && visionSqueezeRatios.y == 0.0) { + return 0.0; + } + + vec2 centerUV; + vec2 semiAxis; + if (perEye) { + // tubes in front of each eye + centerUV = focalPointUV; + semiAxis = vec2(0.25) - visionSqueezeRatios * 0.25; + } else { + // one tube in front of face + centerUV = vec2(0.5, focalPointUV.y); + semiAxis = vec2(0.5) - visionSqueezeRatios * 0.5; + } + float ellipseValue = ellipse(varTexCoord0, centerUV, semiAxis); + float frac = clamp((ellipseValue - 1.0) / clamp(transitionRatio, 0.01, 0.7), 0.0, 1.0); + + return frac; +} + +vec3 gridFloor(vec2 varTexCoord0, mat4 hmdSensorMatrix, mat4 projectionInverse, float groundPlaneY, float spotLightSize) { + vec4 ndc = vec4(varTexCoord0.x * 4.0 - 1.0 - 2.0 * float(varTexCoord0.x > 0.5), varTexCoord0.y * 2.0 - 1.0, -1.0, 1.0); + + vec4 fragmentEyeCoords = hmdSensorMatrix * projectionInverse * ndc; + vec4 near4 = hmdSensorMatrix * vec4(0.0, 0.0, 0.0, 1.0); + + vec3 near = (near4 / near4.w).xyz; + vec3 far = fragmentEyeCoords.xyz / fragmentEyeCoords.w; + + // intersect a line from near to far with the plane y = groundPlaneY + float t = -(near.y - groundPlaneY) / (far.y - near.y); + vec2 R = (near + t * (far - near)).xz; + + float lineThickness = 1.5 / length(R); + vec4 gridColor = vec4(0.35); + vec4 baseColor = vec4(0.1); + vec4 skyColor = vec4(0.0, 0.0, 0.0, 0.0); + vec2 wrapped = fract(R) - 0.5f; + vec2 range = abs(wrapped); + vec2 speeds = fwidth(R); + vec2 pixelRange = range/speeds; + float lineWeight = clamp(min(pixelRange.x, pixelRange.y) - lineThickness, 0.0, 1.0); + + float horizonFuzz = 0.02; + if (t < 0.0) { + return mix(gridColor, skyColor, clamp(0.0, 1.0, -t)).xyz; + } else if (t < horizonFuzz) { + lineWeight = lineWeight * max(0.0, t); + } + + vec4 c = mix(gridColor, baseColor, lineWeight); + + // fade out grid to avoid shimmer + float fadeVal = 0.7; + return mix(c, baseColor * fadeVal + gridColor * (1.0 - fadeVal), + 0.1 * clamp((length(R) - spotLightSize), 0.0, 1.0)).xyz; +} + +<@endif@> diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 3cec5e8265..24c16c1493 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -1,4 +1,4 @@ -// +// // Created by Bradley Austin Davis on 2016/02/15 // Copyright 2016 High Fidelity, Inc. // @@ -113,6 +113,11 @@ void HmdDisplayPlugin::internalDeactivate() { } void HmdDisplayPlugin::customizeContext() { + + VisionSqueezeParameters parameters; + _visionSqueezeParametersBuffer = + gpu::BufferView(std::make_shared(sizeof(VisionSqueezeParameters), (const gpu::Byte*) ¶meters)); + Parent::customizeContext(); _hudRenderer.build(); } @@ -478,3 +483,48 @@ HmdDisplayPlugin::~HmdDisplayPlugin() { float HmdDisplayPlugin::stutterRate() const { return _stutterRate.rate(); } + +float adjustVisionSqueezeRatioForDevice(float visionSqueezeRatio, float visionSqueezeDeviceLow, float visionSqueezeDeviceHigh) { + if (visionSqueezeRatio <= 0.0f) { + return 0.0f; + } + + float deviceRange = visionSqueezeDeviceHigh - visionSqueezeDeviceLow; + const float SQUEEZE_ADJUSTMENT = 0.75f; // magic number picked through experimentation + return deviceRange * (SQUEEZE_ADJUSTMENT * visionSqueezeRatio) + visionSqueezeDeviceLow; +} + +void HmdDisplayPlugin::updateVisionSqueezeParameters(float visionSqueezeX, float visionSqueezeY, + float visionSqueezeTransition, + int visionSqueezePerEye, float visionSqueezeGroundPlaneY, + float visionSqueezeSpotlightSize) { + + visionSqueezeX = adjustVisionSqueezeRatioForDevice(visionSqueezeX, _visionSqueezeDeviceLowX, _visionSqueezeDeviceHighX); + visionSqueezeY = adjustVisionSqueezeRatioForDevice(visionSqueezeY, _visionSqueezeDeviceLowY, _visionSqueezeDeviceHighY); + + auto& params = _visionSqueezeParametersBuffer.get(); + if (params._visionSqueezeX != visionSqueezeX) { + _visionSqueezeParametersBuffer.edit()._visionSqueezeX = visionSqueezeX; + } + if (params._visionSqueezeY != visionSqueezeY) { + _visionSqueezeParametersBuffer.edit()._visionSqueezeY = visionSqueezeY; + } + if (params._visionSqueezeTransition != visionSqueezeTransition) { + _visionSqueezeParametersBuffer.edit()._visionSqueezeTransition = visionSqueezeTransition; + } + if (params._visionSqueezePerEye != visionSqueezePerEye) { + _visionSqueezeParametersBuffer.edit()._visionSqueezePerEye = visionSqueezePerEye; + } + if (params._visionSqueezeGroundPlaneY != visionSqueezeGroundPlaneY) { + _visionSqueezeParametersBuffer.edit()._visionSqueezeGroundPlaneY = visionSqueezeGroundPlaneY; + } + if (params._visionSqueezeSpotlightSize != visionSqueezeSpotlightSize) { + _visionSqueezeParametersBuffer.edit()._visionSqueezeSpotlightSize = visionSqueezeSpotlightSize; + } +} + +void HmdDisplayPlugin::setupCompositeScenePipeline(gpu::Batch& batch) { + batch.setPipeline(_drawTextureSqueezePipeline); + _visionSqueezeParametersBuffer.edit()._hmdSensorMatrix = _currentPresentFrameInfo.presentPose; + batch.setUniformBuffer(drawTextureWithVisionSqueezeParamsSlot, _visionSqueezeParametersBuffer); +} diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h index a381f04689..5317ec54da 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h @@ -50,6 +50,9 @@ public: std::function getHUDOperator() override; virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::PAINT; } + void updateVisionSqueezeParameters(float visionSqueezeX, float visionSqueezeY, float visionSqueezeTransition, + int visionSqueezePerEye, float visionSqueezeGroundPlaneY, + float visionSqueezeSpotlightSize); signals: void hmdMountedChanged(); @@ -91,6 +94,33 @@ protected: RateCounter<> _stutterRate; bool _disablePreview { true }; + + class VisionSqueezeParameters { + public: + float _visionSqueezeX { 0.0f }; + float _visionSqueezeY { 0.0f }; + float _spareA { 0.0f }; + float _spareB { 0.0f }; + glm::mat4 _leftProjection; + glm::mat4 _rightProjection; + glm::mat4 _hmdSensorMatrix; + float _visionSqueezeTransition { 0.15f }; + int _visionSqueezePerEye { 0 }; + float _visionSqueezeGroundPlaneY { 0.0f }; + float _visionSqueezeSpotlightSize { 0.0f }; + + VisionSqueezeParameters() {} + }; + typedef gpu::BufferView UniformBufferView; + gpu::BufferView _visionSqueezeParametersBuffer; + + virtual void setupCompositeScenePipeline(gpu::Batch& batch) override; + + float _visionSqueezeDeviceLowX { 0.0f }; + float _visionSqueezeDeviceHighX { 1.0f }; + float _visionSqueezeDeviceLowY { 0.0f }; + float _visionSqueezeDeviceHighY { 1.0f }; + private: ivec4 getViewportForSourceSize(const uvec2& size) const; float getLeftCenterPixel() const; @@ -112,7 +142,7 @@ private: struct Uniforms { float alpha { 1.0f }; } uniforms; - + struct Vertex { vec3 pos; vec2 uv; @@ -126,3 +156,5 @@ private: std::function render(); } _hudRenderer; }; + +const int drawTextureWithVisionSqueezeParamsSlot = 1; // must match binding in DrawTextureWithVisionSqueeze.slf diff --git a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp index 31969e36fc..d8f0d93bb6 100644 --- a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp @@ -122,7 +122,7 @@ void GridEntityRenderer::doRender(RenderArgs* args) { forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD; }); - if (!_visible) { + if (!_visible || color.a == 0.0f) { return; } diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index cfc94ad92c..9d23bd09ad 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -282,27 +282,26 @@ bool RenderableModelEntityItem::findDetailedParabolaIntersection(const glm::vec3 } void RenderableModelEntityItem::fetchCollisionGeometryResource() { - _compoundShapeResource = DependencyManager::get()->getCollisionGeometryResource(getCollisionShapeURL()); + _collisionGeometryResource = DependencyManager::get()->getCollisionGeometryResource(getCollisionShapeURL()); } -bool RenderableModelEntityItem::computeShapeFailedToLoad() { - if (!_compoundShapeResource) { +bool RenderableModelEntityItem::unableToLoadCollisionShape() { + if (!_collisionGeometryResource) { fetchCollisionGeometryResource(); } - - return (_compoundShapeResource && _compoundShapeResource->isFailed()); + return (_collisionGeometryResource && _collisionGeometryResource->isFailed()); } void RenderableModelEntityItem::setShapeType(ShapeType type) { ModelEntityItem::setShapeType(type); auto shapeType = getShapeType(); if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) { - if (!_compoundShapeResource && !getCollisionShapeURL().isEmpty()) { + if (!_collisionGeometryResource && !getCollisionShapeURL().isEmpty()) { fetchCollisionGeometryResource(); } - } else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) { + } else if (_collisionGeometryResource && !getCompoundShapeURL().isEmpty()) { // the compoundURL has been set but the shapeType does not agree - _compoundShapeResource.reset(); + _collisionGeometryResource.reset(); } } @@ -333,11 +332,11 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const { } if (model->isLoaded()) { - if (!shapeURL.isEmpty() && !_compoundShapeResource) { + if (!shapeURL.isEmpty() && !_collisionGeometryResource) { const_cast(this)->fetchCollisionGeometryResource(); } - if (_compoundShapeResource && _compoundShapeResource->isLoaded()) { + if (_collisionGeometryResource && _collisionGeometryResource->isLoaded()) { // we have both URLs AND both geometries AND they are both fully loaded. if (_needsInitialSimulation) { // the _model's offset will be wrong until _needsInitialSimulation is false @@ -368,7 +367,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { } if (type == SHAPE_TYPE_COMPOUND) { - if (!_compoundShapeResource || !_compoundShapeResource->isLoaded()) { + if (!_collisionGeometryResource || !_collisionGeometryResource->isLoaded()) { return; } @@ -376,8 +375,8 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { // should never fall in here when collision model not fully loaded // TODO: assert that all geometries exist and are loaded - //assert(_model && _model->isLoaded() && _compoundShapeResource && _compoundShapeResource->isLoaded()); - const HFMModel& collisionGeometry = _compoundShapeResource->getHFMModel(); + //assert(_model && _model->isLoaded() && _collisionGeometryResource && _collisionGeometryResource->isLoaded()); + const HFMModel& collisionGeometry = _collisionGeometryResource->getHFMModel(); ShapeInfo::PointCollection& pointCollection = shapeInfo.getPointCollection(); pointCollection.clear(); @@ -499,7 +498,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { std::vector> meshes; if (type == SHAPE_TYPE_SIMPLE_COMPOUND) { - auto& hfmMeshes = _compoundShapeResource->getHFMModel().meshes; + auto& hfmMeshes = _collisionGeometryResource->getHFMModel().meshes; meshes.reserve(hfmMeshes.size()); for (auto& hfmMesh : hfmMeshes) { meshes.push_back(hfmMesh._mesh); @@ -727,10 +726,10 @@ int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) { bool RenderableModelEntityItem::contains(const glm::vec3& point) const { auto model = getModel(); - if (EntityItem::contains(point) && model && _compoundShapeResource && _compoundShapeResource->isLoaded()) { + if (EntityItem::contains(point) && model && _collisionGeometryResource && _collisionGeometryResource->isLoaded()) { glm::mat4 worldToHFMMatrix = model->getWorldToHFMMatrix(); glm::vec3 hfmPoint = worldToHFMMatrix * glm::vec4(point, 1.0f); - return _compoundShapeResource->getHFMModel().convexHullContains(hfmPoint); + return _collisionGeometryResource->getHFMModel().convexHullContains(hfmPoint); } return false; diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index 7f84b3ae62..c32dad901f 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -79,7 +79,7 @@ public: virtual bool isReadyToComputeShape() const override; virtual void computeShapeInfo(ShapeInfo& shapeInfo) override; - bool computeShapeFailedToLoad(); + bool unableToLoadCollisionShape(); virtual bool contains(const glm::vec3& point) const override; void stopModelOverrideIfNoParent(); @@ -120,7 +120,7 @@ private: bool readyToAnimate() const; void fetchCollisionGeometryResource(); - GeometryResource::Pointer _compoundShapeResource; + GeometryResource::Pointer _collisionGeometryResource; std::vector _jointMap; QVariantMap _originalTextures; bool _jointMapCompleted { false }; diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index d517ecd026..36f8ccf8f6 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -23,7 +23,7 @@ static uint8_t CUSTOM_PIPELINE_NUMBER = 0; static gpu::Stream::FormatPointer _vertexFormat; static std::weak_ptr _texturedPipeline; -static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { +static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) { auto texturedPipeline = _texturedPipeline.lock(); if (!texturedPipeline) { auto state = std::make_shared(); diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index adf0a2d162..3adeecabcc 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -34,9 +34,7 @@ #include "EntityTreeRenderer.h" -#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT -# include -#endif +#include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push @@ -1553,52 +1551,49 @@ using namespace render; using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER; -static gpu::PipelinePointer _pipelines[2]; -static gpu::PipelinePointer _wireframePipelines[2]; +static std::map, ShapePipelinePointer> _pipelines; static gpu::Stream::FormatPointer _vertexFormat; -ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { - if (!_pipelines[0]) { +ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) { + // FIXME: custom pipelines like this don't handle shadows or renderLayers correctly + + if (_pipelines.empty()) { using namespace shader::entities_renderer::program; - int programsIds[2] = { polyvox, polyvox_fade }; - auto state = std::make_shared(); - state->setCullMode(gpu::State::CULL_BACK); - state->setDepthTest(true, true, gpu::LESS_EQUAL); - PrepareStencil::testMaskDrawShape(*state); + static const std::vector> keys = { + std::make_tuple(false, false, polyvox), std::make_tuple(true, false, polyvox_forward) +#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT + , std::make_tuple(false, true, polyvox_fade), std::make_tuple(true, true, polyvox_forward_fade) +#else + , std::make_tuple(false, true, polyvox), std::make_tuple(true, true, polyvox_forward) +#endif + }; + for (auto& key : keys) { + for (int i = 0; i < 2; ++i) { + bool wireframe = i != 0; - auto wireframeState = std::make_shared(); - wireframeState->setCullMode(gpu::State::CULL_BACK); - wireframeState->setDepthTest(true, true, gpu::LESS_EQUAL); - wireframeState->setFillMode(gpu::State::FILL_LINE); - PrepareStencil::testMaskDrawShape(*wireframeState); + auto state = std::make_shared(); + state->setCullMode(gpu::State::CULL_BACK); + state->setDepthTest(true, true, gpu::LESS_EQUAL); + PrepareStencil::testMaskDrawShape(*state); - // Two sets of pipelines: normal and fading - for (auto i = 0; i < 2; i++) { - gpu::ShaderPointer program = gpu::Shader::createProgram(programsIds[i]); - _pipelines[i] = gpu::Pipeline::create(program, state); - _wireframePipelines[i] = gpu::Pipeline::create(program, wireframeState); + if (wireframe) { + state->setFillMode(gpu::State::FILL_LINE); + } + + auto pipeline = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state); + if (std::get<1>(key)) { + _pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), wireframe)] = std::make_shared(pipeline, nullptr, nullptr, nullptr); + } else { + const auto& fadeEffect = DependencyManager::get(); + _pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), wireframe)] = std::make_shared(pipeline, nullptr, + fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); + } + } } } -#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT - if (key.isFaded()) { - const auto& fadeEffect = DependencyManager::get(); - if (key.isWireframe()) { - return std::make_shared(_wireframePipelines[1], nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); - } else { - return std::make_shared(_pipelines[1], nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); - } - } else { -#endif - if (key.isWireframe()) { - return std::make_shared(_wireframePipelines[0], nullptr, nullptr, nullptr); - } else { - return std::make_shared(_pipelines[0], nullptr, nullptr, nullptr); - } -#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT - } -#endif + return _pipelines[std::make_tuple(args->_renderMethod == Args::RenderMethod::FORWARD, key.isFaded(), key.isWireframe())]; } PolyVoxEntityRenderer::PolyVoxEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index ceedf5be6e..032e8e1892 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -30,14 +30,11 @@ using namespace render::entities; // is a half unit sphere. However, the geometry cache renders a UNIT sphere, so we need to scale down. static const float SPHERE_ENTITY_SCALE = 0.5f; -static_assert(shader::render_utils::program::simple != 0, "Validate simple program exists"); -static_assert(shader::render_utils::program::simple_transparent != 0, "Validate simple transparent program exists"); - ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { - _procedural._vertexSource = gpu::Shader::getVertexShaderSource(shader::render_utils::vertex::simple); + _procedural._vertexSource = gpu::Shader::getVertexShaderSource(shader::render_utils::vertex::simple_procedural); // FIXME: Setup proper uniform slots and use correct pipelines for forward rendering - _procedural._opaqueFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple); - _procedural._transparentFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple_transparent); + _procedural._opaqueFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple_procedural); + _procedural._transparentFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple_procedural_translucent); // TODO: move into Procedural.cpp PrepareStencil::testMaskDrawShape(*_procedural._opaqueState); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index bb3e99157e..00be4a2f7d 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -315,12 +315,19 @@ void WebEntityRenderer::doRender(RenderArgs* args) { gpu::Batch& batch = *args->_batch; glm::vec4 color; Transform transform; + bool forward; withReadLock([&] { float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; color = glm::vec4(toGlm(_color), _alpha * fadeRatio); color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created); transform = _renderTransform; + forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == render::Args::FORWARD; }); + + if (color.a == 0.0f) { + return; + } + batch.setResourceTexture(0, _texture); transform.setRotation(EntityItem::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode, args->getViewFrustum().getPosition())); @@ -328,7 +335,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) { // Turn off jitter for these entities batch.pushProjectionJitter(); - DependencyManager::get()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD); + DependencyManager::get()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD, forward); DependencyManager::get()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId); batch.popProjectionJitter(); batch.setResourceTexture(0, nullptr); diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp index e4300cca76..bbb8c67ad1 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp @@ -317,6 +317,8 @@ void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity sunLight->setIntensity(_keyLightProperties.getIntensity()); sunLight->setDirection(_lastRotation * _keyLightProperties.getDirection()); sunLight->setCastShadows(_keyLightProperties.getCastShadows()); + sunLight->setShadowBias(_keyLightProperties.getShadowBias()); + sunLight->setShadowsMaxDistance(_keyLightProperties.getShadowMaxDistance()); } void ZoneEntityRenderer::updateAmbientLightFromEntity(const TypedEntityPointer& entity) { diff --git a/libraries/entities-renderer/src/entities-renderer/paintStroke.slp b/libraries/entities-renderer/src/entities-renderer/paintStroke.slp index e69de29bb2..e283f4edcb 100644 --- a/libraries/entities-renderer/src/entities-renderer/paintStroke.slp +++ b/libraries/entities-renderer/src/entities-renderer/paintStroke.slp @@ -0,0 +1 @@ +DEFINES forward \ No newline at end of file diff --git a/libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp b/libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp deleted file mode 100644 index 4d49e0d3a4..0000000000 --- a/libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX paintStroke \ No newline at end of file diff --git a/libraries/entities-renderer/src/entities-renderer/polyvox.slp b/libraries/entities-renderer/src/entities-renderer/polyvox.slp index e69de29bb2..82853b2a91 100644 --- a/libraries/entities-renderer/src/entities-renderer/polyvox.slp +++ b/libraries/entities-renderer/src/entities-renderer/polyvox.slp @@ -0,0 +1 @@ +DEFINES (shadow fade)/forward \ No newline at end of file diff --git a/libraries/entities-renderer/src/entities-renderer/polyvox_fade.slp b/libraries/entities-renderer/src/entities-renderer/polyvox_fade.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/entities-renderer/src/paintStroke.slf b/libraries/entities-renderer/src/paintStroke.slf index 4eb27ca200..837291efe6 100644 --- a/libraries/entities-renderer/src/paintStroke.slf +++ b/libraries/entities-renderer/src/paintStroke.slf @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// paintStroke.frag -// fragment shader -// // Created by Eric Levin on 8/10/2015 // Copyright 2015 High Fidelity, Inc. // @@ -12,29 +10,32 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBufferWrite.slh@> +<@if not HIFI_USE_FORWARD@> + <@include DeferredBufferWrite.slh@> +<@else@> + layout(location=0) out vec4 _fragColor0; +<@endif@> <@include paintStroke.slh@> <$declarePolyLineBuffers()$> LAYOUT(binding=0) uniform sampler2D _texture; -layout(location=0) in vec3 _normalWS; +<@if not HIFI_USE_FORWARD@> + layout(location=0) in vec3 _normalWS; +<@endif@> layout(location=1) in vec2 _texCoord; layout(location=2) in vec4 _color; layout(location=3) in float _distanceFromCenter; void main(void) { vec4 texel = texture(_texture, _texCoord); - float frontCondition = 2.0 * float(gl_FrontFacing) - 1.0; - vec3 color = _color.rgb * texel.rgb; - float alpha = texel.a * _color.a; + texel *= _color; + texel.a *= mix(1.0, pow(1.0 - abs(_distanceFromCenter), 10.0), _polylineData.faceCameraGlow.y); - alpha *= mix(1.0, pow(1.0 - abs(_distanceFromCenter), 10.0), _polylineData.faceCameraGlow.y); - - packDeferredFragmentTranslucent( - _normalWS * frontCondition, - alpha, - color, - DEFAULT_ROUGHNESS); +<@if not HIFI_USE_FORWARD@> + packDeferredFragmentTranslucent((2.0 * float(gl_FrontFacing) - 1.0) * _normalWS, texel.a, texel.rgb, DEFAULT_ROUGHNESS); +<@else@> + _fragColor0 = texel; +<@endif@> } diff --git a/libraries/entities-renderer/src/paintStroke.slv b/libraries/entities-renderer/src/paintStroke.slv index f591370186..9a44223dd4 100644 --- a/libraries/entities-renderer/src/paintStroke.slv +++ b/libraries/entities-renderer/src/paintStroke.slv @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// paintStroke.vert -// vertex shader -// // Created by Eric Levin on 7/20/15. // Copyright 2014 High Fidelity, Inc. // @@ -20,7 +18,9 @@ <@include paintStroke.slh@> <$declarePolyLineBuffers()$> -layout(location=0) out vec3 _normalWS; +<@if not HIFI_USE_FORWARD@> + layout(location=0) out vec3 _normalWS; +<@endif@> layout(location=1) out vec2 _texCoord; layout(location=2) out vec4 _color; layout(location=3) out float _distanceFromCenter; @@ -50,11 +50,15 @@ void main(void) { vec3 binormalEye = normalize(cross(normalEye, tangentEye)); posEye.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormalEye; <$transformEyeToClipPos(cam, posEye, gl_Position)$> +<@if not HIFI_USE_FORWARD@> <$transformEyeToWorldDir(cam, normalEye, _normalWS)$> +<@endif@> } else { vec3 normal = vertex.normal.xyz; position.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormal; <$transformModelToClipPos(cam, obj, position, gl_Position)$> +<@if not HIFI_USE_FORWARD@> <$transformModelToWorldDir(cam, obj, normal, _normalWS)$> +<@endif@> } } \ No newline at end of file diff --git a/libraries/entities-renderer/src/paintStroke_forward.slf b/libraries/entities-renderer/src/paintStroke_forward.slf deleted file mode 100644 index b949332826..0000000000 --- a/libraries/entities-renderer/src/paintStroke_forward.slf +++ /dev/null @@ -1,35 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// paintStroke.frag -// fragment shader -// -// Created by Eric Levin on 8/10/2015 -// Copyright 2015 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 paintStroke.slh@> -<$declarePolyLineBuffers()$> - -LAYOUT(binding=0) uniform sampler2D _texture; - -layout(location=0) in vec3 _normalWS; -layout(location=1) in vec2 _texCoord; -layout(location=2) in vec4 _color; -layout(location=3) in float _distanceFromCenter; -layout(location=0) out vec4 _fragColor0; - -void main(void) { - vec4 texel = texture(_texture, _texCoord); - int frontCondition = 1 - 2 * int(gl_FrontFacing); - vec3 color = _color.rgb * texel.rgb; - float alpha = texel.a * _color.a; - - alpha *= mix(1.0, pow(1.0 - abs(_distanceFromCenter), 10.0), _polylineData.faceCameraGlow.y); - - _fragColor0 = vec4(color, alpha); -} diff --git a/libraries/entities-renderer/src/polyvox.slf b/libraries/entities-renderer/src/polyvox.slf index 6b1aa25a25..3456823081 100644 --- a/libraries/entities-renderer/src/polyvox.slf +++ b/libraries/entities-renderer/src/polyvox.slf @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// polyvox.frag -// fragment shader // // Created by Seth Alves on 2015-8-3 // Copyright 2015 High Fidelity, Inc. @@ -11,51 +10,111 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include graphics/Material.slh@> -<@include DeferredBufferWrite.slh@> -<@include render-utils/ShaderConstants.h@> -<@include entities-renderer/ShaderConstants.h@> +<@if HIFI_USE_FADE@> + <@include Fade.slh@> + <$declareFadeFragment()$> -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normal; -layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _position; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _worldPosition; + layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; +<@endif@> -LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_XMAP) uniform sampler2D xMap; -LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_YMAP) uniform sampler2D yMap; -LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_ZMAP) uniform sampler2D zMap; +<@if not HIFI_USE_SHADOW@> + <@include graphics/Material.slh@> + <@include render-utils/ShaderConstants.h@> + <@include entities-renderer/ShaderConstants.h@> -struct PolyvoxParams { - vec4 voxelVolumeSize; -}; + <@if not HIFI_USE_FORWARD@> + <@include DeferredBufferWrite.slh@> + <@else@> + <@include DefaultMaterials.slh@> -LAYOUT(binding=0) uniform polyvoxParamsBuffer { - PolyvoxParams params; -}; + <@include GlobalLight.slh@> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> + + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + <@endif@> + + <@if HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; + <@endif@> + layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec3 _positionMS; + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; + + LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_XMAP) uniform sampler2D xMap; + LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_YMAP) uniform sampler2D yMap; + LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_ZMAP) uniform sampler2D zMap; + + struct PolyvoxParams { + vec4 voxelVolumeSize; + }; + + LAYOUT(binding=0) uniform polyvoxParamsBuffer { + PolyvoxParams params; + }; +<@endif@> + +<@if HIFI_USE_SHADOW or HIFI_USE_FORWARD@> + layout(location=0) out vec4 _fragColor0; +<@endif@> void main(void) { - vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz)); - worldNormal = normalize(worldNormal); +<@if HIFI_USE_FADE@> + <@if not HIFI_USE_SHADOW@> + vec3 fadeEmissive; + FadeObjectParams fadeParams; + <$fetchFadeObjectParams(fadeParams)$> + applyFade(fadeParams, _positionWS.xyz, fadeEmissive); + <@else@> + FadeObjectParams fadeParams; + <$fetchFadeObjectParams(fadeParams)$> + applyFadeClip(fadeParams, _positionWS.xyz); + <@endif@> +<@endif@> - float inPositionX = (_worldPosition.x - 0.5) / params.voxelVolumeSize.x; - float inPositionY = (_worldPosition.y - 0.5) / params.voxelVolumeSize.y; - float inPositionZ = (_worldPosition.z - 0.5) / params.voxelVolumeSize.z; +<@if not HIFI_USE_SHADOW@> + float inPositionX = (_positionMS.x - 0.5) / params.voxelVolumeSize.x; + float inPositionY = (_positionMS.y - 0.5) / params.voxelVolumeSize.y; + float inPositionZ = (_positionMS.z - 0.5) / params.voxelVolumeSize.z; vec4 xyDiffuse = texture(xMap, vec2(-inPositionX, -inPositionY)); vec4 xzDiffuse = texture(yMap, vec2(-inPositionX, inPositionZ)); vec4 yzDiffuse = texture(zMap, vec2(inPositionZ, -inPositionY)); - vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(worldNormal.z); - vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(worldNormal.y); - vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x); - vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0); + vec3 normalMS = normalize(cross(dFdy(_positionMS.xyz), dFdx(_positionMS.xyz))); + vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(normalMS.z); + vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(normalMS.y); + vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(normalMS.x); + vec3 diffuse = vec3(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled); - packDeferredFragment( - _normal, - 1.0, - vec3(diffuse), - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); + <@if not HIFI_USE_FORWARD@> + packDeferredFragment( + normalize(_normalWS), + 1.0, + diffuse, + DEFAULT_ROUGHNESS, + DEFAULT_METALLIC, + DEFAULT_EMISSIVE + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + DEFAULT_OCCLUSION, + DEFAULT_SCATTERING); + <@else@> + TransformCamera cam = getTransformCamera(); + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + _positionES.xyz, + normalize(_normalWS), + diffuse, + DEFAULT_FRESNEL, + DEFAULT_METALLIC, + DEFAULT_ROUGHNESS), + 1.0); + <@endif@> +<@else@> + _fragColor0 = vec4(1.0); +<@endif@> } diff --git a/libraries/entities-renderer/src/polyvox.slv b/libraries/entities-renderer/src/polyvox.slv index d17974c994..34547cef1a 100644 --- a/libraries/entities-renderer/src/polyvox.slv +++ b/libraries/entities-renderer/src/polyvox.slv @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// polyvox.vert -// vertex shader // // Copyright 2015 High Fidelity, Inc. // @@ -11,20 +10,39 @@ // <@include gpu/Inputs.slh@> -<@include gpu/Transform.slh@> <@include render-utils/ShaderConstants.h@> +<@include gpu/Transform.slh@> <$declareStandardTransform()$> -layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _position; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _worldPosition; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normal; +<@if HIFI_USE_FADE@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; +<@endif@> +<@if not HIFI_USE_SHADOW@> + <@if HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; + <@endif@> + layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec3 _positionMS; + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +<@endif@> void main(void) { - // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$> - <$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$> - _worldPosition = inPosition; + +<@if HIFI_USE_SHADOW@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> +<@else@> + <@if not HIFI_USE_FORWARD@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + <@else@> + <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> + <@endif@> + + <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> + _positionMS = inPosition.xyz; +<@endif@> +<@if HIFI_USE_FADE@> + <$transformModelToWorldPos(obj, inPosition, _positionWS)$> +<@endif@> } diff --git a/libraries/entities-renderer/src/polyvox_fade.slf b/libraries/entities-renderer/src/polyvox_fade.slf deleted file mode 100644 index ae2e05c3dc..0000000000 --- a/libraries/entities-renderer/src/polyvox_fade.slf +++ /dev/null @@ -1,73 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// polyvox_fade.frag -// fragment shader -// -// Created by Olivier Prat on 2017-06-08 -// Copyright 2017 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 graphics/Material.slh@> -<@include DeferredBufferWrite.slh@> -<@include render-utils/ShaderConstants.h@> -<@include entities-renderer/ShaderConstants.h@> - -<@include Fade.slh@> - -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normal; -layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _position; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _worldPosition; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _worldFadePosition; - -LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_XMAP) uniform sampler2D xMap; -LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_YMAP) uniform sampler2D yMap; -LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_ZMAP) uniform sampler2D zMap; - -struct PolyvoxParams { - vec4 voxelVolumeSize; -}; - -LAYOUT(binding=0) uniform polyvoxParamsBuffer { - PolyvoxParams params; -}; - -// Declare after all samplers to prevent sampler location mix up with voxel shading (sampler locations are hardcoded in RenderablePolyVoxEntityItem) -<$declareFadeFragment()$> - -void main(void) { - vec3 emissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _worldFadePosition.xyz, emissive); - - vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz)); - worldNormal = normalize(worldNormal); - - float inPositionX = (_worldPosition.x - 0.5) / params.voxelVolumeSize.x; - float inPositionY = (_worldPosition.y - 0.5) / params.voxelVolumeSize.y; - float inPositionZ = (_worldPosition.z - 0.5) / params.voxelVolumeSize.z; - - vec4 xyDiffuse = texture(xMap, vec2(-inPositionX, -inPositionY)); - vec4 xzDiffuse = texture(yMap, vec2(-inPositionX, inPositionZ)); - vec4 yzDiffuse = texture(zMap, vec2(inPositionZ, -inPositionY)); - - vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(worldNormal.z); - vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(worldNormal.y); - vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x); - vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0); - - packDeferredFragment( - _normal, - 1.0, - vec3(diffuse), - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE+emissive, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); -} diff --git a/libraries/entities-renderer/src/polyvox_fade.slv b/libraries/entities-renderer/src/polyvox_fade.slv deleted file mode 100644 index 97b98f5840..0000000000 --- a/libraries/entities-renderer/src/polyvox_fade.slv +++ /dev/null @@ -1,33 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// polyvox_fade.vert -// vertex shader -// -// Created by Seth Alves on 2015-8-3 -// Copyright 2015 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 gpu/Inputs.slh@> -<@include gpu/Transform.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareStandardTransform()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _position; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _worldPosition; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normal; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _worldFadePosition; - -void main(void) { - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$> - <$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$> - <$transformModelToWorldPos(obj, inPosition, _worldFadePosition)$> - _worldPosition = inPosition; -} diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 9516e1a0c8..b89788040f 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -2753,6 +2753,8 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_INTENSITY, KeyLight, keyLight, Intensity, intensity); ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_DIRECTION, KeyLight, keylight, Direction, direction); ADD_GROUP_PROPERTY_TO_MAP(PROP_KEYLIGHT_CAST_SHADOW, KeyLight, keyLight, CastShadows, castShadows); + ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(PROP_KEYLIGHT_SHADOW_BIAS, KeyLight, keyLight, ShadowBias, shadowBias, 0.0f, 1.0f); + ADD_GROUP_PROPERTY_TO_MAP_WITH_RANGE(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, KeyLight, keyLight, ShadowMaxDistance, shadowMaxDistance, 1.0f, 250.0f); } { // Ambient light ADD_GROUP_PROPERTY_TO_MAP(PROP_AMBIENT_LIGHT_INTENSITY, AmbientLight, ambientLight, Intensity, intensity); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index f98ee913a2..8d3833f364 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -159,6 +159,8 @@ enum EntityPropertyList { PROP_DERIVED_29, PROP_DERIVED_30, PROP_DERIVED_31, + PROP_DERIVED_32, + PROP_DERIVED_33, PROP_AFTER_LAST_ITEM, @@ -249,39 +251,41 @@ enum EntityPropertyList { PROP_KEYLIGHT_INTENSITY = PROP_DERIVED_1, PROP_KEYLIGHT_DIRECTION = PROP_DERIVED_2, PROP_KEYLIGHT_CAST_SHADOW = PROP_DERIVED_3, + PROP_KEYLIGHT_SHADOW_BIAS = PROP_DERIVED_4, + PROP_KEYLIGHT_SHADOW_MAX_DISTANCE = PROP_DERIVED_5, // Ambient light - PROP_AMBIENT_LIGHT_INTENSITY = PROP_DERIVED_4, - PROP_AMBIENT_LIGHT_URL = PROP_DERIVED_5, + PROP_AMBIENT_LIGHT_INTENSITY = PROP_DERIVED_6, + PROP_AMBIENT_LIGHT_URL = PROP_DERIVED_7, // Skybox - PROP_SKYBOX_COLOR = PROP_DERIVED_6, - PROP_SKYBOX_URL = PROP_DERIVED_7, + PROP_SKYBOX_COLOR = PROP_DERIVED_8, + PROP_SKYBOX_URL = PROP_DERIVED_9, // Haze - PROP_HAZE_RANGE = PROP_DERIVED_8, - PROP_HAZE_COLOR = PROP_DERIVED_9, - PROP_HAZE_GLARE_COLOR = PROP_DERIVED_10, - PROP_HAZE_ENABLE_GLARE = PROP_DERIVED_11, - PROP_HAZE_GLARE_ANGLE = PROP_DERIVED_12, - PROP_HAZE_ALTITUDE_EFFECT = PROP_DERIVED_13, - PROP_HAZE_CEILING = PROP_DERIVED_14, - PROP_HAZE_BASE_REF = PROP_DERIVED_15, - PROP_HAZE_BACKGROUND_BLEND = PROP_DERIVED_16, - PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_DERIVED_17, - PROP_HAZE_KEYLIGHT_RANGE = PROP_DERIVED_18, - PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_DERIVED_19, + PROP_HAZE_RANGE = PROP_DERIVED_10, + PROP_HAZE_COLOR = PROP_DERIVED_11, + PROP_HAZE_GLARE_COLOR = PROP_DERIVED_12, + PROP_HAZE_ENABLE_GLARE = PROP_DERIVED_13, + PROP_HAZE_GLARE_ANGLE = PROP_DERIVED_14, + PROP_HAZE_ALTITUDE_EFFECT = PROP_DERIVED_15, + PROP_HAZE_CEILING = PROP_DERIVED_16, + PROP_HAZE_BASE_REF = PROP_DERIVED_17, + PROP_HAZE_BACKGROUND_BLEND = PROP_DERIVED_18, + PROP_HAZE_ATTENUATE_KEYLIGHT = PROP_DERIVED_19, + PROP_HAZE_KEYLIGHT_RANGE = PROP_DERIVED_20, + PROP_HAZE_KEYLIGHT_ALTITUDE = PROP_DERIVED_21, // Bloom - PROP_BLOOM_INTENSITY = PROP_DERIVED_20, - PROP_BLOOM_THRESHOLD = PROP_DERIVED_21, - PROP_BLOOM_SIZE = PROP_DERIVED_22, - PROP_FLYING_ALLOWED = PROP_DERIVED_23, - PROP_GHOSTING_ALLOWED = PROP_DERIVED_24, - PROP_FILTER_URL = PROP_DERIVED_25, - PROP_KEY_LIGHT_MODE = PROP_DERIVED_26, - PROP_AMBIENT_LIGHT_MODE = PROP_DERIVED_27, - PROP_SKYBOX_MODE = PROP_DERIVED_28, - PROP_HAZE_MODE = PROP_DERIVED_29, - PROP_BLOOM_MODE = PROP_DERIVED_30, + PROP_BLOOM_INTENSITY = PROP_DERIVED_22, + PROP_BLOOM_THRESHOLD = PROP_DERIVED_23, + PROP_BLOOM_SIZE = PROP_DERIVED_24, + PROP_FLYING_ALLOWED = PROP_DERIVED_25, + PROP_GHOSTING_ALLOWED = PROP_DERIVED_26, + PROP_FILTER_URL = PROP_DERIVED_27, + PROP_KEY_LIGHT_MODE = PROP_DERIVED_28, + PROP_AMBIENT_LIGHT_MODE = PROP_DERIVED_29, + PROP_SKYBOX_MODE = PROP_DERIVED_30, + PROP_HAZE_MODE = PROP_DERIVED_31, + PROP_BLOOM_MODE = PROP_DERIVED_32, // Avatar priority - PROP_AVATAR_PRIORITY = PROP_DERIVED_31, + PROP_AVATAR_PRIORITY = PROP_DERIVED_33, // Polyvox PROP_VOXEL_VOLUME_SIZE = PROP_DERIVED_0, diff --git a/libraries/entities/src/KeyLightPropertyGroup.cpp b/libraries/entities/src/KeyLightPropertyGroup.cpp index f0ad2965ce..b70e94504d 100644 --- a/libraries/entities/src/KeyLightPropertyGroup.cpp +++ b/libraries/entities/src/KeyLightPropertyGroup.cpp @@ -22,6 +22,8 @@ const float KeyLightPropertyGroup::DEFAULT_KEYLIGHT_INTENSITY = 1.0f; const float KeyLightPropertyGroup::DEFAULT_KEYLIGHT_AMBIENT_INTENSITY = 0.5f; const glm::vec3 KeyLightPropertyGroup::DEFAULT_KEYLIGHT_DIRECTION = { 0.0f, -1.0f, 0.0f }; const bool KeyLightPropertyGroup::DEFAULT_KEYLIGHT_CAST_SHADOWS { false }; +const float KeyLightPropertyGroup::DEFAULT_KEYLIGHT_SHADOW_BIAS { 0.5f }; +const float KeyLightPropertyGroup::DEFAULT_KEYLIGHT_SHADOW_MAX_DISTANCE { 40.0f }; void KeyLightPropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties, QScriptEngine* engine, bool skipDefaults, EntityItemProperties& defaultEntityProperties) const { @@ -30,6 +32,8 @@ void KeyLightPropertyGroup::copyToScriptValue(const EntityPropertyFlags& desired COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_INTENSITY, KeyLight, keyLight, Intensity, intensity); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_DIRECTION, KeyLight, keyLight, Direction, direction); COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_CAST_SHADOW, KeyLight, keyLight, CastShadows, castShadows); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_SHADOW_BIAS, KeyLight, keyLight, ShadowBias, shadowBias); + COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, KeyLight, keyLight, ShadowMaxDistance, shadowMaxDistance); } void KeyLightPropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { @@ -37,6 +41,8 @@ void KeyLightPropertyGroup::copyFromScriptValue(const QScriptValue& object, bool COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, intensity, float, setIntensity); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, direction, vec3, setDirection); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, castShadows, bool, setCastShadows); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, shadowBias, float, setShadowBias); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, shadowMaxDistance, float, setShadowMaxDistance); // legacy property support COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightColor, u8vec3Color, setColor, getColor); @@ -50,14 +56,18 @@ void KeyLightPropertyGroup::merge(const KeyLightPropertyGroup& other) { COPY_PROPERTY_IF_CHANGED(intensity); COPY_PROPERTY_IF_CHANGED(direction); COPY_PROPERTY_IF_CHANGED(castShadows); + COPY_PROPERTY_IF_CHANGED(shadowBias); + COPY_PROPERTY_IF_CHANGED(shadowMaxDistance); } void KeyLightPropertyGroup::debugDump() const { qCDebug(entities) << " KeyLightPropertyGroup: ---------------------------------------------"; - qCDebug(entities) << " color:" << getColor(); // << "," << getColor()[1] << "," << getColor()[2]; - qCDebug(entities) << " intensity:" << getIntensity(); - qCDebug(entities) << " direction:" << getDirection(); - qCDebug(entities) << " castShadows:" << getCastShadows(); + qCDebug(entities) << " color:" << getColor(); + qCDebug(entities) << " intensity:" << getIntensity(); + qCDebug(entities) << " direction:" << getDirection(); + qCDebug(entities) << " castShadows:" << getCastShadows(); + qCDebug(entities) << " shadowBias:" << getShadowBias(); + qCDebug(entities) << " shadowMaxDistance:" << getShadowMaxDistance(); } void KeyLightPropertyGroup::listChangedProperties(QList& out) { @@ -73,6 +83,12 @@ void KeyLightPropertyGroup::listChangedProperties(QList& out) { if (castShadowsChanged()) { out << "keyLight-castShadows"; } + if (shadowBiasChanged()) { + out << "keyLight-shadowBias"; + } + if (shadowMaxDistanceChanged()) { + out << "keyLight-shadowMaxDistance"; + } } bool KeyLightPropertyGroup::appendToEditPacket(OctreePacketData* packetData, @@ -88,6 +104,8 @@ bool KeyLightPropertyGroup::appendToEditPacket(OctreePacketData* packetData, APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getIntensity()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getDirection()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_CAST_SHADOW, getCastShadows()); + APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_BIAS, getShadowBias()); + APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, getShadowMaxDistance()); return true; } @@ -103,11 +121,15 @@ bool KeyLightPropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFl READ_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, float, setIntensity); READ_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, glm::vec3, setDirection); READ_ENTITY_PROPERTY(PROP_KEYLIGHT_CAST_SHADOW, bool, setCastShadows); + READ_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_BIAS, float, setShadowBias); + READ_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, float, setShadowMaxDistance); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_COLOR, Color); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_INTENSITY, Intensity); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_DIRECTION, Direction); DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_CAST_SHADOW, CastShadows); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_SHADOW_BIAS, ShadowBias); + DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, ShadowMaxDistance); processedBytes += bytesRead; @@ -121,6 +143,8 @@ void KeyLightPropertyGroup::markAllChanged() { _intensityChanged = true; _directionChanged = true; _castShadowsChanged = true; + _shadowBiasChanged = true; + _shadowMaxDistanceChanged = true; } EntityPropertyFlags KeyLightPropertyGroup::getChangedProperties() const { @@ -130,6 +154,8 @@ EntityPropertyFlags KeyLightPropertyGroup::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_INTENSITY, intensity); CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_DIRECTION, direction); CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_CAST_SHADOW, castShadows); + CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_SHADOW_BIAS, shadowBias); + CHECK_PROPERTY_CHANGE(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, shadowMaxDistance); return changedProperties; } @@ -139,6 +165,8 @@ void KeyLightPropertyGroup::getProperties(EntityItemProperties& properties) cons COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, Intensity, getIntensity); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, Direction, getDirection); COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, CastShadows, getCastShadows); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, ShadowBias, getShadowBias); + COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(KeyLight, ShadowMaxDistance, getShadowMaxDistance); } bool KeyLightPropertyGroup::setProperties(const EntityItemProperties& properties) { @@ -148,6 +176,8 @@ bool KeyLightPropertyGroup::setProperties(const EntityItemProperties& properties SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, Intensity, intensity, setIntensity); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, Direction, direction, setDirection); SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, CastShadows, castShadows, setCastShadows); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, ShadowBias, shadowBias, setShadowBias); + SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(KeyLight, ShadowMaxDistance, shadowMaxDistance, setShadowMaxDistance); return somethingChanged; } @@ -159,6 +189,8 @@ EntityPropertyFlags KeyLightPropertyGroup::getEntityProperties(EncodeBitstreamPa requestedProperties += PROP_KEYLIGHT_INTENSITY; requestedProperties += PROP_KEYLIGHT_DIRECTION; requestedProperties += PROP_KEYLIGHT_CAST_SHADOW; + requestedProperties += PROP_KEYLIGHT_SHADOW_BIAS; + requestedProperties += PROP_KEYLIGHT_SHADOW_MAX_DISTANCE; return requestedProperties; } @@ -177,6 +209,8 @@ void KeyLightPropertyGroup::appendSubclassData(OctreePacketData* packetData, Enc APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getIntensity()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getDirection()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_CAST_SHADOW, getCastShadows()); + APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_BIAS, getShadowBias()); + APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, getShadowMaxDistance()); } int KeyLightPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, @@ -191,6 +225,8 @@ int KeyLightPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* READ_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, float, setIntensity); READ_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, glm::vec3, setDirection); READ_ENTITY_PROPERTY(PROP_KEYLIGHT_CAST_SHADOW, bool, setCastShadows); + READ_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_BIAS, float, setShadowBias); + READ_ENTITY_PROPERTY(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, float, setShadowMaxDistance); return bytesRead; } diff --git a/libraries/entities/src/KeyLightPropertyGroup.h b/libraries/entities/src/KeyLightPropertyGroup.h index d46f5ce9b5..facbf88f3c 100644 --- a/libraries/entities/src/KeyLightPropertyGroup.h +++ b/libraries/entities/src/KeyLightPropertyGroup.h @@ -37,6 +37,10 @@ class ReadBitstreamToTreeParams; * are cast by avatars, plus {@link Entities.EntityProperties-Model|Model} and * {@link Entities.EntityProperties-Shape|Shape} entities that have their * {@link Entities.EntityProperties|canCastShadow} property set to true. + * @property {number} shadowBias=0.5 - The bias of the shadows cast by the light. Use this to fine-tune your shadows to your scene + * to prevent shadow acne and peter panning. In the range 0.01.0. + * @property {number} shadowMaxDistance=40.0 - The max distance from your view at which shadows will be computed. Higher values will + * cover more of your scene, but with less precision. In the range 1.0250.0. */ class KeyLightPropertyGroup : public PropertyGroup { public: @@ -90,11 +94,15 @@ public: static const float DEFAULT_KEYLIGHT_AMBIENT_INTENSITY; static const glm::vec3 DEFAULT_KEYLIGHT_DIRECTION; static const bool DEFAULT_KEYLIGHT_CAST_SHADOWS; + static const float DEFAULT_KEYLIGHT_SHADOW_BIAS; + static const float DEFAULT_KEYLIGHT_SHADOW_MAX_DISTANCE; DEFINE_PROPERTY_REF(PROP_KEYLIGHT_COLOR, Color, color, glm::u8vec3, DEFAULT_KEYLIGHT_COLOR); DEFINE_PROPERTY(PROP_KEYLIGHT_INTENSITY, Intensity, intensity, float, DEFAULT_KEYLIGHT_INTENSITY); DEFINE_PROPERTY_REF(PROP_KEYLIGHT_DIRECTION, Direction, direction, glm::vec3, DEFAULT_KEYLIGHT_DIRECTION); DEFINE_PROPERTY(PROP_KEYLIGHT_CAST_SHADOW, CastShadows, castShadows, bool, DEFAULT_KEYLIGHT_CAST_SHADOWS); + DEFINE_PROPERTY(PROP_KEYLIGHT_SHADOW_BIAS, ShadowBias, shadowBias, float, DEFAULT_KEYLIGHT_SHADOW_BIAS); + DEFINE_PROPERTY(PROP_KEYLIGHT_SHADOW_MAX_DISTANCE, ShadowMaxDistance, shadowMaxDistance, float, DEFAULT_KEYLIGHT_SHADOW_MAX_DISTANCE); }; #endif // hifi_KeyLightPropertyGroup_h diff --git a/libraries/gl/src/gl/GLHelpers.cpp b/libraries/gl/src/gl/GLHelpers.cpp index 7b47736a3d..c9f17b686d 100644 --- a/libraries/gl/src/gl/GLHelpers.cpp +++ b/libraries/gl/src/gl/GLHelpers.cpp @@ -26,13 +26,19 @@ size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format) { return pixelSize; } +static bool FORCE_DISABLE_OPENGL_45 = false; + +void gl::setDisableGl45(bool disable) { + FORCE_DISABLE_OPENGL_45 = disable; +} + bool gl::disableGl45() { #if defined(USE_GLES) return false; #else static const QString DEBUG_FLAG("HIFI_DISABLE_OPENGL_45"); static bool disableOpenGL45 = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG); - return disableOpenGL45; + return FORCE_DISABLE_OPENGL_45 || disableOpenGL45; #endif } @@ -202,6 +208,15 @@ uint16_t gl::getAvailableVersion() { return; } gl::initModuleGl(); + + std::string glvendor{ (const char*)glGetString(GL_VENDOR) }; + std::transform(glvendor.begin(), glvendor.end(), glvendor.begin(), ::tolower); + + // Intel has *notoriously* buggy DSA implementations, especially around cubemaps + if (std::string::npos != glvendor.find("intel")) { + gl::setDisableGl45(true); + } + wglMakeCurrent(0, 0); hGLRC.reset(); if (!wglChoosePixelFormatARB || !wglCreateContextAttribsARB) { diff --git a/libraries/gl/src/gl/GLHelpers.h b/libraries/gl/src/gl/GLHelpers.h index 95c3b6a5c2..c09f9d4963 100644 --- a/libraries/gl/src/gl/GLHelpers.h +++ b/libraries/gl/src/gl/GLHelpers.h @@ -55,6 +55,7 @@ namespace gl { bool checkGLErrorDebug(const char* name); bool disableGl45(); + void setDisableGl45(bool disable); uint16_t getTargetVersion(); diff --git a/libraries/gpu/src/gpu/Context.cpp b/libraries/gpu/src/gpu/Context.cpp index 927e872fbc..97b67586c6 100644 --- a/libraries/gpu/src/gpu/Context.cpp +++ b/libraries/gpu/src/gpu/Context.cpp @@ -220,7 +220,7 @@ double Context::getFrameTimerBatchAverage() const { const Backend::TransformCamera& Backend::TransformCamera::recomputeDerived(const Transform& xformView) const { _projectionInverse = glm::inverse(_projection); - // Get the viewEyeToWorld matrix form the transformView as passed to the gpu::Batch + // Get the viewEyeToWorld matrix from the transformView as passed to the gpu::Batch // this is the "_viewInverse" fed to the shader // Genetrate the "_view" matrix as well from the xform xformView.getMatrix(_viewInverse); diff --git a/libraries/graphics/src/graphics/Haze.cpp b/libraries/graphics/src/graphics/Haze.cpp index d9bee7507f..9e3cc15c57 100644 --- a/libraries/graphics/src/graphics/Haze.cpp +++ b/libraries/graphics/src/graphics/Haze.cpp @@ -98,7 +98,7 @@ void Haze::setHazeGlareColor(const glm::vec3 hazeGlareColor) { void Haze::setHazeActive(const bool isHazeActive) { auto& params = _hazeParametersBuffer.get(); - if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) { + if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) && !isHazeActive) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ACTIVE; } else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ACTIVE; diff --git a/libraries/render-utils/src/Haze.slh b/libraries/graphics/src/graphics/Haze.slh similarity index 97% rename from libraries/render-utils/src/Haze.slh rename to libraries/graphics/src/graphics/Haze.slh index e2285febe4..a2d8bb0523 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/graphics/src/graphics/Haze.slh @@ -10,7 +10,7 @@ <@if not HAZE_SLH@> <@def HAZE_SLH@> -<@include render-utils/ShaderConstants.h@> +<@include graphics/ShaderConstants.h@> const int HAZE_MODE_IS_ACTIVE = 1 << 0; const int HAZE_MODE_IS_ALTITUDE_BASED = 1 << 1; @@ -38,8 +38,7 @@ struct HazeParams { float hazeKeyLightAltitudeFactor; }; -// See ShapePipeline::Slot::BUFFER in ShapePipeline.h -LAYOUT_STD140(binding=RENDER_UTILS_BUFFER_HAZE_PARAMS) uniform hazeBuffer { +LAYOUT_STD140(binding=GRAPHICS_BUFFER_HAZE_PARAMS) uniform hazeBuffer { HazeParams hazeParams; }; diff --git a/libraries/graphics/src/graphics/Light.cpp b/libraries/graphics/src/graphics/Light.cpp index a5d03beda1..fb14783b4e 100755 --- a/libraries/graphics/src/graphics/Light.cpp +++ b/libraries/graphics/src/graphics/Light.cpp @@ -81,20 +81,12 @@ float Light::getShadowsMaxDistance() const { return _shadowsMaxDistance; } -void Light::setShadowsBiasScale(const float scale) { - _shadowsBiasScale = std::max(0.0f, scale); +void Light::setShadowBias(float bias) { + _shadowBias = bias; } -float Light::getShadowsBiasScale() const { - return _shadowsBiasScale; -} - -void Light::setBiasInput(float bias) { - _biasInput = bias; -} - -float Light::getBiasInput() const { - return _biasInput; +float Light::getShadowBias() const { + return _shadowBias; } void Light::setColor(const Color& color) { diff --git a/libraries/graphics/src/graphics/Light.h b/libraries/graphics/src/graphics/Light.h index 9b431b3e26..81a6fddbd3 100755 --- a/libraries/graphics/src/graphics/Light.h +++ b/libraries/graphics/src/graphics/Light.h @@ -109,11 +109,8 @@ public: void setShadowsMaxDistance(const float maxDistance); float getShadowsMaxDistance() const; - void setShadowsBiasScale(const float scale); - float getShadowsBiasScale() const; - - void setBiasInput(float bias); - float getBiasInput() const; + void setShadowBias(float bias); + float getShadowBias() const; void setOrientation(const Quat& orientation); const glm::quat& getOrientation() const { return _transform.getRotation(); } @@ -201,9 +198,8 @@ protected: Type _type { SUN }; float _spotCos { -1.0f }; // stored here to be able to reset the spot angle when turning the type spot on/off - float _shadowsMaxDistance{ 40.0f }; - float _shadowsBiasScale{ 1.0f }; - float _biasInput{ 0.5f }; // 0.23f will roughly give the default constant and slope values + float _shadowsMaxDistance { 40.0f }; + float _shadowBias { 0.5f }; bool _castShadows{ false }; void updateLightRadius(); diff --git a/libraries/graphics/src/graphics/ShaderConstants.h b/libraries/graphics/src/graphics/ShaderConstants.h index 0aff0a7077..3a614d26cd 100644 --- a/libraries/graphics/src/graphics/ShaderConstants.h +++ b/libraries/graphics/src/graphics/ShaderConstants.h @@ -32,6 +32,8 @@ #define GRAPHICS_TEXTURE_SKYBOX 11 #define GRAPHICS_BUFFER_SKYBOX_PARAMS 5 +#define GRAPHICS_BUFFER_HAZE_PARAMS 7 + // (); +static std::map _pipelines; + +void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox, bool forward) { + if (_pipelines.empty()) { + static const std::vector> keys = { + std::make_tuple(false, shader::graphics::program::skybox), + std::make_tuple(true, shader::graphics::program::skybox_forward) + }; + for (auto& key : keys) { + auto state = std::make_shared(); // Must match PrepareStencil::STENCIL_BACKGROUND const int8_t STENCIL_BACKGROUND = 0; - skyState->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_BACKGROUND, 0xFF, gpu::EQUAL, + state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_BACKGROUND, 0xFF, gpu::EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP)); - thePipeline = gpu::Pipeline::create(skyShader, skyState); + _pipelines[std::get<0>(key)] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<1>(key)), state); } - }); - + } // Render glm::mat4 projMat; @@ -111,7 +111,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky batch.setViewTransform(viewTransform); batch.setModelTransform(Transform()); // only for Mac - batch.setPipeline(thePipeline); + batch.setPipeline(_pipelines[forward]); skybox.prepare(batch); batch.draw(gpu::TRIANGLE_STRIP, 4); diff --git a/libraries/graphics/src/graphics/Skybox.h b/libraries/graphics/src/graphics/Skybox.h index 50189f4c51..5668604c8b 100755 --- a/libraries/graphics/src/graphics/Skybox.h +++ b/libraries/graphics/src/graphics/Skybox.h @@ -44,9 +44,9 @@ public: virtual void clear(); void prepare(gpu::Batch& batch) const; - virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const; + virtual void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const; - static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox); + static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox, bool forward); const UniformBufferView& getSchemaBuffer() const { return _schemaBuffer; } diff --git a/libraries/graphics/src/graphics/skybox.slf b/libraries/graphics/src/graphics/skybox.slf index 801fc33c28..4ae53a657f 100755 --- a/libraries/graphics/src/graphics/skybox.slf +++ b/libraries/graphics/src/graphics/skybox.slf @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// skybox.frag -// fragment shader // // Created by Sam Gateau on 5/5/2015. // Copyright 2015 High Fidelity, Inc. @@ -12,6 +11,16 @@ // <@include graphics/ShaderConstants.h@> +<@if HIFI_USE_FORWARD@> + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + + <@include graphics/Light.slh@> + <$declareLightBuffer()$> + + <@include graphics/Haze.slh@> +<@endif@> + LAYOUT(binding=GRAPHICS_TEXTURE_SKYBOX) uniform samplerCube cubeMap; struct Skybox { @@ -32,8 +41,28 @@ void main(void) { // mix(skyboxColor, skyboxTexel, skybox.color.a) // and the blend factor should be user controlled - vec3 skyboxTexel = texture(cubeMap, normalize(_normal)).rgb; + vec3 normal = normalize(_normal); + vec3 skyboxTexel = texture(cubeMap, normal).rgb; vec3 skyboxColor = skybox.color.rgb; _fragColor = vec4(mix(vec3(1.0), skyboxTexel, float(skybox.color.a > 0.0)) * mix(vec3(1.0), skyboxColor, float(skybox.color.a < 1.0)), 1.0); + +<@if HIFI_USE_FORWARD@> + // FIXME: either move this elsewhere or give it access to isHazeEnabled() (which is in render-utils/LightingModel.slh) + if (/*(isHazeEnabled() > 0.0) && */(hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + TransformCamera cam = getTransformCamera(); + vec4 eyePositionWS = cam._viewInverse[3]; + // We choose an arbitrary large number > BLEND_DISTANCE in Haze.slh + const float SKYBOX_DISTANCE = 32000.0; + vec4 fragPositionWS = eyePositionWS + SKYBOX_DISTANCE * vec4(normal, 0.0); + vec4 fragPositionES = cam._view * fragPositionWS; + + Light light = getKeyLight(); + vec3 lightDirectionWS = getLightDirection(light); + + vec4 hazeColor = computeHazeColor(fragPositionES.xyz, fragPositionWS.xyz, eyePositionWS.xyz, lightDirectionWS); + _fragColor.rgb = mix(_fragColor.rgb, hazeColor.rgb, hazeColor.a); + } +<@endif@> + } diff --git a/libraries/graphics/src/graphics/skybox.slp b/libraries/graphics/src/graphics/skybox.slp index e69de29bb2..e9908ffd1b 100644 --- a/libraries/graphics/src/graphics/skybox.slp +++ b/libraries/graphics/src/graphics/skybox.slp @@ -0,0 +1 @@ +DEFINES forward:f \ No newline at end of file diff --git a/libraries/graphics/src/graphics/skybox.slv b/libraries/graphics/src/graphics/skybox.slv index 4b14872df2..a6e6930d22 100755 --- a/libraries/graphics/src/graphics/skybox.slv +++ b/libraries/graphics/src/graphics/skybox.slv @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// skybox.vert -// vertex shader // // Created by Sam Gateau on 5/5/2015. // Copyright 2015 High Fidelity, Inc. @@ -12,7 +11,6 @@ // <@include gpu/Transform.slh@> - <$declareStandardTransform()$> layout(location=0) out vec3 _normal; diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 96cfa66013..6cb1582dca 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -86,6 +86,7 @@ AccountManager::AccountManager(UserAgentGetter userAgentGetter) : qRegisterMetaType("QHttpMultiPart*"); qRegisterMetaType(); + connect(this, &AccountManager::loginComplete, this, &AccountManager::uploadPublicKey); } const QString DOUBLE_SLASH_SUBSTITUTE = "slashslash"; @@ -838,18 +839,30 @@ void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainI connect(keypairGenerator, &RSAKeypairGenerator::errorGeneratingKeypair, this, &AccountManager::handleKeypairGenerationError); - qCDebug(networking) << "Starting worker thread to generate 2048-bit RSA keypair."; + static constexpr int RSA_THREAD_PRIORITY = 1; + qCDebug(networking) << "Starting worker thread to generate 2048-bit RSA keypair, priority" + << RSA_THREAD_PRIORITY << "- QThreadPool::maxThreadCount =" << QThreadPool::globalInstance()->maxThreadCount(); // Start on Qt's global thread pool. - QThreadPool::globalInstance()->start(keypairGenerator); + QThreadPool::globalInstance()->start(keypairGenerator, RSA_THREAD_PRIORITY); } } void AccountManager::processGeneratedKeypair(QByteArray publicKey, QByteArray privateKey) { - qCDebug(networking) << "Generated 2048-bit RSA keypair. Uploading public key now."; + qCDebug(networking) << "Generated 2048-bit RSA keypair."; // hold the private key to later set our metaverse API account info if upload succeeds + _pendingPublicKey = publicKey; _pendingPrivateKey = privateKey; + uploadPublicKey(); +} + +void AccountManager::uploadPublicKey() { + if (_pendingPrivateKey.isEmpty()) { + return; + } + + qCDebug(networking) << "Attempting upload of public key"; // upload the public key so data-web has an up-to-date key const QString USER_PUBLIC_KEY_UPDATE_PATH = "api/v1/user/public_key"; @@ -871,7 +884,7 @@ void AccountManager::processGeneratedKeypair(QByteArray publicKey, QByteArray pr publicKeyPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"public_key\"; filename=\"public_key\"")); - publicKeyPart.setBody(publicKey); + publicKeyPart.setBody(_pendingPublicKey); requestMultiPart->append(publicKeyPart); // Currently broken? We don't have the temporary domain key. @@ -900,6 +913,7 @@ void AccountManager::publicKeyUploadSucceeded(QNetworkReply* reply) { // public key upload complete - store the matching private key and persist the account to settings _accountInfo.setPrivateKey(_pendingPrivateKey); + _pendingPublicKey.clear(); _pendingPrivateKey.clear(); persistAccountToFile(); @@ -915,9 +929,6 @@ void AccountManager::publicKeyUploadFailed(QNetworkReply* reply) { // we aren't waiting for a response any longer _isWaitingForKeypairResponse = false; - - // clear our pending private key - _pendingPrivateKey.clear(); } void AccountManager::handleKeypairGenerationError() { @@ -961,3 +972,7 @@ void AccountManager::saveLoginStatus(bool isLoggedIn) { } } } + +bool AccountManager::hasKeyPair() const { + return _accountInfo.hasPrivateKey(); +} diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index c2187f79cb..a88a5cc4e7 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -81,6 +81,7 @@ public: bool needsToRefreshToken(); Q_INVOKABLE bool checkAndSignalForAccessToken(); void setAccessTokenForCurrentAuthURL(const QString& accessToken); + bool hasKeyPair() const; void requestProfile(); @@ -139,6 +140,7 @@ signals: private slots: void handleKeypairGenerationError(); void processGeneratedKeypair(QByteArray publicKey, QByteArray privateKey); + void uploadPublicKey(); void publicKeyUploadSucceeded(QNetworkReply* reply); void publicKeyUploadFailed(QNetworkReply* reply); void generateNewKeypair(bool isUserKeypair = true, const QUuid& domainID = QUuid()); @@ -162,6 +164,7 @@ private: bool _isWaitingForKeypairResponse { false }; QByteArray _pendingPrivateKey; + QByteArray _pendingPublicKey; QUuid _sessionID { QUuid::createUuid() }; diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index ef8a7b577d..88e6b14ec7 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -842,7 +842,8 @@ bool Resource::handleFailedRequest(ResourceRequest::Result result) { // FALLTHRU default: { _attemptsRemaining = 0; - qCDebug(networking) << "Error loading, attempt:" << _attempts << "attemptsRemaining:" << _attemptsRemaining; + QMetaEnum metaEnum = QMetaEnum::fromType(); + qCDebug(networking) << "Error loading:" << metaEnum.valueToKey(result) << "resource:" << _url.toString(); auto error = (result == ResourceRequest::Timeout) ? QNetworkReply::TimeoutError : QNetworkReply::UnknownNetworkError; emit failed(error); diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 736296a2d6..2d184fe592 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -272,6 +272,7 @@ enum class EntityVersion : PacketVersion { ParticleShapeTypeDeadlockFix, PrivateUserData, TextUnlit, + ShadowBiasAndDistance, // Add new versions above here NUM_PACKET_TYPE, diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 0a08aaa28d..85c53af10a 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -49,9 +49,9 @@ void PhysicalEntitySimulation::addEntityInternal(EntityItemPointer entity) { assert(entity); assert(!entity->isDead()); uint8_t region = _space->getRegion(entity->getSpaceIndex()); - bool shouldBePhysical = region < workload::Region::R3 && entity->shouldBePhysical(); + bool maybeShouldBePhysical = (region < workload::Region::R3 || region == workload::Region::UNKNOWN) && entity->shouldBePhysical(); bool canBeKinematic = region <= workload::Region::R3; - if (shouldBePhysical) { + if (maybeShouldBePhysical) { EntityMotionState* motionState = static_cast(entity->getPhysicsInfo()); if (motionState) { motionState->setRegion(region); @@ -330,6 +330,18 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() { continue; } + uint8_t region = _space->getRegion(entity->getSpaceIndex()); + if (region == workload::Region::UNKNOWN) { + // the workload hasn't categorized it yet --> skip for later + ++entityItr; + continue; + } + if (region > workload::Region::R2) { + // not in physical zone --> remove from list + entityItr = _entitiesToAddToPhysics.erase(entityItr); + continue; + } + if (entity->isReadyToComputeShape()) { ShapeRequest shapeRequest(entity); ShapeRequests::iterator requestItr = _shapeRequests.find(shapeRequest); diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index 2315f6e4ba..5c95bf05f8 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -214,6 +214,9 @@ public: virtual StencilMaskMode getStencilMaskMode() const { return StencilMaskMode::NONE; } using StencilMaskMeshOperator = std::function; virtual StencilMaskMeshOperator getStencilMaskMeshOperator() { return nullptr; } + virtual void updateParameters(float visionSqueezeX, float visionSqueezeY, float visionSqueezeTransition, + int visionSqueezePerEye, float visionSqueezeGroundPlaneY, + float visionSqueezeSpotlightSize) {} signals: void recommendedFramebufferSizeChanged(const QSize& size); diff --git a/libraries/procedural/src/procedural/ProceduralSkybox.cpp b/libraries/procedural/src/procedural/ProceduralSkybox.cpp index 53df1532dc..5e8c6f4865 100644 --- a/libraries/procedural/src/procedural/ProceduralSkybox.cpp +++ b/libraries/procedural/src/procedural/ProceduralSkybox.cpp @@ -18,6 +18,7 @@ #include ProceduralSkybox::ProceduralSkybox(uint64_t created) : graphics::Skybox(), _created(created) { + // FIXME: support forward rendering for procedural skyboxes (needs haze calculation) _procedural._vertexSource = gpu::Shader::createVertex(shader::graphics::vertex::skybox)->getSource(); _procedural._opaqueFragmentSource = shader::Source::get(shader::procedural::fragment::proceduralSkybox); // Adjust the pipeline state for background using the stencil test @@ -40,15 +41,15 @@ void ProceduralSkybox::clear() { Skybox::clear(); } -void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const { +void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const { if (_procedural.isReady()) { - ProceduralSkybox::render(batch, frustum, (*this)); + ProceduralSkybox::render(batch, frustum, (*this), forward); } else { - Skybox::render(batch, frustum); + Skybox::render(batch, frustum, forward); } } -void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox) { +void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox, bool forward) { glm::mat4 projMat; viewFrustum.evalProjectionMatrix(projMat); diff --git a/libraries/procedural/src/procedural/ProceduralSkybox.h b/libraries/procedural/src/procedural/ProceduralSkybox.h index a1d7ea8fa7..983b432089 100644 --- a/libraries/procedural/src/procedural/ProceduralSkybox.h +++ b/libraries/procedural/src/procedural/ProceduralSkybox.h @@ -26,8 +26,8 @@ public: bool empty() override; void clear() override; - void render(gpu::Batch& batch, const ViewFrustum& frustum) const override; - static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox); + void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const override; + static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox, bool forward); uint64_t getCreated() const { return _created; } diff --git a/libraries/render-utils/src/BackgroundStage.cpp b/libraries/render-utils/src/BackgroundStage.cpp index ca643b9f14..91b766d90b 100644 --- a/libraries/render-utils/src/BackgroundStage.cpp +++ b/libraries/render-utils/src/BackgroundStage.cpp @@ -13,6 +13,8 @@ #include +#include + std::string BackgroundStage::_stageName { "BACKGROUND_STAGE"}; const BackgroundStage::Index BackgroundStage::INVALID_INDEX { render::indexed_container::INVALID_INDEX }; @@ -71,6 +73,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, } } + const auto& hazeFrame = inputs.get2(); + if (skybox && !skybox->empty()) { PerformanceTimer perfTimer("skybox"); auto args = renderContext->args; @@ -91,7 +95,18 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, batch.setProjectionTransform(projMat); batch.setViewTransform(viewMat); - skybox->render(batch, args->getViewFrustum()); + // If we're using forward rendering, we need to calculate haze + if (args->_renderMethod == render::Args::RenderMethod::FORWARD) { + const auto& hazeStage = args->_scene->getStage(); + if (hazeStage && hazeFrame->_hazes.size() > 0) { + const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front()); + if (hazePointer) { + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); + } + } + } + + skybox->render(batch, args->getViewFrustum(), args->_renderMethod == render::Args::RenderMethod::FORWARD); }); args->_batch = nullptr; } diff --git a/libraries/render-utils/src/BackgroundStage.h b/libraries/render-utils/src/BackgroundStage.h index 61ca576ca8..3015b721b1 100644 --- a/libraries/render-utils/src/BackgroundStage.h +++ b/libraries/render-utils/src/BackgroundStage.h @@ -16,6 +16,7 @@ #include #include #include +#include "HazeStage.h" #include "LightingModel.h" @@ -81,7 +82,7 @@ public: class DrawBackgroundStage { public: - using Inputs = render::VaryingSet2; + using Inputs = render::VaryingSet3; using JobModel = render::Job::ModelI; DrawBackgroundStage() {} diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 3ab9340906..3b7c66d42d 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -432,7 +432,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, if (hazeStage && hazeFrame->_hazes.size() > 0) { const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front()); if (hazePointer) { - batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); } } @@ -655,7 +655,6 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { if (!_defaultHaze) { auto hazeStage = renderContext->_scene->getStage(); if (hazeStage) { - auto haze = std::make_shared(); _defaultHaze = haze; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index db80cbecae..f7be5160b6 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -78,7 +78,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(outputFramebufferSize, args->_viewport)); batch.setPipeline(_hazePipeline); - batch.setUniformBuffer(ru::Buffer::HazeParams, haze->getHazeParametersBuffer()); + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer()); batch.setUniformBuffer(ru::Buffer::DeferredFrameTransform, transformBuffer->getFrameTransformBuffer()); batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); diff --git a/libraries/render-utils/src/ForwardGlobalLight.slh b/libraries/render-utils/src/ForwardGlobalLight.slh deleted file mode 100644 index cf5f070c55..0000000000 --- a/libraries/render-utils/src/ForwardGlobalLight.slh +++ /dev/null @@ -1,247 +0,0 @@ - -<@if not DEFERRED_GLOBAL_LIGHT_SLH@> -<@def DEFERRED_GLOBAL_LIGHT_SLH@> - -<@include graphics/Light.slh@> - -<@include LightingModel.slh@> -<$declareLightBuffer()$> -<$declareLightAmbientBuffer()$> - -<@include LightAmbient.slh@> -<@include LightDirectional.slh@> - -<@func prepareGlobalLight(positionES, normalWS)@> - // prepareGlobalLight - // Transform directions to worldspace - vec3 fragNormalWS = vec3(<$normalWS$>); - vec3 fragPositionWS = vec3(invViewMat * vec4(<$positionES$>, 1.0)); - vec3 fragEyeVectorWS = invViewMat[3].xyz - fragPositionWS; - vec3 fragEyeDirWS = normalize(fragEyeVectorWS); - - // Get light - Light light = getKeyLight(); - LightAmbient lightAmbient = getLightAmbient(); - - vec3 lightDirection = getLightDirection(light); - vec3 lightIrradiance = getLightIrradiance(light); - - vec3 color = vec3(0.0); - -<@endfunc@> - - -<@func declareEvalAmbientGlobalColor()@> -vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) { - <$prepareGlobalLight(position, normal)$> - color += albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(lightAmbient); - return color; -} -<@endfunc@> - -<@func declareEvalAmbientSphereGlobalColor(supportScattering)@> - -<$declareLightingAmbient(1, _SCRIBE_NULL, _SCRIBE_NULL, $supportScattering$)$> -<$declareLightingDirectional($supportScattering$)$> - -<@if supportScattering@> -<$declareDeferredCurvature()$> -<@endif@> - -vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, -vec3 albedo, vec3 fresnel, float metallic, float roughness -<@if supportScattering@> - , float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature -<@endif@> ) { - - <$prepareGlobalLight(position, normal)$> - - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); - - // Ambient - vec3 ambientDiffuse; - vec3 ambientSpecular; - evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance -<@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature -<@endif@> ); - color += ambientDiffuse; - color += ambientSpecular; - - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation -<@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature -<@endif@> ); - color += directionalDiffuse; - color += directionalSpecular; - - return color; -} - -<@endfunc@> - - -<@func declareEvalSkyboxGlobalColor(supportScattering)@> - -<$declareLightingAmbient(_SCRIBE_NULL, 1, _SCRIBE_NULL, $supportScattering$)$> -<$declareLightingDirectional($supportScattering$)$> - -<@if supportScattering@> -<$declareDeferredCurvature()$> -<@endif@> - -vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, - vec3 albedo, vec3 fresnel, float metallic, float roughness -<@if supportScattering@> - , float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature -<@endif@> - ) { - <$prepareGlobalLight(position, normal)$> - - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); - - // Ambient - vec3 ambientDiffuse; - vec3 ambientSpecular; - evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance -<@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature -<@endif@> - ); - color += ambientDiffuse; - color += ambientSpecular; - - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation -<@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature -<@endif@> - ); - color += directionalDiffuse; - color += directionalSpecular; - - // FIXME - temporarily removed until we support it for forward... - // Attenuate the light if haze effect selected - // if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { - // color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); - // } - - return color; -} - -<@endfunc@> - -<@func declareEvalLightmappedColor()@> -vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 normal, vec3 albedo, vec3 lightmap) { - Light light = getKeyLight(); - LightAmbient ambient = getLightAmbient(); - - // Catch normals perpendicular to the projection plane, hence the magic number for the threshold - // It should be just 0, but we have inaccuracy so we overshoot - const float PERPENDICULAR_THRESHOLD = -0.005; - vec3 fragNormal = vec3(invViewMat * vec4(normal, 0.0)); // transform to worldspace - float diffuseDot = dot(fragNormal, -getLightDirection(light)); - float facingLight = step(PERPENDICULAR_THRESHOLD, diffuseDot); - - // Reevaluate the shadow attenuation for light facing fragments - float lightAttenuation = (1.0 - facingLight) + facingLight * shadowAttenuation; - - // Diffuse light is the lightmap dimmed by shadow - vec3 diffuseLight = lightAttenuation * lightmap; - - // Ambient light is the lightmap when in shadow - vec3 ambientLight = (1.0 - lightAttenuation) * lightmap * getLightAmbientIntensity(ambient); - - return isLightmapEnabled() * obscurance * albedo * (diffuseLight + ambientLight); -} -<@endfunc@> - - - -<@include Haze.slh@> - -<@func declareEvalGlobalLightingAlphaBlended()@> - -<$declareLightingAmbient(1, 1, 1)$> -<$declareLightingDirectional()$> - -vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) { - <$prepareGlobalLight(position, normal)$> - - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); - - color += emissive * isEmissiveEnabled(); - - // Ambient - vec3 ambientDiffuse; - vec3 ambientSpecular; - evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance); - color += ambientDiffuse; - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation); - color += directionalDiffuse; - color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); - - return color; -} - -vec3 evalGlobalLightingAlphaBlendedWithHaze( - mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, - vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) -{ - <$prepareGlobalLight(position, normal)$> - - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); - - color += emissive * isEmissiveEnabled(); - - // Ambient - vec3 ambientDiffuse; - vec3 ambientSpecular; - evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance); - color += ambientDiffuse; - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation); - color += directionalDiffuse; - color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); - - // Haze - // FIXME - temporarily removed until we support it for forward... - /* if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { - vec4 hazeColor = computeHazeColor( - positionES, // fragment position in eye coordinates - fragPositionWS, // fragment position in world coordinates - invViewMat[3].xyz, // eye position in world coordinates - lightDirection // keylight direction vector - ); - - color = mix(color.rgb, hazeColor.rgb, hazeColor.a); - }*/ - - return color; -} - -<@endfunc@> - - -<@endif@> diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index a2040b02ba..997f87b8d6 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -113,6 +113,7 @@ static const uint SHAPE_NORMALS_OFFSET = offsetof(GeometryCache::ShapeVertex, no static const uint SHAPE_TEXCOORD0_OFFSET = offsetof(GeometryCache::ShapeVertex, uv); static const uint SHAPE_TANGENT_OFFSET = offsetof(GeometryCache::ShapeVertex, tangent); +std::map, gpu::PipelinePointer> GeometryCache::_webPipelines; std::map, gpu::PipelinePointer> GeometryCache::_gridPipelines; void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityExtents, QVector &outPointList) { @@ -2018,7 +2019,7 @@ void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bo const float DEPTH_BIAS = 0.001f; static const std::vector> keys = { - std::make_tuple(false, false, grid), std::make_tuple(false, true, forward_grid), std::make_tuple(true, false, grid_translucent), std::make_tuple(true, true, forward_grid_translucent) + std::make_tuple(false, false, grid), std::make_tuple(false, true, grid_forward), std::make_tuple(true, false, grid_translucent), std::make_tuple(true, true, grid_translucent_forward) }; for (auto& key : keys) { @@ -2109,34 +2110,35 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { return a.getRaw() == b.getRaw(); } -static void buildWebShader(int programId, bool blendEnable, - gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) { - shaderPointerOut = gpu::Shader::createProgram(programId); - auto state = std::make_shared(); - state->setCullMode(gpu::State::CULL_NONE); - state->setDepthTest(true, true, gpu::LESS_EQUAL); - state->setBlendFunction(blendEnable, - 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); - - PrepareStencil::testMaskDrawShapeNoAA(*state); - - pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state); +void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent, bool forward) { + batch.setPipeline(getWebBrowserProgram(transparent, forward)); } -void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) { - batch.setPipeline(getWebBrowserProgram(transparent)); -} +gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent, bool forward) { + if (_webPipelines.empty()) { + using namespace shader::render_utils::program; + const int NUM_WEB_PIPELINES = 4; + for (int i = 0; i < NUM_WEB_PIPELINES; ++i) { + bool transparent = i & 1; + bool forward = i & 2; -gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) { - static std::once_flag once; - std::call_once(once, [&]() { - // FIXME: need a forward pipeline for this - buildWebShader(shader::render_utils::program::simple_opaque_web_browser, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipeline); - buildWebShader(shader::render_utils::program::simple_transparent_web_browser, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipeline); - }); + // For any non-opaque or non-deferred pipeline, we use web_browser_forward + auto pipeline = (transparent || forward) ? web_browser_forward : web_browser; - return transparent ? _simpleTransparentWebBrowserPipeline : _simpleOpaqueWebBrowserPipeline; + gpu::StatePointer state = gpu::StatePointer(new gpu::State()); + state->setDepthTest(true, true, gpu::LESS_EQUAL); + // FIXME: do we need a testMaskDrawNoAA? + PrepareStencil::testMaskDrawShapeNoAA(*state); + state->setBlendFunction(transparent, + 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); + state->setCullMode(gpu::State::CULL_NONE); + + _webPipelines[{ transparent, forward }] = gpu::Pipeline::create(gpu::Shader::createProgram(pipeline), state); + } + } + + return _webPipelines[{ transparent, forward }]; } void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased, bool isAntiAliased, bool forward) { @@ -2164,24 +2166,24 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp std::call_once(once, [&]() { using namespace shader::render_utils::program; - _forwardSimpleShader = gpu::Shader::createProgram(forward_simple_textured); - _forwardTransparentShader = gpu::Shader::createProgram(forward_simple_textured_transparent); - _forwardUnlitShader = gpu::Shader::createProgram(forward_simple_textured_unlit); + _forwardSimpleShader = gpu::Shader::createProgram(simple_forward); + _forwardTransparentShader = gpu::Shader::createProgram(simple_translucent_forward); + _forwardUnlitShader = gpu::Shader::createProgram(simple_unlit_forward); - _simpleShader = gpu::Shader::createProgram(simple_textured); - _transparentShader = gpu::Shader::createProgram(simple_transparent_textured); - _unlitShader = gpu::Shader::createProgram(simple_textured_unlit); + _simpleShader = gpu::Shader::createProgram(simple); + _transparentShader = gpu::Shader::createProgram(simple_translucent); + _unlitShader = gpu::Shader::createProgram(simple_unlit); }); } else { static std::once_flag once; std::call_once(once, [&]() { using namespace shader::render_utils::program; - // FIXME: these aren't right... - _forwardSimpleFadeShader = gpu::Shader::createProgram(forward_simple_textured); - _forwardUnlitFadeShader = gpu::Shader::createProgram(forward_simple_textured_unlit); + // Fading is currently disabled during forward rendering + _forwardSimpleFadeShader = gpu::Shader::createProgram(simple_forward); + _forwardUnlitFadeShader = gpu::Shader::createProgram(simple_unlit_forward); - _simpleFadeShader = gpu::Shader::createProgram(simple_textured_fade); - _unlitFadeShader = gpu::Shader::createProgram(simple_textured_unlit_fade); + _simpleFadeShader = gpu::Shader::createProgram(simple_fade); + _unlitFadeShader = gpu::Shader::createProgram(simple_unlit_fade); }); } diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 687e91f3b3..b474e6c712 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -168,8 +168,9 @@ public: static gpu::PipelinePointer getSimplePipeline(bool textured = false, bool transparent = false, bool culled = true, bool unlit = false, bool depthBias = false, bool fading = false, bool isAntiAliased = true, bool forward = false); - void bindWebBrowserProgram(gpu::Batch& batch, bool transparent = false); - gpu::PipelinePointer getWebBrowserProgram(bool transparent); + void bindWebBrowserProgram(gpu::Batch& batch, bool transparent, bool forward); + gpu::PipelinePointer getWebBrowserProgram(bool transparent, bool forward); + static std::map, gpu::PipelinePointer> _webPipelines; static void initializeShapePipelines(); render::ShapePipelinePointer getShapePipelinePointer(bool transparent, bool unlit, bool forward) { return _shapePipelines[std::make_tuple(transparent, unlit, forward)]; } @@ -458,11 +459,6 @@ private: static std::map, render::ShapePipelinePointer> _shapePipelines; static QHash _simplePrograms; - gpu::ShaderPointer _simpleOpaqueWebBrowserShader; - gpu::PipelinePointer _simpleOpaqueWebBrowserPipeline; - gpu::ShaderPointer _simpleTransparentWebBrowserShader; - gpu::PipelinePointer _simpleTransparentWebBrowserPipeline; - static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true, bool unlit = false, bool depthBias = false, bool forward = false); static render::ShapePipelinePointer getFadingShapePipeline(bool textured = false, bool transparent = false, bool culled = true, diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/GlobalLight.slh similarity index 67% rename from libraries/render-utils/src/DeferredGlobalLight.slh rename to libraries/render-utils/src/GlobalLight.slh index 03ec18c321..6702270a5a 100644 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/GlobalLight.slh @@ -1,5 +1,5 @@ -<@if not DEFERRED_GLOBAL_LIGHT_SLH@> -<@def DEFERRED_GLOBAL_LIGHT_SLH@> +<@if not GLOBAL_LIGHT_SLH@> +<@def GLOBAL_LIGHT_SLH@> <@include graphics/Light.slh@> @@ -43,7 +43,6 @@ <@endfunc@> - <@func declareEvalAmbientGlobalColor()@> vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) { <$prepareGlobalLight(position, normal)$> @@ -62,10 +61,11 @@ vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obsc <@endif@> vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, -vec3 albedo, vec3 fresnel, float metallic, float roughness + vec3 albedo, vec3 fresnel, float metallic, float roughness <@if supportScattering@> , float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature -<@endif@> ) { +<@endif@> + ) { <$prepareGlobalLight(position, normal)$> @@ -76,19 +76,20 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness vec3 ambientSpecular; evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance <@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature -<@endif@> ); + , scattering, midNormalCurvature, lowNormalCurvature +<@endif@> + ); color += ambientDiffuse; color += ambientSpecular; - // Directional vec3 directionalDiffuse; vec3 directionalSpecular; evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation <@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature -<@endif@> ); + , scattering, midNormalCurvature, lowNormalCurvature +<@endif@> + ); color += directionalDiffuse; color += directionalSpecular; @@ -97,9 +98,9 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness <@endfunc@> -<@include Haze.slh@> +<@include graphics/Haze.slh@> -<@func declareEvalSkyboxGlobalColor(supportScattering)@> +<@func declareEvalSkyboxGlobalColor(supportScattering, computeHaze)@> <$declareLightingAmbient(_SCRIBE_NULL, 1, _SCRIBE_NULL, $supportScattering$)$> <$declareLightingDirectional($supportScattering$)$> @@ -108,13 +109,13 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness <$declareDeferredCurvature()$> <@endif@> -vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, +vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, vec3 albedo, vec3 fresnel, float metallic, float roughness <@if supportScattering@> , float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature <@endif@> ) { - <$prepareGlobalLight(position, normal)$> + <$prepareGlobalLight(positionES, normalWS)$> SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); @@ -123,25 +124,41 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu vec3 ambientSpecular; evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance <@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature + , scattering, midNormalCurvature, lowNormalCurvature <@endif@> ); color += ambientDiffuse; color += ambientSpecular; + // Directional vec3 directionalDiffuse; vec3 directionalSpecular; evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation <@if supportScattering@> - ,scattering, midNormalCurvature, lowNormalCurvature + , scattering, midNormalCurvature, lowNormalCurvature <@endif@> ); color += directionalDiffuse; color += directionalSpecular; - // Attenuate the light if haze effect selected - if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { - color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + // Haze + if (isHazeEnabled() > 0.0) { + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { + color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + } + +<@if computeHaze@> + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + positionES, // fragment position in eye coordinates + fragPositionWS, // fragment position in world coordinates + invViewMat[3].xyz, // eye position in world coordinates + lightDirection // keylight direction vector in world coordinates + ); + + color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + } +<@endif@> } return color; @@ -179,41 +196,10 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur <$declareLightingAmbient(1, 1, 1)$> <$declareLightingDirectional()$> -vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity, vec3 prevLighting) { - <$prepareGlobalLight(position, normal)$> - - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); - - color = prevLighting; - color += emissive * isEmissiveEnabled(); - - // Ambient - vec3 ambientDiffuse; - vec3 ambientSpecular; - evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance); - color += ambientDiffuse; - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation); - color += directionalDiffuse; - color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); - - return color; -} -<@endfunc@> - -<@func declareEvalGlobalLightingAlphaBlendedWithHaze()@> - -<$declareLightingAmbient(1, 1, 1)$> -<$declareLightingDirectional()$> - -vec3 evalGlobalLightingAlphaBlendedWithHaze( - mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, - vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) +vec3 evalGlobalLightingAlphaBlended( + mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, + vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) { - <$prepareGlobalLight(positionES, normalWS)$> SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); @@ -234,23 +220,29 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); // Haze - if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { - vec4 hazeColor = computeHazeColor( - positionES, // fragment position in eye coordinates - fragPositionWS, // fragment position in world coordinates - invViewMat[3].xyz, // eye position in world coordinates - lightDirection // keylight direction vector in world coordinates - ); + if (isHazeEnabled() > 0.0) { + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { + color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + } - color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + positionES, // fragment position in eye coordinates + fragPositionWS, // fragment position in world coordinates + invViewMat[3].xyz, // eye position in world coordinates + lightDirection // keylight direction vector in world coordinates + ); + + color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + } } return color; } -vec3 evalGlobalLightingAlphaBlendedWithHaze( - mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 positionWS, - vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting) +vec3 evalGlobalLightingAlphaBlended( + mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, + vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting) { <$fetchGlobalLight()$> @@ -271,15 +263,23 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); // Haze - if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { - vec4 hazeColor = computeHazeColor( - positionES, // fragment position in eye coordinates - positionWS, // fragment position in world coordinates - invViewMat[3].xyz, // eye position in world coordinates - lightDirection // keylight direction vector - ); + if (isHazeEnabled() > 0.0) { + vec3 fragPositionWS = vec3(invViewMat * vec4(positionES, 1.0)); - color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { + color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + } + + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + positionES, // fragment position in eye coordinates + fragPositionWS, // fragment position in world coordinates + invViewMat[3].xyz, // eye position in world coordinates + lightDirection // keylight direction vector in world coordinates + ); + + color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + } } return color; diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 170e69eb2d..899f36b8eb 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -15,11 +15,11 @@ <$declareDeferredFrameTransform()$> <@include graphics/Light.slh@> - -<@include LightingModel.slh@> <$declareLightBuffer()$> -<@include Haze.slh@> +<@include LightingModel.slh@> + +<@include graphics/Haze.slh@> LAYOUT(binding=RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH) uniform sampler2D linearDepthMap; diff --git a/libraries/render-utils/src/LightStage.cpp b/libraries/render-utils/src/LightStage.cpp index 524deaaad2..ccdf45cedc 100755 --- a/libraries/render-utils/src/LightStage.cpp +++ b/libraries/render-utils/src/LightStage.cpp @@ -16,7 +16,8 @@ #include "ViewFrustum.h" std::string LightStage::_stageName { "LIGHT_STAGE"}; -const glm::mat4 LightStage::Shadow::_biasMatrix{ +// The bias matrix goes from homogeneous coordinates to UV coords (see http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/#basic-shader) +const glm::mat4 LightStage::Shadow::_biasMatrix { 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, @@ -249,7 +250,7 @@ void LightStage::Shadow::setKeylightFrustum(const ViewFrustum& viewFrustum, } void LightStage::Shadow::setKeylightCascadeFrustum(unsigned int cascadeIndex, const ViewFrustum& viewFrustum, - float nearDepth, float farDepth, float fixedBias, float slopeBias) { + float nearDepth, float farDepth) { assert(nearDepth < farDepth); assert(cascadeIndex < _cascades.size()); @@ -300,7 +301,12 @@ void LightStage::Shadow::setKeylightCascadeFrustum(unsigned int cascadeIndex, co auto& schema = _schemaBuffer.edit(); auto& schemaCascade = schema.cascades[cascadeIndex]; schemaCascade.reprojection = _biasMatrix * ortho * shadowViewInverse.getMatrix(); - schemaCascade.fixedBias = fixedBias; +} + +void LightStage::Shadow::setKeylightCascadeBias(unsigned int cascadeIndex, float constantBias, float slopeBias) { + auto& schema = _schemaBuffer.edit(); + auto& schemaCascade = schema.cascades[cascadeIndex]; + schemaCascade.fixedBias = constantBias; schemaCascade.slopeBias = slopeBias; } diff --git a/libraries/render-utils/src/LightStage.h b/libraries/render-utils/src/LightStage.h index 4da66843cc..36e62c614f 100755 --- a/libraries/render-utils/src/LightStage.h +++ b/libraries/render-utils/src/LightStage.h @@ -81,7 +81,8 @@ public: void setKeylightFrustum(const ViewFrustum& viewFrustum, float nearDepth = 1.0f, float farDepth = 1000.0f); void setKeylightCascadeFrustum(unsigned int cascadeIndex, const ViewFrustum& viewFrustum, - float nearDepth = 1.0f, float farDepth = 1000.0f, float fixedBias = 0.005f, float slopeBias = 0.005f); + float nearDepth = 1.0f, float farDepth = 1000.0f); + void setKeylightCascadeBias(unsigned int cascadeIndex, float constantBias, float slopeBias); void setCascadeFrustum(unsigned int cascadeIndex, const ViewFrustum& shadowFrustum); const UniformBufferView& getBuffer() const { return _schemaBuffer; } diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 54e43abc07..9ea4ac9f3c 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -59,13 +59,21 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs& const auto& inItems = inputs.get0(); const auto& lightingModel = inputs.get1(); - const auto jitter = inputs.get2(); + const auto& hazeFrame = inputs.get2(); + const auto jitter = inputs.get3(); config->setNumDrawn((int)inItems.size()); emit config->numDrawnChanged(); RenderArgs* args = renderContext->args; + graphics::HazePointer haze; + const auto& hazeStage = renderContext->args->_scene->getStage(); + if (hazeStage && hazeFrame->_hazes.size() > 0) { + // We use _hazes.back() here because the last haze object will always have haze disabled. + haze = hazeStage->getHaze(hazeFrame->_hazes.back()); + } + // Clear the framebuffer without stereo // Needs to be distinct from the other batch because using the clear call // while stereo is enabled triggers a warning @@ -96,6 +104,10 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs& batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); batch.setResourceTexture(ru::Texture::AmbientFresnel, lightingModel->getAmbientFresnelLUT()); + if (haze) { + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer()); + } + if (_opaquePass) { renderStateSortShapes(renderContext, _shapePlumber, inItems, _maxDrawn); } else { diff --git a/libraries/render-utils/src/RenderCommonTask.h b/libraries/render-utils/src/RenderCommonTask.h index 756445a30f..ec50fbf2cc 100644 --- a/libraries/render-utils/src/RenderCommonTask.h +++ b/libraries/render-utils/src/RenderCommonTask.h @@ -11,10 +11,9 @@ #include #include "LightStage.h" +#include "HazeStage.h" #include "LightingModel.h" - - class BeginGPURangeTimer { public: using JobModel = render::Job::ModelO; @@ -62,7 +61,7 @@ protected: class DrawLayered3D { public: - using Inputs = render::VaryingSet3; + using Inputs = render::VaryingSet4; using Config = DrawLayered3DConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index e513fb7282..c26f3b613c 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -207,7 +207,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("RenderDeferred", deferredLightingInputs); // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job - const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame).asVarying(); + const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying(); task.addJob("DrawBackgroundDeferred", backgroundInputs); const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeFrame, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingModel, lightFrame)); @@ -225,8 +225,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("HighlightRangeTimer", outlineRangeTimer); // Layered Over (in front) - const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, jitter).asVarying(); - const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, jitter).asVarying(); + const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, jitter).asVarying(); + const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, jitter).asVarying(); task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); @@ -254,7 +254,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto primaryFramebuffer = task.addJob("PrimaryBufferUpscale", toneMappedBuffer); // HUD Layer - const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying(); + const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying(); task.addJob("RenderHUDLayer", renderHUDLayerInputs); } @@ -506,7 +506,7 @@ void RenderTransparentDeferred::run(const RenderContextPointer& renderContext, c if (hazeStage && hazeFrame->_hazes.size() > 0) { const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front()); if (hazePointer) { - batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); } } diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index ef3dcee15f..b6b17ee376 100755 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -90,6 +90,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto currentStageFrames = lightingStageInputs.get0(); const auto lightFrame = currentStageFrames[0]; const auto backgroundFrame = currentStageFrames[1]; + const auto hazeFrame = currentStageFrames[2]; const auto& zones = lightingStageInputs[1]; @@ -111,21 +112,21 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend task.addJob("PrepareStencil", scaledPrimaryFramebuffer); // Draw opaques forward - const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel).asVarying(); + const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel, hazeFrame).asVarying(); task.addJob("DrawOpaques", opaqueInputs, shapePlumber, true); // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job - const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame).asVarying(); + const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying(); task.addJob("DrawBackgroundForward", backgroundInputs); // Draw transparent objects forward - const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel).asVarying(); + const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel, hazeFrame).asVarying(); task.addJob("DrawTransparents", transparentInputs, shapePlumber, false); // Layered const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); - const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, nullJitter).asVarying(); - const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, nullJitter).asVarying(); + const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, nullJitter).asVarying(); + const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, nullJitter).asVarying(); task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); @@ -167,7 +168,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto primaryFramebuffer = task.addJob("PrimaryBufferUpscale", toneMappedBuffer); // HUD Layer - const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying(); + const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying(); task.addJob("RenderHUDLayer", renderHUDLayerInputs); } @@ -258,11 +259,17 @@ void DrawForward::run(const RenderContextPointer& renderContext, const Inputs& i const auto& inItems = inputs.get0(); const auto& lightingModel = inputs.get1(); + const auto& hazeFrame = inputs.get2(); + + graphics::HazePointer haze; + const auto& hazeStage = renderContext->args->_scene->getStage(); + if (hazeStage && hazeFrame->_hazes.size() > 0) { + haze = hazeStage->getHaze(hazeFrame->_hazes.front()); + } gpu::doInBatch("DrawForward::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; - // Setup projection glm::mat4 projMat; Transform viewMat; @@ -276,6 +283,10 @@ void DrawForward::run(const RenderContextPointer& renderContext, const Inputs& i batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); batch.setResourceTexture(ru::Texture::AmbientFresnel, lightingModel->getAmbientFresnelLUT()); + if (haze) { + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer()); + } + // From the lighting model define a global shapeKey ORED with individiual keys ShapeKey::Builder keyBuilder; if (lightingModel->isWireframeEnabled()) { diff --git a/libraries/render-utils/src/RenderForwardTask.h b/libraries/render-utils/src/RenderForwardTask.h index baf7f66c6c..2abf248692 100755 --- a/libraries/render-utils/src/RenderForwardTask.h +++ b/libraries/render-utils/src/RenderForwardTask.h @@ -96,7 +96,7 @@ private: class DrawForward{ public: - using Inputs = render::VaryingSet2; + using Inputs = render::VaryingSet3; using JobModel = render::Job::ModelI; DrawForward(const render::ShapePlumberPointer& shapePlumber, bool opaquePass) : _shapePlumber(shapePlumber), _opaquePass(opaquePass) {} diff --git a/libraries/render-utils/src/RenderHUDLayerTask.cpp b/libraries/render-utils/src/RenderHUDLayerTask.cpp index 840d9e8002..743e59eebc 100644 --- a/libraries/render-utils/src/RenderHUDLayerTask.cpp +++ b/libraries/render-utils/src/RenderHUDLayerTask.cpp @@ -47,14 +47,15 @@ void RenderHUDLayerTask::build(JobModel& task, const render::Varying& input, ren const auto& lightingModel = inputs[1]; const auto& hudOpaque = inputs[2]; const auto& hudTransparent = inputs[3]; + const auto& hazeFrame = inputs[4]; // Composite the HUD and HUD overlays task.addJob("HUD", primaryFramebuffer); // And HUD Layer objects const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); - const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying(); - const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying(); + const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, hazeFrame, nullJitter).asVarying(); + const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, hazeFrame, nullJitter).asVarying(); task.addJob("DrawHUDOpaque", hudOpaquesInputs, true); task.addJob("DrawHUDTransparent", hudTransparentsInputs, false); } diff --git a/libraries/render-utils/src/RenderHUDLayerTask.h b/libraries/render-utils/src/RenderHUDLayerTask.h index 78cd009636..c30b0498a8 100644 --- a/libraries/render-utils/src/RenderHUDLayerTask.h +++ b/libraries/render-utils/src/RenderHUDLayerTask.h @@ -10,7 +10,7 @@ #define hifi_RenderHUDLayerTask_h #include "LightingModel.h" - +#include "HazeStage.h" class CompositeHUD { public: @@ -25,7 +25,7 @@ public: class RenderHUDLayerTask { public: // Framebuffer where to draw, lighting model, opaque items, transparent items - using Input = render::VaryingSet4; + using Input = render::VaryingSet5; using JobModel = render::Task::ModelI; void build(JobModel& task, const render::Varying& input, render::Varying& output); diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index 69a76cce00..d0ebe167f9 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -54,158 +54,125 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip using namespace shader::render_utils::program; using Key = render::ShapeKey; auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4); - // TODO: Refactor this to use a filter - // Opaques - addPipeline( - Key::Builder().withMaterial(), - model, nullptr, nullptr); - addPipeline( - Key::Builder(), - simple_textured, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withUnlit(), - model_unlit, nullptr, nullptr); - addPipeline( - Key::Builder().withUnlit(), - simple_textured_unlit, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withTangents(), - model_normal_map, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withFade(), - model_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withFade(), - simple_textured_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withUnlit().withFade(), - model_unlit_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withUnlit().withFade(), - simple_textured_unlit_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withTangents().withFade(), - model_normal_map_fade, batchSetter, itemSetter); + // TOOD: build this list algorithmically so we don't have to maintain it + std::vector> pipelines = { + // Simple + { Key::Builder(), simple }, + { Key::Builder().withTranslucent(), simple_translucent }, + { Key::Builder().withUnlit(), simple_unlit }, + { Key::Builder().withTranslucent().withUnlit(), simple_translucent_unlit }, + // Simple Fade + { Key::Builder().withFade(), simple_fade }, + { Key::Builder().withTranslucent().withFade(), simple_translucent_fade }, + { Key::Builder().withUnlit().withFade(), simple_unlit_fade }, + { Key::Builder().withTranslucent().withUnlit().withFade(), simple_translucent_unlit_fade }, - // Translucents - addPipeline( - Key::Builder().withMaterial().withTranslucent(), - model_translucent, nullptr, nullptr); - addPipeline( - Key::Builder().withTranslucent(), - simple_transparent_textured, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withTranslucent().withUnlit(), - model_translucent_unlit, nullptr, nullptr); - addPipeline( - Key::Builder().withTranslucent().withUnlit(), - simple_transparent_textured_unlit, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withTranslucent().withTangents(), - model_translucent_normal_map, nullptr, nullptr); - addPipeline( - // FIXME: Ignore lightmap for translucents meshpart - Key::Builder().withMaterial().withTranslucent().withLightMap(), - model_translucent, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withTranslucent().withFade(), - model_translucent_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withTranslucent().withFade(), - simple_transparent_textured_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withTranslucent().withUnlit().withFade(), - model_translucent_unlit_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withTranslucent().withUnlit().withFade(), - simple_transparent_textured_unlit_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withTranslucent().withTangents().withFade(), - model_translucent_normal_map_fade, batchSetter, itemSetter); - addPipeline( - // FIXME: Ignore lightmap for translucents meshpart - Key::Builder().withMaterial().withTranslucent().withLightMap().withFade(), - model_translucent_fade, batchSetter, itemSetter); - // Lightmapped - addPipeline( - Key::Builder().withMaterial().withLightMap(), - model_lightmap, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withLightMap().withTangents(), - model_lightmap_normal_map, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withLightMap().withFade(), - model_lightmap_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withLightMap().withTangents().withFade(), - model_lightmap_normal_map_fade, batchSetter, itemSetter); + // Unskinned + { Key::Builder().withMaterial(), model }, + { Key::Builder().withMaterial().withTangents(), model_normalmap }, + { Key::Builder().withMaterial().withTranslucent(), model_translucent }, + { Key::Builder().withMaterial().withTangents().withTranslucent(), model_normalmap_translucent }, + // Unskinned Unlit + { Key::Builder().withMaterial().withUnlit(), model_unlit }, + { Key::Builder().withMaterial().withTangents().withUnlit(), model_normalmap_unlit }, + { Key::Builder().withMaterial().withTranslucent().withUnlit(), model_translucent_unlit }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit(), model_normalmap_translucent_unlit }, + // Unskinned Lightmapped + { Key::Builder().withMaterial().withLightMap(), model_lightmap }, + { Key::Builder().withMaterial().withTangents().withLightMap(), model_normalmap_lightmap }, + { Key::Builder().withMaterial().withTranslucent().withLightMap(), model_translucent_lightmap }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap(), model_normalmap_translucent_lightmap }, + // Unskinned Fade + { Key::Builder().withMaterial().withFade(), model_fade }, + { Key::Builder().withMaterial().withTangents().withFade(), model_normalmap_fade }, + { Key::Builder().withMaterial().withTranslucent().withFade(), model_translucent_fade }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withFade(), model_normalmap_translucent_fade }, + // Unskinned Unlit Fade + { Key::Builder().withMaterial().withUnlit().withFade(), model_unlit_fade }, + { Key::Builder().withMaterial().withTangents().withUnlit().withFade(), model_normalmap_unlit_fade }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withFade(), model_translucent_unlit_fade }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withFade(), model_normalmap_translucent_unlit_fade }, + // Unskinned Lightmapped Fade + { Key::Builder().withMaterial().withLightMap().withFade(), model_lightmap_fade }, + { Key::Builder().withMaterial().withTangents().withLightMap().withFade(), model_normalmap_lightmap_fade }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withFade(), model_translucent_lightmap_fade }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withFade(), model_normalmap_translucent_lightmap_fade }, - // matrix palette skinned - addPipeline( - Key::Builder().withMaterial().withDeformed(), - deformed_model, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withDeformed().withTangents(), - deformed_model_normal_map, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withDeformed().withFade(), - deformed_model_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withDeformed().withTangents().withFade(), - deformed_model_normal_map_fade, batchSetter, itemSetter); - // matrix palette skinned and translucent - addPipeline( - Key::Builder().withMaterial().withDeformed().withTranslucent(), - deformed_model_translucent, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents(), - deformed_model_normal_map_translucent, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withDeformed().withTranslucent().withFade(), - deformed_model_translucent_fade, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents().withFade(), - deformed_model_normal_map_translucent_fade, batchSetter, itemSetter); + // Matrix palette skinned + { Key::Builder().withMaterial().withDeformed(), model_deformed }, + { Key::Builder().withMaterial().withTangents().withDeformed(), model_normalmap_deformed }, + { Key::Builder().withMaterial().withTranslucent().withDeformed(), model_translucent_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed(), model_normalmap_translucent_deformed }, + // Matrix palette skinned Unlit + { Key::Builder().withMaterial().withUnlit().withDeformed(), model_unlit_deformed }, + { Key::Builder().withMaterial().withTangents().withUnlit().withDeformed(), model_normalmap_unlit_deformed }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed(), model_translucent_unlit_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed(), model_normalmap_translucent_unlit_deformed }, + // Matrix palette skinned Lightmapped + { Key::Builder().withMaterial().withLightMap().withDeformed(), model_lightmap_deformed }, + { Key::Builder().withMaterial().withTangents().withLightMap().withDeformed(), model_normalmap_lightmap_deformed }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed(), model_translucent_lightmap_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed(), model_normalmap_translucent_lightmap_deformed }, + // Matrix palette skinned Fade + { Key::Builder().withMaterial().withFade().withDeformed(), model_fade_deformed }, + { Key::Builder().withMaterial().withTangents().withFade().withDeformed(), model_normalmap_fade_deformed }, + { Key::Builder().withMaterial().withTranslucent().withFade().withDeformed(), model_translucent_fade_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withFade().withDeformed(), model_normalmap_translucent_fade_deformed }, + // Matrix palette skinned Unlit Fade + { Key::Builder().withMaterial().withUnlit().withFade().withDeformed(), model_unlit_fade_deformed }, + { Key::Builder().withMaterial().withTangents().withUnlit().withFade().withDeformed(), model_normalmap_unlit_fade_deformed }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withFade().withDeformed(), model_translucent_unlit_fade_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withFade().withDeformed(), model_normalmap_translucent_unlit_fade_deformed }, + // Matrix palette skinned Lightmapped Fade + { Key::Builder().withMaterial().withLightMap().withFade().withDeformed(), model_lightmap_fade_deformed }, + { Key::Builder().withMaterial().withTangents().withLightMap().withFade().withDeformed(), model_normalmap_lightmap_fade_deformed }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withFade().withDeformed(), model_translucent_lightmap_fade_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withFade().withDeformed(), model_normalmap_translucent_lightmap_fade_deformed }, - // dual quaternion skinned - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), - deformed_model_dq, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTangents(), - deformed_model_normal_map_dq, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withFade(), - deformed_model_fade_dq, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTangents().withFade(), - deformed_model_normal_map_fade_dq, batchSetter, itemSetter); - // dual quaternion skinned and translucent - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent(), - deformed_model_translucent_dq, nullptr, nullptr); - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withTangents(), - deformed_model_normal_map_translucent_dq, nullptr, nullptr); - // Same thing but with Fade on - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withFade(), - deformed_model_translucent_fade_dq, batchSetter, itemSetter); - addPipeline( - Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withTangents().withFade(), - deformed_model_normal_map_translucent_fade_dq, batchSetter, itemSetter); + // Dual quaternion skinned + { Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), model_deformeddq }, + { Key::Builder().withMaterial().withTangents().withDeformed().withDualQuatSkinned(), model_normalmap_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withDeformed().withDualQuatSkinned(), model_translucent_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_deformeddq }, + // Dual quaternion skinned Unlit + { Key::Builder().withMaterial().withUnlit().withDeformed().withDualQuatSkinned(), model_unlit_deformeddq }, + { Key::Builder().withMaterial().withTangents().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_unlit_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_translucent_unlit_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_unlit_deformeddq }, + // Dual quaternion skinned Lightmapped + { Key::Builder().withMaterial().withLightMap().withDeformed().withDualQuatSkinned(), model_lightmap_deformeddq }, + { Key::Builder().withMaterial().withTangents().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_lightmap_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_translucent_lightmap_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_lightmap_deformeddq }, + // Dual quaternion skinned Fade + { Key::Builder().withMaterial().withFade().withDeformed().withDualQuatSkinned(), model_fade_deformeddq }, + { Key::Builder().withMaterial().withTangents().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_fade_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withFade().withDeformed().withDualQuatSkinned(), model_translucent_fade_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_fade_deformeddq }, + // Dual quaternion skinned Unlit Fade + { Key::Builder().withMaterial().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_unlit_fade_deformeddq }, + { Key::Builder().withMaterial().withTangents().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_unlit_fade_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_translucent_unlit_fade_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_unlit_fade_deformeddq }, + // Dual quaternion skinned Lightmapped Fade + { Key::Builder().withMaterial().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_lightmap_fade_deformeddq }, + { Key::Builder().withMaterial().withTangents().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_lightmap_fade_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_translucent_lightmap_fade_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_lightmap_fade_deformeddq }, + }; + + for (auto& pipeline : pipelines) { + if (pipeline.first.build().isFaded()) { + addPipeline(pipeline.first, pipeline.second, batchSetter, itemSetter); + } else { + addPipeline(pipeline.first, pipeline.second, nullptr, nullptr); + } + } } void initForwardPipelines(ShapePlumber& plumber) { - using namespace shader::render_utils; - + using namespace shader::render_utils::program; using Key = render::ShapeKey; auto addPipelineBind = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4); @@ -218,38 +185,66 @@ void initForwardPipelines(ShapePlumber& plumber) { // Forward pipelines need the lightBatchSetter for opaques and transparents forceLightBatchSetter = true; - // Simple Opaques - addPipeline(Key::Builder(), program::forward_simple_textured); - addPipeline(Key::Builder().withUnlit(), program::forward_simple_textured_unlit); + // TOOD: build this list algorithmically so we don't have to maintain it + std::vector> pipelines = { + // Simple + { Key::Builder(), simple_forward }, + { Key::Builder().withTranslucent(), simple_translucent_forward }, + { Key::Builder().withUnlit(), simple_unlit_forward }, + { Key::Builder().withTranslucent().withUnlit(), simple_translucent_unlit_forward }, - // Simple Translucents - addPipeline(Key::Builder().withTranslucent(), program::forward_simple_textured_transparent); - addPipeline(Key::Builder().withTranslucent().withUnlit(), program::simple_transparent_textured_unlit); + // Unskinned + { Key::Builder().withMaterial(), model_forward }, + { Key::Builder().withMaterial().withTangents(), model_normalmap_forward }, + { Key::Builder().withMaterial().withTranslucent(), model_translucent_forward }, + { Key::Builder().withMaterial().withTangents().withTranslucent(), model_normalmap_translucent_forward }, + // Unskinned Unlit + { Key::Builder().withMaterial().withUnlit(), model_unlit_forward }, + { Key::Builder().withMaterial().withTangents().withUnlit(), model_normalmap_unlit_forward }, + { Key::Builder().withMaterial().withTranslucent().withUnlit(), model_translucent_unlit_forward }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit(), model_normalmap_translucent_unlit_forward }, + // Unskinned Lightmapped + { Key::Builder().withMaterial().withLightMap(), model_lightmap_forward }, + { Key::Builder().withMaterial().withTangents().withLightMap(), model_normalmap_lightmap_forward }, + { Key::Builder().withMaterial().withTranslucent().withLightMap(), model_translucent_lightmap_forward }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap(), model_normalmap_translucent_lightmap_forward }, - // Opaques - addPipeline(Key::Builder().withMaterial(), program::forward_model); - addPipeline(Key::Builder().withMaterial().withLightMap(), program::forward_model_lightmap); - addPipeline(Key::Builder().withMaterial().withUnlit(), program::forward_model_unlit); - addPipeline(Key::Builder().withMaterial().withTangents(), program::forward_model_normal_map); - addPipeline(Key::Builder().withMaterial().withTangents().withLightMap(), program::forward_model_normal_map_lightmap); + // Matrix palette skinned + { Key::Builder().withMaterial().withDeformed(), model_forward_deformed }, + { Key::Builder().withMaterial().withTangents().withDeformed(), model_normalmap_forward_deformed }, + { Key::Builder().withMaterial().withTranslucent().withDeformed(), model_translucent_forward_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed(), model_normalmap_translucent_forward_deformed }, + // Matrix palette skinned Unlit + { Key::Builder().withMaterial().withUnlit().withDeformed(), model_unlit_forward_deformed }, + { Key::Builder().withMaterial().withTangents().withUnlit().withDeformed(), model_normalmap_unlit_forward_deformed }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed(), model_translucent_unlit_forward_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed(), model_normalmap_translucent_unlit_forward_deformed }, + // Matrix palette skinned Lightmapped + { Key::Builder().withMaterial().withLightMap().withDeformed(), model_lightmap_forward_deformed }, + { Key::Builder().withMaterial().withTangents().withLightMap().withDeformed(), model_normalmap_lightmap_forward_deformed }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed(), model_translucent_lightmap_forward_deformed }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed(), model_normalmap_translucent_lightmap_forward_deformed }, - // Deformed Opaques - addPipeline(Key::Builder().withMaterial().withDeformed(), program::forward_deformed_model); - addPipeline(Key::Builder().withMaterial().withDeformed().withTangents(), program::forward_deformed_model_normal_map); - addPipeline(Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), program::forward_deformed_model_dq); - addPipeline(Key::Builder().withMaterial().withDeformed().withTangents().withDualQuatSkinned(), program::forward_deformed_model_normal_map_dq); + // Dual quaternion skinned + { Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), model_forward_deformeddq }, + { Key::Builder().withMaterial().withTangents().withDeformed().withDualQuatSkinned(), model_normalmap_forward_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withDeformed().withDualQuatSkinned(), model_translucent_forward_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_forward_deformeddq }, + // Dual quaternion skinned Unlit + { Key::Builder().withMaterial().withUnlit().withDeformed().withDualQuatSkinned(), model_unlit_forward_deformeddq }, + { Key::Builder().withMaterial().withTangents().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_unlit_forward_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_translucent_unlit_forward_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_unlit_forward_deformeddq }, + // Dual quaternion skinned Lightmapped + { Key::Builder().withMaterial().withLightMap().withDeformed().withDualQuatSkinned(), model_lightmap_forward_deformeddq }, + { Key::Builder().withMaterial().withTangents().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_lightmap_forward_deformeddq }, + { Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_translucent_lightmap_forward_deformeddq }, + { Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_lightmap_forward_deformeddq }, + }; - // Translucents - addPipeline(Key::Builder().withMaterial().withTranslucent(), program::forward_model_translucent); - addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents(), program::forward_model_normal_map_translucent); - - // Deformed Translucents - addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent(), program::forward_deformed_translucent); - addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents(), program::forward_deformed_translucent_normal_map); - addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withDualQuatSkinned(), program::forward_deformed_translucent_dq); - addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents().withDualQuatSkinned(), program::forward_deformed_translucent_normal_map_dq); - - // FIXME: incorrent pipelines for normal mapped + translucent models + for (auto& pipeline : pipelines) { + addPipeline(pipeline.first, pipeline.second); + } forceLightBatchSetter = false; } @@ -300,8 +295,7 @@ void addPlumberPipeline(ShapePlumber& plumber, baseBatchSetter(pipeline, batch, args); extraBatchSetter(pipeline, batch, args); }; - } - else { + } else { finalBatchSetter = baseBatchSetter; } plumber.addPipeline(builder.build(), program, state, finalBatchSetter, itemSetter); @@ -362,17 +356,17 @@ void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state, con shapePlumber.addPipeline( ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withoutFade(), - gpu::Shader::createProgram(deformed_model_shadow), state); + gpu::Shader::createProgram(model_shadow_deformed), state); shapePlumber.addPipeline( ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withFade(), - gpu::Shader::createProgram(deformed_model_shadow_fade), state, extraBatchSetter, itemSetter); + gpu::Shader::createProgram(model_shadow_fade_deformed), state, extraBatchSetter, itemSetter); shapePlumber.addPipeline( ShapeKey::Filter::Builder().withDeformed().withDualQuatSkinned().withoutFade(), - gpu::Shader::createProgram(deformed_model_shadow_dq), state); + gpu::Shader::createProgram(model_shadow_deformeddq), state); shapePlumber.addPipeline( ShapeKey::Filter::Builder().withDeformed().withDualQuatSkinned().withFade(), - gpu::Shader::createProgram(deformed_model_shadow_fade_dq), state, extraBatchSetter, itemSetter); + gpu::Shader::createProgram(model_shadow_fade_deformeddq), state, extraBatchSetter, itemSetter); } bool RenderPipelines::bindMaterial(graphics::MaterialPointer& material, gpu::Batch& batch, render::Args::RenderMode renderMode, bool enableTextures) { diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index f54b2e563e..0d0b776074 100755 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -33,7 +33,6 @@ // but are readjusted afterwards #define SHADOW_FRUSTUM_NEAR 1.0f #define SHADOW_FRUSTUM_FAR 500.0f -static const unsigned int SHADOW_CASCADE_COUNT{ 4 }; using namespace render; @@ -316,85 +315,45 @@ RenderShadowSetup::RenderShadowSetup() : _shadowFrameCache = std::make_shared(); } -void RenderShadowSetup::configure(const Config& configuration) { - distanceTriggeredByConfig = _globalMaxDistance != configuration.globalMaxDistance; - biasTriggeredByConfig = _biasInput != configuration.biasInput; - - // go back to using the config's default bias values if a change to any of those is triggered - if (constant0 != configuration.constantBias0 || slope0 != configuration.slopeBias0 || - constant1 != configuration.constantBias1 || slope1 != configuration.slopeBias1 || - constant2 != configuration.constantBias2 || slope2 != configuration.slopeBias2 || - constant3 != configuration.constantBias3 || slope3 != configuration.slopeBias3) { - constant0 = configuration.constantBias0; - slope0 = configuration.slopeBias0; - constant1 = configuration.constantBias1; - slope1 = configuration.slopeBias1; - constant2 = configuration.constantBias2; - slope2 = configuration.slopeBias2; - constant3 = configuration.constantBias3; - slope3 = configuration.slopeBias3; - changeInDefaultConfigValues = true; - distanceTriggeredByConfig = false; - biasTriggeredByConfig = false; - - setConstantBias(0, constant0); - setSlopeBias(0, slope0); - - #if SHADOW_CASCADE_MAX_COUNT > 1 - setConstantBias(1, constant1); - setConstantBias(2, constant2); - setConstantBias(3, constant3); - - setSlopeBias(1, slope1); - setSlopeBias(2, slope2); - setSlopeBias(3, slope3); - #endif - } - - // modify bias using single input and work in calculateBias() - if (distanceTriggeredByConfig) { - changeInDefaultConfigValues = false; - _globalMaxDistance = configuration.globalMaxDistance; - calculateBiases(); - } - if (biasTriggeredByConfig) { - changeInDefaultConfigValues = false; - _biasInput = configuration.biasInput; - calculateBiases(); - } +void RenderShadowSetup::configure(const Config& config) { + constantBias0 = config.constantBias0; + constantBias1 = config.constantBias1; + constantBias2 = config.constantBias2; + constantBias3 = config.constantBias3; + slopeBias0 = config.slopeBias0; + slopeBias1 = config.slopeBias1; + slopeBias2 = config.slopeBias2; + slopeBias3 = config.slopeBias3; + biasInput = config.biasInput; + maxDistance = config.maxDistance; } -void RenderShadowSetup::calculateBiases() { - // slope scaling values derived from ratio between original constantBias and slopeBias pairs - const std::array SLOPE_SCALES = {{ 2.7f, 3.0f, 3.7f, 3.5f }}; - const float CONVERT_BIAS = 100.0f; - const float MIN_SCALE_DIVISOR = 0.5f; - - // the bias is relative to resolution - // to remain consistent with the constant and slope bias values, the biasInput - // value is in the 0.0 - 1.0 range but needs to be scaled up for further calculations - float inverseResolution = 1.0f / (float)resolution; - int resolutionScale = DEFAULT_RESOLUTION * inverseResolution; - float convertedBias = _biasInput * (CONVERT_BIAS / resolutionScale); - std::array localConstants; - std::array localSlopes; - float scaleFactor = 1.0f; +void RenderShadowSetup::calculateBiases(float biasInput) { + const std::array CONSTANT_CASCADE_SCALE = {{ 0.01f, 0.01f, 0.015f, 0.02f }}; + const float SLOPE_BIAS_SCALE = 0.005f; for (int i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) { - scaleFactor = convertedBias * (cacasdeDistances[0] / glm::max(MIN_SCALE_DIVISOR, cacasdeDistances[i + 4])) * inverseResolution; - localConstants[i] = cacasdeDistances[i] * scaleFactor; - localSlopes[i] = cacasdeDistances[i] * scaleFactor * SLOPE_SCALES[i]; - setConstantBias(i, localConstants[i]); - setSlopeBias(i, localSlopes[i]); + auto& cascade = _globalShadowObject->getCascade(i); + + // Constant bias is dependent on the depth precision + float cascadeDepth = cascade.getMaxDistance() - cascade.getMinDistance(); + float constantBias = CONSTANT_CASCADE_SCALE[i] * biasInput / cascadeDepth; + setConstantBias(i, constantBias); + + // Slope bias is dependent on the texel size + float cascadeWidth = cascade.getFrustum()->getWidth(); + float cascadeHeight = cascade.getFrustum()->getHeight(); + float cascadeTexelMaxDim = glm::max(cascadeWidth, cascadeHeight) / LightStage::Shadow::MAP_SIZE; // TODO: variable cascade resolution + setSlopeBias(i, cascadeTexelMaxDim * constantBias / SLOPE_BIAS_SCALE); } } void RenderShadowSetup::setConstantBias(int cascadeIndex, float value) { - _bias[cascadeIndex]._constant = value * value * value * 0.004f; + _bias[cascadeIndex]._constant = value; } void RenderShadowSetup::setSlopeBias(int cascadeIndex, float value) { - _bias[cascadeIndex]._slope = value * value * value * 0.001f; + _bias[cascadeIndex]._slope = value; } void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, const Input& input, Output& output) { @@ -425,43 +384,42 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c output.edit2() = _cameraFrustum; if (!_globalShadowObject) { - _globalShadowObject = std::make_shared(currentKeyLight, SHADOW_CASCADE_COUNT); + _globalShadowObject = std::make_shared(currentKeyLight, SHADOW_CASCADE_MAX_COUNT); } - resolution = _globalShadowObject->MAP_SIZE; _globalShadowObject->setLight(currentKeyLight); _globalShadowObject->setKeylightFrustum(args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); - // if the max distance isn't altered externally, grab the value from the light - if (!distanceTriggeredByConfig && !biasTriggeredByConfig) { - _globalMaxDistance = currentKeyLight->getShadowsMaxDistance(); - } - _globalShadowObject->setMaxDistance(_globalMaxDistance); - - auto& firstCascade = _globalShadowObject->getCascade(0); - auto& firstCascadeFrustum = firstCascade.getFrustum(); - unsigned int cascadeIndex; - for (cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) { - cacasdeDistances[cascadeIndex] = _globalShadowObject->getCascade(cascadeIndex).getMaxDistance(); - cacasdeDistances[cascadeIndex + 4] = _globalShadowObject->getCascade(cascadeIndex).getMinDistance(); - } - - if (!biasTriggeredByConfig && !distanceTriggeredByConfig && !changeInDefaultConfigValues) { - setBiasInput(currentKeyLight->getBiasInput()); - calculateBiases(); - } + // Update our biases and maxDistance from the light or config + _globalShadowObject->setMaxDistance(maxDistance > 0.0f ? maxDistance : currentKeyLight->getShadowsMaxDistance()); // Adjust each cascade frustum - const auto biasScale = currentKeyLight->getShadowsBiasScale(); - for (cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) { + for (unsigned int cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) { + _globalShadowObject->setKeylightCascadeFrustum(cascadeIndex, args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); + } + + calculateBiases(biasInput > 0.0f ? biasInput : currentKeyLight->getShadowBias()); + + std::array constantBiases = {{ constantBias0, constantBias1, constantBias2, constantBias3 }}; + std::array slopeBiases = {{ slopeBias0, slopeBias1, slopeBias2, slopeBias3 }}; + for (unsigned int cascadeIndex = 0; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) { + float constantBias = constantBiases[cascadeIndex]; + if (constantBias > 0.0f) { + setConstantBias(cascadeIndex, constantBias); + } + float slopeBias = slopeBiases[cascadeIndex]; + if (slopeBias > 0.0f) { + setSlopeBias(cascadeIndex, slopeBias); + } + auto& bias = _bias[cascadeIndex]; - _globalShadowObject->setKeylightCascadeFrustum(cascadeIndex, args->getViewFrustum(), - SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR, - bias._constant, bias._slope * biasScale); + _globalShadowObject->setKeylightCascadeBias(cascadeIndex, bias._constant, bias._slope); } _shadowFrameCache->pushShadow(_globalShadowObject); // Now adjust coarse frustum bounds + auto& firstCascade = _globalShadowObject->getCascade(0); + auto& firstCascadeFrustum = firstCascade.getFrustum(); auto frustumPosition = firstCascadeFrustum->getPosition(); auto farTopLeft = firstCascadeFrustum->getFarTopLeft() - frustumPosition; auto farBottomRight = firstCascadeFrustum->getFarBottomRight() - frustumPosition; @@ -473,7 +431,7 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, c auto near = firstCascadeFrustum->getNearClip(); auto far = firstCascadeFrustum->getFarClip(); - for (cascadeIndex = 1; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) { + for (unsigned int cascadeIndex = 1; cascadeIndex < _globalShadowObject->getCascadeCount(); ++cascadeIndex) { auto& cascadeFrustum = _globalShadowObject->getCascade(cascadeIndex).getFrustum(); farTopLeft = cascadeFrustum->getFarTopLeft() - frustumPosition; diff --git a/libraries/render-utils/src/RenderShadowTask.h b/libraries/render-utils/src/RenderShadowTask.h index ceca28cec8..98b5ac1e10 100755 --- a/libraries/render-utils/src/RenderShadowTask.h +++ b/libraries/render-utils/src/RenderShadowTask.h @@ -75,34 +75,31 @@ public: CullFunctor _cullFunctor; }; -const float DEFAULT_BIAS_INPUT = 0.5f; -const float DEFAULT_MAX_DISTANCE = 40.0f; - class RenderShadowSetupConfig : public render::Job::Config { Q_OBJECT - Q_PROPERTY(float constantBias0 MEMBER constantBias0 NOTIFY dirty) - Q_PROPERTY(float constantBias1 MEMBER constantBias1 NOTIFY dirty) - Q_PROPERTY(float constantBias2 MEMBER constantBias2 NOTIFY dirty) - Q_PROPERTY(float constantBias3 MEMBER constantBias3 NOTIFY dirty) - Q_PROPERTY(float slopeBias0 MEMBER slopeBias0 NOTIFY dirty) - Q_PROPERTY(float slopeBias1 MEMBER slopeBias1 NOTIFY dirty) - Q_PROPERTY(float slopeBias2 MEMBER slopeBias2 NOTIFY dirty) - Q_PROPERTY(float slopeBias3 MEMBER slopeBias3 NOTIFY dirty) - Q_PROPERTY(float biasInput MEMBER biasInput NOTIFY dirty) - Q_PROPERTY(float globalMaxDistance MEMBER globalMaxDistance NOTIFY dirty) + Q_PROPERTY(float constantBias0 MEMBER constantBias0 NOTIFY dirty) + Q_PROPERTY(float constantBias1 MEMBER constantBias1 NOTIFY dirty) + Q_PROPERTY(float constantBias2 MEMBER constantBias2 NOTIFY dirty) + Q_PROPERTY(float constantBias3 MEMBER constantBias3 NOTIFY dirty) + Q_PROPERTY(float slopeBias0 MEMBER slopeBias0 NOTIFY dirty) + Q_PROPERTY(float slopeBias1 MEMBER slopeBias1 NOTIFY dirty) + Q_PROPERTY(float slopeBias2 MEMBER slopeBias2 NOTIFY dirty) + Q_PROPERTY(float slopeBias3 MEMBER slopeBias3 NOTIFY dirty) + Q_PROPERTY(float biasInput MEMBER biasInput NOTIFY dirty) + Q_PROPERTY(float maxDistance MEMBER maxDistance NOTIFY dirty) public: - float biasInput{ DEFAULT_BIAS_INPUT }; - float globalMaxDistance{ DEFAULT_MAX_DISTANCE }; - - float constantBias0{ 0.15f }; - float constantBias1{ 0.15f }; - float constantBias2{ 0.175f }; - float constantBias3{ 0.2f }; - float slopeBias0{ 0.4f }; - float slopeBias1{ 0.45f }; - float slopeBias2{ 0.65f }; - float slopeBias3{ 0.7f }; + // Set to > 0 to experiment with these values + float constantBias0 { 0.0f }; + float constantBias1 { 0.0f }; + float constantBias2 { 0.0f }; + float constantBias3 { 0.0f }; + float slopeBias0 { 0.0f }; + float slopeBias1 { 0.0f }; + float slopeBias2 { 0.0f }; + float slopeBias3 { 0.0f }; + float biasInput { 0.0f }; + float maxDistance { 0.0f }; signals: void dirty(); @@ -116,7 +113,7 @@ public: using JobModel = render::Job::ModelIO; RenderShadowSetup(); - void configure(const Config& configuration); + void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Input& input, Output& output); private: @@ -130,29 +127,21 @@ private: LightStage::ShadowFrame::Object _globalShadowObject; LightStage::ShadowFramePointer _shadowFrameCache; - const int DEFAULT_RESOLUTION = 1024; - float _biasInput{ DEFAULT_BIAS_INPUT }; - float _globalMaxDistance{ DEFAULT_MAX_DISTANCE }; - int resolution{ DEFAULT_RESOLUTION }; - - // initialize with values from RenderShadowSetupConfig - float constant0{ 0.15f }; - float constant1{ 0.15f }; - float constant2{ 0.175f }; - float constant3{ 0.2f }; - float slope0{ 0.4f }; - float slope1{ 0.45f }; - float slope2{ 0.65f }; - float slope3{ 0.7f }; - bool changeInDefaultConfigValues{ false }; - bool distanceTriggeredByConfig{ false }; - bool biasTriggeredByConfig{ false }; - std::array cacasdeDistances; // 4 max then 4 min distances + // Values from config + float constantBias0; + float constantBias1; + float constantBias2; + float constantBias3; + float slopeBias0; + float slopeBias1; + float slopeBias2; + float slopeBias3; + float biasInput; + float maxDistance; void setConstantBias(int cascadeIndex, float value); void setSlopeBias(int cascadeIndex, float value); - void setBiasInput(float input) { _biasInput = input; } - void calculateBiases(); + void calculateBiases(float biasInput); }; class RenderShadowCascadeSetup { diff --git a/libraries/render-utils/src/deformed_model.slv b/libraries/render-utils/src/deformed_model.slv deleted file mode 100644 index 8c6d3d049d..0000000000 --- a/libraries/render-utils/src/deformed_model.slv +++ /dev/null @@ -1,56 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// 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 gpu/Inputs.slh@> -<@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<$declareStandardTransform()$> - -<@include graphics/MaterialTextures.slh@> -<$declareMaterialTexMapArrayBuffer()$> - -<@include MeshDeformer.slh@> -<$declareMeshDeformer(1, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$> -<$declareMeshDeformerActivation(1, 1)$> - -<@include LightingModel.slh@> - - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; - -void main(void) { - vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); - vec3 deformedNormal = vec3(0.0, 0.0, 0.0); - evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, - meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, - meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); - - // pass along the color - _color.rgb = color_sRGBToLinear(inColor.rgb); - _color.a = inColor.a; - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$> - - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> -} diff --git a/libraries/render-utils/src/deformed_model_dq.slv b/libraries/render-utils/src/deformed_model_dq.slv deleted file mode 100644 index 56ac1b6558..0000000000 --- a/libraries/render-utils/src/deformed_model_dq.slv +++ /dev/null @@ -1,53 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// 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 gpu/Inputs.slh@> -<@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<$declareStandardTransform()$> - -<@include graphics/MaterialTextures.slh@> -<$declareMaterialTexMapArrayBuffer()$> - -<@include MeshDeformer.slh@> -<$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$> -<$declareMeshDeformerActivation(1, 1)$> - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; - -void main(void) { - vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); - vec3 deformedNormal = vec3(0.0, 0.0, 0.0); - evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, - meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, - meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); - - // pass along the color - _color.rgb = color_sRGBToLinear(inColor.rgb); - _color.a = inColor.a; - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$> - - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> -} diff --git a/libraries/render-utils/src/deformed_model_normal_map.slv b/libraries/render-utils/src/deformed_model_normal_map.slv deleted file mode 100644 index 85e164b639..0000000000 --- a/libraries/render-utils/src/deformed_model_normal_map.slv +++ /dev/null @@ -1,56 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// 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 gpu/Inputs.slh@> -<@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<$declareStandardTransform()$> - -<@include graphics/MaterialTextures.slh@> -<$declareMaterialTexMapArrayBuffer()$> - -<@include MeshDeformer.slh@> -<$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$> -<$declareMeshDeformerActivation(1, 1)$> - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; - -void main(void) { - vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); - vec3 deformedNormal = vec3(0.0, 0.0, 0.0); - vec3 deformedTangent = vec3(0.0, 0.0, 0.0); - evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent, - meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, - meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); - - // pass along the color - _color.rgb = color_sRGBToLinear(inColor.rgb); - _color.a = inColor.a; - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$> - <$transformModelToWorldDir(cam, obj, deformedTangent, _tangentWS.xyz)$> - - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> -} diff --git a/libraries/render-utils/src/deformed_model_normal_map_dq.slv b/libraries/render-utils/src/deformed_model_normal_map_dq.slv deleted file mode 100644 index 807d343643..0000000000 --- a/libraries/render-utils/src/deformed_model_normal_map_dq.slv +++ /dev/null @@ -1,57 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// 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 gpu/Inputs.slh@> -<@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<@include render-utils/ShaderConstants.h@> -<$declareStandardTransform()$> - -<@include graphics/MaterialTextures.slh@> -<$declareMaterialTexMapArrayBuffer()$> - -<@include MeshDeformer.slh@> -<$declareMeshDeformer(1, 1, 1, 1, 1)$> -<$declareMeshDeformerActivation(1, 1)$> - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; - -void main(void) { - vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); - vec3 deformedNormal = vec3(0.0, 0.0, 0.0); - vec3 deformedTangent = vec3(0.0, 0.0, 0.0); - evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent, - meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, - meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); - - // pass along the color - _color.rgb = color_sRGBToLinear(inColor.rgb); - _color.a = inColor.a; - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$> - <$transformModelToWorldDir(cam, obj, deformedTangent, _tangentWS.xyz)$> - - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> -} diff --git a/libraries/render-utils/src/deformed_model_shadow.slv b/libraries/render-utils/src/deformed_model_shadow.slv deleted file mode 100644 index 827fc69b32..0000000000 --- a/libraries/render-utils/src/deformed_model_shadow.slv +++ /dev/null @@ -1,52 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// Copyright 2014 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 gpu/Inputs.slh@> -<@include gpu/Transform.slh@> -<$declareStandardTransform()$> - -<@include MeshDeformer.slh@> -<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$> -<$declareMeshDeformerActivation(1, 1)$> - -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> - -<$declareMaterialTexMapArrayBuffer()$> - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; - -void main(void) { - vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); - evalMeshDeformer(inPosition, deformedPosition, - meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, - meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToClipPos(cam, obj, deformedPosition, gl_Position)$> - <$transformModelToWorldPos(obj, deformedPosition, _positionWS)$> - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - _texCoord01 = vec4(0.0, 0.0, 0.0, 0.0); - // If we have an opacity mask than we need the first tex coord - if ((matKey & OPACITY_MASK_MAP_BIT) != 0) { - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - } -} - diff --git a/libraries/render-utils/src/deformed_model_shadow_dq.slv b/libraries/render-utils/src/deformed_model_shadow_dq.slv deleted file mode 100644 index 646fc12ce9..0000000000 --- a/libraries/render-utils/src/deformed_model_shadow_dq.slv +++ /dev/null @@ -1,51 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// Copyright 2014 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 gpu/Inputs.slh@> -<@include gpu/Transform.slh@> -<$declareStandardTransform()$> - -<@include MeshDeformer.slh@> -<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$> -<$declareMeshDeformerActivation(1, 1)$> - -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> - -<$declareMaterialTexMapArrayBuffer()$> - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; - -void main(void) { - vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0); - evalMeshDeformer(inPosition, deformedPosition, - meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, - meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToClipPos(cam, obj, deformedPosition, gl_Position)$> - <$transformModelToWorldPos(obj, deformedPosition, _positionWS)$> - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - _texCoord01 = vec4(0.0, 0.0, 0.0, 0.0); - // If we have an opacity mask than we need the first tex coord - if ((matKey & OPACITY_MASK_MAP_BIT) != 0) { - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - } -} diff --git a/libraries/render-utils/src/directional_ambient_light.slf b/libraries/render-utils/src/directional_ambient_light.slf index b1cfc26c66..dd1b59f43e 100644 --- a/libraries/render-utils/src/directional_ambient_light.slf +++ b/libraries/render-utils/src/directional_ambient_light.slf @@ -11,15 +11,10 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - - - <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> - +<@include GlobalLight.slh@> <$declareEvalAmbientSphereGlobalColor(supportScattering)$> layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; diff --git a/libraries/render-utils/src/directional_ambient_light_shadow.slf b/libraries/render-utils/src/directional_ambient_light_shadow.slf index 6b9fb80232..34018125af 100644 --- a/libraries/render-utils/src/directional_ambient_light_shadow.slf +++ b/libraries/render-utils/src/directional_ambient_light_shadow.slf @@ -11,15 +11,14 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - -<@include Shadow.slh@> <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> +<@include GlobalLight.slh@> <$declareEvalAmbientSphereGlobalColor(isScattering)$> +<@include Shadow.slh@> + layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index b820b3d17f..8e2b38b478 100644 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -11,13 +11,11 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> -<$declareEvalSkyboxGlobalColor(isScattering)$> +<@include GlobalLight.slh@> +<$declareEvalSkyboxGlobalColor(isScattering, _SCRIBE_NULL)$> layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy diff --git a/libraries/render-utils/src/directional_skybox_light_shadow.slf b/libraries/render-utils/src/directional_skybox_light_shadow.slf index 8716d60d54..2f289ed00f 100644 --- a/libraries/render-utils/src/directional_skybox_light_shadow.slf +++ b/libraries/render-utils/src/directional_skybox_light_shadow.slf @@ -11,14 +11,13 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html //!> - -<@include Shadow.slh@> <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> -<$declareEvalSkyboxGlobalColor(isScattering)$> +<@include GlobalLight.slh@> +<$declareEvalSkyboxGlobalColor(isScattering, _SCRIBE_NULL)$> + +<@include Shadow.slh@> layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy @@ -35,7 +34,6 @@ void main(void) { vec3 worldLightDirection = getLightDirection(shadowLight); float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal); - // Light mapped or not ? if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) { discard; } else { diff --git a/libraries/render-utils/src/forward_grid.slf b/libraries/render-utils/src/forward_grid.slf deleted file mode 100644 index e34794bfed..0000000000 --- a/libraries/render-utils/src/forward_grid.slf +++ /dev/null @@ -1,40 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gondelman on 5/9/19 -// Copyright 2019 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 gpu/ShaderConstants.h@> -<@include gpu/Paint.slh@> - -struct Grid { - vec4 period; - vec4 offset; - vec4 edge; -}; - -LAYOUT(binding=0) uniform gridBuffer { - Grid grid; -}; - -layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0; -layout(location=GPU_ATTR_COLOR) in vec4 varColor; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), - paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), - float(grid.edge.z == 0.0)); - - if (alpha < 0.0001) { - discard; - } - - _fragColor0 = vec4(varColor.xyz, 1.0); -} diff --git a/libraries/render-utils/src/forward_grid_translucent.slf b/libraries/render-utils/src/forward_grid_translucent.slf deleted file mode 100644 index df0494a22e..0000000000 --- a/libraries/render-utils/src/forward_grid_translucent.slf +++ /dev/null @@ -1,41 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gondelman on 5/9/19 -// Copyright 2019 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 gpu/ShaderConstants.h@> -<@include gpu/Paint.slh@> - -struct Grid { - vec4 period; - vec4 offset; - vec4 edge; -}; - -LAYOUT(binding=0) uniform gridBuffer { - Grid grid; -}; - -layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0; -layout(location=GPU_ATTR_COLOR) in vec4 varColor; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), - paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), - float(grid.edge.z == 0.0)); - alpha *= varColor.w; - - if (alpha < 0.0001) { - discard; - } - - _fragColor0 = vec4(varColor.xyz, alpha); -} diff --git a/libraries/render-utils/src/forward_model.slf b/libraries/render-utils/src/forward_model.slf deleted file mode 100644 index daccd9c6d6..0000000000 --- a/libraries/render-utils/src/forward_model.slf +++ /dev/null @@ -1,83 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 2/15/2016. -// Copyright 2014 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include ForwardGlobalLight.slh@> - -<$declareEvalSkyboxGlobalColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal = normalize(_normalWS); - - TransformCamera cam = getTransformCamera(); - - vec4 color = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - occlusion, - fragPosition, - fragNormal, - albedo, - fresnel, - metallic, - roughness), - opacity); - color.rgb += emissive * isEmissiveEnabled(); - - _fragColor0 = color; -} diff --git a/libraries/render-utils/src/forward_model_lightmap.slf b/libraries/render-utils/src/forward_model_lightmap.slf deleted file mode 100644 index aa1d6dc3b8..0000000000 --- a/libraries/render-utils/src/forward_model_lightmap.slf +++ /dev/null @@ -1,71 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 2/15/2016. -// Copyright 2014 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include ForwardGlobalLight.slh@> - -<$declareEvalLightmappedColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$> -<$declareMaterialLightmap()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fragNormal = normalize(_normalWS); - - TransformCamera cam = getTransformCamera(); - - vec4 color = vec4(evalLightmappedColor( - cam._viewInverse, - 1.0, - 1.0, - fragNormal, - albedo, - lightmap), - opacity); - - _fragColor0 = color; -} diff --git a/libraries/render-utils/src/forward_model_normal_map.slf b/libraries/render-utils/src/forward_model_normal_map.slf deleted file mode 100644 index 33e375c495..0000000000 --- a/libraries/render-utils/src/forward_model_normal_map.slf +++ /dev/null @@ -1,85 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 2/15/2016. -// Copyright 2014 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include ForwardGlobalLight.slh@> - -<$declareEvalSkyboxGlobalColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal; - <$evalMaterialNormalLOD(fragPosition, normalTex, _normalWS, _tangentWS, fragNormal)$> - - TransformCamera cam = getTransformCamera(); - - vec4 color = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - occlusion, - fragPosition, - fragNormal, - albedo, - fresnel, - metallic, - roughness), - opacity); - color.rgb += emissive * isEmissiveEnabled(); - - _fragColor0 = color; -} diff --git a/libraries/render-utils/src/forward_model_normal_map_lightmap.slf b/libraries/render-utils/src/forward_model_normal_map_lightmap.slf deleted file mode 100644 index c36f3d51c6..0000000000 --- a/libraries/render-utils/src/forward_model_normal_map_lightmap.slf +++ /dev/null @@ -1,74 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 2/15/2016. -// Copyright 2014 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include ForwardGlobalLight.slh@> - -<$declareEvalLightmappedColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$> -<$declareMaterialLightmap()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal; - <$evalMaterialNormalLOD(fragPosition, normalTex, _normalWS, _tangentWS, fragNormal)$> - - TransformCamera cam = getTransformCamera(); - - vec4 color = vec4(evalLightmappedColor( - cam._viewInverse, - 1.0, - 1.0, - fragNormal, - albedo, - lightmap), - opacity); - - _fragColor0 = color; -} diff --git a/libraries/render-utils/src/forward_model_translucent.slf b/libraries/render-utils/src/forward_model_translucent.slf deleted file mode 100644 index 080ed7eea3..0000000000 --- a/libraries/render-utils/src/forward_model_translucent.slf +++ /dev/null @@ -1,81 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 2/15/2016. -// Copyright 2014 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include ForwardGlobalLight.slh@> - -<$declareEvalGlobalLightingAlphaBlended()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardInvisible(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal = normalize(_normalWS); - - TransformCamera cam = getTransformCamera(); - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - occlusion, - fragPosition, - fragNormal, - albedo, - fresnel, - metallic, - emissive, - roughness, opacity), - opacity); -} diff --git a/libraries/render-utils/src/forward_model_unlit.slf b/libraries/render-utils/src/forward_model_unlit.slf deleted file mode 100644 index ccd264f0bf..0000000000 --- a/libraries/render-utils/src/forward_model_unlit.slf +++ /dev/null @@ -1,42 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 5/5/2016. -// Copyright 2016 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightingModel.slh@> - -<$declareMaterialTextures(ALBEDO)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - _fragColor0 = vec4(albedo * isUnlitEnabled(), 1.0); -} diff --git a/libraries/render-utils/src/forward_parabola.slf b/libraries/render-utils/src/forward_parabola.slf deleted file mode 100644 index b0def6db6b..0000000000 --- a/libraries/render-utils/src/forward_parabola.slf +++ /dev/null @@ -1,18 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gondelman on 5/9/19 -// Copyright 2019 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 -// - -layout(location=0) in vec4 _color; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - _fragColor0 = _color; -} diff --git a/libraries/render-utils/src/forward_simple.slf b/libraries/render-utils/src/forward_simple.slf deleted file mode 100644 index 50e3cdc511..0000000000 --- a/libraries/render-utils/src/forward_simple.slf +++ /dev/null @@ -1,61 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// forward_simple.frag -// fragment shader -// -// Created by Andrzej Kapolka on 9/15/14. -// Copyright 2014 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 DefaultMaterials.slh@> - -<@include ForwardGlobalLight.slh@> -<$declareEvalSkyboxGlobalColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; - -// For retro-compatibility -#define _normal _normalWS -#define _modelNormal _normalMS -#define _position _positionMS -#define _eyePosition _positionES - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - vec3 normal = normalize(_normalWS.xyz); - vec3 diffuse = _color.rgb; - vec3 specular = DEFAULT_SPECULAR; - float shininess = DEFAULT_SHININESS; - float emissiveAmount = 0.0; - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normal * (2.0 * float(gl_FrontFacing) - 1.0), - diffuse, - DEFAULT_FRESNEL, - length(specular), - max(0.0, 1.0 - shininess / 128.0)), - 1.0); -} diff --git a/libraries/render-utils/src/forward_simple_textured.slf b/libraries/render-utils/src/forward_simple_textured.slf deleted file mode 100644 index 79e1bf1dbc..0000000000 --- a/libraries/render-utils/src/forward_simple_textured.slf +++ /dev/null @@ -1,58 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// forward_simple_textured.frag -// fragment shader -// -// Created by Clément Brisset on 5/29/15. -// Copyright 2014 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 gpu/Color.slh@> -<@include DefaultMaterials.slh@> - -<@include ForwardGlobalLight.slh@> -<$declareEvalSkyboxGlobalColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include render-utils/ShaderConstants.h@> - -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - vec3 albedo = _color.xyz * texel.xyz; - float metallic = DEFAULT_METALLIC; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - albedo, - fresnel, - metallic, - DEFAULT_ROUGHNESS), - 1.0); -} \ No newline at end of file diff --git a/libraries/render-utils/src/forward_simple_textured_transparent.slf b/libraries/render-utils/src/forward_simple_textured_transparent.slf deleted file mode 100644 index 6cff37ba9d..0000000000 --- a/libraries/render-utils/src/forward_simple_textured_transparent.slf +++ /dev/null @@ -1,60 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// forward_simple_textured_transparent.frag -// fragment shader -// -// Created by Clément Brisset on 5/29/15. -// Copyright 2014 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 gpu/Color.slh@> -<@include DefaultMaterials.slh@> - -<@include ForwardGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlended()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include render-utils/ShaderConstants.h@> - -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - vec3 albedo = _color.xyz * texel.xyz; - float alpha = _color.a * texel.a; - float metallic = DEFAULT_METALLIC; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - albedo, - fresnel, - metallic, - DEFAULT_EMISSIVE, - DEFAULT_ROUGHNESS, alpha), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/forward_simple_textured_unlit.slf b/libraries/render-utils/src/forward_simple_textured_unlit.slf deleted file mode 100644 index ddbc5ae4d7..0000000000 --- a/libraries/render-utils/src/forward_simple_textured_unlit.slf +++ /dev/null @@ -1,35 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// forward_simple_textured_unlit.frag -// fragment shader -// -// Created by Clément Brisset on 5/29/15. -// Copyright 2014 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 LightingModel.slh@> -<@include gpu/Color.slh@> - -<@include render-utils/ShaderConstants.h@> - -layout(location=0) out vec4 _fragColor0; - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0.st); - float colorAlpha = _color.a * texel.a; - - _fragColor0 = vec4(_color.rgb * texel.rgb * isUnlitEnabled(), colorAlpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/glowLine.slf b/libraries/render-utils/src/glowLine.slf deleted file mode 100644 index c65d8d6488..0000000000 --- a/libraries/render-utils/src/glowLine.slf +++ /dev/null @@ -1,34 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Bradley Austin Davis on 2016/07/05 -// Copyright 2013-2016 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 render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=0) in float distanceFromCenter; -layout(location=0) out vec4 _fragColor; - -void main(void) { - // The incoming value actually ranges from -1 to 1, so modify it - // so that it goes from 0 -> 1 -> 0 with the solid alpha being at - // the center of the line - float alpha = 1.0 - abs(distanceFromCenter); - - // Convert from a linear alpha curve to a sharp peaked one - alpha = _color.a * pow(alpha, 10.0); - - // Drop everything where the curve falls off to nearly nothing - if (alpha <= 0.05) { - discard; - } - - // Emit the color - _fragColor = vec4(_color.rgb, alpha); -} diff --git a/libraries/render-utils/src/glowLine.slv b/libraries/render-utils/src/glowLine.slv deleted file mode 100644 index 1bcb25817c..0000000000 --- a/libraries/render-utils/src/glowLine.slv +++ /dev/null @@ -1,61 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Bradley Austin Davis on 2016/07/05 -// Copyright 2013-2016 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 gpu/Transform.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareStandardTransform()$> - -struct LineData { - vec4 p1; - vec4 p2; - vec4 color; - float width; -}; - -LAYOUT_STD140(binding=0) uniform LineDataBuffer { - LineData _lineData; -}; - -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; -// the distance from the center in 'quad space' -layout(location=0) out float distanceFromCenter; - -void main(void) { - _color = _lineData.color; - - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - - vec4 p1eye, p2eye; - <$transformModelToEyePos(cam, obj, _lineData.p1, p1eye)$> - <$transformModelToEyePos(cam, obj, _lineData.p2, p2eye)$> - p1eye /= p1eye.w; - p2eye /= p2eye.w; - - // Find the line direction - vec3 v1 = normalize(p1eye.xyz - p2eye.xyz); - // Find the vector from the eye to one of the points - vec3 v2 = normalize(p1eye.xyz); - // The orthogonal vector is the cross product of these two - vec3 orthogonal = cross(v1, v2) * _lineData.width; - - // Deteremine which end to emit based on the vertex id (even / odd) - vec4 eye = mix(p2eye, p1eye, float(gl_VertexID % 2 == 0)); - - // Add or subtract the orthogonal vector based on a different vertex ID - // calculation - distanceFromCenter = 1.0 - 2.0 * float(gl_VertexID < 2); - eye.xyz += distanceFromCenter * orthogonal; - - // Finally, put the eyespace vertex into clip space - <$transformEyeToClipPos(cam, eye, gl_Position)$> -} diff --git a/libraries/render-utils/src/grid.slf b/libraries/render-utils/src/grid.slf index 50c420bc10..8d54dfef4a 100644 --- a/libraries/render-utils/src/grid.slf +++ b/libraries/render-utils/src/grid.slf @@ -1,5 +1,6 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // // Created by Zach Pomerantz on 2/16/2016. @@ -9,11 +10,15 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBufferWrite.slh@> - <@include gpu/ShaderConstants.h@> <@include gpu/Paint.slh@> +<@if not HIFI_USE_FORWARD@> + <@include DeferredBufferWrite.slh@> +<@else@> + layout(location=0) out vec4 _fragColor0; +<@endif@> + struct Grid { vec4 period; vec4 offset; @@ -28,13 +33,21 @@ layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0; layout(location=GPU_ATTR_COLOR) in vec4 varColor; void main(void) { - float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), + float gridLine = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), float(grid.edge.z == 0.0)); - - if (alpha < 0.0001) { + if (gridLine <= 0.0) { discard; } - packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, varColor.xyz); +<@if not HIFI_USE_FORWARD@> + vec3 NORMAL = vec3(1.0, 0.0, 0.0); + <@if not HIFI_USE_TRANSLUCENT@> + packDeferredFragmentUnlit(NORMAL, 1.0, varColor.rgb); + <@else@> + packDeferredFragmentTranslucent(NORMAL, varColor.a, varColor.rgb, DEFAULT_ROUGHNESS); + <@endif@> +<@else@> + _fragColor0 = varColor; +<@endif@> } diff --git a/libraries/render-utils/src/grid_translucent.slf b/libraries/render-utils/src/grid_translucent.slf deleted file mode 100644 index bb61126991..0000000000 --- a/libraries/render-utils/src/grid_translucent.slf +++ /dev/null @@ -1,41 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gondelman on 12/22/18 -// Copyright 2018 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 DeferredBufferWrite.slh@> - -<@include gpu/ShaderConstants.h@> -<@include gpu/Paint.slh@> - -struct Grid { - vec4 period; - vec4 offset; - vec4 edge; -}; - -LAYOUT(binding=0) uniform gridBuffer { - Grid grid; -}; - -layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0; -layout(location=GPU_ATTR_COLOR) in vec4 varColor; - -void main(void) { - float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), - paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), - float(grid.edge.z == 0.0)); - alpha *= varColor.w; - - if (alpha < 0.0001) { - discard; - } - - packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), alpha, varColor.xyz, DEFAULT_ROUGHNESS); -} diff --git a/libraries/render-utils/src/hmd_ui.slv b/libraries/render-utils/src/hmd_ui.slv index 6e782d1672..75423d1882 100644 --- a/libraries/render-utils/src/hmd_ui.slv +++ b/libraries/render-utils/src/hmd_ui.slv @@ -29,7 +29,7 @@ LAYOUT_STD140(binding=0) uniform hudBuffer { layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main() { - _texCoord01.xy = inTexCoord0.st; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index edf5064324..3e4711dac8 100644 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -1,6 +1,6 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // // Created by Andrzej Kapolka on 5/6/14. @@ -10,55 +10,320 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBufferWrite.slh@> <@include graphics/Material.slh@> <@include graphics/MaterialTextures.slh@> <@include render-utils/ShaderConstants.h@> -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> +<@if not HIFI_USE_SHADOW@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + <@include DefaultMaterials.slh@> + <@include GlobalLight.slh@> + <@if HIFI_USE_LIGHTMAP@> + <$declareEvalLightmappedColor()$> + <@elif HIFI_USE_TRANSLUCENT@> + <@if not HIFI_USE_FORWARD@> + <@include LightLocal.slh@> + <@endif@> + <$declareEvalGlobalLightingAlphaBlended()$> + <@else@> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> + <@endif@> + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + layout(location=0) out vec4 _fragColor0; + <@else@> + <@include DeferredBufferWrite.slh@> + <@endif@> +<@else@> + layout(location=0) out vec4 _fragColor0; +<@endif@> +<@if HIFI_USE_UNLIT@> + <@include LightingModel.slh@> +<@endif@> + +<@if HIFI_USE_SHADOW or HIFI_USE_UNLIT@> + <$declareMaterialTextures(ALBEDO)$> +<@else@> + <@if not HIFI_USE_LIGHTMAP@> + <@if HIFI_USE_NORMALMAP and HIFI_USE_TRANSLUCENT@> + <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL , METALLIC, EMISSIVE, OCCLUSION)$> + <@elif HIFI_USE_NORMALMAP@> + <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL , METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> + <@elif HIFI_USE_TRANSLUCENT@> + <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL , METALLIC, EMISSIVE, OCCLUSION)$> + <@else@> + <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL , METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> + <@endif@> + <@else@> + <@if HIFI_USE_NORMALMAP@> + <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$> + <@else@> + <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$> + <@endif@> + <$declareMaterialLightmap()$> + <@endif@> +<@endif@> + +<@if HIFI_USE_FADE@> + <@include Fade.slh@> + <$declareFadeFragment()$> +<@endif@> + +layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; +<@if not HIFI_USE_SHADOW@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; + layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; + <@if HIFI_USE_NORMALMAP@> + layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; + <@endif@> +<@endif@> void main(void) { +<@if HIFI_USE_FADE@> + <@if not HIFI_USE_SHADOW@> + vec3 fadeEmissive; + FadeObjectParams fadeParams; + <$fetchFadeObjectParams(fadeParams)$> + applyFade(fadeParams, _positionWS.xyz, fadeEmissive); + <@else@> + FadeObjectParams fadeParams; + <$fetchFadeObjectParams(fadeParams)$> + applyFadeClip(fadeParams, _positionWS.xyz); + <@endif@> +<@endif@> + Material mat = getMaterial(); BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> +<@if HIFI_USE_SHADOW or HIFI_USE_UNLIT@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; + <@if HIFI_USE_TRANSLUCENT@> + float opacity = getMaterialOpacity(mat) * _color.a; + <@else@> + float opacity = 1.0; + <@endif@> + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; + <@if HIFI_USE_TRANSLUCENT@> + <$discardInvisible(opacity)$>; + <@else@> + <$discardTransparent(opacity)$>; + <@endif@> - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; + <@if not HIFI_USE_SHADOW@> + vec3 albedo = getMaterialAlbedo(mat); + <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; + albedo *= _color.rgb; + <@if HIFI_USE_FADE@> + albedo += fadeEmissive; + <@endif@> + <@endif@> - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; + <@if HIFI_USE_SHADOW@> + _fragColor0 = vec4(1.0); + <@elif HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + _fragColor0 = vec4(albedo * isUnlitEnabled(), opacity); + <@else@> + packDeferredFragmentUnlit( + normalize(_normalWS), + opacity, + albedo * isUnlitEnabled()); + <@endif@> +<@else@> + <@if not HIFI_USE_LIGHTMAP@> + <@if HIFI_USE_NORMALMAP and HIFI_USE_TRANSLUCENT@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, _SCRIBE_NULL)$> + <@elif HIFI_USE_NORMALMAP@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$> + <@elif HIFI_USE_TRANSLUCENT@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, _SCRIBE_NULL)$> + <@else@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$> + <@endif@> + <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> + <@else@> + <@if HIFI_USE_NORMALMAP@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$> + <@else@> + <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$> + <@endif@> + <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> + <@endif@> - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; + <@if HIFI_USE_TRANSLUCENT@> + float opacity = getMaterialOpacity(mat) * _color.a; + <@else@> + float opacity = 1.0; + <@endif@> + <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; + <@if HIFI_USE_TRANSLUCENT@> + <$discardInvisible(opacity)$>; + <@else@> + <$discardTransparent(opacity)$>; + <@endif@> - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; + vec3 albedo = getMaterialAlbedo(mat); + <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; + albedo *= _color.rgb; - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; + float roughness = getMaterialRoughness(mat); + <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - float scattering = getMaterialScattering(mat); - <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; + float metallic = getMaterialMetallic(mat); + <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - packDeferredFragment( - normalize(_normalWS), - opacity, - albedo, - roughness, - metallic, - emissive, - occlusion, - scattering); + <@if not HIFI_USE_LIGHTMAP@> + vec3 emissive = getMaterialEmissive(mat); + <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; + + float occlusion = DEFAULT_OCCLUSION; + <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; + + <@if not HIFI_USE_TRANSLUCENT@> + float scattering = getMaterialScattering(mat); + <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; + <@endif@> + <@endif@> + + <@if HIFI_USE_NORMALMAP@> + vec3 fragNormalWS; + <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> + <@else@> + vec3 fragNormalWS = _normalWS; + <@endif@> + fragNormalWS = normalize(fragNormalWS); + + <@if HIFI_USE_FORWARD@> + TransformCamera cam = getTransformCamera(); + vec3 fresnel = getFresnelF0(metallic, albedo); + <@if not HIFI_USE_TRANSLUCENT@> + <@if not HIFI_USE_LIGHTMAP@> + vec4 color = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + occlusion, + _positionES.xyz, + fragNormalWS, + albedo, + fresnel, + metallic, + roughness), + opacity); + color.rgb += emissive * isEmissiveEnabled(); + _fragColor0 = color; + <@else@> + _fragColor0 = vec4(evalLightmappedColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragNormalWS, + albedo, + lightmap), + opacity); + <@endif@> + <@else@> + <@if not HIFI_USE_LIGHTMAP@> + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( + cam._viewInverse, + 1.0, + occlusion, + _positionES.xyz, + fragNormalWS, + albedo, + fresnel, + metallic, + emissive, + roughness, opacity), + opacity); + <@else@> + _fragColor0 = vec4(evalLightmappedColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragNormalWS, + albedo, + lightmap), + opacity); + <@endif@> + <@endif@> + <@else@> + <@if not HIFI_USE_TRANSLUCENT@> + <@if not HIFI_USE_LIGHTMAP@> + packDeferredFragment( + fragNormalWS, + opacity, + albedo, + roughness, + metallic, + emissive + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + occlusion, + scattering); + <@else@> + packDeferredFragmentLightmap( + fragNormalWS, + evalOpaqueFinalAlpha(getMaterialOpacity(mat), opacity), + albedo, + roughness, + metallic, + lightmap + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + ); + <@endif@> + <@else@> + TransformCamera cam = getTransformCamera(); + <@if not HIFI_USE_LIGHTMAP@> + vec3 fresnel = getFresnelF0(metallic, albedo); + + vec3 fragPositionWS = _positionWS.xyz; + vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; + vec3 fragToEyeDirWS = normalize(fragToEyeWS); + SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS); + + vec4 localLighting = vec4(0.0); + <$fetchClusterInfo(_positionWS)$>; + if (hasLocalLights(numLights, clusterPos, dims)) { + localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS, + metallic, fresnel, albedo, 0.0, + vec4(0), vec4(0), opacity); + } + + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( + cam._viewInverse, + 1.0, + occlusion, + _positionES.xyz, + fragNormalWS, + albedo, + fresnel, + metallic, + emissive + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + surfaceWS, opacity, localLighting.rgb), + opacity); + <@else@> + _fragColor0 = vec4(evalLightmappedColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragNormalWS, + albedo, + lightmap), + opacity); + <@endif@> + <@endif@> + <@endif@> +<@endif@> } diff --git a/libraries/render-utils/src/model.slv b/libraries/render-utils/src/model.slv index 88cbd1e18c..319711eac2 100644 --- a/libraries/render-utils/src/model.slv +++ b/libraries/render-utils/src/model.slv @@ -1,10 +1,10 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> +// <$_SCRIBE_FILENAME$> +// Generated on <$_SCRIBE_DATE$> // -// Created by Hifi Engine Team. -// Copyright 2013 High Fidelity, Inc. +// Created by Hifi Engine Team +// Copyright 2019 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 @@ -12,32 +12,94 @@ <@include gpu/Inputs.slh@> <@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<@include graphics/MaterialTextures.slh@> - -<$declareStandardTransform()$> - -<$declareMaterialTexMapArrayBuffer()$> - <@include render-utils/ShaderConstants.h@> +<@include gpu/Transform.slh@> +<$declareStandardTransform()$> + +<@include graphics/MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> + +<@if HIFI_USE_DEFORMED or HIFI_USE_DEFORMEDDQ@> + <@include MeshDeformer.slh@> + <@if HIFI_USE_DEFORMED@> + <@if HIFI_USE_SHADOW@> + <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$> + <@elif not HIFI_USE_NORMALMAP@> + <$declareMeshDeformer(1, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$> + <@else@> + <$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$> + <@endif@> + <@else@> + <@if HIFI_USE_SHADOW@> + <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$> + <@elif not HIFI_USE_NORMALMAP@> + <$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$> + <@else@> + <$declareMeshDeformer(1, 1, 1, 1, 1)$> + <@endif@> + <@endif@> + <$declareMeshDeformerActivation(1, 1)$> +<@endif@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; +<@if not HIFI_USE_SHADOW@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; + layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; + <@if HIFI_USE_NORMALMAP@> + layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; + <@endif@> +<@endif@> void main(void) { - _color.rgb = color_sRGBToLinear(inColor.rgb); - _color.a = inColor.a; + vec4 positionMS = inPosition; + vec3 normalMS = inNormal.xyz; + vec3 tangentMS = inTangent.xyz; + +<@if HIFI_USE_DEFORMED or HIFI_USE_DEFORMEDDQ@> + evalMeshDeformer(inPosition, positionMS, + <@if not HIFI_USE_SHADOW@> + inNormal.xyz, normalMS, + <@if HIFI_USE_NORMALMAP@> + inTangent.xyz, tangentMS, + <@endif@> + <@endif@> + meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight, + meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID); +<@endif@> - // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToWorldAndEyeAndClipPos(cam, obj, inPosition, _positionWS, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> +<@if not HIFI_USE_SHADOW@> + <$transformModelToWorldAndEyeAndClipPos(cam, obj, positionMS, _positionWS, _positionES, gl_Position)$> + <$transformModelToWorldDir(cam, obj, normalMS, _normalWS)$> +<@else@> + <$transformModelToClipPos(cam, obj, positionMS, gl_Position)$> + <$transformModelToWorldPos(obj, positionMS, _positionWS)$> +<@endif@> - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> +<@if HIFI_USE_NORMALMAP@> + <$transformModelToWorldDir(cam, obj, tangentMS, _tangentWS)$> +<@endif@> + +<@if HIFI_USE_SHADOW@> + Material mat = getMaterial(); + BITFIELD matKey = getMaterialKey(mat); + // If we have an opacity mask than we need the first tex coord + if ((matKey & OPACITY_MASK_MAP_BIT) != 0) { + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> + _texCoord01.zw = vec2(0.0); + } else { + _texCoord01 = vec4(0.0); + } +<@else@> + _color = color_sRGBAToLinear(inColor); + + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> +<@endif@> } diff --git a/libraries/render-utils/src/model_fade.slf b/libraries/render-utils/src/model_fade.slf deleted file mode 100644 index e931ec4cf0..0000000000 --- a/libraries/render-utils/src/model_fade.slf +++ /dev/null @@ -1,73 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - float scattering = getMaterialScattering(mat); - <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; - - packDeferredFragment( - normalize(_normalWS), - opacity, - albedo, - roughness, - metallic, - emissive + fadeEmissive, - occlusion, - scattering); -} diff --git a/libraries/render-utils/src/model_lightmap.slf b/libraries/render-utils/src/model_lightmap.slf deleted file mode 100644 index 1be247e3e9..0000000000 --- a/libraries/render-utils/src/model_lightmap.slf +++ /dev/null @@ -1,50 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Samuel Gateau on 11/19/14. -// Copyright 2014 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$> -<$declareMaterialLightmap()$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - packDeferredFragmentLightmap( - normalize(_normalWS), - evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a), - albedo, - roughness, - metallic, - lightmap); -} diff --git a/libraries/render-utils/src/model_lightmap_fade.slf b/libraries/render-utils/src/model_lightmap_fade.slf deleted file mode 100644 index 61568463a7..0000000000 --- a/libraries/render-utils/src/model_lightmap_fade.slf +++ /dev/null @@ -1,59 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$> -<$declareMaterialLightmap()$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - packDeferredFragmentLightmap( - normalize(_normalWS), - evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a), - albedo, - roughness, - metallic, - lightmap + fadeEmissive); -} diff --git a/libraries/render-utils/src/model_lightmap_normal_map.slf b/libraries/render-utils/src/model_lightmap_normal_map.slf deleted file mode 100644 index 3d961584c2..0000000000 --- a/libraries/render-utils/src/model_lightmap_normal_map.slf +++ /dev/null @@ -1,55 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Samuel Gateau on 11/19/14. -// Copyright 2014 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$> -<$declareMaterialLightmap()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fragNormal; - <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$> - - packDeferredFragmentLightmap( - normalize(fragNormal), - evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a), - albedo, - roughness, - metallic, - lightmap); -} diff --git a/libraries/render-utils/src/model_lightmap_normal_map_fade.slf b/libraries/render-utils/src/model_lightmap_normal_map_fade.slf deleted file mode 100644 index f873847474..0000000000 --- a/libraries/render-utils/src/model_lightmap_normal_map_fade.slf +++ /dev/null @@ -1,64 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$> -<$declareMaterialLightmap()$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fragNormal; - <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$> - - packDeferredFragmentLightmap( - normalize(fragNormal), - evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a), - albedo, - roughness, - metallic, - lightmap + fadeEmissive); -} diff --git a/libraries/render-utils/src/model_normal_map.slf b/libraries/render-utils/src/model_normal_map.slf deleted file mode 100644 index 695fadbca8..0000000000 --- a/libraries/render-utils/src/model_normal_map.slf +++ /dev/null @@ -1,69 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Andrzej Kapolka on 5/6/14. -// Copyright 2014 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - float scattering = getMaterialScattering(mat); - <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; - - vec3 fragNormalWS; - <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> - - packDeferredFragment( - normalize(fragNormalWS), - opacity, - albedo, - roughness, - metallic, - emissive, - occlusion, - scattering); -} diff --git a/libraries/render-utils/src/model_normal_map.slv b/libraries/render-utils/src/model_normal_map.slv deleted file mode 100644 index 0fd9a8b582..0000000000 --- a/libraries/render-utils/src/model_normal_map.slv +++ /dev/null @@ -1,45 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// 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 gpu/Inputs.slh@> -<@include gpu/Color.slh@> -<@include gpu/Transform.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareStandardTransform()$> - -<$declareMaterialTexMapArrayBuffer()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; - -void main(void) { - // pass along the color - _color.rgb = color_sRGBToLinear(inColor.rgb); - _color.a = inColor.a; - - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToWorldAndEyeAndClipPos(cam, obj, inPosition, _positionWS, _positionES, gl_Position)$> - <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> - <$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangentWS)$> - - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$> -} diff --git a/libraries/render-utils/src/model_normal_map_fade.slf b/libraries/render-utils/src/model_normal_map_fade.slf deleted file mode 100644 index 07b6f47b55..0000000000 --- a/libraries/render-utils/src/model_normal_map_fade.slf +++ /dev/null @@ -1,78 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 DeferredBufferWrite.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - float scattering = getMaterialScattering(mat); - <$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>; - - vec3 fragNormalWS; - <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> - - packDeferredFragment( - normalize(fragNormalWS), - opacity, - albedo, - roughness, - metallic, - emissive + fadeEmissive, - occlusion, - scattering); -} diff --git a/libraries/render-utils/src/model_shadow.slf b/libraries/render-utils/src/model_shadow.slf deleted file mode 100644 index 6d8dfb7e2a..0000000000 --- a/libraries/render-utils/src/model_shadow.slf +++ /dev/null @@ -1,34 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Andrzej Kapolka on 3/24/14. -// 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy - -layout(location=0) out vec4 _fragColor; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - // pass-through to set z-buffer - _fragColor = vec4(1.0, 1.0, 1.0, 0.0); -} diff --git a/libraries/render-utils/src/model_shadow.slv b/libraries/render-utils/src/model_shadow.slv deleted file mode 100644 index d455ea4ade..0000000000 --- a/libraries/render-utils/src/model_shadow.slv +++ /dev/null @@ -1,42 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Hifi Engine Team. -// Copyright 2014 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 gpu/Inputs.slh@> - -<@include gpu/Transform.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> - -<$declareStandardTransform()$> -<$declareMaterialTexMapArrayBuffer()$> - -<@include render-utils/ShaderConstants.h@> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; - -void main(void) { - // standard transform - TransformCamera cam = getTransformCamera(); - TransformObject obj = getTransformObject(); - <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> - <$transformModelToWorldPos(obj, inPosition, _positionWS)$> - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - _texCoord01 = vec4(0.0, 0.0, 0.0, 0.0); - // If we have an opacity mask than we need the first tex coord - if ((matKey & OPACITY_MASK_MAP_BIT) != 0) { - TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$> - } -} diff --git a/libraries/render-utils/src/model_shadow_fade.slf b/libraries/render-utils/src/model_shadow_fade.slf deleted file mode 100644 index 1f94d4a0ac..0000000000 --- a/libraries/render-utils/src/model_shadow_fade.slf +++ /dev/null @@ -1,42 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<$declareMaterialTextures(ALBEDO, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy - -layout(location=0) out vec4 _fragColor; - -void main(void) { - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFadeClip(fadeParams, _positionWS.xyz); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - // pass-through to set z-buffer - _fragColor = vec4(1.0, 1.0, 1.0, 0.0); -} diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf deleted file mode 100644 index 72f6b4c187..0000000000 --- a/libraries/render-utils/src/model_translucent.slf +++ /dev/null @@ -1,96 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 2/15/2016. -// Copyright 2014 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightLocal.slh@> -<@include DeferredGlobalLight.slh@> - -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardInvisible(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 fragPositionES = _positionES.xyz; - vec3 fragPositionWS = _positionWS.xyz; - // Lighting is done in world space - vec3 fragNormalWS = normalize(_normalWS); - - TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; - vec3 fragToEyeDirWS = normalize(fragToEyeWS); - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS); - - vec4 localLighting = vec4(0.0); - <$fetchClusterInfo(_positionWS)$>; - if (hasLocalLights(numLights, clusterPos, dims)) { - localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS, - metallic, fresnel, albedo, 0.0, - vec4(0), vec4(0), opacity); - } - - _fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - occlusion, - fragPositionES, - fragPositionWS, - albedo, - fresnel, - metallic, - emissive, - surfaceWS, opacity, localLighting.rgb), - opacity); -} diff --git a/libraries/render-utils/src/model_translucent_fade.slf b/libraries/render-utils/src/model_translucent_fade.slf deleted file mode 100644 index 7e170759c4..0000000000 --- a/libraries/render-utils/src/model_translucent_fade.slf +++ /dev/null @@ -1,104 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightLocal.slh@> -<@include DeferredGlobalLight.slh@> - -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 fragPositionES = _positionES.xyz; - vec3 fragPositionWS = _positionWS.xyz; - // Lighting is done in world space - vec3 fragNormalWS = normalize(_normalWS); - - TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; - vec3 fragToEyeDirWS = normalize(fragToEyeWS); - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS); - - vec4 localLighting = vec4(0.0); - <$fetchClusterInfo(_positionWS)$>; - if (hasLocalLights(numLights, clusterPos, dims)) { - localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS, - metallic, fresnel, albedo, 0.0, - vec4(0), vec4(0), opacity); - } - - _fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - occlusion, - fragPositionES, - fragPositionWS, - albedo, - fresnel, - metallic, - emissive + fadeEmissive, - surfaceWS, opacity, localLighting.rgb), - opacity); -} diff --git a/libraries/render-utils/src/model_translucent_normal_map.slf b/libraries/render-utils/src/model_translucent_normal_map.slf deleted file mode 100644 index b3a9127acf..0000000000 --- a/libraries/render-utils/src/model_translucent_normal_map.slf +++ /dev/null @@ -1,98 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 23/01/2018. -// Copyright 2018 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightLocal.slh@> -<@include DeferredGlobalLight.slh@> - -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor; - -void main(void) { - Material mat = getMaterial(); - int matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardInvisible(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 fragPositionES = _positionES.xyz; - vec3 fragPositionWS = _positionWS.xyz; - // Lighting is done in world space - vec3 fragNormalWS; - <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> - - TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; - vec3 fragToEyeDirWS = normalize(fragToEyeWS); - SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS); - - vec4 localLighting = vec4(0.0); - <$fetchClusterInfo(_positionWS)$>; - if (hasLocalLights(numLights, clusterPos, dims)) { - localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS, - metallic, fresnel, albedo, 0.0, - vec4(0), vec4(0), opacity); - } - - _fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - occlusion, - fragPositionES, - fragPositionWS, - albedo, - fresnel, - metallic, - emissive, - surfaceWS, opacity, localLighting.rgb), - opacity); -} diff --git a/libraries/render-utils/src/model_translucent_normal_map_fade.slf b/libraries/render-utils/src/model_translucent_normal_map_fade.slf deleted file mode 100644 index 4c56ebda2e..0000000000 --- a/libraries/render-utils/src/model_translucent_normal_map_fade.slf +++ /dev/null @@ -1,106 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 23/01/18. -// Copyright 2018 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 DefaultMaterials.slh@> -<@include graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightLocal.slh@> -<@include DeferredGlobalLight.slh@> - -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - int matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$> - <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardInvisible(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - float roughness = getMaterialRoughness(mat); - <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; - - float metallic = getMaterialMetallic(mat); - <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - vec3 emissive = getMaterialEmissive(mat); - <$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>; - - float occlusion = DEFAULT_OCCLUSION; - <$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>; - - vec3 fragPositionES = _positionES.xyz; - vec3 fragPositionWS = _positionWS.xyz; - // Lighting is done in world space - vec3 fragNormalWS; - <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> - - TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; - vec3 fragToEyeDirWS = normalize(fragToEyeWS); - SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS); - - vec4 localLighting = vec4(0.0); - <$fetchClusterInfo(_positionWS)$>; - if (hasLocalLights(numLights, clusterPos, dims)) { - localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS, - metallic, fresnel, albedo, 0.0, - vec4(0), vec4(0), opacity); - } - - _fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - occlusion, - fragPositionES, - fragPositionWS, - albedo, - fresnel, - metallic, - emissive + fadeEmissive, - surfaceWS, opacity, localLighting.rgb), - opacity); -} diff --git a/libraries/render-utils/src/model_translucent_unlit.slf b/libraries/render-utils/src/model_translucent_unlit.slf deleted file mode 100644 index 37f58d3da9..0000000000 --- a/libraries/render-utils/src/model_translucent_unlit.slf +++ /dev/null @@ -1,42 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Zach Pomerantz on 2/3/2016. -// Copyright 2016 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightingModel.slh@> - -<$declareMaterialTextures(ALBEDO)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=0) out vec4 _fragColor; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardInvisible(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - _fragColor = vec4(albedo * isUnlitEnabled(), opacity); -} diff --git a/libraries/render-utils/src/model_translucent_unlit_fade.slf b/libraries/render-utils/src/model_translucent_unlit_fade.slf deleted file mode 100644 index 04d57b7c47..0000000000 --- a/libraries/render-utils/src/model_translucent_unlit_fade.slf +++ /dev/null @@ -1,52 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include LightingModel.slh@> - -<$declareMaterialTextures(ALBEDO)$> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -layout(location=0) out vec4 _fragColor; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = getMaterialOpacity(mat) * _color.a; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardInvisible(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - albedo += fadeEmissive; - - _fragColor = vec4(albedo * isUnlitEnabled(), opacity); -} diff --git a/libraries/render-utils/src/model_unlit.slf b/libraries/render-utils/src/model_unlit.slf deleted file mode 100644 index cbac67a72e..0000000000 --- a/libraries/render-utils/src/model_unlit.slf +++ /dev/null @@ -1,45 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gateau on 5/5/2016. -// Copyright 2016 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include DeferredBufferWrite.slh@> -<@include LightingModel.slh@> - -<$declareMaterialTextures(ALBEDO)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - - packDeferredFragmentUnlit( - normalize(_normalWS), - opacity, - albedo * isUnlitEnabled()); -} diff --git a/libraries/render-utils/src/model_unlit_fade.slf b/libraries/render-utils/src/model_unlit_fade.slf deleted file mode 100644 index 3097c04c26..0000000000 --- a/libraries/render-utils/src/model_unlit_fade.slf +++ /dev/null @@ -1,55 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// <$_SCRIBE_FILENAME$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 graphics/Material.slh@> -<@include graphics/MaterialTextures.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include DeferredBufferWrite.slh@> -<@include LightingModel.slh@> - -<@include Fade.slh@> -<$declareFadeFragment()$> - -<$declareMaterialTextures(ALBEDO)$> - -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - <$fetchFadeObjectParams(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - Material mat = getMaterial(); - BITFIELD matKey = getMaterialKey(mat); - <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - - float opacity = 1.0; - <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; - <$discardTransparent(opacity)$>; - - vec3 albedo = getMaterialAlbedo(mat); - <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color.rgb; - albedo += fadeEmissive; - - packDeferredFragmentUnlit( - normalize(_normalWS), - opacity, - albedo * isUnlitEnabled()); -} diff --git a/libraries/render-utils/src/parabola.slf b/libraries/render-utils/src/parabola.slf index ea51d7e3af..f19f82ec59 100644 --- a/libraries/render-utils/src/parabola.slf +++ b/libraries/render-utils/src/parabola.slf @@ -1,5 +1,6 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // // Created by Sam Gondelman on 7/18/2018 @@ -9,10 +10,22 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBufferWrite.slh@> +<@if not HIFI_USE_FORWARD@> + <@include DeferredBufferWrite.slh@> +<@else@> + layout(location=0) out vec4 _fragColor0; +<@endif@> layout(location=0) in vec4 _color; void main(void) { - packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, _color.rgb); +<@if not HIFI_USE_FORWARD@> + <@if not HIFI_USE_TRANSLUCENT@> + packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, _color.rgb); + <@else@> + packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_ROUGHNESS); + <@endif@> +<@else@> + _fragColor0 = _color; +<@endif@> } diff --git a/libraries/render-utils/src/parabola_translucent.slf b/libraries/render-utils/src/parabola_translucent.slf deleted file mode 100644 index 01f4614172..0000000000 --- a/libraries/render-utils/src/parabola_translucent.slf +++ /dev/null @@ -1,18 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// Created by Sam Gondelman on 9/10/2018 -// Copyright 2018 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 DeferredBufferWrite.slh@> - -layout(location=0) in vec4 _color; - -void main(void) { - packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_ROUGHNESS); -} diff --git a/libraries/render-utils/src/render-utils/ShaderConstants.h b/libraries/render-utils/src/render-utils/ShaderConstants.h index 76c8dd4981..19eb4dd249 100644 --- a/libraries/render-utils/src/render-utils/ShaderConstants.h +++ b/libraries/render-utils/src/render-utils/ShaderConstants.h @@ -68,7 +68,6 @@ #define RENDER_UTILS_BUFFER_LIGHT_CLUSTER_CONTENT 12 // Haze -#define RENDER_UTILS_BUFFER_HAZE_PARAMS 7 #define RENDER_UTILS_TEXTURE_HAZE_COLOR 0 #define RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH 1 @@ -143,7 +142,6 @@ enum Buffer { DeferredFrameTransform = RENDER_UTILS_BUFFER_DEFERRED_FRAME_TRANSFORM, LightModel = RENDER_UTILS_BUFFER_LIGHT_MODEL, AmbientLight = RENDER_UTILS_BUFFER_AMBIENT_LIGHT, - HazeParams = RENDER_UTILS_BUFFER_HAZE_PARAMS, FadeParameters = RENDER_UTILS_BUFFER_FADE_PARAMS, FadeObjectParameters = RENDER_UTILS_BUFFER_FADE_OBJECT_PARAMS, LightClusterFrustumGrid = RENDER_UTILS_BUFFER_LIGHT_CLUSTER_FRUSTUM_GRID, diff --git a/libraries/render-utils/src/render-utils/deformed_model.slp b/libraries/render-utils/src/render-utils/deformed_model.slp deleted file mode 100644 index 9db8938e86..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model diff --git a/libraries/render-utils/src/render-utils/deformed_model_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_dq.slp deleted file mode 100644 index ec950ac784..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model diff --git a/libraries/render-utils/src/render-utils/deformed_model_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_fade.slp deleted file mode 100644 index 5818e5e3af..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp deleted file mode 100644 index 9047bc1286..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map.slp deleted file mode 100644 index ad460652ad..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp deleted file mode 100644 index 44d5cd5272..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp deleted file mode 100644 index 99aab59169..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp deleted file mode 100644 index 0ee002b6a1..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp deleted file mode 100644 index f2e2b2e4da..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_translucent_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp deleted file mode 100644 index 577a6c1616..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_translucent_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp deleted file mode 100644 index de9591b45f..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_translucent_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp deleted file mode 100644 index 3f624f7bf7..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_translucent_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow.slp deleted file mode 100644 index c8718dff09..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow -FRAGMENT model_shadow diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp deleted file mode 100644 index b0f1449234..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow_dq -FRAGMENT model_shadow diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp deleted file mode 100644 index 1063134d96..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow -FRAGMENT model_shadow_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp deleted file mode 100644 index 25c99c75d1..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow_dq -FRAGMENT model_shadow_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent.slp deleted file mode 100644 index 798fec9a5b..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model_translucent diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp deleted file mode 100644 index 8a0b70cfcf..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model_translucent diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp deleted file mode 100644 index 68eef3624d..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model_translucent_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp deleted file mode 100644 index 4ce321fa78..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model_translucent_fade diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model.slp b/libraries/render-utils/src/render-utils/forward_deformed_model.slp deleted file mode 100644 index 3b7c49705b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT forward_model diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp deleted file mode 100644 index 45d886529a..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT forward_model diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp b/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp deleted file mode 100644 index 539ca61193..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT forward_model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp deleted file mode 100644 index c663b671fe..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT forward_model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent.slp deleted file mode 100644 index 605499ebc3..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp deleted file mode 100644 index cd20657b01..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp deleted file mode 100644 index 85d08c1943..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp deleted file mode 100644 index 2f13b16a5b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_grid.slp b/libraries/render-utils/src/render-utils/forward_grid.slp deleted file mode 100644 index c81b208f63..0000000000 --- a/libraries/render-utils/src/render-utils/forward_grid.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX standardTransformPNTC diff --git a/libraries/render-utils/src/render-utils/forward_grid_translucent.slp b/libraries/render-utils/src/render-utils/forward_grid_translucent.slp deleted file mode 100644 index c81b208f63..0000000000 --- a/libraries/render-utils/src/render-utils/forward_grid_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX standardTransformPNTC diff --git a/libraries/render-utils/src/render-utils/forward_model.slp b/libraries/render-utils/src/render-utils/forward_model.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_model_lightmap.slp b/libraries/render-utils/src/render-utils/forward_model_lightmap.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_lightmap.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_model_normal_map.slp b/libraries/render-utils/src/render-utils/forward_model_normal_map.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_normal_map.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp b/libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp b/libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp deleted file mode 100644 index 0979918b98..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX model_normal_map -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_model_translucent.slp b/libraries/render-utils/src/render-utils/forward_model_translucent.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_model_unlit.slp b/libraries/render-utils/src/render-utils/forward_model_unlit.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_parabola.slp b/libraries/render-utils/src/render-utils/forward_parabola.slp deleted file mode 100644 index ab3f1d4126..0000000000 --- a/libraries/render-utils/src/render-utils/forward_parabola.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX parabola diff --git a/libraries/render-utils/src/render-utils/forward_simple_textured.slp b/libraries/render-utils/src/render-utils/forward_simple_textured.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/forward_simple_textured.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp b/libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp b/libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/glowLine.slp b/libraries/render-utils/src/render-utils/glowLine.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/render-utils/src/render-utils/grid.slp b/libraries/render-utils/src/render-utils/grid.slp index c81b208f63..5cf10ff674 100644 --- a/libraries/render-utils/src/render-utils/grid.slp +++ b/libraries/render-utils/src/render-utils/grid.slp @@ -1 +1,2 @@ VERTEX standardTransformPNTC +DEFINES translucent:f forward:f \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/grid_translucent.slp b/libraries/render-utils/src/render-utils/grid_translucent.slp deleted file mode 100644 index c81b208f63..0000000000 --- a/libraries/render-utils/src/render-utils/grid_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX standardTransformPNTC diff --git a/libraries/render-utils/src/render-utils/model.slp b/libraries/render-utils/src/render-utils/model.slp index e69de29bb2..b63ec898eb 100644 --- a/libraries/render-utils/src/render-utils/model.slp +++ b/libraries/render-utils/src/render-utils/model.slp @@ -0,0 +1 @@ +DEFINES (normalmap translucent:f unlit:f/lightmap:f)/shadow fade:f/forward:f deformed:v/deformeddq:v \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_fade.slp b/libraries/render-utils/src/render-utils/model_fade.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_lightmap.slp b/libraries/render-utils/src/render-utils/model_lightmap.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_lightmap_fade.slp b/libraries/render-utils/src/render-utils/model_lightmap_fade.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp b/libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp b/libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp deleted file mode 100644 index 659899f9f8..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_normal_map.slp b/libraries/render-utils/src/render-utils/model_normal_map.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/render-utils/src/render-utils/model_normal_map_fade.slp b/libraries/render-utils/src/render-utils/model_normal_map_fade.slp deleted file mode 100644 index 659899f9f8..0000000000 --- a/libraries/render-utils/src/render-utils/model_normal_map_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_shadow.slp b/libraries/render-utils/src/render-utils/model_shadow.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/render-utils/src/render-utils/model_shadow_fade.slp b/libraries/render-utils/src/render-utils/model_shadow_fade.slp deleted file mode 100644 index f43521cba6..0000000000 --- a/libraries/render-utils/src/render-utils/model_shadow_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_shadow \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_translucent.slp b/libraries/render-utils/src/render-utils/model_translucent.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_translucent_fade.slp b/libraries/render-utils/src/render-utils/model_translucent_fade.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_translucent_normal_map.slp b/libraries/render-utils/src/render-utils/model_translucent_normal_map.slp deleted file mode 100644 index 659899f9f8..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_normal_map.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp b/libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/model_translucent_unlit.slp b/libraries/render-utils/src/render-utils/model_translucent_unlit.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp b/libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_unlit.slp b/libraries/render-utils/src/render-utils/model_unlit.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_unlit_fade.slp b/libraries/render-utils/src/render-utils/model_unlit_fade.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/parabola.slp b/libraries/render-utils/src/render-utils/parabola.slp index e69de29bb2..e9942be5cd 100644 --- a/libraries/render-utils/src/render-utils/parabola.slp +++ b/libraries/render-utils/src/render-utils/parabola.slp @@ -0,0 +1 @@ +DEFINES translucent:f/forward:f \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/parabola_translucent.slp b/libraries/render-utils/src/render-utils/parabola_translucent.slp deleted file mode 100644 index ab3f1d4126..0000000000 --- a/libraries/render-utils/src/render-utils/parabola_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX parabola diff --git a/libraries/render-utils/src/render-utils/sdf_text3D.slp b/libraries/render-utils/src/render-utils/sdf_text3D.slp index e69de29bb2..118135d099 100644 --- a/libraries/render-utils/src/render-utils/sdf_text3D.slp +++ b/libraries/render-utils/src/render-utils/sdf_text3D.slp @@ -0,0 +1 @@ +DEFINES (translucent unlit:f)/forward \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/sdf_text3D_forward.slp b/libraries/render-utils/src/render-utils/sdf_text3D_forward.slp deleted file mode 100644 index 3eea3a0da0..0000000000 --- a/libraries/render-utils/src/render-utils/sdf_text3D_forward.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX sdf_text3D diff --git a/libraries/render-utils/src/render-utils/sdf_text3D_translucent.slp b/libraries/render-utils/src/render-utils/sdf_text3D_translucent.slp deleted file mode 100644 index 52dfbe4f9c..0000000000 --- a/libraries/render-utils/src/render-utils/sdf_text3D_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX sdf_text3D \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/sdf_text3D_translucent_unlit.slp b/libraries/render-utils/src/render-utils/sdf_text3D_translucent_unlit.slp deleted file mode 100644 index 52dfbe4f9c..0000000000 --- a/libraries/render-utils/src/render-utils/sdf_text3D_translucent_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX sdf_text3D \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/sdf_text3D_unlit.slp b/libraries/render-utils/src/render-utils/sdf_text3D_unlit.slp deleted file mode 100644 index 52dfbe4f9c..0000000000 --- a/libraries/render-utils/src/render-utils/sdf_text3D_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX sdf_text3D \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/simple.slp b/libraries/render-utils/src/render-utils/simple.slp index e69de29bb2..5fc7789a21 100644 --- a/libraries/render-utils/src/render-utils/simple.slp +++ b/libraries/render-utils/src/render-utils/simple.slp @@ -0,0 +1 @@ +DEFINES translucent unlit fade/forward \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp b/libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_procedural.slp b/libraries/render-utils/src/render-utils/simple_procedural.slp new file mode 100644 index 0000000000..1348d72a8d --- /dev/null +++ b/libraries/render-utils/src/render-utils/simple_procedural.slp @@ -0,0 +1 @@ +DEFINES translucent:f \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/simple_textured.slp b/libraries/render-utils/src/render-utils/simple_textured.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_textured_fade.slp b/libraries/render-utils/src/render-utils/simple_textured_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_textured_unlit.slp b/libraries/render-utils/src/render-utils/simple_textured_unlit.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp b/libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_transparent.slp b/libraries/render-utils/src/render-utils/simple_transparent.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp b/libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/web_browser.slp b/libraries/render-utils/src/render-utils/web_browser.slp new file mode 100644 index 0000000000..e283f4edcb --- /dev/null +++ b/libraries/render-utils/src/render-utils/web_browser.slp @@ -0,0 +1 @@ +DEFINES forward \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index 91c73e9eec..ac064e5c8f 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// sdf_text3D.frag -// fragment shader // // Created by Bradley Austin Davis on 2015-02-04 // Based on fragment shader code from @@ -10,12 +9,32 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -<@include DeferredBufferWrite.slh@> +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + <@include DefaultMaterials.slh@> + + <@include GlobalLight.slh@> + <@if HIFI_USE_TRANSLUCENT@> + <$declareEvalGlobalLightingAlphaBlended()$> + <@else@> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> + <@endif@> + + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + + layout(location=0) out vec4 _fragColor0; +<@else@> + <@include DeferredBufferWrite.slh@> +<@endif@> + <@include render-utils/ShaderConstants.h@> <@include sdf_text3D.slh@> <$declareEvalSDFSuperSampled()$> +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; +<@endif@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; @@ -23,15 +42,65 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord1 _texCoord01.zw void main() { - float a = evalSDFSuperSampled(_texCoord0); + float alpha = evalSDFSuperSampled(_texCoord0); - packDeferredFragment( - normalize(_normalWS), - a, - _color.rgb, - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); -} \ No newline at end of file +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + alpha *= _color.a; + if (alpha <= 0.0) { + discard; + } +<@endif@> + +<@if HIFI_USE_UNLIT@> + <@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + _fragColor0 = vec4(_color.rgb * isUnlitEnabled(), alpha); + <@else@> + packDeferredFragmentUnlit( + normalize(_normalWS), + alpha, + _color.rgb); + <@endif@> +<@else@> + <@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + TransformCamera cam = getTransformCamera(); + vec3 fragPosition = _positionES.xyz; + + <@if HIFI_USE_TRANSLUCENT@> + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + _color.rgb, + DEFAULT_FRESNEL, + DEFAULT_METALLIC, + DEFAULT_EMISSIVE, + DEFAULT_ROUGHNESS, alpha), + alpha); + <@else@> + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + _color.rgb, + DEFAULT_FRESNEL, + DEFAULT_METALLIC, + DEFAULT_ROUGHNESS), + alpha); + <@endif@> + <@else@> + packDeferredFragment( + normalize(_normalWS), + alpha, + _color.rgb, + DEFAULT_ROUGHNESS, + DEFAULT_METALLIC, + DEFAULT_EMISSIVE, + DEFAULT_OCCLUSION, + DEFAULT_SCATTERING); + <@endif@> +<@endif@> +} diff --git a/libraries/render-utils/src/sdf_text3D.slv b/libraries/render-utils/src/sdf_text3D.slv index 274e09e6ad..731cbc2cad 100644 --- a/libraries/render-utils/src/sdf_text3D.slv +++ b/libraries/render-utils/src/sdf_text3D.slv @@ -19,20 +19,25 @@ <@include sdf_text3D.slh@> -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; +<@endif@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main() { - _texCoord01.xy = inTexCoord0.xy; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); _color = color_sRGBAToLinear(params.color); - - // standard transform + TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> +<@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> +<@endif@> + const vec3 normal = vec3(0, 0, 1); <$transformModelToWorldDir(cam, obj, normal, _normalWS)$> } \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D_forward.slf b/libraries/render-utils/src/sdf_text3D_forward.slf deleted file mode 100644 index 02ad49fc43..0000000000 --- a/libraries/render-utils/src/sdf_text3D_forward.slf +++ /dev/null @@ -1,57 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// sdf_text3D_forward.frag -// fragment shader -// -// Created by Bradley Austin Davis on 2015-02-04 -// Based on fragment shader code from -// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -<@include DefaultMaterials.slh@> - -<@include ForwardGlobalLight.slh@> -<$declareEvalSkyboxGlobalColor()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include render-utils/ShaderConstants.h@> - -<@include sdf_text3D.slh@> -<$declareEvalSDFSuperSampled()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -layout(location=0) out vec4 _fragColor0; - -void main() { - float a = evalSDFSuperSampled(_texCoord0); - - float alpha = a * _color.a; - if (alpha <= 0.0) { - discard; - } - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS), - _color.rgb, - DEFAULT_FRESNEL, - DEFAULT_METALLIC, - DEFAULT_ROUGHNESS), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D_translucent.slf b/libraries/render-utils/src/sdf_text3D_translucent.slf deleted file mode 100644 index bf72345f38..0000000000 --- a/libraries/render-utils/src/sdf_text3D_translucent.slf +++ /dev/null @@ -1,58 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// sdf_text3D_translucent.frag -// fragment shader -// -// Created by Bradley Austin Davis on 2015-02-04 -// Based on fragment shader code from -// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -<@include DefaultMaterials.slh@> - -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include render-utils/ShaderConstants.h@> - -<@include sdf_text3D.slh@> -<$declareEvalSDFSuperSampled()$> - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -layout(location=0) out vec4 _fragColor0; - -void main() { - float a = evalSDFSuperSampled(_texCoord0); - - float alpha = a * _color.a; - if (alpha <= 0.0) { - discard; - } - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS), - _color.rgb, - DEFAULT_FRESNEL, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE, - DEFAULT_ROUGHNESS, alpha), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D_translucent_unlit.slf b/libraries/render-utils/src/sdf_text3D_translucent_unlit.slf deleted file mode 100644 index 43742b0c53..0000000000 --- a/libraries/render-utils/src/sdf_text3D_translucent_unlit.slf +++ /dev/null @@ -1,38 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// sdf_text3D_translucent.frag -// fragment shader -// -// Created by Bradley Austin Davis on 2015-02-04 -// Based on fragment shader code from -// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -<@include DefaultMaterials.slh@> - -<@include LightingModel.slh@> - -<@include render-utils/ShaderConstants.h@> - -<@include sdf_text3D.slh@> -<$declareEvalSDFSuperSampled()$> - -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -layout(location=0) out vec4 _fragColor0; - -void main() { - float a = evalSDFSuperSampled(_texCoord0); - - float alpha = a * _color.a; - if (alpha <= 0.0) { - discard; - } - - _fragColor0 = vec4(_color.rgb * isUnlitEnabled(), alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D_unlit.slf b/libraries/render-utils/src/sdf_text3D_unlit.slf deleted file mode 100644 index db8366518e..0000000000 --- a/libraries/render-utils/src/sdf_text3D_unlit.slf +++ /dev/null @@ -1,32 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// sdf_text3D_unlit.frag -// fragment shader -// -// Created by Bradley Austin Davis on 2015-02-04 -// Based on fragment shader code from -// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -<@include DeferredBufferWrite.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include sdf_text3D.slh@> -<$declareEvalSDFSuperSampled()$> - -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -void main() { - float a = evalSDFSuperSampled(_texCoord0); - - packDeferredFragmentUnlit( - normalize(_normalWS), - a, - _color.rgb); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index 884c7468bb..9760216682 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple.frag -// fragment shader -// // Created by Andrzej Kapolka on 9/15/14. // Copyright 2014 High Fidelity, Inc. // @@ -12,133 +10,144 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBufferWrite.slh@> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - +<@include gpu/Color.slh@> +<@include DefaultMaterials.slh@> <@include render-utils/ShaderConstants.h@> -// the interpolated normal +<@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + <@if not HIFI_USE_UNLIT@> + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + <@else@> + <@include LightingModel.slh@> +<@endif@> + + layout(location=0) out vec4 _fragColor0; +<@endif@> + +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_TRANSLUCENT@> + <@include GlobalLight.slh@> + <$declareEvalGlobalLightingAlphaBlended()$> + <@elif HIFI_USE_FORWARD@> + <@include GlobalLight.slh@> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> + <@else@> + <@include DeferredBufferWrite.slh@> + <@endif@> +<@else@> + <@if not HIFI_USE_FORWARD@> + <@if not HIFI_USE_TRANSLUCENT@> + <@include DeferredBufferWrite.slh@> + <@endif@> + <@endif@> +<@endif@> + +<@if HIFI_USE_FADE@> + <@include Fade.slh@> + <$declareFadeFragmentInstanced()$> +<@endif@> + +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; + <@endif@> +<@endif@> +<@if HIFI_USE_FADE@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; +<@endif@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -// For retro-compatibility -#define _normal _normalWS -#define _modelNormal _normalMS -#define _position _positionMS -#define _eyePosition _positionES +LAYOUT(binding=0) uniform sampler2D simpleTexture; -<@include procedural/ProceduralCommon.slh@> - -#line 1001 -//PROCEDURAL_BLOCK_BEGIN - -vec3 getProceduralColor() { - return _color.rgb; -} - -float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float shininess) { - return 1.0; -} - -float getProceduralFragment(inout ProceduralFragment proceduralData) { - return 1.0; -} - -float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition proceduralData) { - return 1.0; -} - -//PROCEDURAL_BLOCK_END - -#line 2030 void main(void) { - vec3 normal = normalize(_normalWS.xyz) * (2.0 * float(gl_FrontFacing) - 1.0); - vec3 diffuse = _color.rgb; - float roughness = DEFAULT_ROUGHNESS; - float metallic = DEFAULT_METALLIC; - vec3 emissive = DEFAULT_EMISSIVE; - float occlusion = DEFAULT_OCCLUSION; - float scattering = DEFAULT_SCATTERING; + vec4 texel = texture(simpleTexture, _texCoord0); + texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); + texel.rgb *= _color.rgb; + texel.a *= abs(_color.a); - float emissiveAmount = 0.0; +<@if HIFI_USE_FADE@> + vec3 fadeEmissive; + FadeObjectParams fadeParams; + <$fetchFadeObjectParamsInstanced(fadeParams)$> + applyFade(fadeParams, _positionWS.xyz, fadeEmissive); +<@endif@> -#if defined(PROCEDURAL_V1) - diffuse = getProceduralColor().rgb; - emissiveAmount = 1.0; - emissive = vec3(1.0); -#elif defined(PROCEDURAL_V2) - vec3 specular = DEFAULT_SPECULAR; - float shininess = DEFAULT_SHININESS; - emissiveAmount = getProceduralColors(diffuse, specular, shininess); - roughness = max(0.0, 1.0 - shininess / 128.0); - metallic = length(specular); - emissive = vec3(clamp(emissiveAmount, 0.0, 1.0)); -#elif defined(PROCEDURAL_V3) || defined(PROCEDURAL_V4) -#if defined(PROCEDURAL_V3) - ProceduralFragment proceduralData = ProceduralFragment( -#else - TransformCamera cam = getTransformCamera(); - vec4 position = cam._viewInverse * _positionES; - ProceduralFragmentWithPosition proceduralData = ProceduralFragmentWithPosition( - position.xyz, -#endif - normal, - diffuse, - DEFAULT_SPECULAR, - emissive, - 1.0, - roughness, - metallic, - occlusion, - scattering - ); +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + float metallic = DEFAULT_METALLIC; + vec3 fresnel = getFresnelF0(metallic, texel.rgb); -#if defined(PROCEDURAL_V3) - emissiveAmount = getProceduralFragment(proceduralData); -#else - emissiveAmount = getProceduralFragmentWithPosition(proceduralData); -#endif - normal = proceduralData.normal; - diffuse = proceduralData.diffuse; - roughness = proceduralData.roughness; - metallic = proceduralData.metallic; - emissive = proceduralData.emissive; - occlusion = proceduralData.occlusion; - scattering = proceduralData.scattering; + TransformCamera cam = getTransformCamera(); + vec3 fragPosition = _positionES.xyz; + <@endif@> +<@endif@> -#if defined(PROCEDURAL_V4) - position = vec4(proceduralData.position, 1.0); - vec4 posClip = cam._projection * (cam._view * position); - gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0); -#endif - -#endif - - if (emissiveAmount > 0.0) { - packDeferredFragmentLightmap( - normal, +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_TRANSLUCENT@> + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( + cam._viewInverse, 1.0, - diffuse, - roughness, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), + texel.rgb, + fresnel, metallic, - emissive); - } else { + DEFAULT_EMISSIVE + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + DEFAULT_ROUGHNESS, texel.a), + texel.a); + <@elif HIFI_USE_FORWARD@> + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), + texel.rgb, + fresnel, + metallic, + DEFAULT_ROUGHNESS), + texel.a); + <@else@> packDeferredFragment( - normal, + normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), 1.0, - diffuse, - roughness, - metallic, - emissive, - occlusion, - scattering); - } + texel.rgb, + DEFAULT_ROUGHNESS, + DEFAULT_METALLIC, + DEFAULT_EMISSIVE + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + DEFAULT_OCCLUSION, + DEFAULT_SCATTERING); + <@endif@> +<@else@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + _fragColor0 = isUnlitEnabled() * vec4(texel.rgb + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , texel.a); + <@else@> + packDeferredFragmentUnlit( + normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), + 1.0, + texel.rgb + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + ); + <@endif@> +<@endif@> } diff --git a/libraries/render-utils/src/simple.slv b/libraries/render-utils/src/simple.slv index 460ed53281..e47af5d23f 100644 --- a/libraries/render-utils/src/simple.slv +++ b/libraries/render-utils/src/simple.slv @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple.vert -// vertex shader -// // Created by Andrzej Kapolka on 9/15/14. // Copyright 2014 High Fidelity, Inc. // @@ -19,22 +17,41 @@ <@include render-utils/ShaderConstants.h@> +<@if HIFI_USE_FADE@> + <@include Fade.slh@> + <$declareFadeVertexInstanced()$> + + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; +<@endif@> + +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; + <@endif@> +<@endif@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _positionMS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; void main(void) { _color = color_sRGBAToLinear(inColor); - _texCoord01.xy = inTexCoord0.st; - _positionMS = inPosition; - _normalMS = inNormal.xyz; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); - // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> + <@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + <@endif@> +<@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> +<@endif@> + +<@if HIFI_USE_FADE@> + <$transformModelToWorldPos(obj, inPosition, _positionWS)$> + <$passThroughFadeObjectParams()$> +<@endif@> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> } \ No newline at end of file diff --git a/libraries/render-utils/src/simple_opaque_web_browser.slf b/libraries/render-utils/src/simple_opaque_web_browser.slf deleted file mode 100644 index df789ee22b..0000000000 --- a/libraries/render-utils/src/simple_opaque_web_browser.slf +++ /dev/null @@ -1,34 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_opaque_web_browser.frag -// fragment shader -// -// Created by Anthony Thibault on 7/25/16. -// Copyright 2016 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = color_sRGBAToLinear(texel); - packDeferredFragmentUnlit(normalize(_normalWS), 1.0, _color.rgb * texel.rgb); -} diff --git a/libraries/render-utils/src/simple_transparent.slf b/libraries/render-utils/src/simple_procedural.slf similarity index 78% rename from libraries/render-utils/src/simple_transparent.slf rename to libraries/render-utils/src/simple_procedural.slf index 4fc7da60ea..5b0eb62cca 100644 --- a/libraries/render-utils/src/simple_transparent.slf +++ b/libraries/render-utils/src/simple_procedural.slf @@ -1,37 +1,39 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple_transparent.frag -// fragment shader -// // Created by Andrzej Kapolka on 9/15/14. // Copyright 2014 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 DefaultMaterials.slh@> -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> +<@if not HIFI_USE_TRANSLUCENT@> + <@include DeferredBufferWrite.slh@> +<@else@> + <@include DefaultMaterials.slh@> + + <@include GlobalLight.slh@> + <$declareEvalGlobalLightingAlphaBlended()$> + + layout(location=0) out vec4 _fragColor0; +<@endif@> <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> <@include render-utils/ShaderConstants.h@> -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; +layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; +layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; +layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; - -layout(location=0) out vec4 _fragColor0; // For retro-compatibility #define _normal _normalWS @@ -42,7 +44,6 @@ layout(location=0) out vec4 _fragColor0; <@include procedural/ProceduralCommon.slh@> #line 1001 - //PROCEDURAL_BLOCK_BEGIN vec3 getProceduralColor() { @@ -67,19 +68,24 @@ float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition pro void main(void) { vec3 normal = normalize(_normalWS.xyz) * (2.0 * float(gl_FrontFacing) - 1.0); vec3 diffuse = _color.rgb; - float alpha = _color.a; - float occlusion = DEFAULT_OCCLUSION; vec3 fresnel = DEFAULT_FRESNEL; + float roughness = DEFAULT_ROUGHNESS; float metallic = DEFAULT_METALLIC; vec3 emissive = DEFAULT_EMISSIVE; - float roughness = DEFAULT_ROUGHNESS; + float occlusion = DEFAULT_OCCLUSION; + float scattering = DEFAULT_SCATTERING; float emissiveAmount = 0.0; +<@if HIFI_USE_TRANSLUCENT@> + float alpha = _color.a; TransformCamera cam = getTransformCamera(); vec3 posEye = _positionES.xyz; +<@else@> + float alpha = 1.0; +<@endif@> -#ifdef PROCEDURAL_V1 +#if defined(PROCEDURAL_V1) diffuse = getProceduralColor().rgb; emissiveAmount = 1.0; emissive = vec3(1.0); @@ -94,6 +100,7 @@ void main(void) { #if defined(PROCEDURAL_V3) ProceduralFragment proceduralData = ProceduralFragment( #else + TransformCamera cam = getTransformCamera(); vec4 position = cam._viewInverse * _positionES; ProceduralFragmentWithPosition proceduralData = ProceduralFragmentWithPosition( position.xyz, @@ -106,7 +113,7 @@ void main(void) { roughness, metallic, occlusion, - DEFAULT_SCATTERING + scattering ); #if defined(PROCEDURAL_V3) @@ -114,29 +121,53 @@ void main(void) { #else emissiveAmount = getProceduralFragmentWithPosition(proceduralData); #endif - occlusion = proceduralData.occlusion; normal = proceduralData.normal; diffuse = proceduralData.diffuse; fresnel = proceduralData.specular; + roughness = proceduralData.roughness; metallic = proceduralData.metallic; emissive = proceduralData.emissive; - roughness = proceduralData.roughness; + occlusion = proceduralData.occlusion; + scattering = proceduralData.scattering; alpha = proceduralData.alpha; #if defined(PROCEDURAL_V4) position = vec4(proceduralData.position, 1.0); vec4 posEye4 = cam._view * position; +<@if HIFI_USE_TRANSLUCENT@> posEye = posEye4.xyz; +<@endif@> vec4 posClip = cam._projection * posEye4; gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0); #endif #endif +<@if not HIFI_USE_TRANSLUCENT@> + if (emissiveAmount > 0.0) { + packDeferredFragmentLightmap( + normal, + 1.0, + diffuse, + roughness, + metallic, + emissive); + } else { + packDeferredFragment( + normal, + 1.0, + diffuse, + roughness, + metallic, + emissive, + occlusion, + scattering); + } +<@else@> if (emissiveAmount > 0.0) { _fragColor0 = vec4(diffuse, alpha); } else { - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, occlusion, @@ -149,4 +180,5 @@ void main(void) { roughness, alpha), alpha); } +<@endif@> } diff --git a/libraries/render-utils/src/simple_fade.slv b/libraries/render-utils/src/simple_procedural.slv similarity index 70% rename from libraries/render-utils/src/simple_fade.slv rename to libraries/render-utils/src/simple_procedural.slv index 0bbd8eac39..181afa50bd 100644 --- a/libraries/render-utils/src/simple_fade.slv +++ b/libraries/render-utils/src/simple_procedural.slv @@ -1,12 +1,10 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> +// <$_SCRIBE_FILENAME$> +// Generated on <$_SCRIBE_DATE$> // -// simple_fade.vert -// vertex shader -// -// Created by Olivier Prat on 06/04/17. -// Copyright 2017 High Fidelity, Inc. +// Created by Andrzej Kapolka on 9/15/14. +// Copyright 2014 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 @@ -17,31 +15,23 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -<@include Fade.slh@> -<$declareFadeVertexInstanced()$> - <@include render-utils/ShaderConstants.h@> -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; +layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; +layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main(void) { _color = color_sRGBAToLinear(inColor); - _texCoord01.xy = inTexCoord0.st; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); _positionMS = inPosition; _normalMS = inNormal.xyz; - // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> - <$transformModelToWorldPos(obj, inPosition, _positionWS)$> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> - <$passThroughFadeObjectParams()$> } \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured.slf b/libraries/render-utils/src/simple_textured.slf deleted file mode 100644 index c79ff8cea3..0000000000 --- a/libraries/render-utils/src/simple_textured.slf +++ /dev/null @@ -1,44 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured.frag -// fragment shader -// -// Created by Clement Brisset on 5/29/15. -// Copyright 2014 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - - packDeferredFragment( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - 1.0, - texel.rgb, - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_fade.slf b/libraries/render-utils/src/simple_textured_fade.slf deleted file mode 100644 index 5fa4a70fad..0000000000 --- a/libraries/render-utils/src/simple_textured_fade.slf +++ /dev/null @@ -1,66 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - const float ALPHA_THRESHOLD = 0.999; - if (texel.a < ALPHA_THRESHOLD) { - packDeferredFragmentTranslucent( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - texel.a, - texel.rgb + fadeEmissive, - DEFAULT_ROUGHNESS); - } else { - packDeferredFragment( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - 1.0, - texel.rgb, - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE + fadeEmissive, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); - } -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_unlit.slf b/libraries/render-utils/src/simple_textured_unlit.slf deleted file mode 100644 index 7aa1970aee..0000000000 --- a/libraries/render-utils/src/simple_textured_unlit.slf +++ /dev/null @@ -1,49 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured_unlit.frag -// fragment shader -// -// Created by Clement Brisset on 5/29/15. -// Copyright 2014 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - const float ALPHA_THRESHOLD = 0.999; - if (texel.a < ALPHA_THRESHOLD) { - packDeferredFragmentTranslucent( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - texel.a, - texel.rgb, - DEFAULT_ROUGHNESS); - } else { - packDeferredFragmentUnlit( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - 1.0, - texel.rgb); - } -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_unlit_fade.slf b/libraries/render-utils/src/simple_textured_unlit_fade.slf deleted file mode 100644 index 079a046757..0000000000 --- a/libraries/render-utils/src/simple_textured_unlit_fade.slf +++ /dev/null @@ -1,61 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured_unlit_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - const float ALPHA_THRESHOLD = 0.999; - if (texel.a < ALPHA_THRESHOLD) { - packDeferredFragmentTranslucent( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - texel.a, - texel.rgb + fadeEmissive, - DEFAULT_ROUGHNESS); - } else { - packDeferredFragmentUnlit( - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - 1.0, - texel.rgb + fadeEmissive); - } -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured.slf b/libraries/render-utils/src/simple_transparent_textured.slf deleted file mode 100644 index 64e052b376..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured.slf +++ /dev/null @@ -1,60 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured.frag -// fragment shader -// -// Created by Sam Gateau on 4/3/17. -// Copyright 2017 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 DefaultMaterials.slh@> - -<@include gpu/Color.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - vec3 albedo = _color.xyz * texel.xyz; - float alpha = _color.a * texel.a; - float metallic = DEFAULT_METALLIC; - - vec3 fresnel = getFresnelF0(metallic, albedo); - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - albedo, - fresnel, - metallic, - DEFAULT_EMISSIVE, - DEFAULT_ROUGHNESS, alpha), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured_fade.slf b/libraries/render-utils/src/simple_transparent_textured_fade.slf deleted file mode 100644 index 44e849be69..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured_fade.slf +++ /dev/null @@ -1,72 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 gpu/Color.slh@> - -<@include DeferredBufferWrite.slh@> -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal = normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0); - - TransformCamera cam = getTransformCamera(); - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - 1.0, - fragPosition, - fragNormal, - texel.rgb, - DEFAULT_FRESNEL, - 0.0f, - fadeEmissive, - DEFAULT_ROUGHNESS, - texel.a), - texel.a); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured_unlit.slf b/libraries/render-utils/src/simple_transparent_textured_unlit.slf deleted file mode 100644 index 42a8270274..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured_unlit.slf +++ /dev/null @@ -1,36 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured_unlit.frag -// fragment shader -// -// Created by Sam Gateau on 4/3/17. -// Copyright 2017 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 gpu/Color.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -layout(location=0) out vec4 _fragColor0; - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - _fragColor0 = texel; -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf b/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf deleted file mode 100644 index afc0c94575..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf +++ /dev/null @@ -1,48 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured_unlit_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 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 gpu/Color.slh@> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -layout(location=0) out vec4 _fragColor0; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - _fragColor0 = vec4(texel.rgb + fadeEmissive, texel.a); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_web_browser.slf b/libraries/render-utils/src/simple_transparent_web_browser.slf deleted file mode 100644 index 599fd3d87f..0000000000 --- a/libraries/render-utils/src/simple_transparent_web_browser.slf +++ /dev/null @@ -1,38 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_web_browser.frag -// fragment shader -// -// Created by Anthony Thibault on 7/25/16. -// Copyright 2016 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; -#define _texCoord0 _texCoord01.xy -#define _texCoord1 _texCoord01.zw - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = color_sRGBAToLinear(texel); - packDeferredFragmentTranslucent( - normalize(_normalWS), - _color.a * texel.a, - _color.rgb * texel.rgb, - DEFAULT_ROUGHNESS); -} diff --git a/libraries/render-utils/src/ssao_gather.slf b/libraries/render-utils/src/ssao_gather.slf index 1595678295..3e3b8e9120 100644 --- a/libraries/render-utils/src/ssao_gather.slf +++ b/libraries/render-utils/src/ssao_gather.slf @@ -20,8 +20,6 @@ // the source occlusion texture LAYOUT(binding=RENDER_UTILS_TEXTURE_SSAO_OCCLUSION) uniform sampler2DArray occlusionMaps; -layout(location=0) in vec4 varTexCoord0; - layout(location=0) out vec4 outFragColor; void main(void) { diff --git a/libraries/render-utils/src/web_browser.slf b/libraries/render-utils/src/web_browser.slf new file mode 100644 index 0000000000..f746916d3d --- /dev/null +++ b/libraries/render-utils/src/web_browser.slf @@ -0,0 +1,74 @@ +<@include gpu/Config.slh@> +<$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> +// Generated on <$_SCRIBE_DATE$> +// +// Created by Anthony Thibault on 7/25/16. +// Copyright 2016 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 gpu/Color.slh@> +<@include render-utils/ShaderConstants.h@> + +<@if HIFI_USE_FORWARD@> + <@include LightingModel.slh@> + <@include graphics/Haze.slh@> + + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + + <@include graphics/Light.slh@> + <$declareLightBuffer()$> + + layout(location=0) out vec4 _fragColor0; +<@else@> + <@include DeferredBufferWrite.slh@> +<@endif@> + +LAYOUT(binding=0) uniform sampler2D webTexture; + +<@if HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; +<@else@> + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; +<@endif@> +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +#define _texCoord0 _texCoord01.xy +#define _texCoord1 _texCoord01.zw + +void main(void) { + vec4 texel = texture(webTexture, _texCoord0); + texel = color_sRGBAToLinear(texel); + texel *= _color; + +<@if HIFI_USE_FORWARD@> + _fragColor0 = texel; + + if (isHazeEnabled() > 0.0) { + // no light attenuation because we're unlit + + TransformCamera cam = getTransformCamera(); + + Light light = getKeyLight(); + vec3 lightDirectionWS = getLightDirection(light); + + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + _positionES.xyz, + _positionWS.xyz, + cam._viewInverse[3].xyz, + lightDirectionWS + ); + + _fragColor0.xyz = mix(_fragColor0.rgb, hazeColor.rgb, hazeColor.a); + } + } +<@else@> + packDeferredFragmentUnlit(normalize(_normalWS), 1.0, texel.rgb); +<@endif@> +} diff --git a/libraries/render-utils/src/web_browser.slv b/libraries/render-utils/src/web_browser.slv new file mode 100644 index 0000000000..07b4d7d3d7 --- /dev/null +++ b/libraries/render-utils/src/web_browser.slv @@ -0,0 +1,41 @@ +<@include gpu/Config.slh@> +<$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> +// Generated on <$_SCRIBE_DATE$> +// +// Created by Andrzej Kapolka on 9/15/14. +// Copyright 2014 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 gpu/Inputs.slh@> +<@include gpu/Color.slh@> +<@include gpu/Transform.slh@> +<$declareStandardTransform()$> + +<@include render-utils/ShaderConstants.h@> + +<@if HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; +<@else@> + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +<@endif@> +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; + +void main(void) { + _color = color_sRGBAToLinear(inColor); + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); + + TransformCamera cam = getTransformCamera(); + TransformObject obj = getTransformObject(); +<@if HIFI_USE_FORWARD@> + <$transformModelToWorldAndEyeAndClipPos(cam, obj, inPosition, _positionWS, _positionES, gl_Position)$> +<@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> +<@endif@> +} \ No newline at end of file diff --git a/libraries/render/src/render/Args.h b/libraries/render/src/render/Args.h index cb1ca668a7..a75192bad7 100644 --- a/libraries/render/src/render/Args.h +++ b/libraries/render/src/render/Args.h @@ -142,6 +142,13 @@ namespace render { bool _takingSnapshot { false }; StencilMaskMode _stencilMaskMode { StencilMaskMode::NONE }; std::function _stencilMaskOperator; + + float _visionSqueezeX { 0.0f }; + float _visionSqueezeY { 0.0f }; + float _visionSqueezeTransition { 0.15f }; + int _visionSqueezePerEye { 0 }; + float _visionSqueezeGroundPlaneY { 0.0f }; + float _visionSqueezeSpotlightSize { 0.02f }; }; } diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index 21af30c584..12947f5291 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -104,7 +104,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p locations->fadeMaskTextureUnit = reflection.validTexture(render_utils::slot::texture::FadeMask); locations->fadeParameterBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::FadeParameters); locations->fadeObjectParameterBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::FadeObjectParameters); - locations->hazeParameterBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::HazeParams); + locations->hazeParameterBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::HazeParams); if (key.isTranslucent()) { locations->lightClusterGridBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::LightClusterGrid); locations->lightClusterContentBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::LightClusterContent); @@ -134,7 +134,7 @@ const ShapePipelinePointer ShapePlumber::pickPipeline(RenderArgs* args, const Ke auto factoryIt = ShapePipeline::_globalCustomFactoryMap.find(key.getCustom()); if ((factoryIt != ShapePipeline::_globalCustomFactoryMap.end()) && (factoryIt)->second) { // found a factory for the custom key, can now generate a shape pipeline for this case: - addPipelineHelper(Filter(key), key, 0, (factoryIt)->second(*this, key, *(args->_batch))); + addPipelineHelper(Filter(key), key, 0, (factoryIt)->second(*this, key, args)); return pickPipeline(args, key); } else { diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index ad91ea61ef..cf41c85dd9 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -272,7 +272,7 @@ protected: ItemSetter _itemSetter; public: using CustomKey = uint8_t; - using CustomFactory = std::function (const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch)>; + using CustomFactory = std::function (const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args)>; using CustomFactoryMap = std::map; static CustomFactoryMap _globalCustomFactoryMap; diff --git a/libraries/script-engine/src/ScriptEngines.cpp b/libraries/script-engine/src/ScriptEngines.cpp index f94fca3463..da698c6e4e 100644 --- a/libraries/script-engine/src/ScriptEngines.cpp +++ b/libraries/script-engine/src/ScriptEngines.cpp @@ -475,7 +475,8 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i Q_ARG(bool, isUserLoaded), Q_ARG(bool, loadScriptFromEditor), Q_ARG(bool, activateMainWindow), - Q_ARG(bool, reload)); + Q_ARG(bool, reload), + Q_ARG(bool, quitWhenFinished)); return result; } QUrl scriptUrl; diff --git a/libraries/workload/src/workload/Region.h b/libraries/workload/src/workload/Region.h index 43aed9aef4..b12c5b717c 100644 --- a/libraries/workload/src/workload/Region.h +++ b/libraries/workload/src/workload/Region.h @@ -18,17 +18,17 @@ public: using Type = uint8_t; enum Name : uint8_t { - R1 = 0, - R2, - R3, - UNKNOWN, - INVALID, + R1 = 0, // R1 = in physics simulation and client will bid for simulation ownership + R2, // R2 = in physics simulation but client prefers to NOT have simulation ownership + R3, // R3 = are NOT in physics simulation but yes kinematically animated when velocities are non-zero + R4, // R4 = known to workload but outside R3, not in physics, not animated if moving + UNKNOWN, // UNKNOWN = known to workload but unsorted + INVALID, // INVALID = not known to workload }; - static const uint8_t NUM_CLASSIFICATIONS = 4; - static const uint8_t NUM_TRANSITIONS = NUM_CLASSIFICATIONS * (NUM_CLASSIFICATIONS - 1); - - static const uint8_t NUM_VIEW_REGIONS = (NUM_CLASSIFICATIONS - 1); + static constexpr uint32_t NUM_KNOWN_REGIONS = uint32_t(Region::R4 - Region::R1 + 1); // R1 through R4 inclusive + static constexpr uint32_t NUM_TRACKED_REGIONS = uint32_t(Region::R3 - Region::R1 + 1); // R1 through R3 inclusive + static const uint8_t NUM_REGION_TRANSITIONS = NUM_KNOWN_REGIONS * (NUM_KNOWN_REGIONS - 1); static uint8_t computeTransitionIndex(uint8_t prevIndex, uint8_t newIndex); @@ -62,13 +62,13 @@ inline uint8_t Region::computeTransitionIndex(uint8_t prevIndex, uint8_t newInde // 3 | | | | | // | 9 | 10 | 11 | -1 | // +-------+-------+-------+-------+ - uint8_t p = prevIndex + Region::NUM_CLASSIFICATIONS * newIndex; - if (0 == (p % (Region::NUM_CLASSIFICATIONS + 1))) { + uint8_t p = prevIndex + Region::NUM_KNOWN_REGIONS * newIndex; + if (0 == (p % (Region::NUM_KNOWN_REGIONS + 1))) { return -1; } - return p - (1 + p / (Region::NUM_CLASSIFICATIONS + 1)); + return p - (1 + p / (Region::NUM_KNOWN_REGIONS + 1)); } } // namespace workload -#endif // hifi_workload_Region_h \ No newline at end of file +#endif // hifi_workload_Region_h diff --git a/libraries/workload/src/workload/RegionState.cpp b/libraries/workload/src/workload/RegionState.cpp index 47179ad6f7..c7fc8219a3 100644 --- a/libraries/workload/src/workload/RegionState.cpp +++ b/libraries/workload/src/workload/RegionState.cpp @@ -28,7 +28,9 @@ void RegionState::run(const workload::WorkloadContextPointer& renderContext, con // ... // inputs[2N] = vector of ids exiting region N // inputs[2N + 1] = vector of ids entering region N - assert(inputs.size() == 2 * Region::UNKNOWN); + // + // But we only pass inputs for R1 through R3 + assert(inputs.size() == 2 * workload::Region::NUM_TRACKED_REGIONS); // The id's in each vector are sorted in ascending order // because the source vectors are scanned in ascending order. diff --git a/libraries/workload/src/workload/RegionState.h b/libraries/workload/src/workload/RegionState.h index 40db9d4982..ce74f7adaa 100644 --- a/libraries/workload/src/workload/RegionState.h +++ b/libraries/workload/src/workload/RegionState.h @@ -53,9 +53,7 @@ namespace workload { using Inputs = IndexVectors; using JobModel = workload::Job::ModelI; - RegionState() { - _state.resize(Region::UNKNOWN); - } + RegionState() { _state.resize(workload::Region::NUM_TRACKED_REGIONS); } void configure(const Config& config); void run(const workload::WorkloadContextPointer& renderContext, const Inputs& inputs); diff --git a/libraries/workload/src/workload/RegionTracker.cpp b/libraries/workload/src/workload/RegionTracker.cpp index 381b92c414..8cd4a67bce 100644 --- a/libraries/workload/src/workload/RegionTracker.cpp +++ b/libraries/workload/src/workload/RegionTracker.cpp @@ -33,15 +33,15 @@ void RegionTracker::run(const WorkloadContextPointer& context, Outputs& outputs) //Changes changes; space->categorizeAndGetChanges(outChanges); - // use exit/enter lists for each region less than Region::UNKNOWN - outRegionChanges.resize(2 * (workload::Region::NUM_CLASSIFICATIONS - 1)); + // use exit/enter lists for each region less than Region::R4 + outRegionChanges.resize(2 * workload::Region::NUM_TRACKED_REGIONS); for (uint32_t i = 0; i < outChanges.size(); ++i) { Space::Change& change = outChanges[i]; - if (change.prevRegion < Region::UNKNOWN) { + if (change.prevRegion < Region::R4) { // EXIT list index = 2 * regionIndex outRegionChanges[2 * change.prevRegion].push_back(change.proxyId); } - if (change.region < Region::UNKNOWN) { + if (change.region < Region::R4) { // ENTER list index = 2 * regionIndex + 1 outRegionChanges[2 * change.region + 1].push_back(change.proxyId); } diff --git a/libraries/workload/src/workload/Space.cpp b/libraries/workload/src/workload/Space.cpp index 747df5f6c4..f045c8311f 100644 --- a/libraries/workload/src/workload/Space.cpp +++ b/libraries/workload/src/workload/Space.cpp @@ -99,7 +99,7 @@ void Space::categorizeAndGetChanges(std::vector& changes) { if (proxy.region < Region::INVALID) { glm::vec3 proxyCenter = glm::vec3(proxy.sphere); float proxyRadius = proxy.sphere.w; - uint8_t region = Region::UNKNOWN; + uint8_t region = Region::R4; for (uint32_t j = 0; j < numViews; ++j) { auto& view = _views[j]; // for each 'view' we need only increment 'k' below the current value of 'region' diff --git a/libraries/workload/src/workload/View.cpp b/libraries/workload/src/workload/View.cpp index a11b1890fd..c083e0352c 100644 --- a/libraries/workload/src/workload/View.cpp +++ b/libraries/workload/src/workload/View.cpp @@ -42,11 +42,11 @@ Sphere View::evalRegionSphere(const View& view, float originRadius, float maxDis } void View::updateRegionsDefault(View& view) { - std::vector config(Region::NUM_VIEW_REGIONS * 2, 0.0f); + std::vector config(Region::NUM_TRACKED_REGIONS * 2, 0.0f); float refFar = 10.0f; float refClose = 2.0f; - for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) { + for (int i = 0; i < (int)Region::NUM_TRACKED_REGIONS; i++) { float weight = i + 1.0f; config[i * 2] = refClose; config[i * 2 + 1] = refFar * weight; @@ -56,13 +56,13 @@ void View::updateRegionsDefault(View& view) { } void View::updateRegionsFromBackFronts(View& view) { - for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) { + for (int i = 0; i < (int)Region::NUM_TRACKED_REGIONS; i++) { view.regions[i] = evalRegionSphere(view, view.regionBackFronts[i].x, view.regionBackFronts[i].y); } } void View::updateRegionsFromBackFrontDistances(View& view, const float* configDistances) { - for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) { + for (int i = 0; i < (int)Region::NUM_TRACKED_REGIONS; i++) { view.regionBackFronts[i] = glm::vec2(configDistances[i * 2], configDistances[i * 2 + 1]); } updateRegionsFromBackFronts(view); diff --git a/libraries/workload/src/workload/View.h b/libraries/workload/src/workload/View.h index 972caf5101..fe7bed0d18 100644 --- a/libraries/workload/src/workload/View.h +++ b/libraries/workload/src/workload/View.h @@ -48,10 +48,10 @@ public: float originRadius{ 0.5f }; // N regions distances - glm::vec2 regionBackFronts[Region::NUM_VIEW_REGIONS + 1]; + glm::vec2 regionBackFronts[Region::NUM_TRACKED_REGIONS]; // N regions spheres - Sphere regions[Region::NUM_VIEW_REGIONS]; + Sphere regions[Region::NUM_TRACKED_REGIONS]; // Set fov properties from angle void setFov(float angleRad); diff --git a/libraries/workload/src/workload/ViewTask.cpp b/libraries/workload/src/workload/ViewTask.cpp index 0a268df9fc..1c8e4d34b1 100644 --- a/libraries/workload/src/workload/ViewTask.cpp +++ b/libraries/workload/src/workload/ViewTask.cpp @@ -82,7 +82,7 @@ void SetupViews::run(const WorkloadContextPointer& renderContext, const Input& i ControlViews::ControlViews() { - for (int32_t i = 0; i < workload::Region::NUM_VIEW_REGIONS; i++) { + for (uint32_t i = 0; i < workload::Region::NUM_TRACKED_REGIONS; i++) { regionBackFronts[i] = MIN_VIEW_BACK_FRONTS[i]; regionRegulators[i] = Regulator(std::chrono::milliseconds(2), MIN_VIEW_BACK_FRONTS[i], MAX_VIEW_BACK_FRONTS[i], glm::vec2(RELATIVE_STEP_DOWN), glm::vec2(RELATIVE_STEP_UP)); } @@ -166,7 +166,7 @@ glm::vec2 Regulator::clamp(const glm::vec2& backFront) const { void ControlViews::regulateViews(workload::Views& outViews, const workload::Timings& timings) { for (auto& outView : outViews) { - for (int32_t r = 0; r < workload::Region::NUM_VIEW_REGIONS; r++) { + for (uint32_t r = 0; r < workload::Region::NUM_TRACKED_REGIONS; r++) { outView.regionBackFronts[r] = regionBackFronts[r]; } } @@ -198,13 +198,13 @@ void ControlViews::enforceRegionContainment() { // and each region should never exceed its min/max limits const glm::vec2 MIN_REGION_GAP = { 1.0f, 2.0f }; // enforce outside --> in - for (int32_t i = workload::Region::NUM_VIEW_REGIONS - 2; i >= 0; --i) { + for (int32_t i = (int32_t)workload::Region::NUM_TRACKED_REGIONS - 2; i >= 0; --i) { int32_t j = i + 1; regionBackFronts[i] = regionRegulators[i].clamp(glm::min(regionBackFronts[i], regionBackFronts[j] - MIN_REGION_GAP)); } // enforce inside --> out - for (int32_t i = 1; i < workload::Region::NUM_VIEW_REGIONS; ++i) { - int32_t j = i - 1; + for (uint32_t i = 1; i < workload::Region::NUM_TRACKED_REGIONS; ++i) { + uint32_t j = i - 1; regionBackFronts[i] = regionRegulators[i].clamp(glm::max(regionBackFronts[i], regionBackFronts[j] + MIN_REGION_GAP)); } } diff --git a/libraries/workload/src/workload/ViewTask.h b/libraries/workload/src/workload/ViewTask.h index 207bc04276..f6f2faef87 100644 --- a/libraries/workload/src/workload/ViewTask.h +++ b/libraries/workload/src/workload/ViewTask.h @@ -196,7 +196,7 @@ namespace workload { } data; struct DataExport { - static const int SIZE{ workload::Region::NUM_VIEW_REGIONS }; + static const int SIZE{ workload::Region::NUM_TRACKED_REGIONS }; float timings[SIZE]; glm::vec2 ranges[SIZE]; QList _timings { 6, 2.0 }; @@ -252,8 +252,8 @@ namespace workload { void configure(const Config& config); void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs); - std::array regionBackFronts; - std::array regionRegulators; + std::array regionBackFronts; + std::array regionRegulators; void regulateViews(workload::Views& views, const workload::Timings& timings); void enforceRegionContainment(); diff --git a/plugins/oculus/src/OculusDisplayPlugin.cpp b/plugins/oculus/src/OculusDisplayPlugin.cpp index bd0c77ae57..a2dc7be325 100644 --- a/plugins/oculus/src/OculusDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusDisplayPlugin.cpp @@ -53,6 +53,13 @@ bool OculusDisplayPlugin::internalActivate() { void OculusDisplayPlugin::init() { Plugin::init(); + // Different HMDs end up showing the squeezed-vision egg as different sizes. These values + // attempt to make them appear the same. + _visionSqueezeDeviceLowX = 0.7f; + _visionSqueezeDeviceHighX = 0.98f; + _visionSqueezeDeviceLowY = 0.7f; + _visionSqueezeDeviceHighY = 0.9f; + emit deviceConnected(getName()); } @@ -151,8 +158,11 @@ void OculusDisplayPlugin::hmdPresent() { GLuint curTexId; ovr_GetTextureSwapChainBufferGL(_session, _textureSwapChain, curIndex, &curTexId); + _visionSqueezeParametersBuffer.edit()._leftProjection = _eyeProjections[0]; + _visionSqueezeParametersBuffer.edit()._rightProjection = _eyeProjections[1]; + // Manually bind the texture to the FBO - // FIXME we should have a way of wrapping raw GL ids in GPU objects without + // FIXME we should have a way of wrapping raw GL ids in GPU objects without // taking ownership of the object auto fbo = getGLBackend()->getFramebufferID(_outputFramebuffer); glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0, curTexId, 0); diff --git a/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp b/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp index e6b555443f..a8ad10a9a0 100644 --- a/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp +++ b/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp @@ -11,7 +11,7 @@ #include -#include +#include #include #include #include diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index cd318dd9b4..78b462369b 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -396,6 +396,13 @@ void OpenVrDisplayPlugin::init() { _lastGoodHMDPose.m[2][2] = 1.0f; _lastGoodHMDPose.m[2][3] = 0.0f; + // Different HMDs end up showing the squeezed-vision egg as different sizes. These values + // attempt to make them appear the same. + _visionSqueezeDeviceLowX = 0.8f; + _visionSqueezeDeviceHighX = 0.98f; + _visionSqueezeDeviceLowY = 0.8f; + _visionSqueezeDeviceHighY = 0.9f; + emit deviceConnected(getName()); } @@ -651,6 +658,11 @@ void OpenVrDisplayPlugin::hmdPresent() { if (_threadedSubmit) { _submitThread->waitForPresent(); } else { + + _visionSqueezeParametersBuffer.edit()._leftProjection = _eyeProjections[0]; + _visionSqueezeParametersBuffer.edit()._rightProjection = _eyeProjections[1]; + _visionSqueezeParametersBuffer.edit()._hmdSensorMatrix = _currentPresentFrameInfo.presentPose; + GLuint glTexId = getGLBackend()->getTextureID(_compositeFramebuffer->getRenderBuffer(0)); vr::Texture_t vrTexture{ (void*)(uintptr_t)glTexId, vr::TextureType_OpenGL, vr::ColorSpace_Auto }; vr::VRCompositor()->Submit(vr::Eye_Left, &vrTexture, &OPENVR_TEXTURE_BOUNDS_LEFT); @@ -828,4 +840,15 @@ DisplayPlugin::StencilMaskMeshOperator OpenVrDisplayPlugin::getStencilMaskMeshOp } } return nullptr; -} \ No newline at end of file +} + +void OpenVrDisplayPlugin::updateParameters(float visionSqueezeX, float visionSqueezeY, float visionSqueezeTransition, + int visionSqueezePerEye, float visionSqueezeGroundPlaneY, + float visionSqueezeSpotlightSize) { + _visionSqueezeX = visionSqueezeX; + _visionSqueezeY = visionSqueezeY; + _visionSqueezeTransition = visionSqueezeTransition; + _visionSqueezePerEye = visionSqueezePerEye; + _visionSqueezeGroundPlaneY = visionSqueezeGroundPlaneY; + _visionSqueezeSpotlightSize = visionSqueezeSpotlightSize; +} diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.h b/plugins/openvr/src/OpenVrDisplayPlugin.h index 4b042a700d..25427c6dcd 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.h +++ b/plugins/openvr/src/OpenVrDisplayPlugin.h @@ -72,6 +72,10 @@ public: virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::MESH; } virtual StencilMaskMeshOperator getStencilMaskMeshOperator() override; + virtual void updateParameters(float visionSqueezeX, float visionSqueezeY, float visionSqueezeTransition, + int visionSqueezePerEye, float visionSqueezeGroundPlaneY, + float visionSqueezeSpotlightSize) override; + protected: bool internalActivate() override; void internalDeactivate() override; @@ -102,4 +106,11 @@ private: std::array _stencilMeshes; bool _stencilMeshesInitialized { false }; + + float _visionSqueezeX; + float _visionSqueezeY; + float _visionSqueezeTransition; + int _visionSqueezePerEye; + float _visionSqueezeGroundPlaneY; + float _visionSqueezeSpotlightSize; }; diff --git a/scripts/developer/utilities/render/shadow.qml b/scripts/developer/utilities/render/shadow.qml index 427b52c659..6af0b21d1b 100755 --- a/scripts/developer/utilities/render/shadow.qml +++ b/scripts/developer/utilities/render/shadow.qml @@ -117,17 +117,17 @@ Rectangle { max: 1.0 min: 0.0 height: 38 - width:250 + width: 250 } ConfigSlider { label: qsTr("Shadow Max Distance") integral: false config: shadowConfig - property: "globalMaxDistance" - max: 100.0 - min: 1.0 + property: "maxDistance" + max: 250.0 + min: 0.0 height: 38 - width:250 + width: 250 } Repeater { model: [ @@ -159,7 +159,7 @@ Rectangle { max: 1.0 min: 0.0 height: 38 - width:250 + width: 250 } ConfigSlider { label: qsTr("Slope bias") diff --git a/scripts/simplifiedUI/ui/simplifiedNametag/resources/modules/nameTagListManager.js b/scripts/simplifiedUI/ui/simplifiedNametag/resources/modules/nameTagListManager.js index 216767c1cb..407af0e7b3 100644 --- a/scripts/simplifiedUI/ui/simplifiedNametag/resources/modules/nameTagListManager.js +++ b/scripts/simplifiedUI/ui/simplifiedNametag/resources/modules/nameTagListManager.js @@ -253,11 +253,7 @@ function getCorrectName(uuid) { var avatar = _this.avatars[uuid]; var avatarInfo = avatar.avatarInfo; - var displayNameToUse = avatarInfo.sessionDisplayName.trim(); - - if (displayNameToUse === "") { - displayNameToUse = avatarInfo.displayName.trim(); - } + var displayNameToUse = avatarInfo.displayName.trim(); if (displayNameToUse === "") { displayNameToUse = "anonymous"; diff --git a/scripts/simplifiedUI/ui/simplifiedStatusIndicator/simplifiedStatusIndicator.js b/scripts/simplifiedUI/ui/simplifiedStatusIndicator/simplifiedStatusIndicator.js index 789c497104..c064e2d138 100644 --- a/scripts/simplifiedUI/ui/simplifiedStatusIndicator/simplifiedStatusIndicator.js +++ b/scripts/simplifiedUI/ui/simplifiedStatusIndicator/simplifiedStatusIndicator.js @@ -60,10 +60,8 @@ function simplifiedStatusIndicator(properties) { var queryParamString = "type=heartbeat"; queryParamString += "&username=" + AccountServices.username; - var displayNameToSend = MyAvatar.sessionDisplayName; - if (displayNameToSend === "") { - displayNameToSend = MyAvatar.displayName; - } + var displayNameToSend = MyAvatar.displayName; + queryParamString += "&displayName=" + displayNameToSend; queryParamString += "&status=" + currentStatus; queryParamString += "&organization=" + location.hostname; diff --git a/scripts/system/create/assets/data/createAppTooltips.json b/scripts/system/create/assets/data/createAppTooltips.json index f9f3ef5e47..cda6fc9be0 100644 --- a/scripts/system/create/assets/data/createAppTooltips.json +++ b/scripts/system/create/assets/data/createAppTooltips.json @@ -78,6 +78,12 @@ "keyLight.castShadows": { "tooltip": "If enabled, shadows are cast. The entity or avatar casting the shadow must also have Cast Shadows enabled." }, + "keyLight.shadowBias": { + "tooltip": "The bias of the shadows cast by the light. Use this to fine-tune your shadows to your scene to prevent shadow acne and peter panning." + }, + "keyLight.shadowMaxDistance": { + "tooltip": "The max distance from your view at which shadows will be computed." + }, "skyboxMode": { "tooltip": "Configures the skybox in the zone. The skybox is a cube map image." }, diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 40ee1b78bc..76264429ac 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -305,6 +305,26 @@ const GROUPS = [ propertyID: "keyLight.castShadows", showPropertyRule: { "keyLightMode": "enabled" }, }, + { + label: "Shadow Bias", + type: "number-draggable", + min: 0, + max: 1, + step: 0.01, + decimals: 2, + propertyID: "keyLight.shadowBias", + showPropertyRule: { "keyLightMode": "enabled" }, + }, + { + label: "Shadow Max Distance", + type: "number-draggable", + min: 0, + max: 250, + step: 0.1, + decimals: 2, + propertyID: "keyLight.shadowMaxDistance", + showPropertyRule: { "keyLightMode": "enabled" }, + }, { label: "Skybox", type: "dropdown", diff --git a/scripts/system/keyboardShortcuts/keyboardShortcuts.js b/scripts/system/keyboardShortcuts/keyboardShortcuts.js index cf3927ac2d..ca1429ad95 100644 --- a/scripts/system/keyboardShortcuts/keyboardShortcuts.js +++ b/scripts/system/keyboardShortcuts/keyboardShortcuts.js @@ -12,11 +12,19 @@ // (function () { // BEGIN LOCAL_SCOPE + var snapActivateSound = SoundCache.getSound(Script.resourcesPath() + "sounds/snapshot/snap.wav"); function keyPressEvent(event) { - if (event.text.toUpperCase() === "B" && event.isControl) { + if (event.text.toUpperCase() === "B" && event.isControl && !event.isShifted && !event.isAlt && !event.isCommand) { Window.openWebBrowser(); - } else if (event.text.toUpperCase() === "N" && event.isControl) { + } else if (event.text.toUpperCase() === "N" && event.isControl && !event.isShifted && !event.isAlt && !event.isCommand) { Users.toggleIgnoreRadius(); + } else if (event.text.toUpperCase() === "P" && !event.isControl && !event.isShifted && !event.isAlt && !event.isCommand) { + Audio.playSound(snapActivateSound, { + position: { x: MyAvatar.position.x, y: MyAvatar.position.y, z: MyAvatar.position.z }, + localOnly: true, + volume: 0.5 + }); + Window.takeSnapshot(true); } } diff --git a/tests-manual/gpu/CMakeLists.txt b/tests-manual/gpu/CMakeLists.txt index 2b04bdc3f2..6e3781acff 100644 --- a/tests-manual/gpu/CMakeLists.txt +++ b/tests-manual/gpu/CMakeLists.txt @@ -6,7 +6,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") link_hifi_libraries( shared task networking gl ktx shaders gpu procedural octree image - graphics model-networking fbx hfm animation + graphics model-networking fbx hfm animation material-networking script-engine render render-utils ${PLATFORM_GL_BACKEND} ) diff --git a/tools/ci-scripts/linux-package-release/after-install.sh b/tools/ci-scripts/linux-package-release/after-install.sh new file mode 100755 index 0000000000..b3c99a27a8 --- /dev/null +++ b/tools/ci-scripts/linux-package-release/after-install.sh @@ -0,0 +1,5 @@ +#!/bin/bash +if ! systemctl is-active <%= service %> +then + systemctl start <%= service %> +fi diff --git a/tools/ci-scripts/linux-package-release/assignment-client-before-install.sh b/tools/ci-scripts/linux-package-release/assignment-client-before-install.sh new file mode 100755 index 0000000000..36883bfa9f --- /dev/null +++ b/tools/ci-scripts/linux-package-release/assignment-client-before-install.sh @@ -0,0 +1,17 @@ +#!/bin/bash +dpkg -s <%= service %> &>/dev/null +if [ $? -ne 0 ] +then + if systemctl is-active <%= service %> + then + # Stop service that is running + systemctl stop <%= service %> + fi +fi + +[ $(getent group hifi) ] || groupadd hifi +id -u hifi &>/dev/null || useradd hifi -g hifi --system --no-create-home +mkdir -p /.local && chown root:hifi /.local && chmod 775 /.local +mkdir -p /.config && chown root:hifi /.config && chmod 775 /.config +mkdir -p /var/log/hifi && chown root:hifi /var/log/hifi && chmod 775 /var/log/hifi +mkdir -p /usr/share/hifi/assignment-client && chown root:hifi /usr/share/hifi/assignment-client && chmod 775 /usr/share/hifi/assignment-client diff --git a/tools/ci-scripts/linux-package-release/before-remove.sh b/tools/ci-scripts/linux-package-release/before-remove.sh new file mode 100755 index 0000000000..d171cca810 --- /dev/null +++ b/tools/ci-scripts/linux-package-release/before-remove.sh @@ -0,0 +1,6 @@ +#!/bin/bash +if systemctl is-active <%= service %> +then + # Stop service that is running + systemctl stop <%= service %> +fi diff --git a/tools/ci-scripts/linux-package-release/domain-server-before-install.sh b/tools/ci-scripts/linux-package-release/domain-server-before-install.sh new file mode 100755 index 0000000000..390ac67382 --- /dev/null +++ b/tools/ci-scripts/linux-package-release/domain-server-before-install.sh @@ -0,0 +1,17 @@ +#!/bin/bash +dpkg -s <%= service %> &>/dev/null +if [ $? -ne 0 ] +then + if systemctl is-active <%= service %> + then + # Stop service that is running + systemctl stop <%= service %> + fi +fi + +[ $(getent group hifi) ] || groupadd hifi +id -u hifi &>/dev/null || useradd hifi -g hifi --system --no-create-home +mkdir -p /.local && chown root:hifi /.local && chmod 775 /.local +mkdir -p /.config && chown root:hifi /.config && chmod 775 /.config +mkdir -p /var/log/hifi && chown root:hifi /var/log/hifi && chmod 775 /var/log/hifi +mkdir -p /usr/share/hifi/domain-server && chown root:hifi /usr/share/hifi/domain-server && chmod 775 /usr/share/hifi/domain-server diff --git a/tools/ci-scripts/linux-package-release/hifi-assignment-client b/tools/ci-scripts/linux-package-release/hifi-assignment-client new file mode 100644 index 0000000000..ffd30882a1 --- /dev/null +++ b/tools/ci-scripts/linux-package-release/hifi-assignment-client @@ -0,0 +1,12 @@ +[Unit] +Description=Assignment client service for High Fidelity server +After=network.target +[Service] +Restart=always + +WorkingDirectory=/usr/share/hifi/assignment-client +Environment="LD_LIBRARY_PATH=/usr/share/hifi/assignment-client/" + +ExecStart=/bin/bash -c 'ulimit -c unlimited; /usr/share/hifi/assignment-client/assignment-client -n 7 2>&1 >> /var/log/hifi/assignment-client.log' +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/tools/ci-scripts/linux-package-release/hifi-domain-server b/tools/ci-scripts/linux-package-release/hifi-domain-server new file mode 100644 index 0000000000..aed34314dd --- /dev/null +++ b/tools/ci-scripts/linux-package-release/hifi-domain-server @@ -0,0 +1,13 @@ +[Unit] +Description=Domain Server service for High Fidelity +After=network.target +[Service] +Restart=on-failure + +WorkingDirectory=/usr/share/hifi/domain-server +Environment="LD_LIBRARY_PATH=/usr/share/hifi/domain-server/" + +ExecStartPre=/bin/bash -c 'if /usr/bin/pgrep -l domain-server; then /usr/bin/pkill -SIGKILL -f /usr/share/hifi/domain-server/domain-server; fi' +ExecStart=/bin/bash -c 'ulimit -c unlimited; /usr/share/hifi/domain-server/domain-server 2>&1 >> /var/log/hifi/domain-server.log' +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/tools/ci-scripts/linux-package-release/hifi-ice-server b/tools/ci-scripts/linux-package-release/hifi-ice-server new file mode 100644 index 0000000000..55b5e6d7de --- /dev/null +++ b/tools/ci-scripts/linux-package-release/hifi-ice-server @@ -0,0 +1,14 @@ +[Unit] +Description=Ice Server service for High Fidelity +After=network.target +[Service] +Restart=on-failure + +Environment="HIFI_ENVIRONMENT=production" + +WorkingDirectory=/usr/share/hifi/ice-server + +ExecStartPre=/bin/bash -c 'if /usr/bin/pgrep -l ice-server; then /usr/bin/pkill -SIGKILL -f /usr/share/hifi/ice-server/ice-server; fi' +ExecStart=/bin/bash -c 'ulimit -c unlimited; /usr/share/hifi/ice-server/ice-server 2>&1 >> /var/log/hifi/ice-server.log' +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/tools/ci-scripts/linux-package-release/ice-server-before-install.sh b/tools/ci-scripts/linux-package-release/ice-server-before-install.sh new file mode 100755 index 0000000000..1d415d61b7 --- /dev/null +++ b/tools/ci-scripts/linux-package-release/ice-server-before-install.sh @@ -0,0 +1,17 @@ +#!/bin/bash +dpkg -s <%= service %> &>/dev/null +if [ $? -ne 0 ] +then + if systemctl is-active <%= service %> + then + # Stop service that is running + systemctl stop <%= service %> + fi +fi + +[ $(getent group hifi) ] || groupadd hifi +id -u hifi &>/dev/null || useradd hifi -g hifi --system --no-create-home +mkdir -p /.local && chown root:hifi /.local && chmod 775 /.local +mkdir -p /.config && chown root:hifi /.config && chmod 775 /.config +mkdir -p /var/log/hifi && chown root:hifi /var/log/hifi && chmod 775 /var/log/hifi +mkdir -p /usr/share/hifi/ice-server && chown root:hifi /usr/share/hifi/ice-server && chmod 775 /usr/share/hifi/ice-server diff --git a/tools/ci-scripts/linux-package-release/package-and-upload.sh b/tools/ci-scripts/linux-package-release/package-and-upload.sh new file mode 100755 index 0000000000..b38434dcc9 --- /dev/null +++ b/tools/ci-scripts/linux-package-release/package-and-upload.sh @@ -0,0 +1,36 @@ +#!/bin/bash -l +LOCAL_PATH="$( cd "$(dirname "$0")" ; pwd -P )" +prefix=${1:-""} +declare -a packages_systemd=("assignment-client" "domain-server" "ice-server") +cd ./build + +for package_name in "${packages_systemd[@]}" +do + SOURCE_DESTINATION_LIST="${WORKSPACE}/build/${package_name}/${package_name}=/usr/share/hifi/${package_name}/ " + if [ "$package_name" == "domain-server" ]; then + DESCRIPTION="High Fidelity Domain server." + SOURCE_DESTINATION_LIST+="${WORKSPACE}/build/${package_name}/resources/=/usr/share/hifi/${package_name}/resources " + SOURCE_DESTINATION_LIST+="${WORKSPACE}/build/ext/makefiles/quazip/project/build/libquazip5.so.1.0.0=/usr/share/hifi/${package_name}/libquazip5.so.1" + elif [ "$package_name" == "assignment-client" ]; then + DESCRIPTION="High Fidelity Assignment clients. Services target a local domain server. Different assignment clients are managed independently with systemd." + SOURCE_DESTINATION_LIST+="${WORKSPACE}/build/${package_name}/plugins/=/usr/share/hifi/${package_name}/plugins " + SOURCE_DESTINATION_LIST+="${WORKSPACE}/build/ext/makefiles/quazip/project/build/libquazip5.so.1.0.0=/usr/share/hifi/${package_name}/libquazip5.so.1 " + SOURCE_DESTINATION_LIST+="${WORKSPACE}/build/${package_name}/oven=/usr/share/hifi/${package_name}/oven" + elif [ "$package_name" == "ice-server" ]; then + DESCRIPTION="High Fidelity ICE server." + fi + + fpm -s dir -t deb -n hifi-${prefix}${package_name} -v ${VERSION} -d hifiqt5.12.3 --vendor "High Fidelity Inc" -m "" \ + --url "https://highfidelity.com" --license "Apache License 2.0" --description "${DESCRIPTION}" -d libgomp1 -d libtbb2 -d libgl1-mesa-glx -d libnss3 \ + -d libxi6 -d libxcursor1 -d libxcomposite1 -d libasound2 -d libxtst6 -d libxslt1.1 --template-scripts --template-value "service"="hifi-${package_name}" \ + --deb-systemd ${LOCAL_PATH}/hifi-${package_name} --before-install ${LOCAL_PATH}/${package_name}-before-install.sh \ + --after-install ${LOCAL_PATH}/after-install.sh --before-remove ${LOCAL_PATH}/before-remove.sh \ + ${SOURCE_DESTINATION_LIST} + + dpkg-sig --sign builder -k 15FF1AAE -g '--no-tty --passphrase "${MASKED_DEB_REPO_SIGN_PASSPHRASE}"' ./hifi-${prefix}${package_name}_${VERSION}_amd64.deb + + deb-s3 upload ./hifi-${prefix}${package_name}_${VERSION}_amd64.deb --bucket debian.highfidelity.com \ + --sign=15FF1AAE --gpg-options='--no-tty --passphrase "${MASKED_DEB_REPO_SIGN_PASSPHRASE}"' \ + --origin hifi --suite stable -p + +done