From fc51b9369105d92233a3cd3cfdca79342611be8d Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Mon, 30 Jul 2018 17:33:30 -0700 Subject: [PATCH] Fix OSX build --- libraries/gl/src/gl/Context.cpp | 4 +- libraries/gl/src/gl/GLHelpers.cpp | 25 +++- libraries/gl/src/gl/GLHelpers.h | 12 +- libraries/gl/src/gl/GLShaders.cpp | 93 +++++++------ libraries/gl/src/gl/GLShaders.h | 5 + .../gpu-gl-common/src/gpu/gl/GLBackend.cpp | 2 - .../gpu-gl-common/src/gpu/gl/GLBackend.h | 1 - .../gpu-gl/src/gpu/gl/GLDesktopBackend.cpp | 6 +- libraries/gpu-gl/src/gpu/gl41/GL41Backend.h | 4 - .../gpu-gl/src/gpu/gl41/GL41BackendShader.cpp | 43 +++--- libraries/gpu-gl/src/gpu/gl45/GL45Backend.cpp | 2 + libraries/gpu-gl/src/gpu/gl45/GL45Backend.h | 1 + libraries/gpu/src/gpu/Shader.cpp | 52 ++++++-- libraries/gpu/src/gpu/ShaderConstants.h | 3 + libraries/gpu/src/gpu/TextureTable.slh | 3 +- libraries/gpu/src/gpu/Transform.slh | 4 +- libraries/render-utils/src/BloomApply.slf | 1 + libraries/render-utils/src/Haze.slf | 3 - .../render-utils/src/RenderDeferredTask.cpp | 2 + libraries/render-utils/src/deferred_light.slv | 8 +- .../src/deferred_light_limited.slv | 8 +- .../render-utils/src/deferred_light_point.slv | 2 +- .../render-utils/src/deferred_light_spot.slv | 2 +- .../src/directional_ambient_light.slf | 5 +- .../src/directional_ambient_light_shadow.slf | 4 +- .../src/directional_skybox_light.slf | 4 +- .../src/directional_skybox_light_shadow.slf | 4 +- libraries/render-utils/src/forward_model.slf | 9 +- .../src/forward_model_normal_map.slf | 9 +- .../src/forward_model_translucent.slf | 12 +- .../render-utils/src/forward_model_unlit.slf | 8 +- libraries/render-utils/src/forward_simple.slf | 4 +- .../src/forward_simple_textured.slf | 4 +- .../forward_simple_textured_transparent.slf | 4 +- .../src/forward_simple_textured_unlit.slf | 4 +- .../src/forward_simple_transparent.slf | 4 +- libraries/render-utils/src/glowLine.slf | 3 +- libraries/render-utils/src/glowLine.slv | 2 +- libraries/render-utils/src/hmd_ui.slf | 4 +- libraries/render-utils/src/hmd_ui.slv | 4 +- .../src/local_lights_drawOutline.slf | 4 +- .../render-utils/src/local_lights_shading.slf | 4 +- libraries/render-utils/src/model.slf | 9 +- libraries/render-utils/src/model.slv | 14 +- libraries/render-utils/src/model_fade.slf | 9 +- libraries/render-utils/src/model_fade.slv | 14 +- libraries/render-utils/src/model_lightmap.slf | 9 +- libraries/render-utils/src/model_lightmap.slv | 11 +- .../render-utils/src/model_lightmap_fade.slf | 9 +- .../render-utils/src/model_lightmap_fade.slv | 12 +- .../src/model_lightmap_normal_map.slf | 9 +- .../src/model_lightmap_normal_map.slv | 12 +- .../src/model_lightmap_normal_map_fade.slf | 9 +- .../src/model_lightmap_normal_map_fade.slv | 12 +- .../render-utils/src/model_normal_map.slf | 9 +- .../render-utils/src/model_normal_map.slv | 14 +- .../src/model_normal_map_fade.slf | 9 +- .../src/model_normal_map_fade.slv | 14 +- .../render-utils/src/model_translucent.slf | 12 +- .../render-utils/src/model_translucent.slv | 14 +- .../src/model_translucent_fade.slf | 12 +- .../src/model_translucent_normal_map.slf | 12 +- .../src/model_translucent_normal_map.slv | 14 +- .../src/model_translucent_normal_map_fade.slf | 12 +- .../src/model_translucent_unlit.slf | 11 +- .../src/model_translucent_unlit_fade.slf | 11 +- libraries/render-utils/src/model_unlit.slf | 9 +- .../render-utils/src/model_unlit_fade.slf | 9 +- .../src/render-utils/ShaderConstants.h | 27 ++-- libraries/render-utils/src/sdf_text3D.slf | 4 +- libraries/render-utils/src/sdf_text3D.slv | 4 +- .../src/sdf_text3D_transparent.slf | 4 +- libraries/render-utils/src/simple.slf | 4 +- libraries/render-utils/src/simple.slv | 4 +- libraries/render-utils/src/simple_fade.slf | 4 +- libraries/render-utils/src/simple_fade.slv | 4 +- .../src/simple_opaque_web_browser.slf | 4 +- .../render-utils/src/simple_textured.slf | 4 +- .../render-utils/src/simple_textured_fade.slf | 4 +- .../src/simple_textured_unlit.slf | 4 +- .../src/simple_textured_unlit_fade.slf | 4 +- .../render-utils/src/simple_transparent.slf | 4 +- .../src/simple_transparent_textured.slf | 4 +- .../src/simple_transparent_textured_fade.slf | 4 +- .../src/simple_transparent_textured_unlit.slf | 4 +- ...simple_transparent_textured_unlit_fade.slf | 4 +- .../src/simple_transparent_web_browser.slf | 4 +- libraries/render-utils/src/skin_model.slv | 14 +- libraries/render-utils/src/skin_model_dq.slv | 14 +- .../render-utils/src/skin_model_fade.slv | 14 +- .../render-utils/src/skin_model_fade_dq.slv | 14 +- .../src/skin_model_normal_map.slv | 14 +- .../src/skin_model_normal_map_dq.slv | 14 +- .../src/skin_model_normal_map_fade.slv | 14 +- .../src/skin_model_normal_map_fade_dq.slv | 14 +- libraries/shaders/CMakeLists.txt | 2 +- libraries/shaders/src/shaders/Shaders.cpp | 29 ++-- libraries/ui/src/ui/OffscreenQmlSurface.cpp | 10 ++ tests-manual/render-utils/src/main.cpp | 9 +- tests/shaders/src/ShaderTests.cpp | 124 +++++++++++++++--- tools/shreflect/src/main.cpp | 10 +- 101 files changed, 637 insertions(+), 431 deletions(-) diff --git a/libraries/gl/src/gl/Context.cpp b/libraries/gl/src/gl/Context.cpp index 309839808e..ad7e51fbd3 100644 --- a/libraries/gl/src/gl/Context.cpp +++ b/libraries/gl/src/gl/Context.cpp @@ -269,7 +269,9 @@ void Context::create() { #if defined(USE_GLES) _version = 0x0200; #else - if (GLAD_GL_VERSION_4_5) { + if (gl::disableGl45()) { + _version = 0x0401; + } else if (GLAD_GL_VERSION_4_5) { _version = 0x0405; } else if (GLAD_GL_VERSION_4_3) { _version = 0x0403; diff --git a/libraries/gl/src/gl/GLHelpers.cpp b/libraries/gl/src/gl/GLHelpers.cpp index e3f85afa78..7ebba4f8d8 100644 --- a/libraries/gl/src/gl/GLHelpers.cpp +++ b/libraries/gl/src/gl/GLHelpers.cpp @@ -24,6 +24,26 @@ size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format) { return pixelSize; } +bool gl::disableGl45() { +#if defined(USE_GLES) + return false; +#else + static const QString DEBUG_FLAG("HIFI_DISABLE_OPENGL_45"); + static bool disableOpenGL45 = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG); + return disableOpenGL45; +#endif +} + +void gl::getTargetVersion(int& major, int& minor) { +#if defined(USE_GLES) + major = 3; + minor = 2; +#else + major = 4; + minor = disableGl45() ? 1 : 5; +#endif +} + const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() { static QSurfaceFormat format; static std::once_flag once; @@ -40,7 +60,10 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() { // Qt Quick may need a depth and stencil buffer. Always make sure these are available. format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS); format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS); - setGLFormatVersion(format); + int major, minor; + ::gl::getTargetVersion(major, minor); + format.setMajorVersion(major); + format.setMinorVersion(minor); QSurfaceFormat::setDefaultFormat(format); }); return format; diff --git a/libraries/gl/src/gl/GLHelpers.h b/libraries/gl/src/gl/GLHelpers.h index dcbf5a9e77..6252eba2f0 100644 --- a/libraries/gl/src/gl/GLHelpers.h +++ b/libraries/gl/src/gl/GLHelpers.h @@ -26,15 +26,6 @@ class QOpenGLDebugMessage; class QSurfaceFormat; class QGLFormat; -template -// https://bugreports.qt.io/browse/QTBUG-64703 prevents us from using "defined(QT_OPENGL_ES_3_1)" -#if defined(USE_GLES) -void setGLFormatVersion(F& format, int major = 3, int minor = 2) -#else -void setGLFormatVersion(F& format, int major = 4, int minor = 5) -#endif - { format.setVersion(major, minor); } - size_t evalGLFormatSwapchainPixelSize(const QSurfaceFormat& format); const QSurfaceFormat& getDefaultOpenGLSurfaceFormat(); @@ -50,6 +41,9 @@ namespace gl { bool checkGLErrorDebug(const char* name); + bool disableGl45(); + + void getTargetVersion(int& major, int& minor); } // namespace gl #define CHECK_GL_ERROR() ::gl::checkGLErrorDebug(__FUNCTION__) diff --git a/libraries/gl/src/gl/GLShaders.cpp b/libraries/gl/src/gl/GLShaders.cpp index 03b807fbbf..a0d976d727 100644 --- a/libraries/gl/src/gl/GLShaders.cpp +++ b/libraries/gl/src/gl/GLShaders.cpp @@ -102,8 +102,23 @@ Uniforms Uniform::load(GLuint glprogram, const std::vector& indices) { return result; } +Uniform Uniform::loadByName(GLuint glprogram, const std::string& name) { + GLuint index; + const char* nameCStr = name.c_str(); + glGetUniformIndices(glprogram, 1, &nameCStr, &index); + Uniform result; + if (index != GL_INVALID_INDEX) { + result.load(glprogram, index); + } + return result; +} + + Uniforms Uniform::load(GLuint glprogram, const std::vector& cnames) { GLsizei count = static_cast(cnames.size()); + if (0 == count) { + return {}; + } std::vector indices; indices.resize(count); glGetUniformIndices(glprogram, count, cnames.data(), indices.data()); @@ -232,58 +247,28 @@ bool gl::compileShader(GLenum shaderDomain, GLint compiled = 0; glGetShaderiv(glshader, GL_COMPILE_STATUS, &compiled); - GLint infoLength = 0; - glGetShaderiv(glshader, GL_INFO_LOG_LENGTH, &infoLength); - - if ((infoLength > 0) || !compiled) { - char* temp = new char[infoLength]; - glGetShaderInfoLog(glshader, infoLength, NULL, temp); - - message = std::string(temp); - - // if compilation fails - if (!compiled) { - // save the source code to a temp file so we can debug easily - /* - std::ofstream filestream; - filestream.open("debugshader.glsl"); - if (filestream.is_open()) { - for (const auto& str : cstrs) { - filestream << str; - } - filestream.close(); + getShaderInfoLog(glshader, message); + // if compilation fails + if (!compiled) { + qCCritical(glLogging) << "GLShader::compileShader - failed to compile the gl shader object:"; + int lineNumber = 0; + for (const auto& s : cstrs) { + QString str(s); + QStringList lines = str.split("\n"); + for (auto& line : lines) { + qCCritical(glLogging).noquote() << QString("%1: %2").arg(lineNumber++, 5, 10, QChar('0')).arg(line); } - */ - - /* - filestream.open("debugshader.glsl.info.txt"); - if (filestream.is_open()) { - filestream << std::string(temp); - filestream.close(); - } - */ - - qCCritical(glLogging) << "GLShader::compileShader - failed to compile the gl shader object:"; - int lineNumber = 0; - for (const auto& s : cstrs) { - QString str(s); - QStringList lines = str.split("\n"); - for (auto& line : lines) { - qCCritical(glLogging).noquote() << QString("%1: %2").arg(lineNumber++, 5, 10, QChar('0')).arg(line); - } - } - qCCritical(glLogging) << "GLShader::compileShader - errors:"; - qCCritical(glLogging) << temp; - - delete[] temp; - glDeleteShader(glshader); - return false; } + qCCritical(glLogging) << "GLShader::compileShader - errors:"; + qCCritical(glLogging) << message.c_str(); + glDeleteShader(glshader); + return false; + } + if (!message.empty()) { // Compilation success qCWarning(glLogging) << "GLShader::compileShader - Success:"; - qCWarning(glLogging) << temp; - delete[] temp; + qCWarning(glLogging) << message.c_str(); } #ifdef SEPARATE_PROGRAM @@ -341,6 +326,20 @@ bool gl::compileShader(GLenum shaderDomain, return true; } +void gl::getShaderInfoLog(GLuint glshader, std::string& message) { + std::string result; + GLint infoLength = 0; + glGetShaderiv(glshader, GL_INFO_LOG_LENGTH, &infoLength); + if (infoLength > 0) { + char* temp = new char[infoLength]; + glGetShaderInfoLog(glshader, infoLength, NULL, temp); + message = std::string(temp); + delete[] temp; + } else { + message.clear(); + } +} + void gl::getProgramInfoLog(GLuint glprogram, std::string& message) { std::string result; GLint infoLength = 0; diff --git a/libraries/gl/src/gl/GLShaders.h b/libraries/gl/src/gl/GLShaders.h index 5d16bd443e..c12e9d2305 100644 --- a/libraries/gl/src/gl/GLShaders.h +++ b/libraries/gl/src/gl/GLShaders.h @@ -41,9 +41,13 @@ struct Uniform : public ShaderBinding { static Vector load(GLuint glprogram, const std::vector& indices); static Vector load(GLuint glprogram, const std::vector& names); static Vector load(GLuint glprogram, const std::vector& names); + static Uniform loadByName(GLuint glprogram, const std::string& names); template static Vector loadByName(GLuint glprogram, const C& names) { + if (names.empty()) { + return {}; + } std::vector cnames; cnames.reserve(names.size()); for (const auto& name : names) { @@ -113,6 +117,7 @@ bool compileShader(GLenum shaderDomain, GLuint buildProgram(const std::vector& glshaders); GLuint buildProgram(const CachedShader& binary); bool linkProgram(GLuint glprogram, std::string& message); +void getShaderInfoLog(GLuint glshader, std::string& message); void getProgramInfoLog(GLuint glprogram, std::string& message); void getProgramBinary(GLuint glprogram, CachedShader& cachedShader); } // namespace gl diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index 2d26b4b347..01424c2ac6 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -108,7 +108,6 @@ GLint GLBackend::MAX_COMBINED_UNIFORM_BLOCKS{ 0 }; GLint GLBackend::MAX_COMBINED_TEXTURE_IMAGE_UNITS{ 0 }; GLint GLBackend::MAX_UNIFORM_BLOCK_SIZE{ 0 }; GLint GLBackend::UNIFORM_BUFFER_OFFSET_ALIGNMENT{ 1 }; -GLint GLBackend::MAX_UNIFORM_LOCATIONS{ 0 }; void GLBackend::init() { static std::once_flag once; @@ -127,7 +126,6 @@ void GLBackend::init() { GL_GET_INTEGER(MAX_COMBINED_UNIFORM_BLOCKS); GL_GET_INTEGER(MAX_UNIFORM_BLOCK_SIZE); GL_GET_INTEGER(UNIFORM_BUFFER_OFFSET_ALIGNMENT); - GL_GET_INTEGER(MAX_UNIFORM_LOCATIONS); qCDebug(gpugllogging) << "GL Version: " << QString((const char*) glGetString(GL_VERSION)); qCDebug(gpugllogging) << "GL Shader Language Version: " << QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 2be13bbae4..cadcec7a56 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -90,7 +90,6 @@ public: static GLint MAX_COMBINED_UNIFORM_BLOCKS; static GLint MAX_COMBINED_TEXTURE_IMAGE_UNITS; static GLint MAX_UNIFORM_BLOCK_SIZE; - static GLint MAX_UNIFORM_LOCATIONS; static GLint UNIFORM_BUFFER_OFFSET_ALIGNMENT; virtual ~GLBackend(); diff --git a/libraries/gpu-gl/src/gpu/gl/GLDesktopBackend.cpp b/libraries/gpu-gl/src/gpu/gl/GLDesktopBackend.cpp index be8b8cb082..bc7cbdff4a 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLDesktopBackend.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLDesktopBackend.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include "../gl41/GL41Backend.h" @@ -24,9 +25,6 @@ using namespace gpu; using namespace gpu::gl; -static const QString DEBUG_FLAG("HIFI_DISABLE_OPENGL_45"); -static bool disableOpenGL45 = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG); - static GLBackend* INSTANCE{ nullptr }; BackendPointer GLBackend::createBackend() { @@ -34,7 +32,7 @@ BackendPointer GLBackend::createBackend() { // Where the gpuContext is initialized and where the TRUE Backend is created and assigned auto version = QOpenGLContextWrapper::currentContextVersion(); std::shared_ptr result; - if (!disableOpenGL45 && version >= 0x0405) { + if (!::gl::disableGl45() && version >= 0x0405) { qCDebug(gpugllogging) << "Using OpenGL 4.5 backend"; result = std::make_shared(); } else { diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h index 8cf44a33d8..c6fbc43ae5 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h +++ b/libraries/gpu-gl/src/gpu/gl41/GL41Backend.h @@ -19,11 +19,7 @@ #define GPU_CORE_41 410 #define GPU_CORE_43 430 -#ifdef Q_OS_MAC #define GPU_INPUT_PROFILE GPU_CORE_41 -#else -#define GPU_INPUT_PROFILE GPU_CORE_43 -#endif namespace gpu { namespace gl41 { diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp index 2c3010e0f5..8a67ff9619 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendShader.cpp @@ -35,36 +35,41 @@ void GL41Backend::postLinkProgram(ShaderObject& programObject, const Shader& pro continue; } const auto& targetLocation = expectedUbos.at(name); - if (ubo.binding != targetLocation) { - glUniformBlockBinding(glprogram, ubo.index, targetLocation); + glUniformBlockBinding(glprogram, ubo.index, targetLocation); + } + } + + // For the Textures, use glUniform1i to fixup the active texture slots based on the reflection + { + const auto expectedTextures = program.getTextures().getLocationsByName(); + for (const auto& expectedTexture : expectedTextures) { + auto location = glGetUniformLocation(glprogram, expectedTexture.first.c_str()); + if (location < 0) { + continue; } + glProgramUniform1i(glprogram, location, expectedTexture.second); } } - // For the Textures, us glUniform1i to fixup the active texture slots based on the reflection + // For the resource buffers, do the same as for the textures, since in GL 4.1 that's how they're implemented { - const auto expectedTextures = program.getTextures().getLocationsByName(); - const auto textureUniforms = ::gl::Uniform::loadByName(glprogram, program.getTextures().getNames()); - for (const auto& texture : textureUniforms) { - const auto& targetBinding = expectedTextures.at(texture.name); - glProgramUniform1i(glprogram, texture.binding, targetBinding); + const auto expectedResourceBuffers = program.getResourceBuffers().getLocationsByName(); + const auto resourceBufferUniforms = ::gl::Uniform::loadByName(glprogram, program.getResourceBuffers().getNames()); + for (const auto& resourceBuffer : resourceBufferUniforms) { + const auto& targetBinding = expectedResourceBuffers.at(resourceBuffer.name); + glProgramUniform1i(glprogram, resourceBuffer.binding, targetBinding); } } - // For the resource buffers + // Special case for the transformObjectBuffer, which is filtered out of the reflection data at shader load time + // { - const auto expectedTextures = program.getTextures().getLocationsByName(); - const auto textureUniforms = ::gl::Uniform::loadByName(glprogram, program.getTextures().getNames()); - for (const auto& texture : textureUniforms) { - const auto& targetBinding = expectedTextures.at(texture.name); - glProgramUniform1i(glprogram, texture.binding, targetBinding); + static const std::string TRANSFORM_OBJECT_BUFFER = "transformObjectBuffer"; + const auto uniform = ::gl::Uniform::loadByName(glprogram, TRANSFORM_OBJECT_BUFFER); + if (-1 != uniform.binding) { + glProgramUniform1i(glprogram, uniform.binding, ::gpu::slot::texture::ObjectTransforms); } } - -#if defined(Q_OS_MAC) - // For the uniforms, we need to create a remapping layer - programObject.uniformRemap = buildRemap(glprogram, program.getUniforms()); -#endif } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.cpp index 8f8e158334..bbe011d237 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.cpp @@ -19,11 +19,13 @@ using namespace gpu; using namespace gpu::gl45; GLint GL45Backend::MAX_COMBINED_SHADER_STORAGE_BLOCKS{ 0 }; +GLint GL45Backend::MAX_UNIFORM_LOCATIONS{ 0 }; static void staticInit() { static std::once_flag once; std::call_once(once, [&] { glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &GL45Backend::MAX_COMBINED_SHADER_STORAGE_BLOCKS); + glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &GL45Backend::MAX_UNIFORM_LOCATIONS); }); } const std::string GL45Backend::GL45_VERSION { "GL45" }; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h index 8694e15d97..658bea2a3e 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h +++ b/libraries/gpu-gl/src/gpu/gl45/GL45Backend.h @@ -34,6 +34,7 @@ class GL45Backend : public GLBackend { public: static GLint MAX_COMBINED_SHADER_STORAGE_BLOCKS; + static GLint MAX_UNIFORM_LOCATIONS; #if GPU_BINDLESS_TEXTURES virtual bool supportsBindless() const override { return true; } #endif diff --git a/libraries/gpu/src/gpu/Shader.cpp b/libraries/gpu/src/gpu/Shader.cpp index cea7ec6e14..0191d9d4f1 100755 --- a/libraries/gpu/src/gpu/Shader.cpp +++ b/libraries/gpu/src/gpu/Shader.cpp @@ -204,9 +204,33 @@ Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer return createOrReuseProgramShader(PROGRAM, vertexShader, geometryShader, pixelShader); } +static const std::string IGNORED_BINDING = "transformObjectBuffer"; + void updateBindingsFromJsonObject(Shader::LocationMap& inOutSet, const QJsonObject& json) { for (const auto& key : json.keys()) { - inOutSet[key.toStdString()] = json[key].toInt(); + auto keyStr = key.toStdString(); + if (IGNORED_BINDING == keyStr) { + continue; + } + inOutSet[keyStr] = json[key].toInt(); + } +} + +void updateTextureAndResourceBuffersFromJsonObjects(Shader::LocationMap& inOutTextures, Shader::LocationMap& inOutResourceBuffers, + const QJsonObject& json, const QJsonObject& types) { + static const std::string RESOURCE_BUFFER_TEXTURE_TYPE = "samplerBuffer"; + for (const auto& key : json.keys()) { + auto keyStr = key.toStdString(); + if (keyStr == IGNORED_BINDING) { + continue; + } + auto location = json[key].toInt(); + auto type = types[key].toString().toStdString(); + if (type == RESOURCE_BUFFER_TEXTURE_TYPE) { + inOutResourceBuffers[keyStr] = location; + } else { + inOutTextures[key.toStdString()] = location; + } } } @@ -221,6 +245,7 @@ Shader::ReflectionMap getShaderReflection(const std::string& reflectionJson) { #define REFLECT_KEY_SSBOS "storageBuffers" #define REFLECT_KEY_UNIFORMS "uniforms" #define REFLECT_KEY_TEXTURES "textures" +#define REFLECT_KEY_TEXTURE_TYPES "textureTypes" auto doc = QJsonDocument::fromJson(reflectionJson.c_str()); if (doc.isNull()) { @@ -236,17 +261,28 @@ Shader::ReflectionMap getShaderReflection(const std::string& reflectionJson) { if (json.contains(REFLECT_KEY_OUTPUTS)) { updateBindingsFromJsonObject(result[Shader::BindingType::OUTPUT], json[REFLECT_KEY_OUTPUTS].toObject()); } - if (json.contains(REFLECT_KEY_UBOS)) { - updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM_BUFFER], json[REFLECT_KEY_UBOS].toObject()); - } - if (json.contains(REFLECT_KEY_TEXTURES)) { - updateBindingsFromJsonObject(result[Shader::BindingType::TEXTURE], json[REFLECT_KEY_TEXTURES].toObject()); - } + // FIXME eliminate the last of the uniforms if (json.contains(REFLECT_KEY_UNIFORMS)) { updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM], json[REFLECT_KEY_UNIFORMS].toObject()); } + if (json.contains(REFLECT_KEY_UBOS)) { + updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM_BUFFER], json[REFLECT_KEY_UBOS].toObject()); + } + + // SSBOs need to come BEFORE the textures. In GL 4.5 the reflection slots aren't really used, but in 4.1 the slots + // are used to explicitly setup bindings after shader linkage, so we want the resource buffer slots to contain the + // texture locations, not the SSBO locations if (json.contains(REFLECT_KEY_SSBOS)) { - updateBindingsFromJsonObject(result[Shader::BindingType::UNIFORM], json[REFLECT_KEY_SSBOS].toObject()); + updateBindingsFromJsonObject(result[Shader::BindingType::RESOURCE_BUFFER], json[REFLECT_KEY_SSBOS].toObject()); + } + + // samplerBuffer textures map to gpu ResourceBuffer, while all other textures map to regular gpu Texture + if (json.contains(REFLECT_KEY_TEXTURES)) { + updateTextureAndResourceBuffersFromJsonObjects( + result[Shader::BindingType::TEXTURE], + result[Shader::BindingType::RESOURCE_BUFFER], + json[REFLECT_KEY_TEXTURES].toObject(), + json[REFLECT_KEY_TEXTURE_TYPES].toObject()); } diff --git a/libraries/gpu/src/gpu/ShaderConstants.h b/libraries/gpu/src/gpu/ShaderConstants.h index dd9b350a4e..dc5879e7ad 100644 --- a/libraries/gpu/src/gpu/ShaderConstants.h +++ b/libraries/gpu/src/gpu/ShaderConstants.h @@ -37,6 +37,9 @@ #define GPU_ATTR_STEREO_SIDE 14 #define GPU_ATTR_DRAW_CALL_INFO 15 +// OSX seems to have an issue using 14 as an attribute location for passing from the vertex to the fragment shader +#define GPU_ATTR_V2F_STEREO_SIDE 8 + #define GPU_UNIFORM_COLOR 101 #define GPU_UNIFORM_TEXCOORD_RECT 102 #define GPU_UNIFORM_EXTRA0 110 diff --git a/libraries/gpu/src/gpu/TextureTable.slh b/libraries/gpu/src/gpu/TextureTable.slh index f2d89e753b..bedbff954b 100644 --- a/libraries/gpu/src/gpu/TextureTable.slh +++ b/libraries/gpu/src/gpu/TextureTable.slh @@ -22,8 +22,7 @@ struct GPUTextureTable { #define tableTex(name, slot) sampler2D(name._textures[slot].xy) #define tableTexMinLod(name, slot) float(name._textures[slot].z) -#define tableTexValue(name, slot, uv) \ - tableTexValueLod(tableTex(matTex, albedoMap), tableTexMinLod(matTex, albedoMap), uv) +#define tableTexValue(name, slot, uv) tableTexValueLod(tableTex(matTex, albedoMap), tableTexMinLod(matTex, albedoMap), uv) vec4 tableTexValueLod(sampler2D sampler, float minLod, vec2 uv) { float queryLod = textureQueryLod(sampler, uv).x; diff --git a/libraries/gpu/src/gpu/Transform.slh b/libraries/gpu/src/gpu/Transform.slh index fd389e1d50..d0b7587da6 100644 --- a/libraries/gpu/src/gpu/Transform.slh +++ b/libraries/gpu/src/gpu/Transform.slh @@ -35,7 +35,7 @@ layout(std140, binding=GPU_BUFFER_TRANSFORM_CAMERA) uniform transformCameraBuffe layout(location=GPU_ATTR_STEREO_SIDE) in int _inStereoSide; #endif -layout(location=GPU_ATTR_STEREO_SIDE) flat out int _stereoSide; +layout(location=GPU_ATTR_V2F_STEREO_SIDE) flat out int _stereoSide; // In stereo drawcall mode Instances are drawn twice (left then right) hence the true InstanceID is the gl_InstanceID / 2 int gpu_InstanceID() { @@ -60,7 +60,7 @@ int gpu_InstanceID() { #ifdef GPU_PIXEL_SHADER #ifdef GPU_TRANSFORM_STEREO_CAMERA -layout(location=GPU_ATTR_STEREO_SIDE) flat in int _stereoSide; +layout(location=GPU_ATTR_V2F_STEREO_SIDE) flat in int _stereoSide; #endif #endif diff --git a/libraries/render-utils/src/BloomApply.slf b/libraries/render-utils/src/BloomApply.slf index caee76b651..a53894de60 100644 --- a/libraries/render-utils/src/BloomApply.slf +++ b/libraries/render-utils/src/BloomApply.slf @@ -10,6 +10,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // <@include BloomApply.shared.slh@> +<@include render-utils/ShaderConstants.h@> layout(binding=0) uniform sampler2D blurMap0; layout(binding=1) uniform sampler2D blurMap1; diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index ce5141d3c6..bb3c0bc769 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -19,9 +19,6 @@ <@include LightingModel.slh@> <$declareLightBuffer()$> -<@include LightDirectional.slh@> -<$declareLightingDirectional(_SCRIBE_NULL)$> - <@include Haze.slh@> layout(binding=RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH) uniform sampler2D linearDepthMap; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index ea9655d26d..59c86acd19 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -12,6 +12,8 @@ #include "RenderDeferredTask.h" +#include + #include #include diff --git a/libraries/render-utils/src/deferred_light.slv b/libraries/render-utils/src/deferred_light.slv index 3b8aee6aae..654e9a69b2 100644 --- a/libraries/render-utils/src/deferred_light.slv +++ b/libraries/render-utils/src/deferred_light.slv @@ -14,7 +14,7 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_UNIFORM_LIGHT_TEXCOORD_TRANSFORM) uniform vec4 texcoordFrameTransform; @@ -28,10 +28,10 @@ void main(void) { ); vec4 pos = UNIT_QUAD[gl_VertexID]; - _texCoord0 = (pos.xy + 1.0) * 0.5; + _texCoord01.xy = (pos.xy + 1.0) * 0.5; - _texCoord0 *= texcoordFrameTransform.zw; - _texCoord0 += texcoordFrameTransform.xy; + _texCoord01.xy *= texcoordFrameTransform.zw; + _texCoord01.xy += texcoordFrameTransform.xy; gl_Position = pos; } diff --git a/libraries/render-utils/src/deferred_light_limited.slv b/libraries/render-utils/src/deferred_light_limited.slv index 790c305204..fb59b8e78f 100644 --- a/libraries/render-utils/src/deferred_light_limited.slv +++ b/libraries/render-utils/src/deferred_light_limited.slv @@ -20,7 +20,7 @@ uniform vec4 sphereParam; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec4 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main(void) { if (sphereParam.w != 0.0) { @@ -41,7 +41,7 @@ void main(void) { } #endif #endif - _texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w; + _texCoord01.xy = vec4(projected.xy, 0.0, 1.0) * gl_Position.w; } else { const float depth = -1.0; //Draw at near plane const vec4 UNIT_QUAD[4] = vec4[4]( @@ -60,13 +60,13 @@ void main(void) { #endif #endif - _texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0); + _texCoord01.xy = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0); #ifdef GPU_TRANSFORM_IS_STEREO #ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN #else if (cam_isStereo()) { - _texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide()); + _texCoord01.x = 0.5 * (_texCoord01.x + cam_getStereoSide()); } #endif #endif diff --git a/libraries/render-utils/src/deferred_light_point.slv b/libraries/render-utils/src/deferred_light_point.slv index 85707b322d..1f4c66b6e5 100644 --- a/libraries/render-utils/src/deferred_light_point.slv +++ b/libraries/render-utils/src/deferred_light_point.slv @@ -26,7 +26,7 @@ layout(binding=RENDER_UTILS_BUFFER_LIGHT_INDEX) uniform lightIndexBuffer { int lightIndex[256]; }; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec4 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord0; void main(void) { diff --git a/libraries/render-utils/src/deferred_light_spot.slv b/libraries/render-utils/src/deferred_light_spot.slv index 637df14175..c86551936b 100644 --- a/libraries/render-utils/src/deferred_light_spot.slv +++ b/libraries/render-utils/src/deferred_light_spot.slv @@ -24,7 +24,7 @@ layout(binding=RENDER_UTILS_BUFFER_LIGHT_INDEX) uniform lightIndexBuffer { int lightIndex[256]; }; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec4 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord0; void main(void) { vec4 coneVertex = inPosition; diff --git a/libraries/render-utils/src/directional_ambient_light.slf b/libraries/render-utils/src/directional_ambient_light.slf index 86adc744e2..3105b76bde 100644 --- a/libraries/render-utils/src/directional_ambient_light.slf +++ b/libraries/render-utils/src/directional_ambient_light.slf @@ -22,8 +22,9 @@ <$declareEvalAmbientSphereGlobalColor(supportScattering)$> - -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/directional_ambient_light_shadow.slf b/libraries/render-utils/src/directional_ambient_light_shadow.slf index f54f01c4af..88c0188048 100644 --- a/libraries/render-utils/src/directional_ambient_light_shadow.slf +++ b/libraries/render-utils/src/directional_ambient_light_shadow.slf @@ -20,7 +20,9 @@ <$declareEvalLightmappedColor()$> <$declareEvalAmbientSphereGlobalColor(isScattering)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index f9b7664d10..56a7cd1883 100644 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -19,7 +19,9 @@ <$declareEvalLightmappedColor()$> <$declareEvalSkyboxGlobalColor(isScattering)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/directional_skybox_light_shadow.slf b/libraries/render-utils/src/directional_skybox_light_shadow.slf index 34a836e5b0..6eaa989c6b 100644 --- a/libraries/render-utils/src/directional_skybox_light_shadow.slf +++ b/libraries/render-utils/src/directional_skybox_light_shadow.slf @@ -20,7 +20,9 @@ <$declareEvalLightmappedColor()$> <$declareEvalSkyboxGlobalColor(isScattering)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/forward_model.slf b/libraries/render-utils/src/forward_model.slf index 6df5343c5c..82d776602f 100644 --- a/libraries/render-utils/src/forward_model.slf +++ b/libraries/render-utils/src/forward_model.slf @@ -26,10 +26,11 @@ <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor0; @@ -45,7 +46,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/forward_model_normal_map.slf b/libraries/render-utils/src/forward_model_normal_map.slf index 88f9df1ecf..21ed0b9359 100644 --- a/libraries/render-utils/src/forward_model_normal_map.slf +++ b/libraries/render-utils/src/forward_model_normal_map.slf @@ -24,11 +24,12 @@ <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor0; @@ -44,7 +45,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/forward_model_translucent.slf b/libraries/render-utils/src/forward_model_translucent.slf index 5b69a6cb21..74d200542f 100644 --- a/libraries/render-utils/src/forward_model_translucent.slf +++ b/libraries/render-utils/src/forward_model_translucent.slf @@ -23,12 +23,12 @@ <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor0; @@ -38,13 +38,13 @@ void main(void) { <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/forward_model_unlit.slf b/libraries/render-utils/src/forward_model_unlit.slf index d01bd70815..daad2ee6b9 100644 --- a/libraries/render-utils/src/forward_model_unlit.slf +++ b/libraries/render-utils/src/forward_model_unlit.slf @@ -19,8 +19,10 @@ <$declareMaterialTextures(ALBEDO)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor0; @@ -36,7 +38,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; if (opacity != 1.0) { discard; diff --git a/libraries/render-utils/src/forward_simple.slf b/libraries/render-utils/src/forward_simple.slf index d4cf85d802..09365635cf 100644 --- a/libraries/render-utils/src/forward_simple.slf +++ b/libraries/render-utils/src/forward_simple.slf @@ -21,7 +21,9 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; diff --git a/libraries/render-utils/src/forward_simple_textured.slf b/libraries/render-utils/src/forward_simple_textured.slf index 0c50b0b599..532d12dd17 100644 --- a/libraries/render-utils/src/forward_simple_textured.slf +++ b/libraries/render-utils/src/forward_simple_textured.slf @@ -27,7 +27,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=0) out vec4 _fragColor0; diff --git a/libraries/render-utils/src/forward_simple_textured_transparent.slf b/libraries/render-utils/src/forward_simple_textured_transparent.slf index d1cd21b4cb..98dc0bb368 100644 --- a/libraries/render-utils/src/forward_simple_textured_transparent.slf +++ b/libraries/render-utils/src/forward_simple_textured_transparent.slf @@ -27,7 +27,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=0) out vec4 _fragColor0; diff --git a/libraries/render-utils/src/forward_simple_textured_unlit.slf b/libraries/render-utils/src/forward_simple_textured_unlit.slf index cca371a1ff..7d3bf5912a 100644 --- a/libraries/render-utils/src/forward_simple_textured_unlit.slf +++ b/libraries/render-utils/src/forward_simple_textured_unlit.slf @@ -23,7 +23,9 @@ layout(location=0) out vec4 _fragColor0; layout(binding=0) uniform sampler2D originalTexture; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; void main(void) { vec4 texel = texture(originalTexture, _texCoord0.st); diff --git a/libraries/render-utils/src/forward_simple_transparent.slf b/libraries/render-utils/src/forward_simple_transparent.slf index 46328b77b6..a47d5963a2 100644 --- a/libraries/render-utils/src/forward_simple_transparent.slf +++ b/libraries/render-utils/src/forward_simple_transparent.slf @@ -20,7 +20,9 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; diff --git a/libraries/render-utils/src/glowLine.slf b/libraries/render-utils/src/glowLine.slf index 69757ec92a..4e80b3358a 100644 --- a/libraries/render-utils/src/glowLine.slf +++ b/libraries/render-utils/src/glowLine.slf @@ -12,8 +12,7 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; - -layout(location=1) in float distanceFromCenter; +layout(location=0) in float distanceFromCenter; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/glowLine.slv b/libraries/render-utils/src/glowLine.slv index 70947350a4..075b291589 100644 --- a/libraries/render-utils/src/glowLine.slv +++ b/libraries/render-utils/src/glowLine.slv @@ -27,7 +27,7 @@ layout(std140, binding=0) uniform LineDataBuffer { layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; // the distance from the center in 'quad space' -layout(location=1) out float distanceFromCenter; +layout(location=0) out float distanceFromCenter; void main(void) { _color = _lineData.color; diff --git a/libraries/render-utils/src/hmd_ui.slf b/libraries/render-utils/src/hmd_ui.slf index d0e6798cec..b8bca889bf 100644 --- a/libraries/render-utils/src/hmd_ui.slf +++ b/libraries/render-utils/src/hmd_ui.slf @@ -23,7 +23,9 @@ layout(std140, binding=0) uniform hudBuffer { HUDData hud; }; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 fragColor0; diff --git a/libraries/render-utils/src/hmd_ui.slv b/libraries/render-utils/src/hmd_ui.slv index 5352a5ba68..ab0d77c42a 100644 --- a/libraries/render-utils/src/hmd_ui.slv +++ b/libraries/render-utils/src/hmd_ui.slv @@ -26,10 +26,10 @@ layout(std140, binding=0) uniform hudBuffer { HUDData hud; }; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main() { - _texCoord0 = inTexCoord0.st; + _texCoord01.xy = inTexCoord0.st; // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/local_lights_drawOutline.slf b/libraries/render-utils/src/local_lights_drawOutline.slf index c2a53e0490..ff6476e21c 100644 --- a/libraries/render-utils/src/local_lights_drawOutline.slf +++ b/libraries/render-utils/src/local_lights_drawOutline.slf @@ -33,7 +33,9 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/local_lights_shading.slf b/libraries/render-utils/src/local_lights_shading.slf index 60cd9c426d..14cecd1815 100644 --- a/libraries/render-utils/src/local_lights_shading.slf +++ b/libraries/render-utils/src/local_lights_shading.slf @@ -21,7 +21,9 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor; void main(void) { diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index 20fa10f44c..70b71e0d22 100644 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -19,10 +19,11 @@ <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { Material mat = getMaterial(); @@ -36,7 +37,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model.slv b/libraries/render-utils/src/model.slv index 1ec5cf83aa..3763b8d2de 100644 --- a/libraries/render-utils/src/model.slv +++ b/libraries/render-utils/src/model.slv @@ -22,19 +22,17 @@ <$declareMaterialTexMapArrayBuffer()$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { - _color = color_sRGBToLinear(inColor.xyz); - _alpha = inColor.w; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_fade.slf b/libraries/render-utils/src/model_fade.slf index 31a4f4db6e..23c629ddb0 100644 --- a/libraries/render-utils/src/model_fade.slf +++ b/libraries/render-utils/src/model_fade.slf @@ -25,10 +25,11 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { vec3 fadeEmissive; @@ -48,7 +49,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_fade.slv b/libraries/render-utils/src/model_fade.slv index e3f7924bc2..84f4f08fed 100644 --- a/libraries/render-utils/src/model_fade.slv +++ b/libraries/render-utils/src/model_fade.slv @@ -23,19 +23,17 @@ layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { - _color = color_sRGBToLinear(inColor.xyz); - _alpha = inColor.w; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.w; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_lightmap.slf b/libraries/render-utils/src/model_lightmap.slf index 3cd20b1a35..34da0a8a05 100644 --- a/libraries/render-utils/src/model_lightmap.slf +++ b/libraries/render-utils/src/model_lightmap.slf @@ -21,10 +21,11 @@ <$declareMaterialLightmap()$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { Material mat = getMaterial(); @@ -35,7 +36,7 @@ void main(void) { packDeferredFragmentLightmap( normalize(_normalWS), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), - getMaterialAlbedo(mat) * albedo.rgb * _color, + getMaterialAlbedo(mat) * albedo.rgb * _color.rgb, getMaterialRoughness(mat) * roughness, getMaterialMetallic(mat) * metallicTex, /*metallicTex, // no use of */getMaterialFresnel(mat), diff --git a/libraries/render-utils/src/model_lightmap.slv b/libraries/render-utils/src/model_lightmap.slv index e82fcaf85b..7306e2c831 100644 --- a/libraries/render-utils/src/model_lightmap.slv +++ b/libraries/render-utils/src/model_lightmap.slv @@ -23,19 +23,18 @@ <$declareMaterialTexMapArrayBuffer()$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { // pass along the color in linear space - _color = color_sRGBToLinear(inColor.xyz); + _color.rgb = color_sRGBToLinear(inColor.xyz); // and the texture coordinates TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_lightmap_fade.slf b/libraries/render-utils/src/model_lightmap_fade.slf index c7852cfd3f..6f6dd9c413 100644 --- a/libraries/render-utils/src/model_lightmap_fade.slf +++ b/libraries/render-utils/src/model_lightmap_fade.slf @@ -25,10 +25,11 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; void main(void) { @@ -46,7 +47,7 @@ void main(void) { packDeferredFragmentLightmap( normalize(_normalWS), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), - getMaterialAlbedo(mat) * albedo.rgb * _color, + getMaterialAlbedo(mat) * albedo.rgb * _color.rgb, getMaterialRoughness(mat) * roughness, getMaterialMetallic(mat) * metallicTex, /*metallicTex, // no use of */getMaterialFresnel(mat), diff --git a/libraries/render-utils/src/model_lightmap_fade.slv b/libraries/render-utils/src/model_lightmap_fade.slv index 5be90e2384..d174d3c1d3 100644 --- a/libraries/render-utils/src/model_lightmap_fade.slv +++ b/libraries/render-utils/src/model_lightmap_fade.slv @@ -23,20 +23,20 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { // pass along the color in linear space - _color = color_sRGBToLinear(inColor.xyz); + _color.rgb = color_sRGBToLinear(inColor.xyz); + _color.a = 1.0; // and the texture coordinates TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_lightmap_normal_map.slf b/libraries/render-utils/src/model_lightmap_normal_map.slf index 9f26c3063d..362c331f63 100644 --- a/libraries/render-utils/src/model_lightmap_normal_map.slf +++ b/libraries/render-utils/src/model_lightmap_normal_map.slf @@ -21,11 +21,12 @@ <$declareMaterialLightmap()$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { Material mat = getMaterial(); @@ -39,7 +40,7 @@ void main(void) { packDeferredFragmentLightmap( normalize(fragNormal.xyz), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), - getMaterialAlbedo(mat) * albedo.rgb * _color, + getMaterialAlbedo(mat) * albedo.rgb * _color.rgb, getMaterialRoughness(mat) * roughness, getMaterialMetallic(mat) * metallicTex, /*specular, // no use of */ getMaterialFresnel(mat), diff --git a/libraries/render-utils/src/model_lightmap_normal_map.slv b/libraries/render-utils/src/model_lightmap_normal_map.slv index 02524268ec..17794bce5f 100644 --- a/libraries/render-utils/src/model_lightmap_normal_map.slv +++ b/libraries/render-utils/src/model_lightmap_normal_map.slv @@ -24,19 +24,19 @@ layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { // pass along the color in linear space - _color = color_sRGBToLinear(inColor.xyz); + _color.rgb = color_sRGBToLinear(inColor.xyz); + _color.a = 1.0; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_lightmap_normal_map_fade.slf b/libraries/render-utils/src/model_lightmap_normal_map_fade.slf index b1563a6ad9..bbeade488e 100644 --- a/libraries/render-utils/src/model_lightmap_normal_map_fade.slf +++ b/libraries/render-utils/src/model_lightmap_normal_map_fade.slf @@ -26,11 +26,12 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; void main(void) { @@ -51,7 +52,7 @@ void main(void) { packDeferredFragmentLightmap( normalize(fragNormal.xyz), evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a), - getMaterialAlbedo(mat) * albedo.rgb * _color, + getMaterialAlbedo(mat) * albedo.rgb * _color.rgb, getMaterialRoughness(mat) * roughness, getMaterialMetallic(mat) * metallicTex, /*specular, // no use of */ getMaterialFresnel(mat), diff --git a/libraries/render-utils/src/model_lightmap_normal_map_fade.slv b/libraries/render-utils/src/model_lightmap_normal_map_fade.slv index 82f6d795d8..50a2bc43c9 100644 --- a/libraries/render-utils/src/model_lightmap_normal_map_fade.slv +++ b/libraries/render-utils/src/model_lightmap_normal_map_fade.slv @@ -23,20 +23,20 @@ layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { // pass along the color in linear space - _color = color_sRGBToLinear(inColor.xyz); + _color.rgb = color_sRGBToLinear(inColor.xyz); + _color.a = 1.0; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_normal_map.slf b/libraries/render-utils/src/model_normal_map.slf index 5d8ba00936..4e89dfb3e8 100644 --- a/libraries/render-utils/src/model_normal_map.slf +++ b/libraries/render-utils/src/model_normal_map.slf @@ -20,11 +20,12 @@ <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { Material mat = getMaterial(); @@ -38,7 +39,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_normal_map.slv b/libraries/render-utils/src/model_normal_map.slv index 52386d6e4f..4a1a0c9264 100644 --- a/libraries/render-utils/src/model_normal_map.slv +++ b/libraries/render-utils/src/model_normal_map.slv @@ -24,21 +24,19 @@ layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_normal_map_fade.slf b/libraries/render-utils/src/model_normal_map_fade.slf index fb66fe167c..16b8138efe 100644 --- a/libraries/render-utils/src/model_normal_map_fade.slf +++ b/libraries/render-utils/src/model_normal_map_fade.slf @@ -24,11 +24,12 @@ layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { vec3 fadeEmissive; @@ -48,7 +49,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_normal_map_fade.slv b/libraries/render-utils/src/model_normal_map_fade.slv index 74d23d6057..090027ac79 100644 --- a/libraries/render-utils/src/model_normal_map_fade.slv +++ b/libraries/render-utils/src/model_normal_map_fade.slv @@ -24,21 +24,19 @@ layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf index cd170f29e7..7fe81ab992 100644 --- a/libraries/render-utils/src/model_translucent.slf +++ b/libraries/render-utils/src/model_translucent.slf @@ -26,13 +26,13 @@ <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor; @@ -42,13 +42,13 @@ void main(void) { <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_translucent.slv b/libraries/render-utils/src/model_translucent.slv index defdb87172..70e61cd788 100644 --- a/libraries/render-utils/src/model_translucent.slv +++ b/libraries/render-utils/src/model_translucent.slv @@ -21,21 +21,19 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { - _color = color_sRGBToLinear(inColor.xyz); - _alpha = inColor.w; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_translucent_fade.slf b/libraries/render-utils/src/model_translucent_fade.slf index 81b9faf82d..b9df51fcb9 100644 --- a/libraries/render-utils/src/model_translucent_fade.slf +++ b/libraries/render-utils/src/model_translucent_fade.slf @@ -24,13 +24,13 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor; @@ -46,13 +46,13 @@ void main(void) { <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_translucent_normal_map.slf b/libraries/render-utils/src/model_translucent_normal_map.slf index c813097dcf..c023f78e25 100644 --- a/libraries/render-utils/src/model_translucent_normal_map.slf +++ b/libraries/render-utils/src/model_translucent_normal_map.slf @@ -28,14 +28,14 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor; @@ -45,13 +45,13 @@ void main(void) { <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_translucent_normal_map.slv b/libraries/render-utils/src/model_translucent_normal_map.slv index 257711ac24..299e1f53e1 100644 --- a/libraries/render-utils/src/model_translucent_normal_map.slv +++ b/libraries/render-utils/src/model_translucent_normal_map.slv @@ -21,22 +21,20 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { - _color = color_sRGBToLinear(inColor.xyz); - _alpha = inColor.w; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_translucent_normal_map_fade.slf b/libraries/render-utils/src/model_translucent_normal_map_fade.slf index d17c5105b1..992993edb3 100644 --- a/libraries/render-utils/src/model_translucent_normal_map_fade.slf +++ b/libraries/render-utils/src/model_translucent_normal_map_fade.slf @@ -32,13 +32,13 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) in vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=0) out vec4 _fragColor; @@ -55,13 +55,13 @@ void main(void) { <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$> <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; float roughness = getMaterialRoughness(mat); <$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>; diff --git a/libraries/render-utils/src/model_translucent_unlit.slf b/libraries/render-utils/src/model_translucent_unlit.slf index eef3190d2b..8f823e010a 100644 --- a/libraries/render-utils/src/model_translucent_unlit.slf +++ b/libraries/render-utils/src/model_translucent_unlit.slf @@ -20,9 +20,10 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=0) out vec4 _fragColor; @@ -31,13 +32,13 @@ void main(void) { BITFIELD matKey = getMaterialKey(mat); <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; _fragColor = vec4(albedo * isUnlitEnabled(), opacity); } diff --git a/libraries/render-utils/src/model_translucent_unlit_fade.slf b/libraries/render-utils/src/model_translucent_unlit_fade.slf index 4efdd7f4e5..2c72780976 100644 --- a/libraries/render-utils/src/model_translucent_unlit_fade.slf +++ b/libraries/render-utils/src/model_translucent_unlit_fade.slf @@ -23,9 +23,10 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=0) out vec4 _fragColor; @@ -41,13 +42,13 @@ void main(void) { BITFIELD matKey = getMaterialKey(mat); <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> - float opacity = getMaterialOpacity(mat) * _alpha; + float opacity = getMaterialOpacity(mat) * _color.a; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$discardTransparent(opacity)$>; vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; albedo += fadeEmissive; _fragColor = vec4(albedo * isUnlitEnabled(), opacity); } diff --git a/libraries/render-utils/src/model_unlit.slf b/libraries/render-utils/src/model_unlit.slf index e920b3eb67..0e93022b83 100644 --- a/libraries/render-utils/src/model_unlit.slf +++ b/libraries/render-utils/src/model_unlit.slf @@ -20,10 +20,11 @@ <$declareMaterialTextures(ALBEDO)$> -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { @@ -37,7 +38,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; packDeferredFragmentUnlit( normalize(_normalWS), diff --git a/libraries/render-utils/src/model_unlit_fade.slf b/libraries/render-utils/src/model_unlit_fade.slf index 30d023da88..1172bd5556 100644 --- a/libraries/render-utils/src/model_unlit_fade.slf +++ b/libraries/render-utils/src/model_unlit_fade.slf @@ -24,10 +24,11 @@ <$declareMaterialTextures(ALBEDO)$> layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) in vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) in float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; void main(void) { vec3 fadeEmissive; @@ -46,7 +47,7 @@ void main(void) { vec3 albedo = getMaterialAlbedo(mat); <$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>; - albedo *= _color; + albedo *= _color.rgb; albedo += fadeEmissive; packDeferredFragmentUnlit( normalize(_normalWS), diff --git a/libraries/render-utils/src/render-utils/ShaderConstants.h b/libraries/render-utils/src/render-utils/ShaderConstants.h index 443e75159d..afb195c240 100644 --- a/libraries/render-utils/src/render-utils/ShaderConstants.h +++ b/libraries/render-utils/src/render-utils/ShaderConstants.h @@ -14,27 +14,28 @@ #ifndef RENDER_UTILS_SHADER_CONSTANTS_H #define RENDER_UTILS_SHADER_CONSTANTS_H -#define RENDER_UTILS_ATTR_TEXCOORD0 0 -#define RENDER_UTILS_ATTR_TEXCOORD1 1 -#define RENDER_UTILS_ATTR_COLOR 2 -#define RENDER_UTILS_ATTR_ALPHA 3 +#define RENDER_UTILS_ATTR_TEXCOORD01 0 +#define RENDER_UTILS_ATTR_COLOR 1 // World space -#define RENDER_UTILS_ATTR_POSITION_WS 4 -#define RENDER_UTILS_ATTR_NORMAL_WS 5 -#define RENDER_UTILS_ATTR_TANGENT_WS 6 +#define RENDER_UTILS_ATTR_POSITION_WS 2 +#define RENDER_UTILS_ATTR_NORMAL_WS 3 +#define RENDER_UTILS_ATTR_TANGENT_WS 4 // Model space -#define RENDER_UTILS_ATTR_POSITION_MS 7 -#define RENDER_UTILS_ATTR_NORMAL_MS 8 +#define RENDER_UTILS_ATTR_POSITION_MS 5 +#define RENDER_UTILS_ATTR_NORMAL_MS 6 // Eye space -#define RENDER_UTILS_ATTR_POSITION_ES 9 +#define RENDER_UTILS_ATTR_POSITION_ES 7 + +// don't conflict with GPU_ATTR_V2F_STEREO_SIDE in the GPU shader constants +#define RENDER_UTILS_ATTR_DO_NOT_USE 8 // Fade -#define RENDER_UTILS_ATTR_FADE1 10 -#define RENDER_UTILS_ATTR_FADE2 11 -#define RENDER_UTILS_ATTR_FADE3 12 +#define RENDER_UTILS_ATTR_FADE1 9 +#define RENDER_UTILS_ATTR_FADE2 10 +#define RENDER_UTILS_ATTR_FADE3 11 #define RENDER_UTILS_BUFFER_DEFERRED_FRAME_TRANSFORM 0 diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index b4be4d1d02..999fb9e1a9 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -19,7 +19,9 @@ layout(location=RENDER_UTILS_UNIFORM_TEXT_COLOR) uniform vec4 Color; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; #define TAA_TEXTURE_LOD_BIAS -3.0 diff --git a/libraries/render-utils/src/sdf_text3D.slv b/libraries/render-utils/src/sdf_text3D.slv index fa7ee6d409..04ee44510a 100644 --- a/libraries/render-utils/src/sdf_text3D.slv +++ b/libraries/render-utils/src/sdf_text3D.slv @@ -18,10 +18,10 @@ // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main() { - _texCoord0 = inTexCoord0.xy; + _texCoord01.xy = inTexCoord0.xy; // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/sdf_text3D_transparent.slf b/libraries/render-utils/src/sdf_text3D_transparent.slf index 8e8a6db504..fbf4c4c372 100644 --- a/libraries/render-utils/src/sdf_text3D_transparent.slf +++ b/libraries/render-utils/src/sdf_text3D_transparent.slf @@ -19,7 +19,9 @@ layout(location=RENDER_UTILS_UNIFORM_TEXT_COLOR) uniform vec4 Color; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; const float gamma = 2.2; const float smoothing = 32.0; diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index ace0afc60d..a699a10cad 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -20,7 +20,9 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; diff --git a/libraries/render-utils/src/simple.slv b/libraries/render-utils/src/simple.slv index f4bd6795e3..0dd4e55f26 100644 --- a/libraries/render-utils/src/simple.slv +++ b/libraries/render-utils/src/simple.slv @@ -23,13 +23,13 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; void main(void) { _color = color_sRGBAToLinear(inColor); - _texCoord0 = inTexCoord0.st; + _texCoord01.xy = inTexCoord0.st; _positionMS = inPosition; _normalMS = inNormal.xyz; diff --git a/libraries/render-utils/src/simple_fade.slf b/libraries/render-utils/src/simple_fade.slf index c07a608a99..00d81cadc9 100644 --- a/libraries/render-utils/src/simple_fade.slf +++ b/libraries/render-utils/src/simple_fade.slf @@ -23,7 +23,9 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; diff --git a/libraries/render-utils/src/simple_fade.slv b/libraries/render-utils/src/simple_fade.slv index 24aada33b9..0bbd8eac39 100644 --- a/libraries/render-utils/src/simple_fade.slv +++ b/libraries/render-utils/src/simple_fade.slv @@ -26,14 +26,14 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { _color = color_sRGBAToLinear(inColor); - _texCoord0 = inTexCoord0.st; + _texCoord01.xy = inTexCoord0.st; _positionMS = inPosition; _normalMS = inNormal.xyz; diff --git a/libraries/render-utils/src/simple_opaque_web_browser.slf b/libraries/render-utils/src/simple_opaque_web_browser.slf index 3b77fbf431..27a0781eef 100644 --- a/libraries/render-utils/src/simple_opaque_web_browser.slf +++ b/libraries/render-utils/src/simple_opaque_web_browser.slf @@ -23,7 +23,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; void main(void) { vec4 texel = texture(originalTexture, _texCoord0.st); diff --git a/libraries/render-utils/src/simple_textured.slf b/libraries/render-utils/src/simple_textured.slf index c123a9671f..f1a60bdc5a 100644 --- a/libraries/render-utils/src/simple_textured.slf +++ b/libraries/render-utils/src/simple_textured.slf @@ -22,7 +22,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; void main(void) { vec4 texel = texture(originalTexture, _texCoord0); diff --git a/libraries/render-utils/src/simple_textured_fade.slf b/libraries/render-utils/src/simple_textured_fade.slf index 850282d40f..a1476939d1 100644 --- a/libraries/render-utils/src/simple_textured_fade.slf +++ b/libraries/render-utils/src/simple_textured_fade.slf @@ -25,7 +25,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; // Declare after all samplers to prevent sampler location mix up with originalTexture diff --git a/libraries/render-utils/src/simple_textured_unlit.slf b/libraries/render-utils/src/simple_textured_unlit.slf index 78ef85ee21..fcdf118732 100644 --- a/libraries/render-utils/src/simple_textured_unlit.slf +++ b/libraries/render-utils/src/simple_textured_unlit.slf @@ -23,7 +23,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; void main(void) { vec4 texel = texture(originalTexture, _texCoord0.st); diff --git a/libraries/render-utils/src/simple_textured_unlit_fade.slf b/libraries/render-utils/src/simple_textured_unlit_fade.slf index c5882c2173..2007f0f684 100644 --- a/libraries/render-utils/src/simple_textured_unlit_fade.slf +++ b/libraries/render-utils/src/simple_textured_unlit_fade.slf @@ -25,7 +25,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; // Declare after all samplers to prevent sampler location mix up with originalTexture diff --git a/libraries/render-utils/src/simple_transparent.slf b/libraries/render-utils/src/simple_transparent.slf index b52c2a613e..d2ba332566 100644 --- a/libraries/render-utils/src/simple_transparent.slf +++ b/libraries/render-utils/src/simple_transparent.slf @@ -20,7 +20,9 @@ layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; diff --git a/libraries/render-utils/src/simple_transparent_textured.slf b/libraries/render-utils/src/simple_transparent_textured.slf index b7396c3d37..ffd715215a 100644 --- a/libraries/render-utils/src/simple_transparent_textured.slf +++ b/libraries/render-utils/src/simple_transparent_textured.slf @@ -22,7 +22,9 @@ layout(location=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; void main(void) { vec4 texel = texture(originalTexture, _texCoord0); diff --git a/libraries/render-utils/src/simple_transparent_textured_fade.slf b/libraries/render-utils/src/simple_transparent_textured_fade.slf index 92c6fde0bd..8e530f41aa 100644 --- a/libraries/render-utils/src/simple_transparent_textured_fade.slf +++ b/libraries/render-utils/src/simple_transparent_textured_fade.slf @@ -31,7 +31,9 @@ layout(binding=0) uniform sampler2D originalTexture; layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; // Declare after all samplers to prevent sampler location mix up with originalTexture diff --git a/libraries/render-utils/src/simple_transparent_textured_unlit.slf b/libraries/render-utils/src/simple_transparent_textured_unlit.slf index a3e7c65cd1..d05ca02560 100644 --- a/libraries/render-utils/src/simple_transparent_textured_unlit.slf +++ b/libraries/render-utils/src/simple_transparent_textured_unlit.slf @@ -20,7 +20,9 @@ layout(binding=0) uniform sampler2D originalTexture; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=0) out vec4 _fragColor0; diff --git a/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf b/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf index 508ea9a68b..53006b508d 100644 --- a/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf +++ b/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf @@ -22,7 +22,9 @@ layout(binding=0) uniform sampler2D originalTexture; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; layout(location=0) out vec4 _fragColor0; diff --git a/libraries/render-utils/src/simple_transparent_web_browser.slf b/libraries/render-utils/src/simple_transparent_web_browser.slf index 3f05a8a480..156339b702 100644 --- a/libraries/render-utils/src/simple_transparent_web_browser.slf +++ b/libraries/render-utils/src/simple_transparent_web_browser.slf @@ -23,7 +23,9 @@ layout(binding=0) uniform sampler2D originalTexture; // the interpolated normal layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) in vec2 _texCoord0; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; +vec2 _texCoord0 = _texCoord01.xy; +vec2 _texCoord1 = _texCoord01.zw; void main(void) { vec4 texel = texture(originalTexture, _texCoord0.st); diff --git a/libraries/render-utils/src/skin_model.slv b/libraries/render-utils/src/skin_model.slv index fb2f8a8e34..d44ca0ae3f 100644 --- a/libraries/render-utils/src/skin_model.slv +++ b/libraries/render-utils/src/skin_model.slv @@ -26,11 +26,9 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0); @@ -39,12 +37,12 @@ void main(void) { skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/skin_model_dq.slv b/libraries/render-utils/src/skin_model_dq.slv index db062087be..ff73c7a398 100644 --- a/libraries/render-utils/src/skin_model_dq.slv +++ b/libraries/render-utils/src/skin_model_dq.slv @@ -26,11 +26,9 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0); @@ -39,12 +37,12 @@ void main(void) { skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/skin_model_fade.slv b/libraries/render-utils/src/skin_model_fade.slv index 30b3122334..1689476d38 100644 --- a/libraries/render-utils/src/skin_model_fade.slv +++ b/libraries/render-utils/src/skin_model_fade.slv @@ -26,11 +26,9 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { @@ -40,12 +38,12 @@ void main(void) { skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/skin_model_fade_dq.slv b/libraries/render-utils/src/skin_model_fade_dq.slv index fb23e283bc..6e64305de7 100644 --- a/libraries/render-utils/src/skin_model_fade_dq.slv +++ b/libraries/render-utils/src/skin_model_fade_dq.slv @@ -26,11 +26,9 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { @@ -40,12 +38,12 @@ void main(void) { skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/skin_model_normal_map.slv b/libraries/render-utils/src/skin_model_normal_map.slv index 288e338b10..f67220c6bd 100644 --- a/libraries/render-utils/src/skin_model_normal_map.slv +++ b/libraries/render-utils/src/skin_model_normal_map.slv @@ -26,12 +26,10 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0); @@ -41,12 +39,12 @@ void main(void) { skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0); interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0); diff --git a/libraries/render-utils/src/skin_model_normal_map_dq.slv b/libraries/render-utils/src/skin_model_normal_map_dq.slv index 90e85f8a92..b5ffbdc49d 100644 --- a/libraries/render-utils/src/skin_model_normal_map_dq.slv +++ b/libraries/render-utils/src/skin_model_normal_map_dq.slv @@ -25,12 +25,10 @@ <$declareMaterialTexMapArrayBuffer()$> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; void main(void) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0); @@ -40,12 +38,12 @@ void main(void) { skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0); interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0); diff --git a/libraries/render-utils/src/skin_model_normal_map_fade.slv b/libraries/render-utils/src/skin_model_normal_map_fade.slv index 393a756e7e..5759416d44 100644 --- a/libraries/render-utils/src/skin_model_normal_map_fade.slv +++ b/libraries/render-utils/src/skin_model_normal_map_fade.slv @@ -26,12 +26,10 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { @@ -42,12 +40,12 @@ void main(void) { skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0); interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0); diff --git a/libraries/render-utils/src/skin_model_normal_map_fade_dq.slv b/libraries/render-utils/src/skin_model_normal_map_fade_dq.slv index 862c14297f..e48bf47758 100644 --- a/libraries/render-utils/src/skin_model_normal_map_fade_dq.slv +++ b/libraries/render-utils/src/skin_model_normal_map_fade_dq.slv @@ -26,12 +26,10 @@ <@include render-utils/ShaderConstants.h@> layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_TEXCOORD0) out vec2 _texCoord0; -layout(location=RENDER_UTILS_ATTR_TEXCOORD1) out vec2 _texCoord1; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec3 _color; -layout(location=RENDER_UTILS_ATTR_ALPHA) out float _alpha; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; void main(void) { @@ -42,12 +40,12 @@ void main(void) { skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz); // pass along the color - _color = color_sRGBToLinear(inColor.rgb); - _alpha = inColor.a; + _color.rgb = color_sRGBToLinear(inColor.rgb); + _color.a = inColor.a; TexMapArray texMapArray = getTexMapArray(); - <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> - <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$> + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord01.xy)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord01.zw)$> interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0); interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0); diff --git a/libraries/shaders/CMakeLists.txt b/libraries/shaders/CMakeLists.txt index d27dacc769..4f6db48c08 100644 --- a/libraries/shaders/CMakeLists.txt +++ b/libraries/shaders/CMakeLists.txt @@ -189,5 +189,5 @@ foreach(COMPILED_SHADER ${COMPILED_SHADERS}) set_property(TARGET ${TARGET_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${COMPILED_SHADER}") endforeach() -link_hifi_libraries(shared) +link_hifi_libraries(shared gl) diff --git a/libraries/shaders/src/shaders/Shaders.cpp b/libraries/shaders/src/shaders/Shaders.cpp index 50a7d38a69..ac4810a896 100644 --- a/libraries/shaders/src/shaders/Shaders.cpp +++ b/libraries/shaders/src/shaders/Shaders.cpp @@ -17,6 +17,19 @@ #include #include #include +#include + +#include + +static bool cleanShaders() { +#if defined(Q_OS_MAC) + static const bool CLEAN_SHADERS = true; +#else + static const bool CLEAN_SHADERS = ::gl::disableGl45(); + +#endif + return CLEAN_SHADERS; +} // Can't use the Q_INIT_RESOURCE macro inside a namespace on Mac, // so this is done out of line @@ -74,14 +87,14 @@ void cleanShaderSource(std::string& shaderSource) { std::string loadShaderSource(uint32_t shaderId) { initShaders(); auto shaderStr = loadResource(std::string(":/shaders/") + std::to_string(shaderId)); -#if defined(Q_OS_MAC) - // OSX only supports OpenGL 4.1 without ARB_shading_language_420pack or - // ARB_explicit_uniform_location or basically anything useful that's - // been released in the last 8 fucking years, so in that case we need to - // strip out all explicit locations and do a bunch of background magic to - // make the system seem like it is using the explicit locations - cleanShaderSource(shaderStr); -#endif + if (cleanShaders()) { + // OSX only supports OpenGL 4.1 without ARB_shading_language_420pack or + // ARB_explicit_uniform_location or basically anything useful that's + // been released in the last 8 fucking years, so in that case we need to + // strip out all explicit locations and do a bunch of background magic to + // make the system seem like it is using the explicit locations + cleanShaderSource(shaderStr); + } return shaderStr; } diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index 48e778c063..b242d90d0e 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -426,11 +426,17 @@ PointerEvent::EventType OffscreenQmlSurface::choosePointerEventType(QEvent::Type } void OffscreenQmlSurface::hoverBeginEvent(const PointerEvent& event, class QTouchDevice& device) { +#if defined(DISABLE_QML) + return; +#endif handlePointerEvent(event, device); _activeTouchPoints[event.getID()].hovering = true; } void OffscreenQmlSurface::hoverEndEvent(const PointerEvent& event, class QTouchDevice& device) { +#if defined(DISABLE_QML) + return; +#endif _activeTouchPoints[event.getID()].hovering = false; // Send a fake mouse move event if // - the event told us to @@ -444,6 +450,10 @@ void OffscreenQmlSurface::hoverEndEvent(const PointerEvent& event, class QTouchD } bool OffscreenQmlSurface::handlePointerEvent(const PointerEvent& event, class QTouchDevice& device, bool release) { +#if defined(DISABLE_QML) + return false; +#endif + // Ignore mouse interaction if we're paused if (!getRootItem() || isPaused()) { return false; diff --git a/tests-manual/render-utils/src/main.cpp b/tests-manual/render-utils/src/main.cpp index b5bc5daebb..63f56e77ed 100644 --- a/tests-manual/render-utils/src/main.cpp +++ b/tests-manual/render-utils/src/main.cpp @@ -94,16 +94,9 @@ public: QTestWindow() { setSurfaceType(QSurface::OpenGLSurface); - QSurfaceFormat format; - // Qt Quick may need a depth and stencil buffer. Always make sure these are available. - format.setDepthBufferSize(16); - format.setStencilBufferSize(8); - setGLFormatVersion(format); - format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + QSurfaceFormat format = getDefaultOpenGLSurfaceFormat(); format.setOption(QSurfaceFormat::DebugContext); - setFormat(format); - _context.setFormat(format); _context.create(); diff --git a/tests/shaders/src/ShaderTests.cpp b/tests/shaders/src/ShaderTests.cpp index dffd69054d..f7d8222de1 100644 --- a/tests/shaders/src/ShaderTests.cpp +++ b/tests/shaders/src/ShaderTests.cpp @@ -47,15 +47,34 @@ void ShaderTests::cleanupTestCase() { qDebug() << "Done"; } -template -QStringList toStringList(const C& c, F f) { +template +QStringList toQStringList(const C& c) { QStringList result; for (const auto& v : c) { - result << f(v); + result << v.c_str(); } return result; } +template +std::unordered_set toStringSet(const C& c, F f) { + std::unordered_set result; + for (const auto& v : c) { + result.insert(f(v)); + } + return result; +} + +template +bool isSubset(const C& parent, const C& child) { + for (const auto& v : child) { + if (0 == parent.count(v)) { + return false; + } + } + return true; +} + gpu::Shader::ReflectionMap mergeReflection(const std::initializer_list& list) { gpu::Shader::ReflectionMap result; std::unordered_map> usedLocationsByType; @@ -87,6 +106,77 @@ gpu::Shader::ReflectionMap mergeReflection(const std::initializer_list +std::unordered_map invertMap(const std::unordered_map& map) { + std::unordered_map result; + for (const auto& entry : map) { + result[entry.second] = entry.first; + } + return result; +} + +static void verifyBindings(const gpu::Shader::Source& source) { + const auto reflection = source.getReflection(); + for (const auto& entry : reflection) { + const auto& map = entry.second; + const auto reverseMap = invertMap(map); + if (map.size() != reverseMap.size()) { + QFAIL("Bindings are not unique"); + } + } + +} + + +static void verifyInterface(const gpu::Shader::Source& vertexSource, const gpu::Shader::Source& fragmentSource) { + if (0 == fragmentSource.getReflection().count(gpu::Shader::BindingType::INPUT)) { + return; + } + auto fragIn = fragmentSource.getReflection().at(gpu::Shader::BindingType::INPUT); + if (0 == vertexSource.getReflection().count(gpu::Shader::BindingType::OUTPUT)) { + qDebug() << "No vertex output for fragment input"; + //QFAIL("No vertex output for fragment input"); + return; + } + auto vout = vertexSource.getReflection().at(gpu::Shader::BindingType::OUTPUT); + auto vrev = invertMap(vout); + static const std::string IN_STEREO_SIDE_STRING = "_inStereoSide"; + for (const auto entry : fragIn) { + const auto& name = entry.first; + // The presence of "_inStereoSide" in fragment shaders is a bug due to the way we do reflection + // and use preprocessor macros in the shaders + if (name == IN_STEREO_SIDE_STRING) { + continue; + } + if (0 == vout.count(name)) { + qDebug() << "Vertex output missing"; + //QFAIL("Vertex output missing"); + continue; + } + const auto& inLocation = entry.second; + const auto& outLocation = vout.at(name); + if (inLocation != outLocation) { + qDebug() << "Mismatch in vertex / fragment interface"; + //QFAIL("Mismatch in vertex / fragment interface"); + continue; + } + } +} + +template +bool compareBindings(const C& actual, const gpu::Shader::LocationMap& expected) { + if (actual.size() != expected.size()) { + auto actualNames = toStringSet(actual, [](const auto& v) { return v.name; }); + auto expectedNames = toStringSet(expected, [](const auto& v) { return v.first; }); + if (!isSubset(expectedNames, actualNames)) { + qDebug() << "Found" << toQStringList(actualNames); + qDebug() << "Expected" << toQStringList(expectedNames); + return false; + } + } + return true; +} + void ShaderTests::testShaderLoad() { std::set usedShaders; uint32_t maxShader = 0; @@ -97,16 +187,17 @@ void ShaderTests::testShaderLoad() { ++index; uint32_t vertexId = shader::getVertexId(programId); - //QVERIFY(0 != vertexId); uint32_t fragmentId = shader::getFragmentId(programId); - QVERIFY(0 != fragmentId); usedShaders.insert(vertexId); usedShaders.insert(fragmentId); maxShader = std::max(maxShader, std::max(fragmentId, vertexId)); auto vertexSource = gpu::Shader::getShaderSource(vertexId); QVERIFY(!vertexSource.getCode().empty()); + verifyBindings(vertexSource); auto fragmentSource = gpu::Shader::getShaderSource(fragmentId); QVERIFY(!fragmentSource.getCode().empty()); + verifyBindings(fragmentSource); + verifyInterface(vertexSource, fragmentSource); auto expectedBindings = mergeReflection({ vertexSource, fragmentSource }); @@ -124,16 +215,11 @@ void ShaderTests::testShaderLoad() { // Uniforms { - -#ifdef Q_OS_MAC - const auto& uniformRemap = shaderObject.uniformRemap; -#endif auto uniforms = gl::Uniform::load(program); + const auto& uniformRemap = shaderObject.uniformRemap; auto expectedUniforms = expectedBindings[gpu::Shader::BindingType::UNIFORM]; - if (uniforms.size() != expectedUniforms.size()) { - qDebug() << "Found" << toStringList(uniforms, [](const auto& v) { return v.name.c_str(); }); - qDebug() << "Expected" << toStringList(expectedUniforms, [](const auto& v) { return v.first.c_str(); }); - qDebug() << "Uniforms size mismatch"; + if (!compareBindings(uniforms, expectedUniforms)) { + qDebug() << "Uniforms mismatch"; } for (const auto& uniform : uniforms) { if (0 != expectedUniforms.count(uniform.name)) { @@ -152,10 +238,8 @@ void ShaderTests::testShaderLoad() { { const auto textures = gl::Uniform::loadTextures(program); const auto expectedTextures = expectedBindings[gpu::Shader::BindingType::TEXTURE]; - if (textures.size() != expectedTextures.size()) { - qDebug() << "Found" << toStringList(textures, [](const auto& v) { return v.name.c_str(); }); - qDebug() << "Expected" << toStringList(expectedTextures, [](const auto& v) { return v.first.c_str(); }); - qDebug() << "Uniforms size mismatch"; + if (!compareBindings(textures, expectedTextures)) { + qDebug() << "Textures mismatch"; } for (const auto& texture : textures) { if (0 != expectedTextures.count(texture.name)) { @@ -172,10 +256,8 @@ void ShaderTests::testShaderLoad() { { auto ubos = gl::UniformBlock::load(program); auto expectedUbos = expectedBindings[gpu::Shader::BindingType::UNIFORM_BUFFER]; - if (ubos.size() != expectedUbos.size()) { - qDebug() << "Found" << toStringList(ubos, [](const auto& v) { return v.name.c_str(); }); - qDebug() << "Expected" << toStringList(expectedUbos, [](const auto& v) { return v.first.c_str(); }); - qDebug() << "UBOs size mismatch"; + if (!compareBindings(ubos, expectedUbos)) { + qDebug() << "UBOs mismatch"; } for (const auto& ubo : ubos) { if (0 != expectedUbos.count(ubo.name)) { diff --git a/tools/shreflect/src/main.cpp b/tools/shreflect/src/main.cpp index b95b36fd94..e13f937102 100644 --- a/tools/shreflect/src/main.cpp +++ b/tools/shreflect/src/main.cpp @@ -130,6 +130,7 @@ json reflectShader(const std::string& shaderPath) { json inputs; json outputs; json textures; + json textureTypes; json uniforms; json storageBuffers; json uniformBuffers; @@ -148,8 +149,12 @@ json reflectShader(const std::string& shaderPath) { if (m[DECL_SIMPLE].matched) { auto name = m[SIMPLE_NAME].str(); auto type = m[SIMPLE_TYPE].str(); - auto& map = 0 == type.find("sampler") ? textures : uniforms; + bool isTexture = 0 == type.find("sampler"); + auto& map = isTexture ? textures : uniforms; map[name] = binding; + if (isTexture) { + textureTypes[name] = type; + } } else if (m[DECL_STRUCT].matched) { auto name = m[STRUCT_NAME].str(); auto type = m[STRUCT_TYPE].str(); @@ -173,6 +178,9 @@ json reflectShader(const std::string& shaderPath) { if (!textures.empty()) { result["textures"] = textures; } + if (!textureTypes.empty()) { + result["texturesTypes"] = textureTypes; + } if (!uniforms.empty()) { result["uniforms"] = uniforms; }