Make use of the new uniform cache method that uses the variable names as uniform names (#3217)

This commit is contained in:
Alexander Bock
2024-04-30 08:12:33 +02:00
committed by GitHub
parent be3e30e6b4
commit 203cff04cc
36 changed files with 122 additions and 348 deletions
@@ -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<ghoul::opengl::ProgramObject> _shader;
};
@@ -70,16 +70,6 @@
namespace {
constexpr std::string_view _loggerCat = "AtmosphereDeferredcaster";
constexpr std::array<const char*, 29> 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) {
@@ -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;
@@ -58,18 +58,6 @@
namespace {
constexpr std::string_view _loggerCat = "RenderablePointCloud";
constexpr std::array<const char*, 37> 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);
@@ -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,
+2 -2
View File
@@ -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);
+2 -1
View File
@@ -71,7 +71,8 @@ protected:
std::unique_ptr<TextureComponent> _texture;
private:
UniformCache(modelViewProjection, opacity, width, texture) _uniformCache;
UniformCache(modelViewProjectionTransform, opacity, width,
colorTexture) _uniformCache;
bool _planeIsDirty = false;
};
+5 -28
View File
@@ -69,20 +69,6 @@ namespace {
constexpr glm::vec4 PosBufferClearVal = glm::vec4(1e32, 1e32, 1e32, 1.f);
constexpr std::array<const char*, 26> 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<const char*, 5> 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<GLfloat, 24> 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()) {
+2 -7
View File
@@ -41,11 +41,6 @@
#include <variant>
namespace {
constexpr std::array<const char*, 6> 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) {
+3 -7
View File
@@ -37,10 +37,6 @@
#include <optional>
namespace {
constexpr std::array<const char*, 2> 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();
+1 -1
View File
@@ -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<ghoul::opengl::ProgramObject> _shader;
GLuint _vaoId = 0;
+2 -7
View File
@@ -40,11 +40,6 @@
#include <optional>
namespace {
constexpr std::array<const char*, 6> 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) {
+6 -3
View File
@@ -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);
+7 -6
View File
@@ -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
};
+2 -2
View File
@@ -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;
}
@@ -52,10 +52,6 @@
namespace {
constexpr std::string_view _loggerCat = "RenderableDUMeshes";
constexpr std::array<const char*, 4> 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);
}
}
@@ -40,11 +40,6 @@
#include <optional>
namespace {
constexpr std::array<const char*, 7> 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) {
@@ -70,7 +70,7 @@ private:
properties::Vec3Property _multiplyColor;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader = nullptr;
UniformCache(modelViewProjection, offset, opacity, texture,
UniformCache(modelViewProjectionTransform, offset, opacity, discTexture,
eccentricity, semiMajorAxis, multiplyColor) _uniformCache;
std::unique_ptr<PlaneGeometry> _plane;
+4 -22
View File
@@ -64,16 +64,6 @@ namespace {
Billboards
};
constexpr std::array<const char*, 4> UniformNamesPoints = {
"modelMatrix", "viewProjectionMatrix", "eyePosition",
"opacityCoefficient"
};
constexpr std::array<const char*, 5> 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
);
+2 -4
View File
@@ -101,12 +101,10 @@ private:
std::unique_ptr<ghoul::opengl::ProgramObject> _pointsProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _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<float> _pointsData;
size_t _nPoints = 0;
@@ -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;
+7 -37
View File
@@ -53,24 +53,6 @@
namespace {
constexpr std::string_view _loggerCat = "RingsComponent";
constexpr std::array<const char*, 10> UniformNames = {
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "nightFactor",
"sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture",
"zFightingPercentage", "opacity"
};
constexpr std::array<const char*, 16> UniformNamesAdvancedRings = {
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "nightFactor",
"sunPosition", "sunPositionObj", "camPositionObj", "ringTextureFwrd",
"ringTextureBckwrd", "ringTextureUnlit", "ringTextureColor",
"ringTextureTransparency", "shadowMatrix", "shadowMapTexture",
"zFightingPercentage", "opacity"
};
constexpr std::array<const char*, 3> 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) {
+4 -4
View File
@@ -97,15 +97,15 @@ private:
std::unique_ptr<ghoul::opengl::ProgramObject> _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<ghoul::opengl::Texture> _texture;
std::unique_ptr<ghoul::opengl::Texture> _textureForwards;
std::unique_ptr<ghoul::opengl::Texture> _textureBackwards;
+2 -4
View File
@@ -50,8 +50,6 @@ namespace {
ImFont* captionFont = nullptr;
constexpr std::array<const char*, 2> 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);
}
//
@@ -38,12 +38,6 @@
#include <optional>
namespace {
constexpr std::array<const char*, 9> 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);
}
}
@@ -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;
@@ -39,20 +39,6 @@
#include <ghoul/opengl/textureunit.h>
namespace {
constexpr std::array<const char*, 7> MainUniformNames = {
"performShading", "directionToSunViewSpace", "modelViewTransform",
"projectionTransform", "projectionFading", "baseTexture", "projectionTexture"
};
constexpr std::array<const char*, 6> FboUniformNames = {
"projectionTexture", "depthTexture", "needShadowMap", "ProjectorMatrix",
"ModelTransform", "boresight"
};
constexpr std::array<const char*, 2> 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
);
}
@@ -80,6 +80,7 @@ private:
std::unique_ptr<ghoul::opengl::ProgramObject> _fboProgramObject;
UniformCache(projectionTexture, depthTexture, needShadowMap, ProjectorMatrix,
ModelTransform, boresight) _fboUniformCache;
std::unique_ptr<ghoul::opengl::ProgramObject> _depthFboProgramObject;
UniformCache(ProjectorMatrix, ModelTransform) _depthFboUniformCache;
@@ -39,17 +39,6 @@
#include <ghoul/opengl/textureunit.h>
namespace {
constexpr std::array<const char*, 12> MainUniformNames = {
"sun_pos", "modelTransform", "modelViewProjectionTransform", "hasBaseMap",
"hasHeightMap", "heightExaggeration", "meridianShift", "ambientBrightness",
"projectionFading", "baseTexture", "projectionTexture", "heightTexture"
};
constexpr std::array<const char*, 6> 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<glm::vec3>(sunPos));
_programObject->setUniform(_mainUniformCache.sun_pos, static_cast<glm::vec3>(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) {
@@ -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<ghoul::opengl::Texture> _baseTexture;
@@ -34,10 +34,6 @@
#include <ghoul/filesystem/filesystem.h>
namespace {
constexpr std::array<const char*, 3> 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());
}
+1 -5
View File
@@ -31,10 +31,6 @@
#include <ghoul/opengl/programobject.h>
namespace {
constexpr std::array<const char*, 4> 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() {
+6 -38
View File
@@ -53,20 +53,6 @@ namespace {
constexpr glm::vec4 PosBufferClearVal = glm::vec4(1e32, 1e32, 1e32, 1.f);
constexpr std::array<const char*, 9> HDRUniformNames = {
"hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma",
"Hue", "Saturation", "Value", "Viewport", "Resolution"
};
constexpr std::array<const char*, 4> FXAAUniformNames = {
"renderedTexture", "inverseScreenSize", "Viewport", "Resolution"
};
constexpr std::array<const char*, 4> 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
);
}
+2 -4
View File
@@ -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
);
+3 -8
View File
@@ -43,11 +43,6 @@
#include <variant>
namespace {
constexpr std::array<const char*, 9> 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);