3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 23:15:31 +02:00

Merge branch 'master' into bias

This commit is contained in:
Sam Gondelman 2019-07-03 10:20:16 -07:00 committed by GitHub
commit 0d9f639331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 598 additions and 435 deletions
interface/src
launchers/win32
libraries
avatars-renderer/src/avatars-renderer
display-plugins/src/display-plugins
entities-renderer/src
entities/src
gpu/src/gpu
networking/src/udt
plugins/src/plugins
render-utils/src
render/src/render
plugins/oculus/src
script-archive/example/ui
scripts
simplifiedUI
system
ui/simplifiedNametag/resources/modules
system
create
assets/data
entityProperties/html/js
libraries

View file

@ -1345,9 +1345,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
connect(this, &Application::activeDisplayPluginChanged, this, [](){
connect(this, &Application::activeDisplayPluginChanged, this, [=](){
qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
auto displayPlugin = qApp->getActiveDisplayPlugin();
if (displayPlugin->isHmd()) {
if (_preferredCursor.get() == Cursor::Manager::getIconName(Cursor::Icon::RETICLE)) {
setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::RETICLE));
}
else {
setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::ARROW));
}
}
else {
setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM));
}
setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString());
setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0");
});

View file

@ -108,8 +108,8 @@ void WorldBoxRenderData::renderWorldBox(RenderArgs* args, gpu::Batch& batch) {
glm::vec3(HALF_TREE_SCALE, 0.0f, HALF_TREE_SCALE), GREY,
geometryIds[17]);
geometryCache->renderWireCubeInstance(args, batch, GREY4);
auto pipeline = geometryCache->getShapePipelinePointer(false, false, args->_renderMethod == render::Args::RenderMethod::FORWARD);
geometryCache->renderWireCubeInstance(args, batch, GREY4, pipeline);
// Draw meter markers along the 3 axis to help with measuring things
const float MARKER_DISTANCE = 1.0f;
@ -117,22 +117,22 @@ void WorldBoxRenderData::renderWorldBox(RenderArgs* args, gpu::Batch& batch) {
transform = Transform().setScale(MARKER_RADIUS);
batch.setModelTransform(transform);
geometryCache->renderSolidSphereInstance(args, batch, RED);
geometryCache->renderSolidSphereInstance(args, batch, RED, pipeline);
transform = Transform().setTranslation(glm::vec3(MARKER_DISTANCE, 0.0f, 0.0f)).setScale(MARKER_RADIUS);
batch.setModelTransform(transform);
geometryCache->renderSolidSphereInstance(args, batch, RED);
geometryCache->renderSolidSphereInstance(args, batch, RED, pipeline);
transform = Transform().setTranslation(glm::vec3(0.0f, MARKER_DISTANCE, 0.0f)).setScale(MARKER_RADIUS);
batch.setModelTransform(transform);
geometryCache->renderSolidSphereInstance(args, batch, GREEN);
geometryCache->renderSolidSphereInstance(args, batch, GREEN, pipeline);
transform = Transform().setTranslation(glm::vec3(0.0f, 0.0f, MARKER_DISTANCE)).setScale(MARKER_RADIUS);
batch.setModelTransform(transform);
geometryCache->renderSolidSphereInstance(args, batch, BLUE);
geometryCache->renderSolidSphereInstance(args, batch, BLUE, pipeline);
transform = Transform().setTranslation(glm::vec3(MARKER_DISTANCE, 0.0f, MARKER_DISTANCE)).setScale(MARKER_RADIUS);
batch.setModelTransform(transform);
geometryCache->renderSolidSphereInstance(args, batch, GREY);
geometryCache->renderSolidSphereInstance(args, batch, GREY, pipeline);
}

View file

@ -143,10 +143,6 @@ void Snapshot::save360Snapshot(const glm::vec3& cameraPosition,
secondaryCameraRenderConfig->enableSecondaryCameraRenderConfigs(true);
}
// Initialize some secondary camera render config options for 360 snapshot capture
static_cast<ToneMappingConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("SecondaryCameraJob.ToneMapping"))
->setCurve(0);
secondaryCameraRenderConfig->resetSizeSpectatorCamera(static_cast<int>(CUBEMAP_SIDE_PIXEL_DIMENSION),
static_cast<int>(CUBEMAP_SIDE_PIXEL_DIMENSION));
secondaryCameraRenderConfig->setProperty("attachedEntityId", "");
@ -209,7 +205,6 @@ void Snapshot::takeNextSnapshot() {
// Reset secondary camera render config
SecondaryCameraJobConfig* config = static_cast<SecondaryCameraJobConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("SecondaryCamera"));
static_cast<ToneMappingConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("SecondaryCameraJob.ToneMapping"))->setCurve(1);
config->resetSizeSpectatorCamera(qApp->getWindow()->geometry().width(), qApp->getWindow()->geometry().height());
config->setProperty("attachedEntityId", _oldAttachedEntityId);
config->setProperty("vFoV", _oldvFoV);

View file

@ -21,6 +21,7 @@
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@ -103,7 +104,7 @@ BEGIN
CTEXT "",IDC_MESSAGE2_LABEL,35,172,239,15,NOT WS_VISIBLE
CTEXT "",IDC_ACTION2_LABEL,15,147,278,25,NOT WS_VISIBLE
RTEXT "",IDC_TERMS,15,172,180,15,NOT WS_VISIBLE
CONTROL "",IDC_TERMS_LINK,"Button", BS_OWNERDRAW | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,197,172,80,15
CONTROL "",IDC_TERMS_LINK,"Button",BS_OWNERDRAW | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,197,172,80,15
CTEXT "",IDC_TROUBLE,65,203,174,15,NOT WS_VISIBLE
CONTROL "NEXT",IDC_BUTTON_NEXT,"Button",BS_OWNERDRAW | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,107,158,94,16
CONTROL "Having Trouble?",IDC_TROUBLE_LINK,"Button",BS_OWNERDRAW | BS_FLAT | NOT WS_VISIBLE | WS_TABSTOP,126,203,56,11

View file

@ -32,19 +32,31 @@ CLauncherApp theApp;
// CLauncherApp initialization
BOOL CLauncherApp::InitInstance() {
// don't launch if already running
CreateMutex(NULL, TRUE, _T("HQ_Launcher_Mutex"));
if (GetLastError() == ERROR_ALREADY_EXISTS) {
return FALSE;
}
int iNumOfArgs;
LPWSTR* pArgs = CommandLineToArgvW(GetCommandLine(), &iNumOfArgs);
if (iNumOfArgs > 1 && CString(pArgs[1]).Compare(_T("--uninstall")) == 0) {
bool isUninstalling = false;
bool isRestarting = false;
if (iNumOfArgs > 1) {
if (CString(pArgs[1]).Compare(_T("--uninstall")) == 0) {
isUninstalling = true;
} else if (CString(pArgs[1]).Compare(_T("--restart")) == 0) {
isRestarting = true;
}
}
if (!isRestarting) {
// don't launch if already running
CreateMutex(NULL, TRUE, _T("HQ_Launcher_Mutex"));
if (GetLastError() == ERROR_ALREADY_EXISTS) {
return FALSE;
}
}
if (isUninstalling) {
_manager.uninstall();
} else {
_manager.init();
}
if (!_manager.installLauncher()) {
if (!_manager.hasFailed() && !_manager.installLauncher()) {
return FALSE;
}
installFont(IDR_FONT_REGULAR);

View file

@ -207,6 +207,9 @@ void CLauncherDlg::startProcess() {
default:
break;
}
if (error != LauncherUtils::DeleteDirError::NoErrorDeleting) {
theApp._manager.setFailed(true);
}
});
}
@ -230,7 +233,15 @@ afx_msg void CLauncherDlg::OnTermsClicked() {
}
afx_msg void CLauncherDlg::OnNextClicked() {
if (_drawStep != DrawStep::DrawChoose) {
if (_drawStep == DrawStep::DrawChoose) {
CString displayName;
m_username.GetWindowTextW(displayName);
theApp._manager.setDisplayName(displayName);
theApp._manager.addToLog(_T("Setting display name: " + displayName));
startProcess();
} else if (_drawStep == DrawStep::DrawError) {
theApp._manager.restartLauncher();
} else {
CString token;
CString username, password, orgname;
m_orgname.GetWindowTextW(orgname);
@ -261,12 +272,6 @@ afx_msg void CLauncherDlg::OnNextClicked() {
setDrawDialog(DrawStep::DrawLoginErrorOrg);
}
}
} else {
CString displayName;
m_username.GetWindowTextW(displayName);
theApp._manager.setDisplayName(displayName);
theApp._manager.addToLog(_T("Setting display name: " + displayName));
startProcess();
}
}
@ -318,7 +323,6 @@ void CLauncherDlg::drawVoxel(CHwndRenderTarget* pRenderTarget) {
pRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity());
}
void CLauncherDlg::showWindows(std::vector<CStatic*> windows, bool show) {
for (auto window : windows) {
window->ShowWindow(show ? SW_SHOW : SW_HIDE);
@ -342,7 +346,7 @@ void CLauncherDlg::prepareLogin(DrawStep step) {
m_password.ShowWindow(SW_SHOW);
CString actionText = step == DrawStep::DrawLoginLogin ? _T("Please log in") : _T("Uh-oh, we have a problem");
CString messageText = step == DrawStep::DrawLoginLogin ? _T("Be sure you've uploaded your Avatar before signing in.") :
step == DrawStep::DrawLoginErrorCred ? _T("There is a problem with your credentials\n please try again.") : _T("There is a problem with your Organization name\n please try again.");
step == DrawStep::DrawLoginErrorCred ? _T("There is a problem with your credentials.\n Please try again.") : _T("There is a problem with your Organization name.\n Please try again.");
m_action_label->SetWindowTextW(actionText);
m_message_label->SetWindowTextW(messageText);
m_action_label->ShowWindow(SW_SHOW);
@ -354,7 +358,6 @@ void CLauncherDlg::prepareLogin(DrawStep step) {
}
void CLauncherDlg::prepareChoose() {
m_orgname.ShowWindow(SW_HIDE);
m_username.SetWindowTextW(_T(""));
@ -371,14 +374,7 @@ void CLauncherDlg::prepareChoose() {
m_terms_link.ShowWindow(SW_SHOW);
m_terms->SetWindowTextW(_T("By signing in, you agree to the High Fidelity"));
m_terms_link.SetWindowTextW(_T("Terms of Service"));
CRect rec;
m_btnNext.GetWindowRect(&rec);
ScreenToClient(&rec);
if (rec.top > 281) {
rec.bottom -= 35;
rec.top -= 35;
m_btnNext.MoveWindow(rec, FALSE);
}
setVerticalElement(&m_btnNext, -35, 0, false);
m_btnNext.ShowWindow(SW_SHOW);
}
@ -401,6 +397,7 @@ void CLauncherDlg::prepareProcess(DrawStep step) {
m_voxel->ShowWindow(SW_SHOW);
CString actionText = _T("");
CString messageText = _T("");
switch (step) {
case DrawStep::DrawProcessSetup:
actionText = _T("We're building your virtual HQ");
@ -422,6 +419,15 @@ void CLauncherDlg::prepareProcess(DrawStep step) {
actionText = _T("Uninstalling...");
messageText = _T("It'll take one sec.");
break;
case DrawStep::DrawError:
actionText = _T("Uh oh.");
messageText = _T("We seem to have a problem.\nPlease restart HQ.");
setVerticalElement(m_message2_label, 0, 5, false);
setVerticalElement(&m_btnNext, 10);
m_btnNext.ShowWindow(SW_SHOW);
break;
default:
break;
}
m_action2_label->SetWindowTextW(actionText);
m_message2_label->SetWindowTextW(messageText);
@ -429,9 +435,6 @@ void CLauncherDlg::prepareProcess(DrawStep step) {
m_message2_label->ShowWindow(SW_SHOW);
}
void CLauncherDlg::prepareError() {
}
BOOL CLauncherDlg::getTextFormat(int resID, TextFormat& formatOut) {
// Set default values for message
BOOL isText = TRUE;
@ -523,6 +526,8 @@ void CLauncherDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
btnName += _drawStep == DrawStep::DrawLoginLogin ? _T("NEXT") : _T("LOG IN");
int xpan = -20;
defrect = CRect(rect.left - xpan, rect.top, rect.right + xpan, rect.bottom);
} else if (_drawStep == DrawStep::DrawError) {
btnName += _T("RESTART");
} else {
btnName += _T("TRY AGAIN");
}
@ -594,49 +599,86 @@ BOOL CLauncherDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) {
const int CONSOLE_MAX_SHUTDOWN_TRY_COUNT = 10;
const int CONSOLE_DELTATIME_BETWEEN_TRYS = 10;
if (_drawStep == DrawStep::DrawProcessSetup ||
_drawStep == DrawStep::DrawProcessUpdate ||
_drawStep == DrawStep::DrawProcessUninstall) {
// Refresh
setDrawDialog(_drawStep, true);
if (theApp._manager.hasFailed() && _drawStep != DrawStep::DrawError) {
theApp._manager.saveErrorLog();
prepareProcess(DrawStep::DrawError);
setDrawDialog(DrawStep::DrawError, false);
}
if (_showSplash) {
if (_splashStep == 0){
if (theApp._manager.needsUninstall()) {
theApp._manager.addToLog(_T("Waiting to uninstall"));
setDrawDialog(DrawStep::DrawProcessUninstall);
} else {
theApp._manager.addToLog(_T("Start splash screen"));
setDrawDialog(DrawStep::DrawLogo);
if (_drawStep != DrawStep::DrawError) {
if (_drawStep == DrawStep::DrawProcessSetup ||
_drawStep == DrawStep::DrawProcessUpdate ||
_drawStep == DrawStep::DrawProcessUninstall) {
// Refresh
setDrawDialog(_drawStep, true);
}
if (_showSplash) {
if (_splashStep == 0) {
if (theApp._manager.needsUninstall()) {
theApp._manager.addToLog(_T("Waiting to uninstall"));
setDrawDialog(DrawStep::DrawProcessUninstall);
}
else {
theApp._manager.addToLog(_T("Start splash screen"));
setDrawDialog(DrawStep::DrawLogo);
}
}
} else if (_splashStep > 100) {
_showSplash = false;
if (theApp._manager.shouldShutDown()) {
if (_applicationWND != NULL) {
::SetForegroundWindow(_applicationWND);
::SetActiveWindow(_applicationWND);
else if (_splashStep > 100) {
_showSplash = false;
if (theApp._manager.shouldShutDown()) {
if (_applicationWND != NULL) {
::SetForegroundWindow(_applicationWND);
::SetActiveWindow(_applicationWND);
}
if (LauncherUtils::IsProcessRunning(L"interface.exe")) {
exit(0);
}
}
if (LauncherUtils::IsProcessRunning(L"interface.exe")) {
exit(0);
else if (theApp._manager.needsUpdate()) {
startProcess();
}
} else if (theApp._manager.needsUpdate()) {
startProcess();
} else if (theApp._manager.needsUninstall()) {
theApp._manager.uninstallApplication();
else if (theApp._manager.needsUninstall()) {
if (theApp._manager.uninstallApplication()) {
theApp._manager.addToLog(_T("HQ uninstalled successfully."));
exit(0);
}
else {
theApp._manager.addToLog(_T("HQ failed to uninstall."));
theApp._manager.setFailed(true);
}
}
else {
theApp._manager.addToLog(_T("Starting login"));
setDrawDialog(DrawStep::DrawLoginLogin);
}
}
_splashStep++;
} else if (theApp._manager.shouldShutDown()) {
if (LauncherUtils::IsProcessRunning(L"interface.exe")) {
exit(0);
} else {
theApp._manager.addToLog(_T("Starting login"));
setDrawDialog(DrawStep::DrawLoginLogin);
}
}
_splashStep++;
} else if (theApp._manager.shouldShutDown()) {
if (LauncherUtils::IsProcessRunning(L"interface.exe")) {
exit(0);
if (theApp._manager.shouldLaunch()) {
_applicationWND = theApp._manager.launchApplication();
}
}
if (theApp._manager.shouldLaunch()) {
_applicationWND = theApp._manager.launchApplication();
}
void CLauncherDlg::setVerticalElement(CWnd* element, int verticalOffset, int heightOffset, bool fromMainWindowBottom) {
CRect elementRec;
CRect windowRec;
if (element != NULL) {
element->GetWindowRect(&elementRec);
ScreenToClient(&elementRec);
int offset = verticalOffset;
if (fromMainWindowBottom) {
GetWindowRect(&windowRec);
ScreenToClient(&windowRec);
int currentDistance = windowRec.bottom - elementRec.bottom;
offset = currentDistance - verticalOffset;
}
elementRec.bottom = elementRec.bottom + offset + heightOffset;
elementRec.top = elementRec.top + offset;
element->MoveWindow(elementRec, FALSE);
}
}
@ -671,6 +713,7 @@ void CLauncherDlg::setDrawDialog(DrawStep step, BOOL isUpdate) {
m_pRenderTarget->EndDraw();
RedrawWindow();
break;
case DrawStep::DrawError:
case DrawStep::DrawProcessFinishHq:
case DrawStep::DrawProcessFinishUpdate:
case DrawStep::DrawProcessUpdate:

View file

@ -43,19 +43,18 @@ public:
void setDrawDialog(DrawStep step, BOOL isUpdate = FALSE);
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_LAUNCHER_DIALOG };
#endif
protected:
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
void startProcess();
void setCustomDialog();
// Implementation
protected:
void setVerticalElement(CWnd* element, int verticalOffset, int heightOffset = 0, bool fromMainWindowBottom = true);
BOOL getHQInfo(const CString& orgname);
DrawStep _drawStep { DrawStep::DrawLogo };
@ -100,7 +99,6 @@ protected:
void prepareLogin(DrawStep step);
void prepareProcess(DrawStep step);
void prepareChoose();
void prepareError();
void redrawBanner(const CEdit& edit, CStatic* banner);

View file

@ -27,20 +27,28 @@ LauncherManager::~LauncherManager()
void LauncherManager::init() {
initLog();
addToLog(_T("Getting most recent build"));
getMostRecentBuild(_latestApplicationURL, _latestVersion);
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;
LauncherUtils::ResponseError error = getMostRecentBuild(_latestApplicationURL, _latestVersion);
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 {
_hasFailed = true;
CString msg;
msg.Format(_T("Getting most recent build has failed with error: %d"), error);
addToLog(msg);
}
}
BOOL LauncherManager::initLog() {
@ -74,8 +82,19 @@ void LauncherManager::closeLog() {
}
}
void LauncherManager::saveErrorLog() {
CString logPath = _logFile.GetFilePath();
CString errorLogPath;
auto result = getAndCreatePaths(PathType::Launcher_Directory, errorLogPath);
if (result) {
CString filename;
errorLogPath += _T("log_error.txt");
closeLog();
CopyFile(logPath, errorLogPath, FALSE);
}
}
BOOL LauncherManager::installLauncher() {
addToLog(_T("Installing Launcher."));
CString appPath;
BOOL result = getAndCreatePaths(PathType::Running_Path, appPath);
if (!result) {
@ -93,13 +112,14 @@ BOOL LauncherManager::installLauncher() {
if (!_shouldUninstall) {
// The installer is not running on the desired location and has to be installed
// Kill of running before self-copy
addToLog(_T("Installing Launcher."));
if (LauncherUtils::IsProcessRunning(LAUNCHER_EXE_FILENAME)) {
ShellExecute(NULL, NULL, L"taskkill", L"/F /T /IM " + LAUNCHER_EXE_FILENAME, NULL, SW_HIDE);
}
CopyFile(appPath, instalationPath, FALSE);
}
} else if (_shouldUninstall) {
addToLog(_T("Launching uninstall mode."));
addToLog(_T("Launching Uninstall mode."));
CString tempPath;
if (getAndCreatePaths(PathType::Temp_Directory, tempPath)) {
tempPath += _T("\\HQ_uninstaller_tmp.exe");
@ -111,6 +131,18 @@ BOOL LauncherManager::installLauncher() {
return TRUE;
}
BOOL LauncherManager::restartLauncher() {
addToLog(_T("Restarting Launcher."));
CString installDirectory;
if (getAndCreatePaths(PathType::Launcher_Directory, installDirectory)) {
CString installPath = installDirectory + LAUNCHER_EXE_FILENAME;
LauncherUtils::launchApplication(installPath, _T(" --restart"));
exit(0);
}
addToLog(_T("Error restarting Launcher."));
return FALSE;
}
BOOL LauncherManager::createShortcuts() {
CString desktopLnkPath;
addToLog(_T("Creating shortcuts."));
@ -395,8 +427,10 @@ BOOL LauncherManager::uninstallApplication() {
CString installDir;
getAndCreatePaths(PathType::Launcher_Directory, installDir);
BOOL success = LauncherUtils::deleteFileOrDirectory(installDir);
success = success && (deleteShortcuts());
success = success && (deleteApplicationRegistryKeys());
if (success) {
deleteShortcuts();
deleteApplicationRegistryKeys();
}
return success;
}
@ -425,7 +459,12 @@ BOOL LauncherManager::extractApplication() {
getAndCreatePaths(LauncherManager::PathType::Interface_Directory, installPath);
BOOL success = LauncherUtils::unzipFileOnThread(ZipType::ZipApplication, LauncherUtils::cStringToStd(_applicationZipPath),
LauncherUtils::cStringToStd(installPath), [&](int type, int size) {
onZipExtracted((ZipType)type, size);
if (size > 0) {
onZipExtracted((ZipType)type, size);
} else {
addToLog(_T("Error decompressing application zip file."));
_hasFailed = true;
}
});
if (success) {
addToLog(_T("Created thread for unzipping application."));
@ -452,7 +491,13 @@ BOOL LauncherManager::installContent() {
getAndCreatePaths(LauncherManager::PathType::Content_Directory, contentPath);
BOOL success = LauncherUtils::unzipFileOnThread(ZipType::ZipContent, contentZipFile,
LauncherUtils::cStringToStd(contentPath), [&](int type, int size) {
onZipExtracted((ZipType)type, size);
if (size > 0) {
addToLog(_T("Content zip decompresed."));
onZipExtracted((ZipType)type, size);
} else {
addToLog(_T("Error decompressing content zip file."));
_hasFailed = true;
}
});
if (success) {
addToLog(_T("Created thread for unzipping content."));
@ -469,8 +514,18 @@ BOOL LauncherManager::downloadFile(DownloadType type, const CString& url, CStrin
BOOL success = getAndCreatePaths(LauncherManager::PathType::Download_Directory, downloadDirectory);
outPath = downloadDirectory + fileName;
if (success) {
if (!LauncherUtils::downloadFileOnThread(type, url, outPath, [&](int type) {
onFileDownloaded((DownloadType)type);
addToLog(_T("Downloading: ") + url);
if (!LauncherUtils::downloadFileOnThread(type, url, outPath, [&](int type, bool error) {
if (!error) {
onFileDownloaded((DownloadType)type);
} else {
if (type == DownloadType::DownloadApplication) {
addToLog(_T("Error downloading content."));
} else {
addToLog(_T("Error downloading application."));
}
_hasFailed = true;
}
})) {
success = FALSE;
}

View file

@ -56,6 +56,7 @@ public:
BOOL initLog();
BOOL addToLog(const CString& line);
void closeLog();
void saveErrorLog();
BOOL getAndCreatePaths(PathType type, CString& outPath);
BOOL getInstalledVersion(const CString& path, CString& version);
BOOL isApplicationInstalled(CString& version, CString& domain,
@ -73,6 +74,7 @@ public:
HWND launchApplication();
BOOL uninstallApplication();
BOOL installLauncher();
BOOL restartLauncher();
// getters
const CString& getContentURL() const { return _contentURL; }
@ -84,6 +86,8 @@ public:
BOOL needsUninstall() { return _shouldUninstall; }
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; };
@ -106,6 +110,7 @@ private:
CString _applicationZipPath;
CString _contentZipPath;
bool _loggedIn{ false };
bool _hasFailed{ false };
BOOL _shouldUpdate{ FALSE };
BOOL _shouldUninstall{ FALSE };
BOOL _shouldShutdown{ FALSE };

View file

@ -258,38 +258,54 @@ uint64_t LauncherUtils::extractZip(const std::string& zipFile, const std::string
}
int fileCount = (int)mz_zip_reader_get_num_files(&zip_archive);
if (fileCount == 0) {
theApp._manager.addToLog(_T("Zip archive has a file count of 0"));
{
CString msg;
msg.Format(_T("Zip archive has a file count of %d"), fileCount);
theApp._manager.addToLog(msg);
}
if (fileCount == 0) {
mz_zip_reader_end(&zip_archive);
return 0;
}
mz_zip_archive_file_stat file_stat;
if (!mz_zip_reader_file_stat(&zip_archive, 0, &file_stat)) {
theApp._manager.addToLog(_T("Zip archive cannot be stat'd"));
mz_zip_reader_end(&zip_archive);
return 0;
}
// Get root folder
CString lastDir = _T("");
uint64_t totalSize = 0;
bool _shouldFail = false;
for (int i = 0; i < fileCount; i++) {
if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat)) continue;
std::string filename = file_stat.m_filename;
std::replace(filename.begin(), filename.end(), '/', '\\');
CString fullFilename = CString(path.c_str()) + "\\" + CString(filename.c_str());
if (mz_zip_reader_is_file_a_directory(&zip_archive, i)) {
if (SHCreateDirectoryEx(NULL, fullFilename, NULL) || ERROR_ALREADY_EXISTS == GetLastError()) {
break;
} else {
continue;
int error = SHCreateDirectoryEx(NULL, fullFilename, NULL);
if (error == ERROR_BAD_PATHNAME ||
error == ERROR_FILENAME_EXCED_RANGE ||
error == ERROR_PATH_NOT_FOUND ||
error == ERROR_CANCELLED) {
CString msg;
msg.Format(_T("Unzipping error: %d creating folder: %s"), error, fullFilename);
theApp._manager.addToLog(msg);
mz_zip_reader_end(&zip_archive);
return 0;
}
continue;
}
CT2A destFile(fullFilename);
if (mz_zip_reader_extract_to_file(&zip_archive, i, destFile, 0)) {
totalSize += (uint64_t)file_stat.m_uncomp_size;
files.emplace_back(destFile);
} else {
CString msg;
msg.Format(_T("Error unzipping the file: %s"), fullFilename);
theApp._manager.addToLog(msg);
_shouldFail = true;
}
}
@ -421,11 +437,10 @@ DWORD WINAPI LauncherUtils::unzipThread(LPVOID lpParameter) {
return 0;
}
DWORD WINAPI LauncherUtils::downloadThread(LPVOID lpParameter)
{
DWORD WINAPI LauncherUtils::downloadThread(LPVOID lpParameter) {
DownloadThreadData& data = *((DownloadThreadData*)lpParameter);
auto hr = URLDownloadToFile(0, data._url, data._file, 0, NULL);
data.callback(data._type);
data.callback(data._type, hr != S_OK);
return 0;
}
@ -457,7 +472,7 @@ BOOL LauncherUtils::unzipFileOnThread(int type, const std::string& zipFile, cons
return FALSE;
}
BOOL LauncherUtils::downloadFileOnThread(int type, const CString& url, const CString& file, std::function<void(int)> callback) {
BOOL LauncherUtils::downloadFileOnThread(int type, const CString& url, const CString& file, std::function<void(int, bool)> callback) {
DWORD myThreadID;
DownloadThreadData* downloadThreadData = new DownloadThreadData();
downloadThreadData->_type = type;

View file

@ -41,10 +41,10 @@ public:
int _type;
CString _url;
CString _file;
std::function<void(int)> callback;
// function(type)
void setCallback(std::function<void(int)> fn) {
callback = std::bind(fn, std::placeholders::_1);
std::function<void(int, bool)> callback;
// function(type, errorType)
void setCallback(std::function<void(int, bool)> fn) {
callback = std::bind(fn, std::placeholders::_1, std::placeholders::_2);
}
};
@ -82,7 +82,7 @@ public:
static uint64_t extractZip(const std::string& zipFile, const std::string& path, std::vector<std::string>& files);
static BOOL deleteRegistryKey(const CString& registryPath);
static BOOL unzipFileOnThread(int type, const std::string& zipFile, const std::string& path, std::function<void(int, int)> callback);
static BOOL downloadFileOnThread(int type, const CString& url, const CString& file, std::function<void(int)> callback);
static BOOL downloadFileOnThread(int type, const CString& url, const CString& file, std::function<void(int, bool)> callback);
static BOOL deleteDirectoriesOnThread(const CString& applicationDir,
const CString& downloadsDir,
std::function<void(int)> callback);

View file

@ -1108,7 +1108,7 @@ void Avatar::renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const
batch.setModelTransform(textTransform);
{
PROFILE_RANGE_BATCH(batch, __FUNCTION__":renderText");
renderer->draw(batch, text_x, -text_y, nameUTF8.data(), textColor, glm::vec2(-1.0f), forward);
renderer->draw(batch, text_x, -text_y, nameUTF8.data(), textColor, glm::vec2(-1.0f), true, forward);
}
}
}

View file

@ -331,18 +331,19 @@ void SkeletonModel::renderBoundingCollisionShapes(RenderArgs* args, gpu::Batch&
// draw a blue sphere at the capsule top point
glm::vec3 topPoint = _translation + _rotation * (scale * (_boundingCapsuleLocalOffset + (0.5f * _boundingCapsuleHeight) * Vectors::UNIT_Y));
batch.setModelTransform(Transform().setTranslation(topPoint).postScale(scale * _boundingCapsuleRadius));
geometryCache->renderSolidSphereInstance(args, batch, glm::vec4(0.6f, 0.6f, 0.8f, alpha));
auto pipeline = geometryCache->getShapePipelinePointer(alpha < 1.0f, false, args->_renderMethod == render::Args::RenderMethod::FORWARD);
geometryCache->renderSolidSphereInstance(args, batch, glm::vec4(0.6f, 0.6f, 0.8f, alpha), pipeline);
// draw a yellow sphere at the capsule bottom point
glm::vec3 bottomPoint = topPoint - _rotation * glm::vec3(0.0f, scale * _boundingCapsuleHeight, 0.0f);
batch.setModelTransform(Transform().setTranslation(bottomPoint).postScale(scale * _boundingCapsuleRadius));
geometryCache->renderSolidSphereInstance(args, batch, glm::vec4(0.8f, 0.8f, 0.6f, alpha));
geometryCache->renderSolidSphereInstance(args, batch, glm::vec4(0.8f, 0.8f, 0.6f, alpha), pipeline);
// draw a green cylinder between the two points
float capsuleDiameter = 2.0f * _boundingCapsuleRadius;
glm::vec3 cylinderDimensions = glm::vec3(capsuleDiameter, _boundingCapsuleHeight, capsuleDiameter);
batch.setModelTransform(Transform().setScale(scale * cylinderDimensions).setRotation(_rotation).setTranslation(0.5f * (topPoint + bottomPoint)));
geometryCache->renderSolidShapeInstance(args, batch, GeometryCache::Shape::Cylinder, glm::vec4(0.6f, 0.8f, 0.6f, alpha));
geometryCache->renderSolidShapeInstance(args, batch, GeometryCache::Shape::Cylinder, glm::vec4(0.6f, 0.8f, 0.6f, alpha), pipeline);
}
bool SkeletonModel::hasSkeleton() {

View file

@ -113,14 +113,8 @@ gpu::PipelinePointer Basic2DWindowOpenGLDisplayPlugin::getRenderTexturePipeline(
#if defined(Q_OS_ANDROID)
return _linearToSRGBPipeline;
#else
#ifndef USE_GLES
return _SRGBToLinearPipeline;
#else
return _drawTexturePipeline;
#endif
#endif
}
void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() {

View file

@ -392,13 +392,11 @@ void OpenGLDisplayPlugin::customizeContext() {
_drawTexturePipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTexture), scissorState);
_linearToSRGBPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureGammaLinearToSRGB), scissorState);
_linearToSRGBPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureLinearToSRGB), scissorState);
_SRGBToLinearPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureGammaSRGBToLinear), scissorState);
_SRGBToLinearPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureSRGBToLinear), scissorState);
_hudPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTexture), blendState);
_mirrorHUDPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureMirroredX), blendState);
_hudPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureSRGBToLinear), blendState);
_cursorPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTransformedTexture), blendState);
}
@ -413,7 +411,6 @@ void OpenGLDisplayPlugin::uncustomizeContext() {
_SRGBToLinearPipeline.reset();
_cursorPipeline.reset();
_hudPipeline.reset();
_mirrorHUDPipeline.reset();
_compositeFramebuffer.reset();
withPresentThreadLock([&] {
@ -582,20 +579,18 @@ void OpenGLDisplayPlugin::updateFrameData() {
});
}
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> OpenGLDisplayPlugin::getHUDOperator() {
std::function<void(gpu::Batch&, const gpu::TexturePointer&)> OpenGLDisplayPlugin::getHUDOperator() {
auto hudPipeline = _hudPipeline;
auto hudMirrorPipeline = _mirrorHUDPipeline;
auto hudStereo = isStereo();
auto hudCompositeFramebufferSize = _compositeFramebuffer->getSize();
std::array<glm::ivec4, 2> hudEyeViewports;
for_each_eye([&](Eye eye) {
hudEyeViewports[eye] = eyeViewport(eye);
});
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) {
auto pipeline = mirror ? hudMirrorPipeline : hudPipeline;
if (pipeline && hudTexture) {
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture) {
if (hudPipeline && hudTexture) {
batch.enableStereo(false);
batch.setPipeline(pipeline);
batch.setPipeline(hudPipeline);
batch.setResourceTexture(0, hudTexture);
if (hudStereo) {
for_each_eye([&](Eye eye) {
@ -642,7 +637,7 @@ void OpenGLDisplayPlugin::compositeScene() {
batch.setStateScissorRect(ivec4(uvec2(), _compositeFramebuffer->getSize()));
batch.resetViewTransform();
batch.setProjectionTransform(mat4());
batch.setPipeline(getCompositeScenePipeline());
batch.setPipeline(_drawTexturePipeline);
batch.setResourceTexture(0, _currentFrame->framebuffer->getRenderBuffer(0));
batch.draw(gpu::TRIANGLE_STRIP, 4);
});
@ -905,7 +900,7 @@ OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
auto renderSize = glm::uvec2(getRecommendedRenderSize());
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_RGBA_32, renderSize.x, renderSize.y));
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_SRGBA_32, renderSize.x, renderSize.y));
}
}
@ -964,7 +959,3 @@ gpu::PipelinePointer OpenGLDisplayPlugin::getRenderTexturePipeline() {
return _drawTexturePipeline;
}
gpu::PipelinePointer OpenGLDisplayPlugin::getCompositeScenePipeline() {
return _drawTexturePipeline;
}

View file

@ -80,7 +80,7 @@ public:
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
int getRequiredThreadCount() const override { return 3; }
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() override;
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&)> getHUDOperator() override;
void copyTextureToQuickFramebuffer(NetworkTexturePointer source,
QOpenGLFramebufferObject* target,
GLsync* fenceSync) override;
@ -162,7 +162,6 @@ protected:
float _compositeHUDAlpha{ 1.0f };
virtual gpu::PipelinePointer getRenderTexturePipeline();
virtual gpu::PipelinePointer getCompositeScenePipeline();
struct CursorData {
QImage image;

View file

@ -174,10 +174,6 @@ float HmdDisplayPlugin::getLeftCenterPixel() const {
return leftCenterPixel;
}
gpu::PipelinePointer HmdDisplayPlugin::getRenderTexturePipeline() {
return _SRGBToLinearPipeline;
}
void HmdDisplayPlugin::internalPresent() {
PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)presentCount())
@ -417,7 +413,7 @@ void HmdDisplayPlugin::HUDRenderer::build() {
pipeline = gpu::Pipeline::create(program, state);
}
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDisplayPlugin::HUDRenderer::render() {
std::function<void(gpu::Batch&, const gpu::TexturePointer&)> HmdDisplayPlugin::HUDRenderer::render() {
auto hudPipeline = pipeline;
auto hudFormat = format;
auto hudVertices = vertices;
@ -425,7 +421,7 @@ std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDis
auto hudUniformBuffer = uniformsBuffer;
auto hudUniforms = uniforms;
auto hudIndexCount = indexCount;
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) {
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture) {
if (hudPipeline && hudTexture) {
batch.setPipeline(hudPipeline);
@ -440,9 +436,6 @@ std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDis
auto compositorHelper = DependencyManager::get<CompositorHelper>();
glm::mat4 modelTransform = compositorHelper->getUiTransform();
if (mirror) {
modelTransform = glm::scale(modelTransform, glm::vec3(-1, 1, 1));
}
batch.setModelTransform(modelTransform);
batch.setResourceTexture(0, hudTexture);
@ -475,7 +468,7 @@ void HmdDisplayPlugin::compositePointer() {
});
}
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> HmdDisplayPlugin::getHUDOperator() {
std::function<void(gpu::Batch&, const gpu::TexturePointer&)> HmdDisplayPlugin::getHUDOperator() {
return _hudRenderer.render();
}

View file

@ -48,11 +48,9 @@ public:
void pluginUpdate() override {};
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() override;
std::function<void(gpu::Batch&, const gpu::TexturePointer&)> getHUDOperator() override;
virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::PAINT; }
virtual gpu::PipelinePointer getRenderTexturePipeline() override;
signals:
void hmdMountedChanged();
void hmdVisibleChanged(bool visible);
@ -125,6 +123,6 @@ private:
static const int VERTEX_STRIDE { sizeof(Vertex) };
void build();
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> render();
std::function<void(gpu::Batch&, const gpu::TexturePointer&)> render();
} _hudRenderer;
};

View file

@ -185,7 +185,7 @@ ItemKey EntityRenderer::getKey() {
}
}
uint32_t EntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) {
uint32_t EntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) const {
if (Item::isValidID(_renderItemID)) {
subItems.emplace_back(_renderItemID);
return 1;

View file

@ -62,7 +62,7 @@ public:
static glm::vec4 calculatePulseColor(const glm::vec4& color, const PulsePropertyGroup& pulseProperties, quint64 start);
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const override;
virtual Item::Bound getBound() override;
protected:

View file

@ -111,9 +111,9 @@ void ImageEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
void* key = (void*)this;
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity]() {
withWriteLock([&] {
_dimensions = entity->getScaledDimensions();
updateModelTransformAndBound();
_renderTransform = getModelTransform();
_renderTransform.postScale(entity->getScaledDimensions());
});
});
}
@ -152,14 +152,12 @@ void ImageEntityRenderer::doRender(RenderArgs* args) {
NetworkTexturePointer texture;
QRect subImage;
glm::vec4 color;
glm::vec3 dimensions;
Transform transform;
withReadLock([&] {
texture = _texture;
subImage = _subImage;
color = glm::vec4(toGlm(_color), _alpha);
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
dimensions = _dimensions;
transform = _renderTransform;
});
@ -171,7 +169,6 @@ void ImageEntityRenderer::doRender(RenderArgs* args) {
gpu::Batch* batch = args->_batch;
transform.setRotation(EntityItem::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode, args->getViewFrustum().getPosition()));
transform.postScale(dimensions);
batch->setModelTransform(transform);
batch->setResourceTexture(0, texture->getGPUTexture());
@ -200,16 +197,14 @@ void ImageEntityRenderer::doRender(RenderArgs* args) {
float maxSize = glm::max(fromImage.width(), fromImage.height());
float x = _keepAspectRatio ? fromImage.width() / (2.0f * maxSize) : 0.5f;
float y = _keepAspectRatio ? -fromImage.height() / (2.0f * maxSize) : -0.5f;
float y = _keepAspectRatio ? fromImage.height() / (2.0f * maxSize) : 0.5f;
glm::vec2 topLeft(-x, -y);
glm::vec2 bottomRight(x, y);
glm::vec2 texCoordTopLeft((fromImage.x() + 0.5f) / imageWidth, (fromImage.y() + 0.5f) / imageHeight);
glm::vec2 texCoordBottomRight((fromImage.x() + fromImage.width() - 0.5f) / imageWidth,
(fromImage.y() + fromImage.height() - 0.5f) / imageHeight);
glm::vec2 texCoordBottomLeft((fromImage.x() + 0.5f) / imageWidth, -(fromImage.y() + 0.5f) / imageHeight);
glm::vec2 texCoordTopRight((fromImage.x() + fromImage.width() - 0.5f) / imageWidth,
-(fromImage.y() + fromImage.height() - 0.5f) / imageHeight);
DependencyManager::get<GeometryCache>()->renderQuad(
*batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
*batch, glm::vec2(-x, -y), glm::vec2(x, y), texCoordBottomLeft, texCoordTopRight,
color, _geometryId
);

View file

@ -47,8 +47,6 @@ private:
PulsePropertyGroup _pulseProperties;
BillboardMode _billboardMode;
glm::vec3 _dimensions;
int _geometryId { 0 };
};

View file

@ -1073,7 +1073,7 @@ ItemKey ModelEntityRenderer::getKey() {
return _itemKey;
}
uint32_t ModelEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) {
uint32_t ModelEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) const {
if (_model) {
auto metaSubItems = _model->fetchRenderItemIDs();
subItems.insert(subItems.end(), metaSubItems.begin(), metaSubItems.end());
@ -1519,7 +1519,8 @@ void ModelEntityRenderer::doRender(RenderArgs* args) {
static glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
gpu::Batch& batch = *args->_batch;
batch.setModelTransform(getModelTransform()); // we want to include the scale as well
DependencyManager::get<GeometryCache>()->renderWireCubeInstance(args, batch, greenColor);
auto geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->renderWireCubeInstance(args, batch, greenColor, geometryCache->getShapePipelinePointer(false, false, args->_renderMethod == Args::RenderMethod::FORWARD));
#if WANT_EXTRA_DEBUGGING
ModelPointer model;

View file

@ -154,7 +154,7 @@ protected:
void setKey(bool didVisualGeometryRequestSucceed);
virtual ItemKey getKey() override;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const override;
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
virtual bool needsRenderUpdate() const override;

View file

@ -283,12 +283,8 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) {
} else if (!useMaterialPipeline(materials)) {
// FIXME, support instanced multi-shape rendering using multidraw indirect
outColor.a *= _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
render::ShapePipelinePointer pipeline;
if (renderLayer == RenderLayer::WORLD && args->_renderMethod != Args::RenderMethod::FORWARD) {
pipeline = outColor.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
} else {
pipeline = outColor.a < 1.0f ? geometryCache->getForwardTransparentShapePipeline() : geometryCache->getForwardOpaqueShapePipeline();
}
render::ShapePipelinePointer pipeline = geometryCache->getShapePipelinePointer(outColor.a < 1.0f, false,
renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD);
if (render::ShapeKey(args->_globalShapeKey).isWireframe() || primitiveMode == PrimitiveMode::LINES) {
geometryCache->renderWireShapeInstance(args, batch, geometryShape, outColor, pipeline);
} else {

View file

@ -31,6 +31,17 @@ const float LINE_SCALE_RATIO = 1.2f;
TextEntityRenderer::TextEntityRenderer(const EntityItemPointer& entity) :
Parent(entity),
_textRenderer(TextRenderer3D::getInstance(SANS_FONT_FAMILY, FIXED_FONT_POINT_SIZE / 2.0f)) {
auto geometryCache = DependencyManager::get<GeometryCache>();
if (geometryCache) {
_geometryID = geometryCache->allocateID();
}
}
TextEntityRenderer::~TextEntityRenderer() {
auto geometryCache = DependencyManager::get<GeometryCache>();
if (_geometryID && geometryCache) {
geometryCache->releaseID(_geometryID);
}
}
bool TextEntityRenderer::isTransparent() const {
@ -59,17 +70,20 @@ ItemKey TextEntityRenderer::getKey() {
}
ShapeKey TextEntityRenderer::getShapeKey() {
auto builder = render::ShapeKey::Builder();
auto builder = render::ShapeKey::Builder().withoutCullFace();
if (isTransparent()) {
builder.withTranslucent();
}
if (_unlit) {
builder.withUnlit();
}
if (_primitiveMode == PrimitiveMode::LINES) {
builder.withWireframe();
}
return builder.build();
}
uint32_t TextEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) {
uint32_t TextEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) const {
auto parentSubs = Parent::metaFetchMetaSubItems(subItems);
if (Item::isValidID(_textRenderID)) {
subItems.emplace_back(_textRenderID);
@ -127,6 +141,10 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
return true;
}
if (_unlit != entity->getUnlit()) {
return true;
}
if (_pulseProperties != entity->getPulseProperties()) {
return true;
}
@ -160,6 +178,7 @@ void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointe
_rightMargin = entity->getRightMargin();
_topMargin = entity->getTopMargin();
_bottomMargin = entity->getBottomMargin();
_unlit = entity->getUnlit();
updateTextRenderItem();
});
}
@ -193,17 +212,19 @@ void TextEntityRenderer::doRender(RenderArgs* args) {
batch.setModelTransform(modelTransform);
auto geometryCache = DependencyManager::get<GeometryCache>();
render::ShapePipelinePointer pipeline;
if (renderLayer == RenderLayer::WORLD && args->_renderMethod != Args::RenderMethod::FORWARD) {
pipeline = backgroundColor.a < 1.0f ? geometryCache->getTransparentShapePipeline() : geometryCache->getOpaqueShapePipeline();
} else {
pipeline = backgroundColor.a < 1.0f ? geometryCache->getForwardTransparentShapePipeline() : geometryCache->getForwardOpaqueShapePipeline();
}
if (render::ShapeKey(args->_globalShapeKey).isWireframe() || primitiveMode == PrimitiveMode::LINES) {
geometryCache->renderWireShapeInstance(args, batch, GeometryCache::Quad, backgroundColor, pipeline);
} else {
geometryCache->renderSolidShapeInstance(args, batch, GeometryCache::Quad, backgroundColor, pipeline);
}
// FIXME: we want to use instanced rendering here, but if textAlpha < 1 and backgroundAlpha < 1, the transparency sorting will be wrong
//render::ShapePipelinePointer pipeline = geometryCache->getShapePipelinePointer(backgroundColor.a < 1.0f, _unlit,
// renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD);
//if (render::ShapeKey(args->_globalShapeKey).isWireframe() || primitiveMode == PrimitiveMode::LINES) {
// geometryCache->renderWireShapeInstance(args, batch, GeometryCache::Quad, backgroundColor, pipeline);
//} else {
// geometryCache->renderSolidShapeInstance(args, batch, GeometryCache::Quad, backgroundColor, pipeline);
//}
geometryCache->renderQuad(batch, glm::vec2(-0.5), glm::vec2(0.5), backgroundColor, _geometryID);
const int TRIANBLES_PER_QUAD = 2;
args->_details._trianglesRendered += TRIANBLES_PER_QUAD;
}
QSizeF TextEntityRenderer::textSize(const QString& text) const {
@ -224,7 +245,6 @@ void TextEntityRenderer::onAddToSceneTyped(const TypedEntityPointer& entity) {
render::Transaction transaction;
transaction.resetItem(_textRenderID, renderPayload);
AbstractViewStateInterface::instance()->getMain3DScene()->enqueueTransaction(transaction);
updateTextRenderItem();
}
void TextEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity) {
@ -295,6 +315,9 @@ ShapeKey entities::TextPayload::getShapeKey() const {
if (textRenderable->isTextTransparent()) {
builder.withTranslucent();
}
if (textRenderable->_unlit) {
builder.withUnlit();
}
if (textRenderable->_primitiveMode == PrimitiveMode::LINES) {
builder.withWireframe();
}
@ -355,7 +378,7 @@ void entities::TextPayload::render(RenderArgs* args) {
batch.setModelTransform(modelTransform);
glm::vec2 bounds = glm::vec2(dimensions.x - (leftMargin + rightMargin), dimensions.y - (topMargin + bottomMargin));
textRenderer->draw(batch, leftMargin / scale, -topMargin / scale, text, textColor, bounds / scale, forward);
textRenderer->draw(batch, leftMargin / scale, -topMargin / scale, text, textColor, bounds / scale, textRenderable->_unlit, forward);
}
namespace render {

View file

@ -26,6 +26,7 @@ class TextEntityRenderer : public TypedEntityRenderer<TextEntityItem> {
using Pointer = std::shared_ptr<TextEntityRenderer>;
public:
TextEntityRenderer(const EntityItemPointer& entity);
~TextEntityRenderer();
QSizeF textSize(const QString& text) const;
@ -35,7 +36,7 @@ protected:
Item::Bound getBound() override;
ShapeKey getShapeKey() override;
ItemKey getKey() override;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const override;
void onAddToSceneTyped(const TypedEntityPointer& entity) override;
void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override;
@ -56,6 +57,7 @@ private:
float _textAlpha;
glm::vec3 _backgroundColor;
float _backgroundAlpha;
bool _unlit;
float _leftMargin;
float _rightMargin;
@ -65,6 +67,8 @@ private:
BillboardMode _billboardMode;
glm::vec3 _dimensions;
int _geometryID { 0 };
std::shared_ptr<TextPayload> _textPayload;
render::ItemID _textRenderID;
void updateTextRenderItem() const;

View file

@ -26,14 +26,14 @@ layout(location=3) in float _distanceFromCenter;
void main(void) {
vec4 texel = texture(_texture, _texCoord);
int frontCondition = 1 - 2 * int(gl_FrontFacing);
float frontCondition = 2.0 * float(gl_FrontFacing) - 1.0;
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);
packDeferredFragmentTranslucent(
float(frontCondition) * _normalWS,
_normalWS * frontCondition,
alpha,
color,
DEFAULT_ROUGHNESS);

View file

@ -527,6 +527,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_RIGHT_MARGIN, rightMargin);
CHECK_PROPERTY_CHANGE(PROP_TOP_MARGIN, topMargin);
CHECK_PROPERTY_CHANGE(PROP_BOTTOM_MARGIN, bottomMargin);
CHECK_PROPERTY_CHANGE(PROP_UNLIT, unlit);
// Zone
changedProperties += _keyLight.getChangedProperties();
@ -1284,6 +1285,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
* @property {number} rightMargin=0.0 - The right margin, in meters.
* @property {number} topMargin=0.0 - The top margin, in meters.
* @property {number} bottomMargin=0.0 - The bottom margin, in meters.
* @property {boolean} unlit=false - <code>true</code> if the entity should be unaffected by lighting. Otherwise, the text
* is lit by the keylight and local lights.
* @property {BillboardMode} billboardMode="none" - Whether the entity is billboarded to face the camera.
* @property {boolean} faceCamera - <code>true</code> if <code>billboardMode</code> is <code>"yaw"</code>, <code>false</code>
* if it isn't. Setting this property to <code>false</code> sets the <code>billboardMode</code> to <code>"none"</code>.
@ -1723,6 +1726,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_RIGHT_MARGIN, rightMargin);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_TOP_MARGIN, topMargin);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_BOTTOM_MARGIN, bottomMargin);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_UNLIT, unlit);
}
// Zones only
@ -2098,6 +2102,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(rightMargin, float, setRightMargin);
COPY_PROPERTY_FROM_QSCRIPTVALUE(topMargin, float, setTopMargin);
COPY_PROPERTY_FROM_QSCRIPTVALUE(bottomMargin, float, setBottomMargin);
COPY_PROPERTY_FROM_QSCRIPTVALUE(unlit, bool, setUnlit);
// Zone
_keyLight.copyFromScriptValue(object, _defaultSettings);
@ -2381,6 +2386,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
COPY_PROPERTY_IF_CHANGED(rightMargin);
COPY_PROPERTY_IF_CHANGED(topMargin);
COPY_PROPERTY_IF_CHANGED(bottomMargin);
COPY_PROPERTY_IF_CHANGED(unlit);
// Zone
_keyLight.merge(other._keyLight);
@ -2739,6 +2745,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
ADD_PROPERTY_TO_MAP(PROP_RIGHT_MARGIN, RightMargin, rightMargin, float);
ADD_PROPERTY_TO_MAP(PROP_TOP_MARGIN, TopMargin, topMargin, float);
ADD_PROPERTY_TO_MAP(PROP_BOTTOM_MARGIN, BottomMargin, bottomMargin, float);
ADD_PROPERTY_TO_MAP(PROP_UNLIT, Unlit, unlit, bool);
// Zone
{ // Keylight
@ -3170,6 +3177,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
APPEND_ENTITY_PROPERTY(PROP_RIGHT_MARGIN, properties.getRightMargin());
APPEND_ENTITY_PROPERTY(PROP_TOP_MARGIN, properties.getTopMargin());
APPEND_ENTITY_PROPERTY(PROP_BOTTOM_MARGIN, properties.getBottomMargin());
APPEND_ENTITY_PROPERTY(PROP_UNLIT, properties.getUnlit());
}
if (properties.getType() == EntityTypes::Zone) {
@ -3648,6 +3656,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_RIGHT_MARGIN, float, setRightMargin);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TOP_MARGIN, float, setTopMargin);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BOTTOM_MARGIN, float, setBottomMargin);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_UNLIT, bool, setUnlit);
}
if (properties.getType() == EntityTypes::Zone) {
@ -4040,6 +4049,7 @@ void EntityItemProperties::markAllChanged() {
_rightMarginChanged = true;
_topMarginChanged = true;
_bottomMarginChanged = true;
_unlitChanged = true;
// Zone
_keyLight.markAllChanged();
@ -4629,6 +4639,9 @@ QList<QString> EntityItemProperties::listChangedProperties() {
if (bottomMarginChanged()) {
out += "bottomMargin";
}
if (unlitChanged()) {
out += "unlit";
}
// Zone
getKeyLight().listChangedProperties(out);

View file

@ -314,6 +314,7 @@ public:
DEFINE_PROPERTY_REF(PROP_RIGHT_MARGIN, RightMargin, rightMargin, float, TextEntityItem::DEFAULT_MARGIN);
DEFINE_PROPERTY_REF(PROP_TOP_MARGIN, TopMargin, topMargin, float, TextEntityItem::DEFAULT_MARGIN);
DEFINE_PROPERTY_REF(PROP_BOTTOM_MARGIN, BottomMargin, bottomMargin, float, TextEntityItem::DEFAULT_MARGIN);
DEFINE_PROPERTY_REF(PROP_UNLIT, Unlit, unlit, bool, false);
// Zone
DEFINE_PROPERTY_GROUP(KeyLight, keyLight, KeyLightPropertyGroup);

View file

@ -243,6 +243,7 @@ enum EntityPropertyList {
PROP_RIGHT_MARGIN = PROP_DERIVED_7,
PROP_TOP_MARGIN = PROP_DERIVED_8,
PROP_BOTTOM_MARGIN = PROP_DERIVED_9,
PROP_UNLIT = PROP_DERIVED_10,
// Zone
// Keylight

View file

@ -64,6 +64,7 @@ EntityItemProperties TextEntityItem::getProperties(const EntityPropertyFlags& de
COPY_ENTITY_PROPERTY_TO_PROPERTIES(rightMargin, getRightMargin);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(topMargin, getTopMargin);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(bottomMargin, getBottomMargin);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(unlit, getUnlit);
return properties;
}
@ -87,6 +88,7 @@ bool TextEntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(rightMargin, setRightMargin);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(topMargin, setTopMargin);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(bottomMargin, setBottomMargin);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(unlit, setUnlit);
if (somethingChanged) {
bool wantDebug = false;
@ -129,7 +131,8 @@ int TextEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
READ_ENTITY_PROPERTY(PROP_RIGHT_MARGIN, float, setRightMargin);
READ_ENTITY_PROPERTY(PROP_TOP_MARGIN, float, setTopMargin);
READ_ENTITY_PROPERTY(PROP_BOTTOM_MARGIN, float, setBottomMargin);
READ_ENTITY_PROPERTY(PROP_UNLIT, bool, setUnlit);
return bytesRead;
}
@ -149,6 +152,7 @@ EntityPropertyFlags TextEntityItem::getEntityProperties(EncodeBitstreamParams& p
requestedProperties += PROP_RIGHT_MARGIN;
requestedProperties += PROP_TOP_MARGIN;
requestedProperties += PROP_BOTTOM_MARGIN;
requestedProperties += PROP_UNLIT;
return requestedProperties;
}
@ -179,6 +183,7 @@ void TextEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
APPEND_ENTITY_PROPERTY(PROP_RIGHT_MARGIN, getRightMargin());
APPEND_ENTITY_PROPERTY(PROP_TOP_MARGIN, getTopMargin());
APPEND_ENTITY_PROPERTY(PROP_BOTTOM_MARGIN, getBottomMargin());
APPEND_ENTITY_PROPERTY(PROP_UNLIT, getUnlit());
}
glm::vec3 TextEntityItem::getRaycastDimensions() const {
@ -382,6 +387,18 @@ float TextEntityItem::getBottomMargin() const {
});
}
void TextEntityItem::setUnlit(bool value) {
withWriteLock([&] {
_unlit = value;
});
}
bool TextEntityItem::getUnlit() const {
return resultWithReadLock<bool>([&] {
return _unlit;
});
}
PulsePropertyGroup TextEntityItem::getPulseProperties() const {
return resultWithReadLock<PulsePropertyGroup>([&] {
return _pulseProperties;

View file

@ -97,6 +97,9 @@ public:
float getBottomMargin() const;
void setBottomMargin(float value);
bool getUnlit() const;
void setUnlit(bool value);
PulsePropertyGroup getPulseProperties() const;
private:
@ -113,6 +116,7 @@ private:
float _rightMargin;
float _topMargin;
float _bottomMargin;
bool _unlit;
};
#endif // hifi_TextEntityItem_h

View file

@ -2,7 +2,7 @@
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// DrawTextureGammaLinearToSRGB.frag
// DrawTextureLinearToSRGB.frag
//
// Draw texture 0 fetched at texcoord.xy, and apply linear to sRGB color space conversion
//

View file

@ -13,6 +13,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Color.slh@>
LAYOUT(binding=0) uniform sampler2D colorMap;
@ -20,5 +21,5 @@ layout(location=0) in vec2 varTexCoord0;
layout(location=0) out vec4 outFragColor;
void main(void) {
outFragColor = texture(colorMap, vec2(1.0 - varTexCoord0.x, varTexCoord0.y));
outFragColor = vec4(texture(colorMap, vec2(1.0 - varTexCoord0.x, varTexCoord0.y)).xyz, 1.0);
}

View file

@ -1 +1 @@
VERTEX DrawUnitQuadTexcoord
VERTEX DrawTransformUnitQuad

View file

@ -14,8 +14,6 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/ShaderConstants.h@>
LAYOUT(binding=0) uniform sampler2D colorMap;
layout(location=0) in vec2 varTexCoord0;

View file

@ -2,7 +2,7 @@
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// DrawTextureGammaSRGBToLinear.frag
// DrawTextureSRGBToLinear.frag
//
// Draw texture 0 fetched at texcoord.xy, and apply sRGB to Linear color space conversion
//

View file

@ -271,6 +271,7 @@ enum class EntityVersion : PacketVersion {
ParticleShapeType,
ParticleShapeTypeDeadlockFix,
PrivateUserData,
TextUnlit,
ShadowBiasAndDistance,
// Add new versions above here

View file

@ -210,7 +210,7 @@ public:
// for updating plugin-related commands. Mimics the input plugin.
virtual void pluginUpdate() = 0;
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() { return nullptr; }
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&)> getHUDOperator() { return nullptr; }
virtual StencilMaskMode getStencilMaskMode() const { return StencilMaskMode::NONE; }
using StencilMaskMeshOperator = std::function<void(gpu::Batch&)>;
virtual StencilMaskMeshOperator getStencilMaskMeshOperator() { return nullptr; }

View file

@ -722,42 +722,12 @@ gpu::ShaderPointer GeometryCache::_forwardUnlitShader;
gpu::ShaderPointer GeometryCache::_forwardSimpleFadeShader;
gpu::ShaderPointer GeometryCache::_forwardUnlitFadeShader;
render::ShapePipelinePointer GeometryCache::_simpleOpaquePipeline;
render::ShapePipelinePointer GeometryCache::_simpleTransparentPipeline;
render::ShapePipelinePointer GeometryCache::_forwardSimpleOpaquePipeline;
render::ShapePipelinePointer GeometryCache::_forwardSimpleTransparentPipeline;
render::ShapePipelinePointer GeometryCache::_simpleOpaqueFadePipeline;
render::ShapePipelinePointer GeometryCache::_simpleTransparentFadePipeline;
render::ShapePipelinePointer GeometryCache::_simpleWirePipeline;
uint8_t GeometryCache::CUSTOM_PIPELINE_NUMBER = 0;
render::ShapePipelinePointer GeometryCache::shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) {
initializeShapePipelines();
if (key.isWireframe()) {
return _simpleWirePipeline;
}
if (key.isFaded()) {
if (key.isTranslucent()) {
return _simpleTransparentFadePipeline;
} else {
return _simpleOpaqueFadePipeline;
}
} else {
if (key.isTranslucent()) {
return _simpleTransparentPipeline;
} else {
return _simpleOpaquePipeline;
}
}
}
std::map<std::tuple<bool, bool, bool>, render::ShapePipelinePointer> GeometryCache::_shapePipelines;
GeometryCache::GeometryCache() :
_nextID(0) {
// Let's register its special shapePipeline factory:
registerShapePipeline();
initializeShapePipelines();
buildShapes();
}
@ -799,16 +769,14 @@ void GeometryCache::releaseID(int id) {
}
void GeometryCache::initializeShapePipelines() {
if (!_simpleOpaquePipeline) {
_simpleOpaquePipeline = getShapePipeline(false, false, true, false);
_simpleTransparentPipeline = getShapePipeline(false, true, true, false);
_forwardSimpleOpaquePipeline = getShapePipeline(false, false, true, false, false, true);
_forwardSimpleTransparentPipeline = getShapePipeline(false, true, true, false, false, true);
// FIXME: these need forward pipelines
_simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, false, false, false);
_simpleTransparentFadePipeline = getFadingShapePipeline(false, true, false, false, false);
_simpleWirePipeline = getShapePipeline(false, false, true, true);
if (_shapePipelines.empty()) {
const int NUM_PIPELINES = 8;
for (int i = 0; i < NUM_PIPELINES; ++i) {
bool transparent = i & 1;
bool unlit = i & 2;
bool forward = i & 4;
_shapePipelines[std::make_tuple(transparent, unlit, forward)] = getShapePipeline(false, transparent, true, unlit, false, forward);
}
}
}
@ -1027,7 +995,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f);
const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f);
auto pointCount = points.size();
auto colorCount = colors.size();
int compactColor = 0;
@ -1105,7 +1073,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f);
const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f);
auto pointCount = points.size();
auto colorCount = colors.size();
for (auto i = 0; i < pointCount; i++) {
@ -1193,7 +1161,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con
int* colorData = new int[details.vertices];
int* colorDataAt = colorData;
const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f);
const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f);
for (int i = 0; i < points.size(); i++) {
glm::vec3 point = points[i];
glm::vec2 texCoord = texCoords[i];
@ -2281,8 +2249,7 @@ void renderInstances(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color
if (isWire) {
DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]);
}
else {
} else {
DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]);
}
});

View file

@ -157,14 +157,6 @@ public:
static void computeSimpleHullPointListForShape(int entityShape, const glm::vec3 &entityExtents, QVector<glm::vec3> &outPointList);
static uint8_t CUSTOM_PIPELINE_NUMBER;
static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch);
static void registerShapePipeline() {
if (!CUSTOM_PIPELINE_NUMBER) {
CUSTOM_PIPELINE_NUMBER = render::ShapePipeline::registerCustomShapePipelineFactory(shapePipelineFactory);
}
}
int allocateID() { return _nextID++; }
void releaseID(int id);
static const int UNKNOWN_ID;
@ -180,11 +172,7 @@ public:
gpu::PipelinePointer getWebBrowserProgram(bool transparent);
static void initializeShapePipelines();
render::ShapePipelinePointer getOpaqueShapePipeline() { assert(_simpleOpaquePipeline != nullptr); return _simpleOpaquePipeline; }
render::ShapePipelinePointer getTransparentShapePipeline() { assert(_simpleTransparentPipeline != nullptr); return _simpleTransparentPipeline; }
render::ShapePipelinePointer getForwardOpaqueShapePipeline() { assert(_forwardSimpleOpaquePipeline != nullptr); return _forwardSimpleOpaquePipeline; }
render::ShapePipelinePointer getForwardTransparentShapePipeline() { assert(_forwardSimpleTransparentPipeline != nullptr); return _forwardSimpleTransparentPipeline; }
render::ShapePipelinePointer getShapePipelinePointer(bool transparent, bool unlit, bool forward) { return _shapePipelines[std::make_tuple(transparent, unlit, forward)]; }
// Static (instanced) geometry
void renderShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer);
@ -195,17 +183,17 @@ public:
void renderWireFadeShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer,
gpu::BufferPointer& fadeBuffer1, gpu::BufferPointer& fadeBuffer2, gpu::BufferPointer& fadeBuffer3);
void renderSolidShapeInstance(RenderArgs* args, gpu::Batch& batch, Shape shape, const glm::vec4& color = glm::vec4(1),
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
void renderSolidShapeInstance(RenderArgs* args, gpu::Batch& batch, Shape shape, const glm::vec4& color,
const render::ShapePipelinePointer& pipeline);
void renderSolidShapeInstance(RenderArgs* args, gpu::Batch& batch, Shape shape, const glm::vec3& color,
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
const render::ShapePipelinePointer& pipeline) {
renderSolidShapeInstance(args, batch, shape, glm::vec4(color, 1.0f), pipeline);
}
void renderWireShapeInstance(RenderArgs* args, gpu::Batch& batch, Shape shape, const glm::vec4& color = glm::vec4(1),
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
void renderWireShapeInstance(RenderArgs* args, gpu::Batch& batch, Shape shape, const glm::vec4& color,
const render::ShapePipelinePointer& pipeline);
void renderWireShapeInstance(RenderArgs* args, gpu::Batch& batch, Shape shape, const glm::vec3& color,
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
const render::ShapePipelinePointer& pipeline) {
renderWireShapeInstance(args, batch, shape, glm::vec4(color, 1.0f), pipeline);
}
@ -217,33 +205,33 @@ public:
const render::ShapePipelinePointer& pipeline);
void renderSolidSphereInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color,
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
const render::ShapePipelinePointer& pipeline);
void renderSolidSphereInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec3& color,
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
const render::ShapePipelinePointer& pipeline) {
renderSolidSphereInstance(args, batch, glm::vec4(color, 1.0f), pipeline);
}
void renderWireSphereInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color,
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline);
const render::ShapePipelinePointer& pipeline);
void renderWireSphereInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec3& color,
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline) {
const render::ShapePipelinePointer& pipeline) {
renderWireSphereInstance(args, batch, glm::vec4(color, 1.0f), pipeline);
}
void renderSolidCubeInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color,
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline);
const render::ShapePipelinePointer& pipeline);
void renderSolidCubeInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec3& color,
const render::ShapePipelinePointer& pipeline = _simpleOpaquePipeline) {
const render::ShapePipelinePointer& pipeline) {
renderSolidCubeInstance(args, batch, glm::vec4(color, 1.0f), pipeline);
}
void renderWireCubeInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color,
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline);
const render::ShapePipelinePointer& pipeline);
void renderWireCubeInstance(RenderArgs* args, gpu::Batch& batch, const glm::vec3& color,
const render::ShapePipelinePointer& pipeline = _simpleWirePipeline) {
const render::ShapePipelinePointer& pipeline) {
renderWireCubeInstance(args, batch, glm::vec4(color, 1.0f), pipeline);
}
// Dynamic geometry
void renderShape(gpu::Batch& batch, Shape shape);
void renderWireShape(gpu::Batch& batch, Shape shape);
@ -467,14 +455,7 @@ private:
static gpu::ShaderPointer _forwardSimpleFadeShader;
static gpu::ShaderPointer _forwardUnlitFadeShader;
static render::ShapePipelinePointer _simpleOpaquePipeline;
static render::ShapePipelinePointer _simpleTransparentPipeline;
static render::ShapePipelinePointer _forwardSimpleOpaquePipeline;
static render::ShapePipelinePointer _forwardSimpleTransparentPipeline;
static render::ShapePipelinePointer _simpleOpaqueFadePipeline;
static render::ShapePipelinePointer _simpleTransparentFadePipeline;
static render::ShapePipelinePointer _simpleWirePipeline;
static std::map<std::tuple<bool, bool, bool>, render::ShapePipelinePointer> _shapePipelines;
static QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
gpu::ShaderPointer _simpleOpaqueWebBrowserShader;

View file

@ -128,52 +128,11 @@ void Blit::run(const RenderContextPointer& renderContext, const gpu::Framebuffer
gpu::doInBatch("Blit", renderArgs->_context, [&](gpu::Batch& batch) {
batch.setFramebuffer(blitFbo);
if (renderArgs->_renderMode == RenderArgs::MIRROR_RENDER_MODE) {
if (renderArgs->isStereo()) {
gpu::Vec4i srcRectLeft;
srcRectLeft.z = width / 2;
srcRectLeft.w = height;
gpu::Vec4i rect;
rect.z = width;
rect.w = height;
gpu::Vec4i srcRectRight;
srcRectRight.x = width / 2;
srcRectRight.z = width;
srcRectRight.w = height;
gpu::Vec4i destRectLeft;
destRectLeft.x = srcRectLeft.z;
destRectLeft.z = srcRectLeft.x;
destRectLeft.y = srcRectLeft.y;
destRectLeft.w = srcRectLeft.w;
gpu::Vec4i destRectRight;
destRectRight.x = srcRectRight.z;
destRectRight.z = srcRectRight.x;
destRectRight.y = srcRectRight.y;
destRectRight.w = srcRectRight.w;
// Blit left to right and right to left in stereo
batch.blit(primaryFbo, srcRectRight, blitFbo, destRectLeft);
batch.blit(primaryFbo, srcRectLeft, blitFbo, destRectRight);
} else {
gpu::Vec4i srcRect;
srcRect.z = width;
srcRect.w = height;
gpu::Vec4i destRect;
destRect.x = width;
destRect.y = 0;
destRect.z = 0;
destRect.w = height;
batch.blit(primaryFbo, srcRect, blitFbo, destRect);
}
} else {
gpu::Vec4i rect;
rect.z = width;
rect.w = height;
batch.blit(primaryFbo, rect, blitFbo, rect);
}
batch.blit(primaryFbo, rect, blitFbo, rect);
});
}

View file

@ -144,9 +144,9 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
// Just resolve the msaa
const auto resolveInputs = ResolveFramebuffer::Inputs(scaledPrimaryFramebuffer, static_cast<gpu::FramebufferPointer>(nullptr)).asVarying();
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
const auto resolvedFramebuffer = task.addJob<ResolveFramebuffer>("Resolve", resolveInputs);
const auto toneMappedBuffer = resolvedFramebuffer;
const auto toneMappedBuffer = resolvedFramebuffer;
#else
const auto newResolvedFramebuffer = task.addJob<NewOrDefaultFramebuffer>("MakeResolvingFramebuffer");

View file

@ -34,7 +34,7 @@ void CompositeHUD::run(const RenderContextPointer& renderContext, const gpu::Fra
batch.setFramebuffer(inputs);
}
if (renderContext->args->_hudOperator) {
renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture, renderContext->args->_renderMode == RenderArgs::RenderMode::MIRROR_RENDER_MODE);
renderContext->args->_hudOperator(batch, renderContext->args->_hudTexture);
}
});
#endif

View file

@ -67,11 +67,11 @@ float TextRenderer3D::getFontSize() const {
}
void TextRenderer3D::draw(gpu::Batch& batch, float x, float y, const QString& str, const glm::vec4& color,
const glm::vec2& bounds, bool forward) {
const glm::vec2& bounds, bool unlit, bool forward) {
// The font does all the OpenGL work
if (_font) {
_color = color;
_font->drawString(batch, _drawInfo, str, _color, _effectType, { x, y }, bounds, forward);
_font->drawString(batch, _drawInfo, str, _color, _effectType, { x, y }, bounds, unlit, forward);
}
}

View file

@ -39,7 +39,7 @@ public:
float getFontSize() const; // Pixel size
void draw(gpu::Batch& batch, float x, float y, const QString& str, const glm::vec4& color,
const glm::vec2& bounds, bool forward);
const glm::vec2& bounds, bool unlit, bool forward);
private:
TextRenderer3D(const char* family, float pointSize, int weight = -1, bool italic = false,

View file

@ -52,7 +52,7 @@ void main(void) {
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normal,
normal * (2.0 * float(gl_FrontFacing) - 1.0),
diffuse,
DEFAULT_FRESNEL,
length(specular),

View file

@ -49,7 +49,7 @@ void main(void) {
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
albedo,
fresnel,
metallic,

View file

@ -50,7 +50,7 @@ void main(void) {
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
albedo,
fresnel,
metallic,

View file

@ -12,6 +12,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include render-utils/ShaderConstants.h@>
<@include gpu/Color.slh@>
LAYOUT(binding=0) uniform sampler2D hudTexture;
@ -36,5 +37,5 @@ void main() {
discard;
}
fragColor0 = color;
fragColor0 = color_sRGBAToLinear(color);
}

View file

@ -0,0 +1 @@
VERTEX sdf_text3D

View file

@ -0,0 +1 @@
VERTEX sdf_text3D

View file

@ -1 +0,0 @@
VERTEX sdf_text3D

View file

@ -0,0 +1 @@
VERTEX sdf_text3D

View file

@ -1,7 +1,7 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// sdf_text3D_transparent.frag
// sdf_text3D_forward.frag
// fragment shader
//
// Created by Bradley Austin Davis on 2015-02-04
@ -53,5 +53,5 @@ void main() {
DEFAULT_FRESNEL,
DEFAULT_METALLIC,
DEFAULT_ROUGHNESS),
1.0);
alpha);
}

View file

@ -1,7 +1,7 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// sdf_text3D_transparent.frag
// sdf_text3D_translucent.frag
// fragment shader
//
// Created by Bradley Austin Davis on 2015-02-04
@ -12,8 +12,8 @@
<@include DefaultMaterials.slh@>
<@include ForwardGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlended()$>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>

View file

@ -0,0 +1,38 @@
<@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);
}

View file

@ -0,0 +1,32 @@
<@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);
}

View file

@ -60,7 +60,7 @@ float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition pro
#line 2030
void main(void) {
vec3 normal = normalize(_normalWS.xyz);
vec3 normal = normalize(_normalWS.xyz) * (2.0 * float(gl_FrontFacing) - 1.0);
vec3 diffuse = _color.rgb;
float roughness = DEFAULT_ROUGHNESS;
float metallic = DEFAULT_METALLIC;

View file

@ -33,7 +33,7 @@ void main(void) {
texel.rgb *= _color.rgb;
packDeferredFragment(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
1.0,
texel.rgb,
DEFAULT_ROUGHNESS,

View file

@ -48,13 +48,13 @@ void main(void) {
const float ALPHA_THRESHOLD = 0.999;
if (texel.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
texel.a,
texel.rgb + fadeEmissive,
DEFAULT_ROUGHNESS);
} else {
packDeferredFragment(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
1.0,
texel.rgb,
DEFAULT_ROUGHNESS,

View file

@ -36,13 +36,13 @@ void main(void) {
const float ALPHA_THRESHOLD = 0.999;
if (texel.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
texel.a,
texel.rgb,
DEFAULT_ROUGHNESS);
} else {
packDeferredFragmentUnlit(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
1.0,
texel.rgb);
}

View file

@ -48,13 +48,13 @@ void main(void) {
const float ALPHA_THRESHOLD = 0.999;
if (texel.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
texel.a,
texel.rgb + fadeEmissive,
DEFAULT_ROUGHNESS);
} else {
packDeferredFragmentUnlit(
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
1.0,
texel.rgb + fadeEmissive);
}

View file

@ -65,7 +65,7 @@ float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition pro
#line 2030
void main(void) {
vec3 normal = normalize(_normalWS.xyz);
vec3 normal = normalize(_normalWS.xyz) * (2.0 * float(gl_FrontFacing) - 1.0);
vec3 diffuse = _color.rgb;
float alpha = _color.a;
float occlusion = DEFAULT_OCCLUSION;

View file

@ -50,7 +50,7 @@ void main(void) {
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normalize(_normalWS),
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
albedo,
fresnel,
metallic,

View file

@ -52,7 +52,7 @@ void main(void) {
texel.a *= abs(_color.a);
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal = normalize(_normalWS);
vec3 fragNormal = normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0);
TransformCamera cam = getTransformCamera();

View file

@ -15,9 +15,7 @@
static std::mutex fontMutex;
gpu::PipelinePointer Font::_deferredPipeline;
gpu::PipelinePointer Font::_forwardPipeline;
gpu::PipelinePointer Font::_transparentPipeline;
std::map<std::tuple<bool, bool, bool>, gpu::PipelinePointer> Font::_pipelines;
gpu::Stream::FormatPointer Font::_format;
struct TextureVertex {
@ -221,31 +219,28 @@ void Font::read(QIODevice& in) {
}
void Font::setupGPU() {
if (!_deferredPipeline) {
// Setup render pipeline
{
{
auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(false,
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::testMaskDrawShape(*state);
_deferredPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D), state);
_forwardPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::forward_sdf_text3D), state);
}
if (_pipelines.empty()) {
using namespace shader::render_utils::program;
{
auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(true,
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
static const std::vector<std::tuple<bool, bool, bool, uint32_t>> keys = {
std::make_tuple(false, false, false, sdf_text3D), std::make_tuple(true, false, false, sdf_text3D_translucent),
std::make_tuple(false, true, false, sdf_text3D_unlit), std::make_tuple(true, true, false, sdf_text3D_translucent_unlit),
std::make_tuple(false, false, true, sdf_text3D_forward), std::make_tuple(true, false, true, sdf_text3D_forward/*sdf_text3D_translucent_forward*/),
std::make_tuple(false, true, true, sdf_text3D_translucent_unlit/*sdf_text3D_unlit_forward*/), std::make_tuple(true, true, true, sdf_text3D_translucent_unlit/*sdf_text3D_translucent_unlit_forward*/)
};
for (auto& key : keys) {
auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(std::get<0>(key),
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);
if (std::get<0>(key)) {
PrepareStencil::testMask(*state);
_transparentPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D_transparent), state);
} else {
PrepareStencil::testMaskDrawShape(*state);
}
_pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), std::get<2>(key))] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<3>(key)), state);
}
// Sanity checks
@ -349,7 +344,7 @@ void Font::buildVertices(Font::DrawInfo& drawInfo, const QString& str, const glm
}
void Font::drawString(gpu::Batch& batch, Font::DrawInfo& drawInfo, const QString& str, const glm::vec4& color,
EffectType effectType, const glm::vec2& origin, const glm::vec2& bounds, bool forward) {
EffectType effectType, const glm::vec2& origin, const glm::vec2& bounds, bool unlit, bool forward) {
if (str == "") {
return;
}
@ -376,7 +371,7 @@ void Font::drawString(gpu::Batch& batch, Font::DrawInfo& drawInfo, const QString
}
// need the gamma corrected color here
batch.setPipeline(color.a < 1.0f ? _transparentPipeline : (forward ? _forwardPipeline : _deferredPipeline));
batch.setPipeline(_pipelines[std::make_tuple(color.a < 1.0f, unlit, forward)]);
batch.setInputFormat(_format);
batch.setInputBuffer(0, drawInfo.verticesBuffer, 0, _format->getChannels().at(0)._stride);
batch.setResourceTexture(render_utils::slot::texture::TextFont, _texture);

View file

@ -46,11 +46,10 @@ public:
// Render string to batch
void drawString(gpu::Batch& batch, DrawInfo& drawInfo, const QString& str,
const glm::vec4& color, EffectType effectType,
const glm::vec2& origin, const glm::vec2& bound, bool forward);
const glm::vec2& origin, const glm::vec2& bound, bool unlit, bool forward);
static Pointer load(const QString& family);
private:
static Pointer load(QIODevice& fontFile);
QStringList tokenizeForWrapping(const QString& str) const;
@ -80,9 +79,7 @@ private:
gpu::TexturePointer _texture;
gpu::BufferStreamPointer _stream;
static gpu::PipelinePointer _deferredPipeline;
static gpu::PipelinePointer _forwardPipeline;
static gpu::PipelinePointer _transparentPipeline;
static std::map<std::tuple<bool, bool, bool>, gpu::PipelinePointer> _pipelines;
static gpu::Stream::FormatPointer _format;
};

View file

@ -20,6 +20,7 @@ struct ToneMappingParams {
ivec4 _toneCurve_s0_s1_s2;
};
const float GAMMA_22 = 2.2;
const float INV_GAMMA_22 = 1.0 / 2.2;
const int ToneCurveNone = 0;
const int ToneCurveGamma22 = 1;
@ -51,13 +52,20 @@ void main(void) {
vec3 tonedColor = srcColor;
if (toneCurve == ToneCurveFilmic) {
vec3 x = max(vec3(0.0), srcColor-0.004);
tonedColor = (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
tonedColor = pow((x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06), vec3(GAMMA_22));
} else if (toneCurve == ToneCurveReinhard) {
tonedColor = srcColor/(1.0 + srcColor);
tonedColor = pow(tonedColor, vec3(INV_GAMMA_22));
} else if (toneCurve == ToneCurveGamma22) {
tonedColor = pow(srcColor, vec3(INV_GAMMA_22));
} // else None toned = src
// We use glEnable(GL_FRAMEBUFFER_SRGB), which automatically converts textures from RGB to SRGB
// when writing from an RGB framebuffer to an SRGB framebuffer (note that it doesn't do anything
// when writing from an SRGB framebuffer to an RGB framebuffer).
// Since the conversion happens automatically, we don't need to do anything in this shader
} else {
// toneCurve == ToneCurveNone
// For debugging purposes, we may want to see what the colors look like before the automatic OpenGL
// conversion mentioned above, so we undo it here
tonedColor = pow(srcColor, vec3(GAMMA_22));
}
outFragColor = vec4(tonedColor, 1.0);
}

View file

@ -136,7 +136,7 @@ namespace render {
render::ScenePointer _scene;
int8_t _cameraMode { -1 };
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator { nullptr };
std::function<void(gpu::Batch&, const gpu::TexturePointer&)> _hudOperator { nullptr };
gpu::TexturePointer _hudTexture { nullptr };
bool _takingSnapshot { false };

View file

@ -614,7 +614,7 @@ public:
virtual ShapeKey getShapeKey() = 0;
virtual Item::Bound getBound() = 0;
virtual void render(RenderArgs* args) = 0;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) = 0;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const = 0;
};
template <> const ItemKey payloadGetKey(const PayloadProxyInterface::Pointer& payload);

View file

@ -16,6 +16,7 @@
#include <shaders/Shaders.h>
using namespace render;
using namespace shader::gpu::program;
gpu::PipelinePointer HalfDownsample::_pipeline;
@ -137,6 +138,7 @@ void Upsample::run(const RenderContextPointer& renderContext, const gpu::Framebu
}
gpu::PipelinePointer UpsampleToBlitFramebuffer::_pipeline;
gpu::PipelinePointer UpsampleToBlitFramebuffer::_mirrorPipeline;
void UpsampleToBlitFramebuffer::run(const RenderContextPointer& renderContext, const Input& input, gpu::FramebufferPointer& resampledFrameBuffer) {
assert(renderContext->args);
@ -148,10 +150,11 @@ void UpsampleToBlitFramebuffer::run(const RenderContextPointer& renderContext, c
if (resampledFrameBuffer != sourceFramebuffer) {
if (!_pipeline) {
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawTransformUnitQuadTextureOpaque);
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
state->setDepthTest(gpu::State::DepthTest(false, false));
_pipeline = gpu::Pipeline::create(program, state);
_pipeline = gpu::Pipeline::create(gpu::Shader::createProgram(drawTransformUnitQuadTextureOpaque), state);
_mirrorPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTextureMirroredX), state);
}
const auto bufferSize = resampledFrameBuffer->getSize();
glm::ivec4 viewport{ 0, 0, bufferSize.x, bufferSize.y };
@ -164,7 +167,7 @@ void UpsampleToBlitFramebuffer::run(const RenderContextPointer& renderContext, c
batch.setViewportTransform(viewport);
batch.setProjectionTransform(glm::mat4());
batch.resetViewTransform();
batch.setPipeline(_pipeline);
batch.setPipeline(args->_renderMode == RenderArgs::MIRROR_RENDER_MODE ? _mirrorPipeline : _pipeline);
batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(bufferSize, viewport));
batch.setResourceTexture(0, sourceFramebuffer->getRenderBuffer(0));

View file

@ -80,6 +80,7 @@ namespace render {
protected:
static gpu::PipelinePointer _pipeline;
static gpu::PipelinePointer _mirrorPipeline;
};
}

View file

@ -163,7 +163,7 @@ void OculusDisplayPlugin::hmdPresent() {
batch.setStateScissorRect(ivec4(uvec2(), _outputFramebuffer->getSize()));
batch.resetViewTransform();
batch.setProjectionTransform(mat4());
batch.setPipeline(_SRGBToLinearPipeline);
batch.setPipeline(_drawTexturePipeline);
batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
batch.draw(gpu::TRIANGLE_STRIP, 4);
});

View file

@ -33,14 +33,14 @@ var bar = Overlays.addOverlay("text", {
// Takes an energy value between 0 and 1 and sets energy bar width appropriately
function setEnergy(energy) {
energy = clamp(energy, 0, 1);
energy = hifiClamp(energy, 0, 1);
var barWidth = totalWidth * energy;
var color = energy <= lowEnergyThreshold ? lowEnergyColor: energyColor;
Overlays.editOverlay(bar, { width: barWidth, backgroundColor: color});
}
function update() {
currentEnergy = clamp(MyAvatar.energy, 0, 1);
currentEnergy = hifiClamp(MyAvatar.energy, 0, 1);
setEnergy(currentEnergy);
}

View file

@ -45,14 +45,14 @@ var bar = Overlays.addOverlay("text", {
// Takes an energy value between 0 and 1 and sets energy bar width appropriately
function setEnergy(energy) {
energy = clamp(energy, 0, 1);
energy = hifiClamp(energy, 0, 1);
var barWidth = totalWidth * energy;
var color = energy <= lowEnergyThreshold ? lowEnergyColor: energyColor;
Overlays.editOverlay(bar, { width: barWidth, backgroundColor: color});
}
function update() {
currentEnergy = clamp(MyAvatar.energy, 0, 1);
currentEnergy = hifiClamp(MyAvatar.energy, 0, 1);
setEnergy(currentEnergy);
}

View file

@ -39,6 +39,10 @@
"leftMargin": {
"tooltip": "The left margin, in meters."
},
"unlit": {
"tooltip": "If enabled, the entity will not be lit by the keylight or local lights.",
"jsPropertyName": "unlit"
},
"zoneShapeType": {
"tooltip": "The shape of the volume in which the zone's lighting effects and avatar permissions have effect.",
"jsPropertyName": "shapeType"

View file

@ -216,6 +216,11 @@ const GROUPS = [
decimals: 2,
propertyID: "leftMargin",
},
{
label: "Unlit",
type: "bool",
propertyID: "unlit",
},
]
},
{

View file

@ -10,9 +10,9 @@
/* global getControllerWorldLocation, Tablet, WebTablet:true, HMD, Settings, Script,
Vec3, Quat, MyAvatar, Entities, Overlays, Camera, Messages, Xform, clamp, Controller, Mat4, resizeTablet */
Script.include(Script.resolvePath("../libraries/utils.js"));
Script.include(Script.resolvePath("../libraries/controllers.js"));
Script.include(Script.resolvePath("../libraries/Xform.js"));
Script.include(Script.resolvePath("utils.js"));
Script.include(Script.resolvePath("controllers.js"));
Script.include(Script.resolvePath("Xform.js"));
var Y_AXIS = {x: 0, y: 1, z: 0};
var X_AXIS = {x: 1, y: 0, z: 0};
@ -380,8 +380,8 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos
var TABLET_TEXEL_PADDING = {x: 60, y: 90};
var X_CLAMP = (DESKTOP_TABLET_SCALE / 100) * ((this.getTabletTextureResolution().x / 2) + TABLET_TEXEL_PADDING.x);
var Y_CLAMP = (DESKTOP_TABLET_SCALE / 100) * ((this.getTabletTextureResolution().y / 2) + TABLET_TEXEL_PADDING.y);
windowPos.x = clamp(windowPos.x, X_CLAMP, Window.innerWidth - X_CLAMP);
windowPos.y = clamp(windowPos.y, Y_CLAMP, Window.innerHeight - Y_CLAMP);
windowPos.x = hifiClamp(windowPos.x, X_CLAMP, Window.innerWidth - X_CLAMP);
windowPos.y = hifiClamp(windowPos.y, Y_CLAMP, Window.innerHeight - Y_CLAMP);
var fov = (Settings.getValue('fieldOfView') || DEFAULT_VERTICAL_FIELD_OF_VIEW) * (Math.PI / 180);

View file

@ -340,8 +340,8 @@ calculateHandSizeRatio = function() {
return handSizeRatio;
}
clamp = function(val, min, max){
return Math.max(min, Math.min(max, val))
hifiClamp = function(val, min, max) {
return Math.max(min, Math.min(max, val));
}
// flattens an array of arrays into a single array

View file

@ -344,24 +344,19 @@ function makeNameTag(uuid) {
}, REDRAW_TIMEOUT_AMOUNT_MS);
}
// Check to see if the display named changed or if the distance is big enough to need a redraw.
var MAX_RADIUS_IGNORE_METERS = 22;
var MAX_ON_MODE_DISTANCE = 35;
var CHECK_AVATAR = true;
var MIN_DISTANCE_FOR_REDRAW_METERS = 0.1;
function maybeRedraw(uuid) {
var avatar = _this.avatars[uuid];
getAvatarData(uuid);
getDistance(uuid);
var distanceDelta = Math.abs(avatar.currentDistance - avatar.previousDistance);
var name = getCorrectName(uuid);
if (avatar.previousName !== name) {
updateName(uuid, name);
} else if (distanceDelta > MIN_DISTANCE_FOR_REDRAW_METERS) {
} else {
redraw(uuid);
}
}

View file

@ -39,6 +39,10 @@
"leftMargin": {
"tooltip": "The left margin, in meters."
},
"unlit": {
"tooltip": "If enabled, the entity will not be lit by the keylight or local lights.",
"jsPropertyName": "unlit"
},
"zoneShapeType": {
"tooltip": "The shape of the volume in which the zone's lighting effects and avatar permissions have effect.",
"jsPropertyName": "shapeType"

View file

@ -216,6 +216,11 @@ const GROUPS = [
decimals: 2,
propertyID: "leftMargin",
},
{
label: "Unlit",
type: "bool",
propertyID: "unlit",
},
]
},
{

View file

@ -10,9 +10,9 @@
/* global getControllerWorldLocation, Tablet, WebTablet:true, HMD, Settings, Script,
Vec3, Quat, MyAvatar, Entities, Overlays, Camera, Messages, Xform, clamp, Controller, Mat4, resizeTablet */
Script.include(Script.resolvePath("../libraries/utils.js"));
Script.include(Script.resolvePath("../libraries/controllers.js"));
Script.include(Script.resolvePath("../libraries/Xform.js"));
Script.include(Script.resolvePath("utils.js"));
Script.include(Script.resolvePath("controllers.js"));
Script.include(Script.resolvePath("Xform.js"));
var Y_AXIS = {x: 0, y: 1, z: 0};
var X_AXIS = {x: 1, y: 0, z: 0};
@ -380,8 +380,8 @@ WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function (windowPos
var TABLET_TEXEL_PADDING = {x: 60, y: 90};
var X_CLAMP = (DESKTOP_TABLET_SCALE / 100) * ((this.getTabletTextureResolution().x / 2) + TABLET_TEXEL_PADDING.x);
var Y_CLAMP = (DESKTOP_TABLET_SCALE / 100) * ((this.getTabletTextureResolution().y / 2) + TABLET_TEXEL_PADDING.y);
windowPos.x = clamp(windowPos.x, X_CLAMP, Window.innerWidth - X_CLAMP);
windowPos.y = clamp(windowPos.y, Y_CLAMP, Window.innerHeight - Y_CLAMP);
windowPos.x = hifiClamp(windowPos.x, X_CLAMP, Window.innerWidth - X_CLAMP);
windowPos.y = hifiClamp(windowPos.y, Y_CLAMP, Window.innerHeight - Y_CLAMP);
var fov = (Settings.getValue('fieldOfView') || DEFAULT_VERTICAL_FIELD_OF_VIEW) * (Math.PI / 180);

View file

@ -340,8 +340,8 @@ calculateHandSizeRatio = function() {
return handSizeRatio;
}
clamp = function(val, min, max){
return Math.max(min, Math.min(max, val))
hifiClamp = function(val, min, max) {
return Math.max(min, Math.min(max, val));
}
// flattens an array of arrays into a single array