mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:29:47 +02:00
Post merge with Zach work for environment map
This commit is contained in:
commit
99ba011996
22 changed files with 104 additions and 81 deletions
|
@ -210,8 +210,6 @@ static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html";
|
||||||
|
|
||||||
static const unsigned int THROTTLED_SIM_FRAMERATE = 15;
|
static const unsigned int THROTTLED_SIM_FRAMERATE = 15;
|
||||||
static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE;
|
static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE;
|
||||||
static const unsigned int CAPPED_SIM_FRAMERATE = 120;
|
|
||||||
static const int CAPPED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / CAPPED_SIM_FRAMERATE;
|
|
||||||
|
|
||||||
static const uint32_t INVALID_FRAME = UINT32_MAX;
|
static const uint32_t INVALID_FRAME = UINT32_MAX;
|
||||||
|
|
||||||
|
@ -817,6 +815,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
} else if (action == controller::toInt(controller::Action::RETICLE_Y)) {
|
} else if (action == controller::toInt(controller::Action::RETICLE_Y)) {
|
||||||
auto oldPos = _compositor.getReticlePosition();
|
auto oldPos = _compositor.getReticlePosition();
|
||||||
_compositor.setReticlePosition({ oldPos.x, oldPos.y + state });
|
_compositor.setReticlePosition({ oldPos.x, oldPos.y + state });
|
||||||
|
} else if (action == controller::toInt(controller::Action::TOGGLE_OVERLAY)) {
|
||||||
|
toggleOverlays();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -967,6 +967,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
|
|
||||||
connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
|
connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
|
||||||
qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
|
qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
|
||||||
|
|
||||||
_idleTimer = new QTimer(this);
|
_idleTimer = new QTimer(this);
|
||||||
connect(_idleTimer, &QTimer::timeout, [=] {
|
connect(_idleTimer, &QTimer::timeout, [=] {
|
||||||
idle(usecTimestampNow());
|
idle(usecTimestampNow());
|
||||||
|
@ -1198,7 +1199,6 @@ void Application::initializeUi() {
|
||||||
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
||||||
// support the window management and scripting proxies for VR use
|
// support the window management and scripting proxies for VR use
|
||||||
offscreenUi->createDesktop(QString("hifi/Desktop.qml"));
|
offscreenUi->createDesktop(QString("hifi/Desktop.qml"));
|
||||||
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
|
|
||||||
|
|
||||||
// FIXME either expose so that dialogs can set this themselves or
|
// FIXME either expose so that dialogs can set this themselves or
|
||||||
// do better detection in the offscreen UI of what has focus
|
// do better detection in the offscreen UI of what has focus
|
||||||
|
@ -1296,6 +1296,7 @@ void Application::initializeUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::paintGL() {
|
void Application::paintGL() {
|
||||||
|
|
||||||
// paintGL uses a queued connection, so we can get messages from the queue even after we've quit
|
// paintGL uses a queued connection, so we can get messages from the queue even after we've quit
|
||||||
// and the plugins have shutdown
|
// and the plugins have shutdown
|
||||||
if (_aboutToQuit) {
|
if (_aboutToQuit) {
|
||||||
|
@ -1321,10 +1322,6 @@ void Application::paintGL() {
|
||||||
_lastFramesPerSecondUpdate = now;
|
_lastFramesPerSecondUpdate = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isGLInitialized) {
|
|
||||||
idle(now);
|
|
||||||
}
|
|
||||||
|
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
PerformanceTimer perfTimer("paintGL");
|
PerformanceTimer perfTimer("paintGL");
|
||||||
|
|
||||||
|
@ -1619,7 +1616,6 @@ void Application::paintGL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastInstantaneousFps = instantaneousFps;
|
_lastInstantaneousFps = instantaneousFps;
|
||||||
_pendingPaint = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::runTests() {
|
void Application::runTests() {
|
||||||
|
@ -2030,9 +2026,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson));
|
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson));
|
||||||
cameraMenuChanged();
|
cameraMenuChanged();
|
||||||
break;
|
break;
|
||||||
case Qt::Key_O:
|
|
||||||
_overlayConductor.setEnabled(!_overlayConductor.getEnabled());
|
|
||||||
break;
|
|
||||||
case Qt::Key_Slash:
|
case Qt::Key_Slash:
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Stats);
|
Menu::getInstance()->triggerOption(MenuOption::Stats);
|
||||||
break;
|
break;
|
||||||
|
@ -2432,10 +2426,24 @@ bool Application::acceptSnapshot(const QString& urlString) {
|
||||||
static uint32_t _renderedFrameIndex { INVALID_FRAME };
|
static uint32_t _renderedFrameIndex { INVALID_FRAME };
|
||||||
|
|
||||||
void Application::idle(uint64_t now) {
|
void Application::idle(uint64_t now) {
|
||||||
|
|
||||||
if (_aboutToQuit) {
|
if (_aboutToQuit) {
|
||||||
return; // bail early, nothing to do here.
|
return; // bail early, nothing to do here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stats::getInstance()->updateStats();
|
||||||
|
AvatarInputs::getInstance()->update();
|
||||||
|
|
||||||
|
// These tasks need to be done on our first idle, because we don't want the showing of
|
||||||
|
// overlay subwindows to do a showDesktop() until after the first time through
|
||||||
|
static bool firstIdle = true;
|
||||||
|
if (firstIdle) {
|
||||||
|
firstIdle = false;
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
|
||||||
|
_overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays));
|
||||||
|
}
|
||||||
|
|
||||||
auto displayPlugin = getActiveDisplayPlugin();
|
auto displayPlugin = getActiveDisplayPlugin();
|
||||||
// depending on whether we're throttling or not.
|
// depending on whether we're throttling or not.
|
||||||
// Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
|
// Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
|
||||||
|
@ -2456,30 +2464,16 @@ void Application::idle(uint64_t now) {
|
||||||
_renderedFrameIndex = INVALID_FRAME;
|
_renderedFrameIndex = INVALID_FRAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nested ifs are for clarity in the logic. Don't collapse them into a giant single if.
|
// Don't saturate the main thread with rendering and simulation,
|
||||||
// Don't saturate the main thread with rendering, no paint calls until the last one is complete
|
// unless display plugin has increased by at least one frame
|
||||||
if (!_pendingPaint) {
|
if (_renderedFrameIndex == INVALID_FRAME || presentCount > _renderedFrameIndex) {
|
||||||
// Also no paint calls until the display plugin has increased by at least one frame
|
// Record what present frame we're on
|
||||||
// (don't render at 90fps if the display plugin only goes at 60)
|
_renderedFrameIndex = presentCount;
|
||||||
if (_renderedFrameIndex == INVALID_FRAME || presentCount > _renderedFrameIndex) {
|
|
||||||
// Record what present frame we're on
|
|
||||||
_renderedFrameIndex = presentCount;
|
|
||||||
// Don't allow paint requests to stack up in the event queue
|
|
||||||
_pendingPaint = true;
|
|
||||||
// But when we DO request a paint, get to it as soon as possible: high priority
|
|
||||||
postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the rest of idle, we want to cap at the max sim rate, so we might not call
|
// request a paint, get to it as soon as possible: high priority
|
||||||
// the remaining idle work every paint frame, or vice versa
|
postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
|
||||||
// In theory this means we could call idle processing more often than painting,
|
} else {
|
||||||
// but in practice, when the paintGL calls aren't keeping up, there's no room left
|
// there's no use in simulating or rendering faster then the present rate.
|
||||||
// in the main thread to call idle more often than paint.
|
|
||||||
// This check is mostly to keep idle from burning up CPU cycles by running at
|
|
||||||
// hundreds of idles per second when the rendering is that fast
|
|
||||||
if ((timeSinceLastUpdateUs / USECS_PER_MSEC) < CAPPED_SIM_FRAME_PERIOD_MS) {
|
|
||||||
// No paint this round, but might be time for a new idle, otherwise return
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2993,6 +2987,16 @@ void Application::updateThreads(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::toggleOverlays() {
|
||||||
|
auto newOverlaysVisible = !_overlayConductor.getEnabled();
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, newOverlaysVisible);
|
||||||
|
_overlayConductor.setEnabled(newOverlaysVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::setOverlaysVisible(bool visible) {
|
||||||
|
_overlayConductor.setEnabled(visible);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::cycleCamera() {
|
void Application::cycleCamera() {
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) {
|
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
const ApplicationOverlay& getApplicationOverlay() const { return _applicationOverlay; }
|
const ApplicationOverlay& getApplicationOverlay() const { return _applicationOverlay; }
|
||||||
ApplicationCompositor& getApplicationCompositor() { return _compositor; }
|
ApplicationCompositor& getApplicationCompositor() { return _compositor; }
|
||||||
const ApplicationCompositor& getApplicationCompositor() const { return _compositor; }
|
const ApplicationCompositor& getApplicationCompositor() const { return _compositor; }
|
||||||
|
|
||||||
Overlays& getOverlays() { return _overlays; }
|
Overlays& getOverlays() { return _overlays; }
|
||||||
|
|
||||||
bool isForeground() const { return _isForeground; }
|
bool isForeground() const { return _isForeground; }
|
||||||
|
@ -270,6 +271,8 @@ public slots:
|
||||||
|
|
||||||
void cycleCamera();
|
void cycleCamera();
|
||||||
void cameraMenuChanged();
|
void cameraMenuChanged();
|
||||||
|
void toggleOverlays();
|
||||||
|
void setOverlaysVisible(bool visible);
|
||||||
|
|
||||||
void reloadResourceCaches();
|
void reloadResourceCaches();
|
||||||
|
|
||||||
|
@ -509,7 +512,6 @@ private:
|
||||||
int _avatarAttachmentRequest = 0;
|
int _avatarAttachmentRequest = 0;
|
||||||
|
|
||||||
bool _settingsLoaded { false };
|
bool _settingsLoaded { false };
|
||||||
bool _pendingPaint { false };
|
|
||||||
QTimer* _idleTimer { nullptr };
|
QTimer* _idleTimer { nullptr };
|
||||||
|
|
||||||
bool _fakedMouseEvent { false };
|
bool _fakedMouseEvent { false };
|
||||||
|
|
|
@ -247,6 +247,9 @@ Menu::Menu() {
|
||||||
0, true, qApp, SLOT(rotationModeChanged()),
|
0, true, qApp, SLOT(rotationModeChanged()),
|
||||||
UNSPECIFIED_POSITION, "Advanced");
|
UNSPECIFIED_POSITION, "Advanced");
|
||||||
|
|
||||||
|
// View > Overlays
|
||||||
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Overlays, 0, true,
|
||||||
|
qApp, SLOT(setOverlaysVisible(bool)));
|
||||||
|
|
||||||
// Navigate menu ----------------------------------
|
// Navigate menu ----------------------------------
|
||||||
MenuWrapper* navigateMenu = addMenu("Navigate");
|
MenuWrapper* navigateMenu = addMenu("Navigate");
|
||||||
|
|
|
@ -247,6 +247,7 @@ namespace MenuOption {
|
||||||
const QString OnePointCalibration = "1 Point Calibration";
|
const QString OnePointCalibration = "1 Point Calibration";
|
||||||
const QString OnlyDisplayTopTen = "Only Display Top Ten";
|
const QString OnlyDisplayTopTen = "Only Display Top Ten";
|
||||||
const QString OutputMenu = "Display";
|
const QString OutputMenu = "Display";
|
||||||
|
const QString Overlays = "Overlays";
|
||||||
const QString PackageModel = "Package Model...";
|
const QString PackageModel = "Package Model...";
|
||||||
const QString Pair = "Pair";
|
const QString Pair = "Pair";
|
||||||
const QString PhysicsShowHulls = "Draw Collision Hulls";
|
const QString PhysicsShowHulls = "Draw Collision Hulls";
|
||||||
|
|
|
@ -131,7 +131,7 @@ private:
|
||||||
float _textureAspectRatio { 1.0f };
|
float _textureAspectRatio { 1.0f };
|
||||||
int _hemiVerticesID { GeometryCache::UNKNOWN_ID };
|
int _hemiVerticesID { GeometryCache::UNKNOWN_ID };
|
||||||
|
|
||||||
float _alpha { 1.0f };
|
float _alpha { 0.0f }; // hidden by default
|
||||||
float _prevAlpha { 1.0f };
|
float _prevAlpha { 1.0f };
|
||||||
float _fadeInAlpha { true };
|
float _fadeInAlpha { true };
|
||||||
float _oculusUIRadius { 1.0f };
|
float _oculusUIRadius { 1.0f };
|
||||||
|
|
|
@ -58,10 +58,6 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
||||||
|
|
||||||
// TODO move to Application::idle()?
|
|
||||||
Stats::getInstance()->updateStats();
|
|
||||||
AvatarInputs::getInstance()->update();
|
|
||||||
|
|
||||||
buildFramebufferObject();
|
buildFramebufferObject();
|
||||||
|
|
||||||
if (!_overlayFramebuffer) {
|
if (!_overlayFramebuffer) {
|
||||||
|
|
|
@ -110,19 +110,12 @@ void OverlayConductor::setEnabled(bool enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, enabled);
|
||||||
|
|
||||||
|
_enabled = enabled; // set the new value
|
||||||
|
|
||||||
|
// if the new state is visible/enabled...
|
||||||
if (_enabled) {
|
if (_enabled) {
|
||||||
// alpha fadeOut the overlay mesh.
|
|
||||||
qApp->getApplicationCompositor().fadeOut();
|
|
||||||
|
|
||||||
// disable mouse clicks from script
|
|
||||||
qApp->getOverlays().disable();
|
|
||||||
|
|
||||||
// disable QML events
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
offscreenUi->getRootItem()->setEnabled(false);
|
|
||||||
|
|
||||||
_enabled = false;
|
|
||||||
} else {
|
|
||||||
// alpha fadeIn the overlay mesh.
|
// alpha fadeIn the overlay mesh.
|
||||||
qApp->getApplicationCompositor().fadeIn();
|
qApp->getApplicationCompositor().fadeIn();
|
||||||
|
|
||||||
|
@ -142,8 +135,16 @@ void OverlayConductor::setEnabled(bool enabled) {
|
||||||
t.setRotation(glm::quat_cast(camMat));
|
t.setRotation(glm::quat_cast(camMat));
|
||||||
qApp->getApplicationCompositor().setModelTransform(t);
|
qApp->getApplicationCompositor().setModelTransform(t);
|
||||||
}
|
}
|
||||||
|
} else { // other wise, if the new state is hidden/not enabled
|
||||||
|
// alpha fadeOut the overlay mesh.
|
||||||
|
qApp->getApplicationCompositor().fadeOut();
|
||||||
|
|
||||||
_enabled = true;
|
// disable mouse clicks from script
|
||||||
|
qApp->getOverlays().disable();
|
||||||
|
|
||||||
|
// disable QML events
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
offscreenUi->getRootItem()->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ private:
|
||||||
STANDING
|
STANDING
|
||||||
};
|
};
|
||||||
|
|
||||||
Mode _mode = FLAT;
|
Mode _mode { FLAT };
|
||||||
bool _enabled = true;
|
bool _enabled { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace controller {
|
||||||
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
||||||
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
||||||
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
||||||
|
makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"),
|
||||||
|
|
||||||
makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"),
|
makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"),
|
||||||
makeAxisPair(Action::RETICLE_X, "ReticleX"),
|
makeAxisPair(Action::RETICLE_X, "ReticleX"),
|
||||||
|
|
|
@ -52,6 +52,7 @@ enum class Action {
|
||||||
CONTEXT_MENU,
|
CONTEXT_MENU,
|
||||||
TOGGLE_MUTE,
|
TOGGLE_MUTE,
|
||||||
CYCLE_CAMERA,
|
CYCLE_CAMERA,
|
||||||
|
TOGGLE_OVERLAY,
|
||||||
|
|
||||||
SHIFT,
|
SHIFT,
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setModelTransform(transToCenter); // we want to include the scale as well
|
batch.setModelTransform(transToCenter); // we want to include the scale as well
|
||||||
if (_procedural->ready()) {
|
if (_procedural && _procedural->ready()) {
|
||||||
_procedural->prepare(batch, getPosition(), getDimensions());
|
_procedural->prepare(batch, getPosition(), getDimensions());
|
||||||
auto color = _procedural->getColor(cubeColor);
|
auto color = _procedural->getColor(cubeColor);
|
||||||
batch._glColor4f(color.r, color.g, color.b, color.a);
|
batch._glColor4f(color.r, color.g, color.b, color.a);
|
||||||
|
|
|
@ -130,7 +130,7 @@ void Light::setShowContour(float show) {
|
||||||
if (show <= 0.f) {
|
if (show <= 0.f) {
|
||||||
show = 0.0f;
|
show = 0.0f;
|
||||||
}
|
}
|
||||||
editSchema()._control.w = show;
|
editSchema()._control.z = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Light::setAmbientSphere(const gpu::SphericalHarmonics& sphere) {
|
void Light::setAmbientSphere(const gpu::SphericalHarmonics& sphere) {
|
||||||
|
@ -140,3 +140,7 @@ void Light::setAmbientSphere(const gpu::SphericalHarmonics& sphere) {
|
||||||
void Light::setAmbientSpherePreset(gpu::SphericalHarmonics::Preset preset) {
|
void Light::setAmbientSpherePreset(gpu::SphericalHarmonics::Preset preset) {
|
||||||
editSchema()._ambientSphere.assignPreset(preset);
|
editSchema()._ambientSphere.assignPreset(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Light::setAmbientMapNumMips(int numMips) {
|
||||||
|
editSchema()._ambientMapNumMips = numMips;
|
||||||
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
// For editing purpose, show the light volume contour.
|
// For editing purpose, show the light volume contour.
|
||||||
// Set to non 0 to show it, the value is used as the intensity of the contour color
|
// Set to non 0 to show it, the value is used as the intensity of the contour color
|
||||||
void setShowContour(float show);
|
void setShowContour(float show);
|
||||||
float getShowContour() const { return getSchema()._control.w; }
|
float getShowContour() const { return getSchema()._control.z; }
|
||||||
|
|
||||||
// If the light has an ambient (Indirect) component, then the Ambientintensity can be used to control its contribution to the lighting
|
// If the light has an ambient (Indirect) component, then the Ambientintensity can be used to control its contribution to the lighting
|
||||||
void setAmbientIntensity(float intensity);
|
void setAmbientIntensity(float intensity);
|
||||||
|
@ -108,6 +108,9 @@ public:
|
||||||
const gpu::SphericalHarmonics& getAmbientSphere() const { return getSchema()._ambientSphere; }
|
const gpu::SphericalHarmonics& getAmbientSphere() const { return getSchema()._ambientSphere; }
|
||||||
void setAmbientSpherePreset(gpu::SphericalHarmonics::Preset preset);
|
void setAmbientSpherePreset(gpu::SphericalHarmonics::Preset preset);
|
||||||
|
|
||||||
|
void setAmbientMapNumMips(int numMips);
|
||||||
|
int getAmbientMapNumMips() const { return getSchema()._ambientMapNumMips; }
|
||||||
|
|
||||||
// Schema to access the attribute values of the light
|
// Schema to access the attribute values of the light
|
||||||
class Schema {
|
class Schema {
|
||||||
public:
|
public:
|
||||||
|
@ -120,7 +123,8 @@ public:
|
||||||
Vec4 _spot{0.0f, 0.0f, 0.0f, 0.0f};
|
Vec4 _spot{0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
Vec4 _shadow{0.0f};
|
Vec4 _shadow{0.0f};
|
||||||
|
|
||||||
Vec4 _control{0.0f, 0.0f, 0.0f, 0.0f};
|
int _ambientMapNumMips{ 0 };
|
||||||
|
Vec3 _control{ 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
gpu::SphericalHarmonics _ambientSphere;
|
gpu::SphericalHarmonics _ambientSphere;
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,6 +109,10 @@ SphericalHarmonics getLightAmbientSphere(Light l) {
|
||||||
return l._ambientSphere;
|
return l._ambientSphere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getLightAmbientMapNumMips(Light l) {
|
||||||
|
return l._control.x;
|
||||||
|
}
|
||||||
|
|
||||||
<@if GPU_FEATURE_PROFILE == GPU_CORE @>
|
<@if GPU_FEATURE_PROFILE == GPU_CORE @>
|
||||||
uniform lightBuffer {
|
uniform lightBuffer {
|
||||||
Light light;
|
Light light;
|
||||||
|
|
|
@ -142,6 +142,8 @@ SunSkyStage::SunSkyStage() :
|
||||||
_skybox(std::make_shared<Skybox>())
|
_skybox(std::make_shared<Skybox>())
|
||||||
{
|
{
|
||||||
_sunLight->setType(Light::SUN);
|
_sunLight->setType(Light::SUN);
|
||||||
|
// Default ambient sphere (for lack of skybox)
|
||||||
|
_sunLight->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset::OLD_TOWN_SQUARE);
|
||||||
|
|
||||||
setSunIntensity(1.0f);
|
setSunIntensity(1.0f);
|
||||||
setSunAmbientIntensity(0.5f);
|
setSunAmbientIntensity(0.5f);
|
||||||
|
|
|
@ -35,8 +35,7 @@ struct DeferredTransform {
|
||||||
mat4 projection;
|
mat4 projection;
|
||||||
mat4 viewInverse;
|
mat4 viewInverse;
|
||||||
float stereoSide;
|
float stereoSide;
|
||||||
float skyboxMipmapLevels;
|
vec3 _spareABC;
|
||||||
vec2 _spareAB;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(std140) uniform deferredTransformBuffer {
|
layout(std140) uniform deferredTransformBuffer {
|
||||||
|
|
|
@ -37,7 +37,7 @@ vec4 evalSkyboxLight(vec3 direction, float lod) {
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
|
||||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, vec3(metallic), roughness);
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, metallic, vec3(metallic), roughness);
|
||||||
color = vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
vec3 color = vec3(albedo * shading.w + shading.rgb) * min(shadowAttenuation, obscurance) * getLightColor(light) * getLightIntensity(light);
|
||||||
color += emissive;
|
color += emissive;
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
<$prepareGlobalLight()$>
|
<$prepareGlobalLight()$>
|
||||||
|
|
||||||
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
||||||
float lod = min(1.0 + floor((1.0 - gloss) * levels), levels);
|
float levels = getLightAmbientMapNumMips(light);
|
||||||
|
float lod = min(1.0 + floor((roughness) * levels), levels);
|
||||||
vec4 skyboxLight = evalSkyboxLight(direction, lod);
|
vec4 skyboxLight = evalSkyboxLight(direction, lod);
|
||||||
color += albedo * skyboxLight.rgb * skyboxLight.a * obscurance * getLightAmbientIntensity(light);
|
color += albedo * skyboxLight.rgb * skyboxLight.a * obscurance * getLightAmbientIntensity(light);
|
||||||
|
|
||||||
|
@ -73,7 +74,6 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
|
|
||||||
<@func declareEvalLightmappedColor()@>
|
<@func declareEvalLightmappedColor()@>
|
||||||
vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 normal, vec3 albedo, vec3 lightmap) {
|
vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 normal, vec3 albedo, vec3 lightmap) {
|
||||||
vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 normal, vec3 diffuse, vec3 lightmap) {
|
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
|
|
||||||
// Catch normals perpendicular to the projection plane, hence the magic number for the threshold
|
// Catch normals perpendicular to the projection plane, hence the magic number for the threshold
|
||||||
|
|
|
@ -87,6 +87,8 @@ void DeferredLightingEffect::init() {
|
||||||
_allocatedLights.push_back(std::make_shared<model::Light>());
|
_allocatedLights.push_back(std::make_shared<model::Light>());
|
||||||
|
|
||||||
model::LightPointer lp = _allocatedLights[0];
|
model::LightPointer lp = _allocatedLights[0];
|
||||||
|
lp->setType(model::Light::SUN);
|
||||||
|
|
||||||
// Add the global light to the light stage (for later shadow rendering)
|
// Add the global light to the light stage (for later shadow rendering)
|
||||||
_lightStage.addLight(lp);
|
_lightStage.addLight(lp);
|
||||||
|
|
||||||
|
@ -318,18 +320,18 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
||||||
// Setup the global directional pass pipeline
|
// Setup the global directional pass pipeline
|
||||||
{
|
{
|
||||||
if (_shadowMapEnabled) {
|
if (_shadowMapEnabled) {
|
||||||
if (_skyboxTexture) {
|
/* if (_skyboxTexture) {
|
||||||
program = _directionalSkyboxLightShadow;
|
program = _directionalSkyboxLightShadow;
|
||||||
locations = _directionalSkyboxLightShadowLocations;
|
locations = _directionalSkyboxLightShadowLocations;
|
||||||
} else {
|
} else {*/
|
||||||
program = _directionalAmbientSphereLightShadow;
|
program = _directionalAmbientSphereLightShadow;
|
||||||
locations = _directionalAmbientSphereLightShadowLocations;
|
locations = _directionalAmbientSphereLightShadowLocations;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_skyboxTexture) {
|
/* if (_skyboxTexture) {
|
||||||
program = _directionalSkyboxLight;
|
program = _directionalSkyboxLight;
|
||||||
locations = _directionalSkyboxLightLocations;
|
locations = _directionalSkyboxLightLocations;
|
||||||
} else {
|
} else {*/
|
||||||
program = _directionalAmbientSphereLight;
|
program = _directionalAmbientSphereLight;
|
||||||
locations = _directionalAmbientSphereLightLocations;
|
locations = _directionalAmbientSphereLightLocations;
|
||||||
}
|
}
|
||||||
|
@ -560,16 +562,17 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) {
|
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) {
|
||||||
_allocatedLights.front() = light;
|
auto globalLight = _allocatedLights.front();
|
||||||
|
globalLight->setDirection(light->getDirection());
|
||||||
|
globalLight->setColor(light->getColor());
|
||||||
|
globalLight->setIntensity(light->getIntensity());
|
||||||
|
globalLight->setAmbientIntensity(light->getAmbientIntensity());
|
||||||
|
globalLight->setAmbientSphere(light->getAmbientSphere());
|
||||||
|
|
||||||
_skyboxTexture = skyboxTexture;
|
_skyboxTexture = skyboxTexture;
|
||||||
|
|
||||||
// Update the available mipmap levels
|
// Update the available mipmap levels
|
||||||
if (_skyboxTexture) {
|
globalLight->setAmbientMapNumMips((_skyboxTexture ? _skyboxTexture->evalNumMips() : 0));
|
||||||
float dim = glm::max(_skyboxTexture->getHeight(), _skyboxTexture->getWidth(), _skyboxTexture->getDepth());
|
|
||||||
auto skyboxMipmapLevels = 1 + glm::floor(glm::log2(dim));
|
|
||||||
_deferredTransformBuffer[0].edit<DeferredTransform>().skyboxMipmapLevels = skyboxMipmapLevels;
|
|
||||||
_deferredTransformBuffer[1].edit<DeferredTransform>().skyboxMipmapLevels = skyboxMipmapLevels;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
||||||
|
|
|
@ -104,8 +104,7 @@ private:
|
||||||
glm::mat4 projection;
|
glm::mat4 projection;
|
||||||
glm::mat4 viewInverse;
|
glm::mat4 viewInverse;
|
||||||
float stereoSide { 0.f };
|
float stereoSide { 0.f };
|
||||||
float skyboxMipmapLevels { 1.0f };
|
float spareA, spareB, spareC;
|
||||||
float spareA, spareB;
|
|
||||||
|
|
||||||
DeferredTransform() {}
|
DeferredTransform() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,8 +47,7 @@ void main(void) {
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
frag.metallic,
|
frag.metallic,
|
||||||
frag.emissive,
|
frag.emissive,
|
||||||
frag.roughness,
|
frag.roughness);
|
||||||
deferredTransform.skyboxMipmapLevels);
|
|
||||||
|
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,7 @@ void main(void) {
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
frag.metallic,
|
frag.metallic,
|
||||||
frag.emissive,
|
frag.emissive,
|
||||||
frag.roughness,
|
frag.roughness);
|
||||||
deferredTransform.skyboxMipmapLevels);
|
|
||||||
|
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,6 +460,7 @@ void OffscreenUi::unfocusWindows() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::toggleMenu(const QPoint& screenPosition) {
|
void OffscreenUi::toggleMenu(const QPoint& screenPosition) {
|
||||||
|
emit showDesktop(); // we really only want to do this if you're showing the menu, but for now this works
|
||||||
auto virtualPos = mapToVirtualScreen(screenPosition, nullptr);
|
auto virtualPos = mapToVirtualScreen(screenPosition, nullptr);
|
||||||
QMetaObject::invokeMethod(_desktop, "toggleMenu", Q_ARG(QVariant, virtualPos));
|
QMetaObject::invokeMethod(_desktop, "toggleMenu", Q_ARG(QVariant, virtualPos));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue