diff --git a/ext/ghoul b/ext/ghoul index 2feafb0496..9c13aaa212 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 2feafb0496504336b71935135a90ea05ee77ea4e +Subproject commit 9c13aaa212d75005fc0a2ae1d0b124485c120261 diff --git a/include/openspace/rendering/screenspacerenderable.h b/include/openspace/rendering/screenspacerenderable.h index bdba579e20..ae6e4cd9f6 100644 --- a/include/openspace/rendering/screenspacerenderable.h +++ b/include/openspace/rendering/screenspacerenderable.h @@ -141,7 +141,7 @@ protected: properties::TriggerProperty _delete; glm::ivec2 _objectSize = glm::ivec2(0); - UniformCache(color, opacity, blackoutFactor, mvp, texture, backgroundColor, gamma, + UniformCache(color, opacity, blackoutFactor, mvpMatrix, tex, backgroundColor, gamma, borderColor, borderWidth) _uniformCache; std::unique_ptr _shader; }; diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index bae86d11ee..53eafdca18 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -70,16 +70,6 @@ namespace { constexpr std::string_view _loggerCat = "AtmosphereDeferredcaster"; - constexpr std::array UniformNames = { - "cullAtmosphere", "opacity", "Rg", "Rt", "groundRadianceEmission", "HR", - "betaRayleigh", "HM", "betaMieExtinction", "mieG", "sunRadiance", - "ozoneLayerEnabled", "HO", "betaOzoneExtinction", "SAMPLES_R", "SAMPLES_MU", - "SAMPLES_MU_S", "SAMPLES_NU", "inverseModelTransformMatrix", - "modelTransformMatrix", "projectionToModelTransformMatrix", "viewToWorldMatrix", - "camPosObj", "sunDirectionObj", "hardShadows", "transmittanceTexture", - "irradianceTexture", "inscatterTexture", "sunAngularSize" - }; - constexpr float ATM_EPS = 2000.f; constexpr float KM_TO_M = 1000.f; @@ -376,7 +366,10 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& data, const Deferred const glm::dmat4 invWholePipeline = invModelMatrix * viewToWorld * dInvProj; - program.setUniform(_uniformCache.projectionToModelTransform, invWholePipeline); + program.setUniform( + _uniformCache.projectionToModelTransformMatrix, + invWholePipeline + ); const glm::dvec4 camPosObjCoords = invModelMatrix * glm::dvec4(data.camera.eyePositionVec3(), 1.0); @@ -555,7 +548,7 @@ std::filesystem::path AtmosphereDeferredcaster::helperPath() const { void AtmosphereDeferredcaster::initializeCachedVariables( ghoul::opengl::ProgramObject& program) { - ghoul::opengl::updateUniformLocations(program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(program, _uniformCache); } void AtmosphereDeferredcaster::setModelTransform(glm::dmat4 transform) { diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.h b/modules/atmosphere/rendering/atmospheredeferredcaster.h index 861a161c6b..3f34bbc967 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.h +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.h @@ -117,9 +117,10 @@ private: UniformCache(cullAtmosphere, opacity, Rg, Rt, groundRadianceEmission, HR, betaRayleigh, HM, betaMieExtinction, mieG, sunRadiance, ozoneLayerEnabled, HO, betaOzoneExtinction, SAMPLES_R, SAMPLES_MU, SAMPLES_MU_S, SAMPLES_NU, - inverseModelTransformMatrix, modelTransformMatrix, projectionToModelTransform, - viewToWorldMatrix, camPosObj, sunDirectionObj, hardShadows, transmittanceTexture, - irradianceTexture, inscatterTexture, sunAngularSize) _uniformCache; + inverseModelTransformMatrix, modelTransformMatrix, + projectionToModelTransformMatrix, viewToWorldMatrix, camPosObj, sunDirectionObj, + hardShadows, transmittanceTexture, irradianceTexture, inscatterTexture, + sunAngularSize) _uniformCache; ghoul::opengl::TextureUnit _transmittanceTableTextureUnit; ghoul::opengl::TextureUnit _irradianceTableTextureUnit; diff --git a/modules/base/rendering/pointcloud/renderablepointcloud.cpp b/modules/base/rendering/pointcloud/renderablepointcloud.cpp index 3b31642379..d15a2486a5 100644 --- a/modules/base/rendering/pointcloud/renderablepointcloud.cpp +++ b/modules/base/rendering/pointcloud/renderablepointcloud.cpp @@ -58,18 +58,6 @@ namespace { constexpr std::string_view _loggerCat = "RenderablePointCloud"; - constexpr std::array UniformNames = { - "cameraViewMatrix", "projectionMatrix", "modelMatrix", "cameraPosition", - "cameraLookUp", "renderOption", "maxAngularSize", "color", "opacity", - "scaleExponent", "scaleFactor", "up", "right", "fadeInValue", "hasSpriteTexture", - "spriteTexture", "useColorMap", "colorMapTexture", "cmapRangeMin", "cmapRangeMax", - "nanColor", "useNanColor", "hideOutsideRange", "enableMaxSizeControl", - "aboveRangeColor", "useAboveRangeColor", "belowRangeColor", "useBelowRangeColor", - "hasDvarScaling", "dvarScaleFactor", "enableOutline", "outlineColor", - "outlineWeight", "outlineStyle", "useCmapOutline", "aspectRatioScale", - "useOrientationData" - }; - enum RenderOption { ViewDirection = 0, PositionNormal, @@ -899,7 +887,7 @@ void RenderablePointCloud::initializeGL() { initializeShadersAndGlExtras(); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); if (_hasSpriteTexture) { switch (_textureMode) { @@ -1214,9 +1202,9 @@ void RenderablePointCloud::renderPoints(const RenderData& data, _program->activate(); - _program->setUniform(_uniformCache.cameraPos, data.camera.positionVec3()); + _program->setUniform(_uniformCache.cameraPosition, data.camera.positionVec3()); _program->setUniform( - _uniformCache.cameraLookup, + _uniformCache.cameraLookUp, glm::vec3(data.camera.lookUpVectorWorldSpace()) ); _program->setUniform(_uniformCache.renderOption, _renderOption.value()); @@ -1269,7 +1257,7 @@ void RenderablePointCloud::renderPoints(const RenderData& data, bool useColorMap = hasColorData() && _colorSettings.colorMapping->enabled && _colorSettings.colorMapping->texture(); - _program->setUniform(_uniformCache.useColormap, useColorMap); + _program->setUniform(_uniformCache.useColorMap, useColorMap); ghoul::opengl::TextureUnit colorMapTextureUnit; _program->setUniform(_uniformCache.colorMapTexture, colorMapTextureUnit); diff --git a/modules/base/rendering/pointcloud/renderablepointcloud.h b/modules/base/rendering/pointcloud/renderablepointcloud.h index d0aed60b73..ed29d153cf 100644 --- a/modules/base/rendering/pointcloud/renderablepointcloud.h +++ b/modules/base/rendering/pointcloud/renderablepointcloud.h @@ -227,9 +227,9 @@ protected: ghoul::opengl::ProgramObject* _program = nullptr; UniformCache( - cameraViewMatrix, projectionMatrix, modelMatrix, cameraPos, cameraLookup, + cameraViewMatrix, projectionMatrix, modelMatrix, cameraPosition, cameraLookUp, renderOption, maxAngularSize, color, opacity, scaleExponent, scaleFactor, up, - right, fadeInValue, hasSpriteTexture, spriteTexture, useColormap, colorMapTexture, + right, fadeInValue, hasSpriteTexture, spriteTexture, useColorMap, colorMapTexture, cmapRangeMin, cmapRangeMax, nanColor, useNanColor, hideOutsideRange, enableMaxSizeControl, aboveRangeColor, useAboveRangeColor, belowRangeColor, useBelowRangeColor, hasDvarScaling, dvarScaleFactor, enableOutline, outlineColor, diff --git a/modules/base/rendering/renderabledisc.cpp b/modules/base/rendering/renderabledisc.cpp index dfbce826f2..92f72d6dd9 100644 --- a/modules/base/rendering/renderabledisc.cpp +++ b/modules/base/rendering/renderabledisc.cpp @@ -150,7 +150,7 @@ void RenderableDisc::render(const RenderData& data, RendererTasks&) { calcModelViewProjectionTransform(data); _shader->setUniform( - _uniformCache.modelViewProjection, + _uniformCache.modelViewProjectionTransform, glm::mat4(modelViewProjectionTransform) ); _shader->setUniform(_uniformCache.width, _width); @@ -159,7 +159,7 @@ void RenderableDisc::render(const RenderData& data, RendererTasks&) { ghoul::opengl::TextureUnit unit; unit.activate(); _texture->bind(); - _shader->setUniform(_uniformCache.texture, unit); + _shader->setUniform(_uniformCache.colorTexture, unit); glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/modules/base/rendering/renderabledisc.h b/modules/base/rendering/renderabledisc.h index 3c0d51b5e1..ef970ae4d5 100644 --- a/modules/base/rendering/renderabledisc.h +++ b/modules/base/rendering/renderabledisc.h @@ -71,7 +71,8 @@ protected: std::unique_ptr _texture; private: - UniformCache(modelViewProjection, opacity, width, texture) _uniformCache; + UniformCache(modelViewProjectionTransform, opacity, width, + colorTexture) _uniformCache; bool _planeIsDirty = false; }; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 96a8d3452e..4c74a7edc5 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -69,20 +69,6 @@ namespace { constexpr glm::vec4 PosBufferClearVal = glm::vec4(1e32, 1e32, 1e32, 1.f); - constexpr std::array UniformNames = { - "modelViewTransform", "projectionTransform", "normalTransform", "meshTransform", - "meshNormalTransform", "ambientIntensity", "diffuseIntensity", - "specularIntensity", "performShading", "use_forced_color", "has_texture_diffuse", - "has_texture_normal", "has_texture_specular", "has_color_specular", - "texture_diffuse", "texture_normal", "texture_specular", "color_diffuse", - "color_specular", "opacity", "nLightSources", "lightDirectionsViewSpace", - "lightIntensities", "performManualDepthTest", "gBufferDepthTexture", "resolution" - }; - - constexpr std::array UniformOpacityNames = { - "opacity", "colorTexture", "depthTexture", "viewport", "resolution" - }; - constexpr openspace::properties::Property::PropertyInfo EnableAnimationInfo = { "EnableAnimation", "Enable Animation", @@ -617,7 +603,7 @@ void RenderableModel::initializeGL() { ghoul::opengl::ProgramObject::IgnoreError::Yes ); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); _quadProgram = BaseModule::ProgramObjectManager.request( "ModelOpacityProgram", @@ -627,18 +613,13 @@ void RenderableModel::initializeGL() { const std::filesystem::path fs = absPath("${MODULE_BASE}/shaders/modelOpacity_fs.glsl"); - return global::renderEngine->buildRenderProgram( - "ModelOpacityProgram", + return global::renderEngine->buildRenderProgram("ModelOpacityProgram", vs, fs ); } ); - ghoul::opengl::updateUniformLocations( - *_quadProgram, - _uniformOpacityCache, - UniformOpacityNames - ); + ghoul::opengl::updateUniformLocations(*_quadProgram, _uniformOpacityCache); // Screen quad VAO constexpr std::array QuadVtx = { @@ -1016,16 +997,12 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { void RenderableModel::update(const UpdateData& data) { if (_program->isDirty()) { _program->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); } if (_quadProgram->isDirty()) { _quadProgram->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_quadProgram, - _uniformOpacityCache, - UniformOpacityNames - ); + ghoul::opengl::updateUniformLocations(*_quadProgram, _uniformOpacityCache); } if (!hasOverrideRenderBin()) { diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index e11bc64a24..0903fdb943 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -41,11 +41,6 @@ #include namespace { - constexpr std::array UniformNames = { - "modelViewProjection", "modelViewTransform", "colorTexture", "opacity", - "mirrorBackside", "multiplyColor" - }; - enum BlendMode { Normal = 0, Additive @@ -214,7 +209,7 @@ void RenderablePlane::initializeGL() { } ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } void RenderablePlane::deinitializeGL() { @@ -310,7 +305,7 @@ void RenderablePlane::update(const UpdateData&) { if (_shader->isDirty()) { _shader->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } if (_planeIsDirty) { diff --git a/modules/base/rendering/renderableprism.cpp b/modules/base/rendering/renderableprism.cpp index a03209fcc0..c33a174030 100644 --- a/modules/base/rendering/renderableprism.cpp +++ b/modules/base/rendering/renderableprism.cpp @@ -37,10 +37,6 @@ #include namespace { - constexpr std::array UniformNames = { - "modelViewProjectionTransform", "vs_color" - }; - constexpr openspace::properties::Property::PropertyInfo SegmentsInfo = { "Segments", "Segments", @@ -183,7 +179,7 @@ void RenderablePrism::initializeGL() { absPath("${MODULE_BASE}/shaders/prism_vs.glsl"), absPath("${MODULE_BASE}/shaders/prism_fs.glsl") ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); glGenVertexArrays(1, &_vaoId); glGenBuffers(1, &_vboId); @@ -326,7 +322,7 @@ void RenderablePrism::render(const RenderData& data, RendererTasks&) { // Uniforms _shader->setUniform( - _uniformCache.modelViewProjection, + _uniformCache.modelViewProjectionTransform, glm::mat4(modelViewProjectionTransform) ); _shader->setUniform(_uniformCache.color, glm::vec4(_lineColor.value(), opacity())); @@ -354,7 +350,7 @@ void RenderablePrism::render(const RenderData& data, RendererTasks&) { void RenderablePrism::update(const UpdateData& data) { if (_shader->isDirty()) { _shader->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } if (_prismIsDirty) { updateVertexData(); diff --git a/modules/base/rendering/renderableprism.h b/modules/base/rendering/renderableprism.h index 79afeb5568..3e49f264ef 100644 --- a/modules/base/rendering/renderableprism.h +++ b/modules/base/rendering/renderableprism.h @@ -67,7 +67,7 @@ private: properties::FloatProperty _lineWidth; properties::Vec3Property _lineColor; properties::FloatProperty _length; - UniformCache(modelViewProjection, color) _uniformCache; + UniformCache(modelViewProjectionTransform, color) _uniformCache; std::unique_ptr _shader; GLuint _vaoId = 0; diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index efd1678d9b..96dccbe7c7 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -40,11 +40,6 @@ #include namespace { - constexpr std::array UniformNames = { - "opacity", "modelViewProjection", "modelViewTransform", "modelViewRotation", - "colorTexture", "mirrorTexture" - }; - constexpr openspace::properties::Property::PropertyInfo SizeInfo = { "Size", "Size (in meters)", @@ -215,7 +210,7 @@ void RenderableSphere::initializeGL() { } ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } void RenderableSphere::deinitializeGL() { @@ -363,7 +358,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { void RenderableSphere::update(const UpdateData&) { if (_shader->isDirty()) { _shader->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } if (_sphereIsDirty) { diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 3d0fe8551e..e1a57ee6db 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -313,7 +313,7 @@ void RenderableTrail::internalRender(bool renderLines, bool renderPoints, // is necessary as they are usually far away from their reference const glm::dmat4 modelViewTransform = calcModelViewTransform(data, modelTransform); _programObject->setUniform( - _uniformCache.modelView, + _uniformCache.modelViewTransform, modelViewTransform * info._localTransform ); @@ -327,7 +327,7 @@ void RenderableTrail::internalRender(bool renderLines, bool renderPoints, }(info.sorting); // The vertex sorting method is used to tweak the fading along the trajectory - _programObject->setUniform(_uniformCache.vertexSorting, sorting); + _programObject->setUniform(_uniformCache.vertexSortingMethod, sorting); // This value is subtracted from the vertex id in the case of a potential ring // buffer (as used in RenderableTrailOrbit) to keep the first vertex at its @@ -418,7 +418,10 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { const glm::dmat4 modelTransform = calcModelTransform(data); - _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); + _programObject->setUniform( + _uniformCache.projectionTransform, + data.camera.projectionMatrix() + ); _programObject->setUniform(_uniformCache.color, _appearance.lineColor); _programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade); diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index ca9bbdba50..525e8d9cfb 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -193,14 +193,15 @@ private: /// Program object used to render the data stored in RenderInformation ghoul::opengl::ProgramObject* _programObject = nullptr; #ifdef __APPLE__ - UniformCache(opacity, modelView, projection, color, useLineFade, lineLength, - lineFadeAmount, vertexSorting, idOffset, nVertices, stride, pointSize, - renderPhase, useSplitRenderMode, floatingOffset, numberOfUniqueVertices + UniformCache(opacity, modelViewTransform, projectionTransform, color, useLineFade, + lineLength, lineFadeAmount, vertexSortingMethod, idOffset, nVertices, stride, + pointSize, renderPhase, useSplitRenderMode, floatingOffset, numberOfUniqueVertices ) _uniformCache; #else - UniformCache(opacity, modelView, projection, color, useLineFade, lineLength, - lineFadeAmount, vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase, - viewport, lineWidth, floatingOffset, useSplitRenderMode, numberOfUniqueVertices + UniformCache(opacity, modelViewTransform, projectionTransform, color, useLineFade, + lineLength, lineFadeAmount, vertexSortingMethod, idOffset, nVertices, stride, + pointSize, renderPhase, viewport, lineWidth, floatingOffset, useSplitRenderMode, + numberOfUniqueVertices ) _uniformCache; #endif }; diff --git a/modules/base/shaders/prism_fs.glsl b/modules/base/shaders/prism_fs.glsl index 81445ccb3f..149a8e92fe 100644 --- a/modules/base/shaders/prism_fs.glsl +++ b/modules/base/shaders/prism_fs.glsl @@ -26,12 +26,12 @@ in float vs_depth; -uniform vec4 vs_color; +uniform vec4 color; Fragment getFragment() { Fragment frag; - frag.color = vs_color; + frag.color = color; frag.depth = vs_depth; return frag; } diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index a933ccb66e..7be2a91f8b 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -52,10 +52,6 @@ namespace { constexpr std::string_view _loggerCat = "RenderableDUMeshes"; - constexpr std::array UniformNames = { - "modelViewTransform", "projectionTransform", "alphaValue", "color" - }; - constexpr int RenderOptionViewDirection = 0; constexpr int RenderOptionPositionNormal = 1; @@ -283,7 +279,7 @@ void RenderableDUMeshes::initializeGL() { } ); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); createMeshes(); @@ -440,7 +436,7 @@ void RenderableDUMeshes::render(const RenderData& data, RendererTasks&) { void RenderableDUMeshes::update(const UpdateData&) { if (_program->isDirty()) { _program->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); } } diff --git a/modules/exoplanets/rendering/renderableorbitdisc.cpp b/modules/exoplanets/rendering/renderableorbitdisc.cpp index 5e81661183..a9002f0270 100644 --- a/modules/exoplanets/rendering/renderableorbitdisc.cpp +++ b/modules/exoplanets/rendering/renderableorbitdisc.cpp @@ -40,11 +40,6 @@ #include namespace { - constexpr std::array UniformNames = { - "modelViewProjectionTransform", "offset", "opacity", - "discTexture", "eccentricity", "semiMajorAxis", "multiplyColor" - }; - constexpr openspace::properties::Property::PropertyInfo TextureInfo = { "Texture", "Texture", @@ -164,7 +159,7 @@ void RenderableOrbitDisc::initializeGL() { absPath("${BASE}/modules/exoplanets/shaders/orbitdisc_fs.glsl") ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); _texture->loadFromFile(_texturePath.value()); _texture->uploadToGpu(); @@ -185,7 +180,7 @@ void RenderableOrbitDisc::render(const RenderData& data, RendererTasks&) { _shader->activate(); _shader->setUniform( - _uniformCache.modelViewProjection, + _uniformCache.modelViewProjectionTransform, glm::mat4(calcModelViewProjectionTransform(data)) ); _shader->setUniform(_uniformCache.offset, _offset); @@ -197,7 +192,7 @@ void RenderableOrbitDisc::render(const RenderData& data, RendererTasks&) { ghoul::opengl::TextureUnit unit; unit.activate(); _texture->bind(); - _shader->setUniform(_uniformCache.texture, unit); + _shader->setUniform(_uniformCache.discTexture, unit); glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -217,7 +212,7 @@ void RenderableOrbitDisc::render(const RenderData& data, RendererTasks&) { void RenderableOrbitDisc::update(const UpdateData&) { if (_shader->isDirty()) { _shader->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } if (_planeIsDirty) { diff --git a/modules/exoplanets/rendering/renderableorbitdisc.h b/modules/exoplanets/rendering/renderableorbitdisc.h index b615079bfa..796cb5f8a2 100644 --- a/modules/exoplanets/rendering/renderableorbitdisc.h +++ b/modules/exoplanets/rendering/renderableorbitdisc.h @@ -70,7 +70,7 @@ private: properties::Vec3Property _multiplyColor; std::unique_ptr _shader = nullptr; - UniformCache(modelViewProjection, offset, opacity, texture, + UniformCache(modelViewProjectionTransform, offset, opacity, discTexture, eccentricity, semiMajorAxis, multiplyColor) _uniformCache; std::unique_ptr _plane; diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 0e53203d10..13b8fd6e75 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -64,16 +64,6 @@ namespace { Billboards }; - constexpr std::array UniformNamesPoints = { - "modelMatrix", "viewProjectionMatrix", "eyePosition", - "opacityCoefficient" - }; - - constexpr std::array UniformNamesBillboards = { - "modelMatrix", "viewProjectionMatrix", - "cameraUp", "eyePosition", "psfTexture" - }; - constexpr openspace::properties::Property::PropertyInfo VolumeRenderingEnabledInfo = { "VolumeRenderingEnabled", "Volume Rendering", @@ -471,16 +461,8 @@ void RenderableGalaxy::initializeGL() { ); } - ghoul::opengl::updateUniformLocations( - *_pointsProgram, - _uniformCachePoints, - UniformNamesPoints - ); - ghoul::opengl::updateUniformLocations( - *_billboardsProgram, - _uniformCacheBillboards, - UniformNamesBillboards - ); + ghoul::opengl::updateUniformLocations(*_pointsProgram, _uniformCachePoints); + ghoul::opengl::updateUniformLocations(*_billboardsProgram, _uniformCacheBillboards); glGenVertexArrays(1, &_pointsVao); glGenBuffers(1, &_positionVbo); @@ -647,7 +629,7 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { _pointsProgram->setUniform(_uniformCachePoints.modelMatrix, modelTransform); _pointsProgram->setUniform( - _uniformCachePoints.cameraViewProjectionMatrix, + _uniformCachePoints.viewProjectionMatrix, cameraViewProjectionMatrix ); @@ -698,7 +680,7 @@ void RenderableGalaxy::renderBillboards(const RenderData& data) { _billboardsProgram->setUniform(_uniformCacheBillboards.modelMatrix, modelTransform); _billboardsProgram->setUniform( - _uniformCacheBillboards.cameraViewProjectionMatrix, + _uniformCacheBillboards.viewProjectionMatrix, cameraViewProjectionMatrix ); diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index 39639363b9..c1a9390a86 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -101,12 +101,10 @@ private: std::unique_ptr _pointsProgram; std::unique_ptr _billboardsProgram; UniformCache( - modelMatrix, cameraViewProjectionMatrix, eyePosition, - opacityCoefficient + modelMatrix, viewProjectionMatrix, eyePosition, opacityCoefficient ) _uniformCachePoints; UniformCache( - modelMatrix, cameraViewProjectionMatrix, - cameraUp, eyePosition, psfTexture + modelMatrix, viewProjectionMatrix, cameraUp, eyePosition, psfTexture ) _uniformCacheBillboards; std::vector _pointsData; size_t _nPoints = 0; diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 2845affd15..da6615d4d5 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -929,8 +929,7 @@ void RenderableGlobe::update(const UpdateData& data) { ghoul::opengl::updateUniformLocations( *_localRenderer.program, - _localRenderer.uniformCache, - { "skirtLength", "p01", "p11", "p00", "p10", "patchNormalCameraSpace" } + _localRenderer.uniformCache ); } @@ -947,8 +946,7 @@ void RenderableGlobe::update(const UpdateData& data) { ghoul::opengl::updateUniformLocations( *_globalRenderer.program, - _globalRenderer.uniformCache, - { "skirtLength", "minLatLon", "lonLatScalingFactor" } + _globalRenderer.uniformCache ); } @@ -1866,8 +1864,7 @@ void RenderableGlobe::recompileShaders() { ghoul::opengl::updateUniformLocations( *_localRenderer.program, - _localRenderer.uniformCache, - { "skirtLength", "p01", "p11", "p00", "p10", "patchNormalCameraSpace" } + _localRenderer.uniformCache ); @@ -1893,8 +1890,7 @@ void RenderableGlobe::recompileShaders() { ghoul::opengl::updateUniformLocations( *_globalRenderer.program, - _globalRenderer.uniformCache, - { "skirtLength", "minLatLon", "lonLatScalingFactor" } + _globalRenderer.uniformCache ); _globalRenderer.updatedSinceLastCall = true; diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 846f134121..c075f1dec0 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -53,24 +53,6 @@ namespace { constexpr std::string_view _loggerCat = "RingsComponent"; - constexpr std::array UniformNames = { - "modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "nightFactor", - "sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture", - "zFightingPercentage", "opacity" - }; - - constexpr std::array UniformNamesAdvancedRings = { - "modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "nightFactor", - "sunPosition", "sunPositionObj", "camPositionObj", "ringTextureFwrd", - "ringTextureBckwrd", "ringTextureUnlit", "ringTextureColor", - "ringTextureTransparency", "shadowMatrix", "shadowMapTexture", - "zFightingPercentage", "opacity" - }; - - constexpr std::array GeomUniformNames = { - "modelViewProjectionMatrix", "textureOffset", "ringTexture" - }; - constexpr openspace::properties::Property::PropertyInfo EnabledInfo = { "Enabled", "Enabled", @@ -370,11 +352,7 @@ void RingsComponent::initializeGL() { absPath("${MODULE_GLOBEBROWSING}/shaders/rings_geom_fs.glsl") ); - ghoul::opengl::updateUniformLocations( - *_geometryOnlyShader, - _geomUniformCache, - GeomUniformNames - ); + ghoul::opengl::updateUniformLocations(*_geometryOnlyShader, _geomUniformCache); } catch (const ghoul::RuntimeError& e) { LERROR(e.message); @@ -502,7 +480,7 @@ void RingsComponent::draw(const RenderData& data, RenderPass renderPass, _uniformCacheAdvancedRings.ringTextureTransparency, ringTextureTransparencyUnit ); - _shader->setUniform(_uniformCacheAdvancedRings.opacityValue, opacity()); + _shader->setUniform(_uniformCacheAdvancedRings.opacity, opacity()); // Adding the model transformation to the final shadow matrix so we have a // complete transformation from the model coordinates to the clip space of @@ -552,7 +530,7 @@ void RingsComponent::draw(const RenderData& data, RenderPass renderPass, _uniformCache.modelViewProjectionMatrix, modelViewProjectionTransform ); - _shader->setUniform(_uniformCache.opacityValue, opacity()); + _shader->setUniform(_uniformCache.opacity, opacity()); ringTextureUnit.activate(); _texture->bind(); @@ -620,11 +598,7 @@ void RingsComponent::update(const UpdateData& data) { if (_geometryOnlyShader->isDirty()) { _geometryOnlyShader->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_geometryOnlyShader, - _geomUniformCache, - GeomUniformNames - ); + ghoul::opengl::updateUniformLocations(*_geometryOnlyShader, _geomUniformCache); } if (_planeIsDirty) { @@ -853,7 +827,7 @@ void RingsComponent::compileShadowShader() { // dict // ); - // ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + // ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); // Uses multiple textures for the Rings // See https://bjj.mmedia.is/data/s_rings/index.html for theory behind it @@ -865,11 +839,7 @@ void RingsComponent::compileShadowShader() { dict ); - ghoul::opengl::updateUniformLocations( - *_shader, - _uniformCacheAdvancedRings, - UniformNamesAdvancedRings - ); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCacheAdvancedRings); } else { // Uses simple texture for the Rings @@ -880,7 +850,7 @@ void RingsComponent::compileShadowShader() { dict ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } } catch (const ghoul::RuntimeError& e) { diff --git a/modules/globebrowsing/src/ringscomponent.h b/modules/globebrowsing/src/ringscomponent.h index 79589aeb82..2ec5de4801 100644 --- a/modules/globebrowsing/src/ringscomponent.h +++ b/modules/globebrowsing/src/ringscomponent.h @@ -97,15 +97,15 @@ private: std::unique_ptr _geometryOnlyShader; UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor, sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage, - opacityValue + opacity ) _uniformCache; UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor, sunPosition, sunPositionObj, camPositionObj, ringTextureFwrd, ringTextureBckwrd, ringTextureUnlit, ringTextureColor, ringTextureTransparency, shadowMatrix, - shadowMapTexture, zFightingPercentage, opacityValue + shadowMapTexture, zFightingPercentage, opacity ) _uniformCacheAdvancedRings; - UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture - ) _geomUniformCache; + UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture) _geomUniformCache; + std::unique_ptr _texture; std::unique_ptr _textureForwards; std::unique_ptr _textureBackwards; diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index 10073bb2ed..8031e560cf 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -50,8 +50,6 @@ namespace { ImFont* captionFont = nullptr; - constexpr std::array UniformNames = { "tex", "ortho" }; - constexpr openspace::properties::Property::PropertyInfo EnabledInfo = { "Enabled", "Enabled", @@ -390,7 +388,7 @@ void ImGUIModule::internalInitializeGL() { absPath("${MODULE_IMGUI}/shaders/gui_fs.glsl") ); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); { unsigned char* texData = nullptr; @@ -499,7 +497,7 @@ void ImGUIModule::renderFrame(float deltaTime, const glm::vec2& windowSize, if (_program->isDirty()) { _program->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); } // diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index 2c3dd74c80..7adda960af 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -38,12 +38,6 @@ #include namespace { - constexpr std::array UniformNames = { - "modelViewProjectionTransform", "colorStart", "colorEnd", - "activeColor", "targetInFieldOfViewColor", "intersectionStartColor", - "intersectionEndColor", "squareColor", "interpolation" - }; - constexpr int InterpolationSteps = 5; constexpr double Epsilon = 1e-4; @@ -286,7 +280,7 @@ void RenderableFov::initializeGL() { } ); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); // Fetch information about the specific instrument SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView( @@ -766,10 +760,13 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) { const glm::mat4 modelViewProjectionTransform = calcModelViewProjectionTransform(data); - _program->setUniform(_uniformCache.modelViewProjection, modelViewProjectionTransform); + _program->setUniform( + _uniformCache.modelViewProjectionTransform, + modelViewProjectionTransform + ); - _program->setUniform(_uniformCache.defaultColorStart, _colors.defaultStart); - _program->setUniform(_uniformCache.defaultColorEnd, _colors.defaultEnd); + _program->setUniform(_uniformCache.colorStart, _colors.defaultStart); + _program->setUniform(_uniformCache.colorEnd, _colors.defaultEnd); _program->setUniform(_uniformCache.activeColor, _colors.active); _program->setUniform( _uniformCache.targetInFieldOfViewColor, @@ -824,7 +821,7 @@ void RenderableFov::update(const UpdateData& data) { if (_program->isDirty()) { _program->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_program, _uniformCache); } } diff --git a/modules/spacecraftinstruments/rendering/renderablefov.h b/modules/spacecraftinstruments/rendering/renderablefov.h index c085bc9cc1..cabf63f940 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.h +++ b/modules/spacecraftinstruments/rendering/renderablefov.h @@ -81,9 +81,9 @@ private: properties::DoubleProperty _standOffDistance; properties::BoolProperty _alwaysDrawFov; ghoul::opengl::ProgramObject* _program = nullptr; - UniformCache(modelViewProjection, defaultColorStart, defaultColorEnd, activeColor, - targetInFieldOfViewColor, intersectionStartColor, intersectionEndColor, - squareColor, interpolation) _uniformCache; + UniformCache(modelViewProjectionTransform, colorStart, colorEnd, + activeColor, targetInFieldOfViewColor, intersectionStartColor, + intersectionEndColor, squareColor, interpolation) _uniformCache; bool _simplifyBounds = false; diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 5b37ea0661..163842bd2c 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -39,20 +39,6 @@ #include namespace { - constexpr std::array MainUniformNames = { - "performShading", "directionToSunViewSpace", "modelViewTransform", - "projectionTransform", "projectionFading", "baseTexture", "projectionTexture" - }; - - constexpr std::array FboUniformNames = { - "projectionTexture", "depthTexture", "needShadowMap", "ProjectorMatrix", - "ModelTransform", "boresight" - }; - - constexpr std::array DepthFboUniformNames = { - "ProjectorMatrix", "ModelTransform" - }; - constexpr openspace::properties::Property::PropertyInfo PerformShadingInfo = { "PerformShading", "Perform Shading", @@ -165,11 +151,7 @@ void RenderableModelProjection::initializeGL() { absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl") ); - ghoul::opengl::updateUniformLocations( - *_programObject, - _mainUniformCache, - MainUniformNames - ); + ghoul::opengl::updateUniformLocations(*_programObject, _mainUniformCache); _fboProgramObject = ghoul::opengl::ProgramObject::Build( "ProjectionPass", @@ -181,11 +163,7 @@ void RenderableModelProjection::initializeGL() { ) ); - ghoul::opengl::updateUniformLocations( - *_fboProgramObject, - _fboUniformCache, - FboUniformNames - ); + ghoul::opengl::updateUniformLocations(*_fboProgramObject, _fboUniformCache); _depthFboProgramObject = ghoul::opengl::ProgramObject::Build( "DepthPass", @@ -193,11 +171,7 @@ void RenderableModelProjection::initializeGL() { absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl") ); - ghoul::opengl::updateUniformLocations( - *_depthFboProgramObject, - _depthFboUniformCache, - DepthFboUniformNames - ); + ghoul::opengl::updateUniformLocations(*_depthFboProgramObject, _depthFboUniformCache); _projectionComponent.initializeGL(); @@ -309,21 +283,13 @@ void RenderableModelProjection::update(const UpdateData& data) { if (_programObject->isDirty()) { _programObject->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_programObject, - _mainUniformCache, - MainUniformNames - ); + ghoul::opengl::updateUniformLocations(*_programObject, _mainUniformCache); } if (_fboProgramObject->isDirty()) { _fboProgramObject->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_fboProgramObject, - _fboUniformCache, - FboUniformNames - ); + ghoul::opengl::updateUniformLocations(*_fboProgramObject, _fboUniformCache); } _projectionComponent.update(); @@ -333,8 +299,7 @@ void RenderableModelProjection::update(const UpdateData& data) { ghoul::opengl::updateUniformLocations( *_depthFboProgramObject, - _depthFboUniformCache, - DepthFboUniformNames + _depthFboUniformCache ); } diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h index 05cfb5a8db..5ef866bb5b 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h @@ -80,6 +80,7 @@ private: std::unique_ptr _fboProgramObject; UniformCache(projectionTexture, depthTexture, needShadowMap, ProjectorMatrix, ModelTransform, boresight) _fboUniformCache; + std::unique_ptr _depthFboProgramObject; UniformCache(ProjectorMatrix, ModelTransform) _depthFboUniformCache; diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 4ad3070d35..36aacb019a 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -39,17 +39,6 @@ #include namespace { - constexpr std::array MainUniformNames = { - "sun_pos", "modelTransform", "modelViewProjectionTransform", "hasBaseMap", - "hasHeightMap", "heightExaggeration", "meridianShift", "ambientBrightness", - "projectionFading", "baseTexture", "projectionTexture", "heightTexture" - }; - - constexpr std::array FboUniformNames = { - "projectionTexture", "ProjectorMatrix", "ModelTransform", - "boresight", "radius", "segments" - }; - constexpr std::string_view NoImageText = "No Image"; constexpr openspace::properties::Property::PropertyInfo ColorTexturePathsInfo = { @@ -318,11 +307,7 @@ void RenderablePlanetProjection::initializeGL() { } ); - ghoul::opengl::updateUniformLocations( - *_programObject, - _mainUniformCache, - MainUniformNames - ); + ghoul::opengl::updateUniformLocations(*_programObject, _mainUniformCache); _fboProgramObject = SpacecraftInstrumentsModule::ProgramObjectManager.request( "FBOPassProgram", @@ -341,11 +326,7 @@ void RenderablePlanetProjection::initializeGL() { } ); - ghoul::opengl::updateUniformLocations( - *_fboProgramObject, - _fboUniformCache, - FboUniformNames - ); + ghoul::opengl::updateUniformLocations(*_fboProgramObject, _fboUniformCache); loadColorTexture(); loadHeightTexture(); @@ -412,8 +393,8 @@ void RenderablePlanetProjection::imageProjectGPU( projectionTexture.bind(); _fboProgramObject->setUniform(_fboUniformCache.projectionTexture, unitFbo); - _fboProgramObject->setUniform(_fboUniformCache.projectorMatrix, projectorMatrix); - _fboProgramObject->setUniform(_fboUniformCache.modelTransform, _transform); + _fboProgramObject->setUniform(_fboUniformCache.ProjectorMatrix, projectorMatrix); + _fboProgramObject->setUniform(_fboUniformCache.ModelTransform, _transform); _fboProgramObject->setUniform(_fboUniformCache.boresight, _boresight); _fboProgramObject->setUniform(_fboUniformCache.radius, _radius); _fboProgramObject->setUniform(_fboUniformCache.segments, _segments); @@ -519,7 +500,7 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) // Main renderpass _programObject->activate(); - _programObject->setUniform(_mainUniformCache.sunPos, static_cast(sunPos)); + _programObject->setUniform(_mainUniformCache.sun_pos, static_cast(sunPos)); // Model transform and view transform needs to be in double precision const glm::dmat4 modelTransform = calcModelTransform(data); @@ -573,21 +554,13 @@ void RenderablePlanetProjection::update(const UpdateData& data) { if (_programObject->isDirty()) { _programObject->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_programObject, - _mainUniformCache, - MainUniformNames - ); + ghoul::opengl::updateUniformLocations(*_programObject, _mainUniformCache); } if (_fboProgramObject->isDirty()) { _fboProgramObject->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_fboProgramObject, - _fboUniformCache, - FboUniformNames - ); + ghoul::opengl::updateUniformLocations(*_fboProgramObject, _fboUniformCache); } if (_colorTextureDirty) { diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h index 2fe44e2ac4..12fdfc7d6f 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h @@ -79,12 +79,12 @@ private: ghoul::opengl::ProgramObject* _programObject = nullptr; ghoul::opengl::ProgramObject* _fboProgramObject = nullptr; - UniformCache(sunPos, modelTransform, modelViewProjectionTransform, hasBaseMap, + UniformCache(sun_pos, modelTransform, modelViewProjectionTransform, hasBaseMap, hasHeightMap, heightExaggeration, meridianShift, ambientBrightness, - projectionFading, baseTexture, projectionTexture, heightTexture) - _mainUniformCache; + projectionFading, baseTexture, projectionTexture, + heightTexture) _mainUniformCache; - UniformCache(projectionTexture, projectorMatrix, modelTransform, boresight, + UniformCache(projectionTexture, ProjectorMatrix, ModelTransform, boresight, radius, segments) _fboUniformCache; std::unique_ptr _baseTexture; diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 9eefa880d6..6c07db10d3 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -34,10 +34,6 @@ #include namespace { - constexpr std::array UniformNames = { - "modelViewProjectionTransform", "shadowColor", "opacity" - }; - constexpr openspace::properties::Property::PropertyInfo NumberPointsInfo = { "AmountOfPoints", "Points", @@ -229,7 +225,7 @@ void RenderableShadowCylinder::initializeGL() { } ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } void RenderableShadowCylinder::deinitializeGL() { @@ -285,7 +281,7 @@ void RenderableShadowCylinder::update(const UpdateData& data) { if (_shader->isDirty()) { _shader->rebuildFromFile(); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } createCylinder(data.time.j2000Seconds()); } diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index 7d7e2d7912..5863efed3f 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -31,10 +31,6 @@ #include namespace { - constexpr std::array UniformNames = { - "radius", "opacity", "thickness", "color" - }; - constexpr openspace::properties::Property::PropertyInfo VisibilityInfo = { "Visibility", "Toggle visibility of markers", @@ -101,7 +97,7 @@ void TouchMarker::initialize() { absPath("${MODULE_TOUCH}/shaders/marker_fs.glsl") ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } void TouchMarker::deinitialize() { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index be3f1d9db3..e519330916 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -53,20 +53,6 @@ namespace { constexpr glm::vec4 PosBufferClearVal = glm::vec4(1e32, 1e32, 1e32, 1.f); - constexpr std::array HDRUniformNames = { - "hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma", - "Hue", "Saturation", "Value", "Viewport", "Resolution" - }; - - constexpr std::array FXAAUniformNames = { - "renderedTexture", "inverseScreenSize", "Viewport", "Resolution" - }; - - constexpr std::array DownscaledVolumeUniformNames = { - "downscaledRenderedVolume", "downscaledRenderedVolumeDepth", "viewport", - "resolution" - }; - constexpr std::string_view ExitFragmentShaderPath = "${SHADERS}/framebuffer/exitframebuffer.frag"; constexpr std::string_view RaycastFragmentShaderPath = @@ -355,20 +341,11 @@ void FramebufferRenderer::initialize() { // Sets back to default FBO glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); - ghoul::opengl::updateUniformLocations( - *_hdrFilteringProgram, - _hdrUniformCache, - HDRUniformNames - ); - ghoul::opengl::updateUniformLocations( - *_fxaaProgram, - _fxaaUniformCache, - FXAAUniformNames - ); + ghoul::opengl::updateUniformLocations(*_hdrFilteringProgram, _hdrUniformCache); + ghoul::opengl::updateUniformLocations(*_fxaaProgram, _fxaaUniformCache); ghoul::opengl::updateUniformLocations( *_downscaledVolumeProgram, - _writeDownscaledVolumeUniformCache, - DownscaledVolumeUniformNames + _writeDownscaledVolumeUniformCache ); global::raycasterManager->addListener(*this); @@ -625,21 +602,13 @@ void FramebufferRenderer::update() { if (_hdrFilteringProgram->isDirty()) { _hdrFilteringProgram->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_hdrFilteringProgram, - _hdrUniformCache, - HDRUniformNames - ); + ghoul::opengl::updateUniformLocations(*_hdrFilteringProgram, _hdrUniformCache); } if (_fxaaProgram->isDirty()) { _fxaaProgram->rebuildFromFile(); - ghoul::opengl::updateUniformLocations( - *_fxaaProgram, - _fxaaUniformCache, - FXAAUniformNames - ); + ghoul::opengl::updateUniformLocations(*_fxaaProgram, _fxaaUniformCache); } if (_downscaledVolumeProgram->isDirty()) { @@ -647,8 +616,7 @@ void FramebufferRenderer::update() { ghoul::opengl::updateUniformLocations( *_downscaledVolumeProgram, - _writeDownscaledVolumeUniformCache, - DownscaledVolumeUniformNames + _writeDownscaledVolumeUniformCache ); } diff --git a/src/rendering/helper.cpp b/src/rendering/helper.cpp index 817fab517f..56e1cea0c4 100644 --- a/src/rendering/helper.cpp +++ b/src/rendering/helper.cpp @@ -176,8 +176,7 @@ void initialize() { ); ghoul::opengl::updateUniformLocations( *shaders.xyuvrgba.program, - shaders.xyuvrgba.cache, - { "tex", "hasTexture", "shouldFlipTexture", "proj", "color" } + shaders.xyuvrgba.cache ); // @@ -206,8 +205,7 @@ void initialize() { ); ghoul::opengl::updateUniformLocations( *shaders.screenfilling.program, - shaders.screenfilling.cache, - { "tex", "hasTexture", "shouldFlipTexture", "proj", "color" } + shaders.screenfilling.cache ); diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index 40b27847f5..b3e973714a 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -43,11 +43,6 @@ #include namespace { - constexpr std::array UniformNames = { - "color", "opacity", "blackoutFactor", "mvpMatrix", "tex", "backgroundColor", - "gamma", "borderColor", "borderWidth" - }; - constexpr openspace::properties::Property::PropertyInfo EnabledInfo = { "Enabled", "Enabled", @@ -524,7 +519,7 @@ void ScreenSpaceRenderable::createShaders() { dict ); - ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames); + ghoul::opengl::updateUniformLocations(*_shader, _uniformCache); } glm::mat4 ScreenSpaceRenderable::scaleMatrix() { @@ -660,14 +655,14 @@ void ScreenSpaceRenderable::draw(const glm::mat4& modelTransform, float blackout _shader->setUniform(_uniformCache.borderWidth, borderUV); _shader->setUniform(_uniformCache.borderColor, _borderColor); _shader->setUniform( - _uniformCache.mvp, + _uniformCache.mvpMatrix, global::renderEngine->scene()->camera()->viewProjectionMatrix() * modelTransform ); ghoul::opengl::TextureUnit unit; unit.activate(); bindTexture(); - _shader->setUniform(_uniformCache.texture, unit); + _shader->setUniform(_uniformCache.tex, unit); glBindVertexArray(rendering::helper::vertexObjects.square.vao); glDrawArrays(GL_TRIANGLES, 0, 6);