Adapt to UniformCache changes when updating uniform locations (closes #648)

This commit is contained in:
Alexander Bock
2018-07-19 17:46:21 -04:00
parent 0774348fc2
commit f55828198f
27 changed files with 284 additions and 544 deletions
@@ -90,6 +90,20 @@
namespace {
constexpr const char* _loggerCat = "AtmosphereDeferredcaster";
constexpr const std::array<const char*, 17> UniformNames1 = {
"cullAtmosphere", "Rg", "Rt", "groundRadianceEmittion", "HR", "betaRayleigh",
"HM", "betaMieExtinction", "mieG", "sunRadiance", "ozoneLayerEnabled", "HO",
"betaOzoneExtinction", "SAMPLES_R", "SAMPLES_MU", "SAMPLES_MU_S", "SAMPLES_NU"
};
constexpr const std::array<const char*, 10> UniformNames2 = {
"dInverseModelTransformMatrix", "dModelTransformMatrix",
"dSgctProjectionToModelTransformMatrix", "dSGCTViewToWorldMatrix", "dCamPosObj",
"sunDirectionObj", "hardShadows", "transmittanceTexture", "irradianceTexture",
"inscatterTexture"
};
constexpr const char* GlslDeferredcastPath =
"${MODULES}/atmosphere/shaders/atmosphere_deferred_fs.glsl";
constexpr const char* GlslDeferredcastFSPath =
@@ -464,48 +478,11 @@ std::string AtmosphereDeferredcaster::helperPath() const {
void AtmosphereDeferredcaster::initializeCachedVariables(
ghoul::opengl::ProgramObject& program)
{
_uniformCache.cullAtmosphere = program.uniformLocation("cullAtmosphere");
_uniformCache.Rg = program.uniformLocation("Rg");
_uniformCache.Rt = program.uniformLocation("Rt");
_uniformCache.groundRadianceEmittion = program.uniformLocation(
"groundRadianceEmittion"
);
_uniformCache.HR = program.uniformLocation("HR");
_uniformCache.betaRayleigh = program.uniformLocation("betaRayleigh");
_uniformCache.HM = program.uniformLocation("HM");
_uniformCache.betaMieExtinction = program.uniformLocation("betaMieExtinction");
_uniformCache.mieG = program.uniformLocation("mieG");
_uniformCache.sunRadiance = program.uniformLocation("sunRadiance");
_uniformCache.ozoneLayerEnabled = program.uniformLocation("ozoneLayerEnabled");
_uniformCache.HO = program.uniformLocation("HO");
_uniformCache.betaOzoneExtinction = program.uniformLocation("betaOzoneExtinction");
_uniformCache.SAMPLES_R = program.uniformLocation("SAMPLES_R");
_uniformCache.SAMPLES_MU = program.uniformLocation("SAMPLES_MU");
_uniformCache.SAMPLES_MU_S = program.uniformLocation("SAMPLES_MU_S");
_uniformCache.SAMPLES_NU = program.uniformLocation("SAMPLES_NU");
_uniformCache2.dInverseModelTransformMatrix = program.uniformLocation(
"dInverseModelTransformMatrix"
);
_uniformCache2.dModelTransformMatrix = program.uniformLocation(
"dModelTransformMatrix"
);
_uniformCache2.dSgctProjectionToModelTransformMatrix = program.uniformLocation(
"dSgctProjectionToModelTransformMatrix"
);
_uniformCache2.dSGCTViewToWorldMatrix = program.uniformLocation(
"dSGCTViewToWorldMatrix"
);
_uniformCache2.dCamPosObj = program.uniformLocation("dCamPosObj");
_uniformCache2.sunDirectionObj = program.uniformLocation("sunDirectionObj");
_uniformCache2.hardShadows = program.uniformLocation("hardShadows");
_uniformCache2.transmittanceTexture = program.uniformLocation("transmittanceTexture");
_uniformCache2.irradianceTexture = program.uniformLocation("irradianceTexture");
_uniformCache2.inscatterTexture = program.uniformLocation("inscatterTexture");
ghoul::opengl::updateUniformLocations(program, _uniformCache, UniformNames1);
ghoul::opengl::updateUniformLocations(program, _uniformCache2, UniformNames2);
}
void AtmosphereDeferredcaster::update(const UpdateData&) {
}
void AtmosphereDeferredcaster::update(const UpdateData&) {}
void AtmosphereDeferredcaster::setModelTransform(const glm::dmat4& transform) {
_modelTransform = transform;
+28 -54
View File
@@ -47,6 +47,12 @@ namespace {
constexpr const char* ProgramName = "ModelProgram";
constexpr const char* KeyGeometry = "Geometry";
constexpr const std::array<const char*, 11> UniformNames = {
"opacity", "nLightSources", "lightDirectionsViewSpace", "lightIntensities",
"modelViewTransform", "projectionTransform", "performShading", "texture1",
"ambientIntensity", "diffuseIntensity", "specularIntensity"
};
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
"ColorTexture",
"Color Texture",
@@ -237,7 +243,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
RenderableModel::~RenderableModel() {}
bool RenderableModel::isReady() const {
return _programObject && _texture;
return _program && _texture;
}
void RenderableModel::initialize() {
@@ -247,7 +253,7 @@ void RenderableModel::initialize() {
}
void RenderableModel::initializeGL() {
_programObject = BaseModule::ProgramObjectManager.request(
_program = BaseModule::ProgramObjectManager.request(
ProgramName,
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
return OsEng.renderEngine().buildRenderProgram(
@@ -257,7 +263,8 @@ void RenderableModel::initializeGL() {
);
}
);
updateUniformCache();
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
loadTexture();
@@ -277,13 +284,13 @@ void RenderableModel::deinitializeGL() {
OsEng.renderEngine().removeRenderProgram(p);
}
);
_programObject = nullptr;
_program = nullptr;
}
void RenderableModel::render(const RenderData& data, RendererTasks&) {
_programObject->activate();
_program->activate();
_programObject->setUniform(_uniformCache.opacity, _opacity);
_program->setUniform(_uniformCache.opacity, _opacity);
// Model transform and view transform needs to be in double precision
const glm::dmat4 modelTransform =
@@ -309,98 +316,65 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
++nLightSources;
}
_programObject->setUniform(
_program->setUniform(
_uniformCache.nLightSources,
nLightSources
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.lightIntensities,
_lightIntensitiesBuffer.data(),
nLightSources
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.lightDirectionsViewSpace,
_lightDirectionsViewSpaceBuffer.data(),
nLightSources
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.modelViewTransform,
glm::mat4(modelViewTransform)
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.projectionTransform,
data.camera.projectionMatrix()
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.ambientIntensity,
_ambientIntensity
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.diffuseIntensity,
_diffuseIntensity
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.specularIntensity,
_specularIntensity
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.performShading,
_performShading
);
_geometry->setUniforms(*_programObject);
_geometry->setUniforms(*_program);
// Bind texture
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_programObject->setUniform(_uniformCache.texture, unit);
_program->setUniform(_uniformCache.texture, unit);
_geometry->render();
_programObject->deactivate();
_program->deactivate();
}
void RenderableModel::update(const UpdateData&) {
if (_programObject->isDirty()) {
_programObject->rebuildFromFile();
updateUniformCache();
if (_program->isDirty()) {
_program->rebuildFromFile();
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
}
void RenderableModel::updateUniformCache() {
_uniformCache.opacity = _programObject->uniformLocation("opacity");
_uniformCache.nLightSources = _programObject->uniformLocation(
"nLightSources"
);
_uniformCache.lightDirectionsViewSpace = _programObject->uniformLocation(
"lightDirectionsViewSpace"
);
_uniformCache.lightIntensities = _programObject->uniformLocation(
"lightIntensities"
);
_uniformCache.modelViewTransform = _programObject->uniformLocation(
"modelViewTransform"
);
_uniformCache.projectionTransform = _programObject->uniformLocation(
"projectionTransform"
);
_uniformCache.performShading = _programObject->uniformLocation(
"performShading"
);
_uniformCache.ambientIntensity = _programObject->uniformLocation(
"ambientIntensity"
);
_uniformCache.diffuseIntensity = _programObject->uniformLocation(
"diffuseIntensity"
);
_uniformCache.specularIntensity = _programObject->uniformLocation(
"specularIntensity"
);
_uniformCache.texture = _programObject->uniformLocation("texture1");
}
void RenderableModel::loadTexture() {
_texture = nullptr;
if (!_colorTexturePath.value().empty()) {
+1 -3
View File
@@ -68,8 +68,6 @@ protected:
void loadTexture();
private:
void updateUniformCache();
std::unique_ptr<modelgeometry::ModelGeometry> _geometry;
properties::StringProperty _colorTexturePath;
@@ -81,7 +79,7 @@ private:
properties::BoolProperty _performShading;
properties::Mat3Property _modelTransform;
ghoul::opengl::ProgramObject* _programObject = nullptr;
ghoul::opengl::ProgramObject* _program = nullptr;
UniformCache(opacity, nLightSources, lightDirectionsViewSpace, lightIntensities,
modelViewTransform, projectionTransform, performShading, texture,
ambientIntensity, diffuseIntensity, specularIntensity) _uniformCache;
+6 -9
View File
@@ -43,6 +43,10 @@
namespace {
constexpr const char* ProgramName = "Sphere";
constexpr const std::array<const char*, 4> UniformNames = {
"opacity", "ViewProjection", "ModelTransform", "texture1"
};
enum Orientation {
Outside = 1,
Inside = 2
@@ -248,10 +252,7 @@ void RenderableSphere::initializeGL() {
}
);
_uniformCache.opacity = _shader->uniformLocation("opacity");
_uniformCache.viewProjection = _shader->uniformLocation("ViewProjection");
_uniformCache.modelTransform = _shader->uniformLocation("ModelTransform");
_uniformCache.texture = _shader->uniformLocation("texture1");
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
loadTexture();
}
@@ -348,11 +349,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
void RenderableSphere::update(const UpdateData&) {
if (_shader->isDirty()) {
_shader->rebuildFromFile();
_uniformCache.opacity = _shader->uniformLocation("opacity");
_uniformCache.viewProjection = _shader->uniformLocation("ViewProjection");
_uniformCache.modelTransform = _shader->uniformLocation("ModelTransform");
_uniformCache.texture = _shader->uniformLocation("texture1");
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
if (_sphereIsDirty) {
+7 -12
View File
@@ -38,6 +38,12 @@ namespace {
constexpr const char* ProgramName = "EphemerisProgram";
constexpr const char* KeyTranslation = "Translation";
constexpr const std::array<const char*, 12> UniformNames = {
"opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade",
"lineFade", "vertexSortingMethod", "idOffset", "nVertices", "stride", "pointSize",
"renderPhase"
};
// The possible values for the _renderingModes property
enum RenderingMode {
RenderingModeLines = 0,
@@ -236,18 +242,7 @@ void RenderableTrail::initializeGL() {
}
);
_uniformCache.opacity = _programObject->uniformLocation("opacity");
_uniformCache.modelView = _programObject->uniformLocation("modelViewTransform");
_uniformCache.projection = _programObject->uniformLocation("projectionTransform");
_uniformCache.color = _programObject->uniformLocation("color");
_uniformCache.useLineFade = _programObject->uniformLocation("useLineFade");
_uniformCache.lineFade = _programObject->uniformLocation("lineFade");
_uniformCache.vertexSorting = _programObject->uniformLocation("vertexSortingMethod");
_uniformCache.idOffset = _programObject->uniformLocation("idOffset");
_uniformCache.nVertices = _programObject->uniformLocation("nVertices");
_uniformCache.stride = _programObject->uniformLocation("stride");
_uniformCache.pointSize = _programObject->uniformLocation("pointSize");
_uniformCache.renderPhase = _programObject->uniformLocation("renderPhase");
ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames);
setRenderBin(Renderable::RenderBin::Overlay);
}
@@ -56,6 +56,14 @@ namespace {
constexpr const char* ProgramObjectName = "RenderableBillboardsCloud";
constexpr const char* RenderToPolygonProgram = "RenderableBillboardsCloud_Polygon";
constexpr const std::array<const char*, 19> UniformNames = {
"cameraViewProjectionMatrix", "modelMatrix", "cameraPosition", "cameraLookUp",
"renderOption", "minBillboardSize", "maxBillboardSize",
"correctionSizeEndDistance", "correctionSizeFactor", "color", "alphaValue",
"scaleFactor", "up", "right", "fadeInValue", "screenSize", "spriteTexture",
"hasColorMap", "enabledRectSizeControl"
};
constexpr const char* KeyFile = "File";
constexpr const char* keyColor = "Color";
constexpr const char* keyUnit = "Unit";
@@ -677,37 +685,7 @@ void RenderableBillboardsCloud::initializeGL() {
}
);
_uniformCache.cameraViewProjectionMatrix = _program->uniformLocation(
"cameraViewProjectionMatrix"
);
_uniformCache.modelMatrix = _program->uniformLocation(
"modelMatrix"
);
_uniformCache.cameraPos = _program->uniformLocation("cameraPosition");
_uniformCache.cameraLookup = _program->uniformLocation("cameraLookUp");
_uniformCache.renderOption = _program->uniformLocation("renderOption");
_uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize");
_uniformCache.maxBillboardSize = _program->uniformLocation("maxBillboardSize");
_uniformCache.correctionSizeEndDistance = _program->uniformLocation(
"correctionSizeEndDistance"
);
_uniformCache.correctionSizeFactor = _program->uniformLocation(
"correctionSizeFactor"
);
_uniformCache.color = _program->uniformLocation("color");
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.up = _program->uniformLocation("up");
_uniformCache.right = _program->uniformLocation("right");
_uniformCache.fadeInValue = _program->uniformLocation("fadeInValue");
_uniformCache.screenSize = _program->uniformLocation("screenSize");
_uniformCache.spriteTexture = _program->uniformLocation("spriteTexture");
_uniformCache.hasColormap = _program->uniformLocation("hasColorMap");
_uniformCache.enabledRectSizeControl = _program->uniformLocation(
"enabledRectSizeControl"
);
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
if (_hasPolygon) {
createPolygonTexture();
@@ -139,8 +139,8 @@ private:
UniformCache(cameraViewProjectionMatrix, modelMatrix, cameraPos, cameraLookup,
renderOption, minBillboardSize, maxBillboardSize, correctionSizeEndDistance,
correctionSizeFactor, color, sides, alphaValue, scaleFactor, up, right,
fadeInValue, screenSize, spriteTexture, hasColormap, enabledRectSizeControl
correctionSizeFactor, color, alphaValue, scaleFactor, up, right, fadeInValue,
screenSize, spriteTexture, hasColormap, enabledRectSizeControl
) _uniformCache;
std::shared_ptr<ghoul::fontrendering::Font> _font;
@@ -46,18 +46,22 @@
#include <stdint.h>
namespace {
constexpr const char* _loggerCat = "RenderableDUMeshes";
constexpr const char* _loggerCat = "RenderableDUMeshes";
constexpr const char* ProgramObjectName = "RenderableDUMeshes";
constexpr const char* KeyFile = "File";
constexpr const char* keyColor = "Color";
constexpr const char* keyUnit = "Unit";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* ParsecUnit = "pc";
constexpr const char* KiloparsecUnit = "Kpc";
constexpr const char* MegaparsecUnit = "Mpc";
constexpr const char* GigaparsecUnit = "Gpc";
constexpr const std::array<const char*, 4> UniformNames = {
"modelViewTransform", "projectionTransform", "alphaValue", "color"
};
constexpr const char* KeyFile = "File";
constexpr const char* keyColor = "Color";
constexpr const char* keyUnit = "Unit";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* ParsecUnit = "pc";
constexpr const char* KiloparsecUnit = "Kpc";
constexpr const char* MegaparsecUnit = "Mpc";
constexpr const char* GigaparsecUnit = "Gpc";
constexpr const char* GigalightyearUnit = "Gly";
constexpr const int8_t CurrentCacheVersion = 1;
@@ -403,11 +407,7 @@ void RenderableDUMeshes::initializeGL() {
}
);
_uniformCache.modelViewTransform = _program->uniformLocation("modelViewTransform");
_uniformCache.projectionTransform = _program->uniformLocation("projectionTransform");
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
//_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.color = _program->uniformLocation("color");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
bool success = loadData();
if (!success) {
@@ -616,16 +616,7 @@ void RenderableDUMeshes::render(const RenderData& data, RendererTasks&) {
void RenderableDUMeshes::update(const UpdateData&) {
if (_program->isDirty()) {
_program->rebuildFromFile();
_uniformCache.modelViewTransform = _program->uniformLocation(
"modelViewTransform"
);
_uniformCache.projectionTransform = _program->uniformLocation(
"projectionTransform"
);
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
//_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.color = _program->uniformLocation("color");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
}
@@ -135,7 +135,7 @@ private:
ghoul::opengl::ProgramObject* _program = nullptr;
UniformCache(modelViewTransform, projectionTransform, alphaValue,
/*scaleFactor,*/ color) _uniformCache;
color) _uniformCache;
std::shared_ptr<ghoul::fontrendering::Font> _font = nullptr;
std::string _speckFile;
@@ -43,18 +43,21 @@
#include <string>
namespace {
constexpr const char* _loggerCat = "RenderablePlanesCloud";
constexpr const char* _loggerCat = "RenderablePlanesCloud";
constexpr const char* ProgramObjectName = "RenderablePlanesCloud";
constexpr std::array<const char*, 4> UniformNames = {
"modelViewProjectionTransform", "alphaValue", "fadeInValue", "galaxyTexture"
};
constexpr const char* KeyFile = "File";
constexpr const char* keyUnit = "Unit";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* ParsecUnit = "pc";
constexpr const char* KiloparsecUnit = "Kpc";
constexpr const char* MegaparsecUnit = "Mpc";
constexpr const char* GigaparsecUnit = "Gpc";
constexpr const char* KeyFile = "File";
constexpr const char* keyUnit = "Unit";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* ParsecUnit = "pc";
constexpr const char* KiloparsecUnit = "Kpc";
constexpr const char* MegaparsecUnit = "Mpc";
constexpr const char* GigaparsecUnit = "Gpc";
constexpr const char* GigalightyearUnit = "Gly";
constexpr int8_t CurrentCacheVersion = 2;
@@ -499,12 +502,7 @@ void RenderablePlanesCloud::initializeGL() {
}
);
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.fadeInValue = _program->uniformLocation("fadeInValue");
_uniformCache.galaxyTexture = _program->uniformLocation("galaxyTexture");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
createPlanes();
@@ -817,13 +815,7 @@ void RenderablePlanesCloud::update(const UpdateData&) {
if (_program->isDirty()) {
_program->rebuildFromFile();
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.fadeInValue = _program->uniformLocation("fadeInValue");
_uniformCache.galaxyTexture = _program->uniformLocation("galaxyTexture");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
}
@@ -129,7 +129,7 @@ private:
properties::OptionProperty _renderOption;
ghoul::opengl::ProgramObject* _program = nullptr;
UniformCache(modelViewProjectionTransform, alphaValue, scaleFactor, fadeInValue,
UniformCache(modelViewProjectionTransform, alphaValue, fadeInValue,
galaxyTexture) _uniformCache;
std::shared_ptr<ghoul::fontrendering::Font> _font = nullptr;
std::unordered_map<int, std::unique_ptr<ghoul::opengl::Texture>> _textureMap;
@@ -45,17 +45,22 @@
#include <string>
namespace {
constexpr const char* _loggerCat = "RenderablePoints";
constexpr const char* _loggerCat = "RenderablePoints";
constexpr const char* KeyFile = "File";
constexpr const char* keyColor = "Color";
constexpr const char* keyUnit = "Unit";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* ParsecUnit = "pc";
constexpr const char* KiloparsecUnit = "Kpc";
constexpr const char* MegaparsecUnit = "Mpc";
constexpr const char* GigaparsecUnit = "Gpc";
constexpr const std::array<const char*, 7> UniformNames = {
"modelViewProjectionTransform", "color", "sides", "alphaValue", "scaleFactor",
"spriteTexture", "hasColorMap"
};
constexpr const char* KeyFile = "File";
constexpr const char* keyColor = "Color";
constexpr const char* keyUnit = "Unit";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* ParsecUnit = "pc";
constexpr const char* KiloparsecUnit = "Kpc";
constexpr const char* MegaparsecUnit = "Mpc";
constexpr const char* GigaparsecUnit = "Gpc";
constexpr const char* GigalightyearUnit = "Gly";
constexpr int8_t CurrentCacheVersion = 1;
@@ -271,16 +276,6 @@ void RenderablePoints::initializeGL() {
);
}
);
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.color = _program->uniformLocation("color");
_uniformCache.sides = _program->uniformLocation("sides");
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.spriteTexture = _program->uniformLocation("spriteTexture");
_uniformCache.hasColorMap = _program->uniformLocation("hasColorMap");
}
else {
_program = DigitalUniverseModule::ProgramObjectManager.request(
@@ -293,16 +288,8 @@ void RenderablePoints::initializeGL() {
);
}
);
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.color = _program->uniformLocation("color");
_uniformCache.sides = _program->uniformLocation("sides");
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.hasColorMap = _program->uniformLocation("hasColorMap");
}
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
void RenderablePoints::deinitializeGL() {
+7 -11
View File
@@ -32,6 +32,10 @@
#include <ghoul/opengl/programobject.h>
namespace {
constexpr const std::array<const char*, 3> UniformNames = {
"lightIntensityClamped", "modelViewTransform", "projectionTransform"
};
constexpr openspace::properties::Property::PropertyInfo IntensityClampInfo = {
"IntensityClamp",
"Intensity clamp",
@@ -69,15 +73,7 @@ void PointGlobe::initialize() {
absPath("${MODULE_GLOBEBROWSING}/shaders/pointglobe_fs.glsl")
);
_uniformCache.lightIntensityClamped = _programObject->uniformLocation(
"lightIntensityClamped"
);
_uniformCache.modelView = _programObject->uniformLocation(
"modelViewTransform"
);
_uniformCache.projection = _programObject->uniformLocation(
"projectionTransform"
);
ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames);
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vertexBufferID);
@@ -159,8 +155,8 @@ void PointGlobe::render(const RenderData& data, RendererTasks&) {
_uniformCache.lightIntensityClamped,
lightIntensityClamped
);
//_programObject->setUniform("lightOverflow", lightOverflow);
//_programObject->setUniform("directionToSunViewSpace", directionToSunViewSpace);
//_program->setUniform("lightOverflow", lightOverflow);
//_program->setUniform("directionToSunViewSpace", directionToSunViewSpace);
_programObject->setUniform(
_uniformCache.modelView,
glm::mat4(modelViewTransform)
+7 -6
View File
@@ -53,6 +53,8 @@ namespace {
ImFont* captionFont = nullptr;
constexpr const std::array<const char*, 2> UniformNames = { "tex", "ortho" };
void addScreenSpaceRenderableLocal(std::string texturePath) {
if (!FileSys.fileExists(absPath(texturePath))) {
LWARNING(fmt::format("Could not find image '{}'", texturePath));
@@ -172,6 +174,8 @@ void GUI::initialize() {
ghoul::filesystem::CacheManager::Persistent::Yes
);
LDEBUG(fmt::format("Using {} as ImGUI cache location", cachedFile));
iniFileBuffer = new char[cachedFile.size() + 1];
#ifdef WIN32
@@ -304,9 +308,8 @@ void GUI::initializeGL() {
absPath("${MODULE_IMGUI}/shaders/gui_vs.glsl"),
absPath("${MODULE_IMGUI}/shaders/gui_fs.glsl")
);
_uniformCache.tex = _program->uniformLocation("tex");
_uniformCache.ortho = _program->uniformLocation("ortho");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
int nWindows = OsEng.windowWrapper().nWindows();
{
@@ -416,9 +419,7 @@ void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
void GUI::endFrame() {
if (_program->isDirty()) {
_program->rebuildFromFile();
_uniformCache.tex = _program->uniformLocation("tex");
_uniformCache.ortho = _program->uniformLocation("ortho");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
_performance.setEnabled(OsEng.renderEngine().doesPerformanceMeasurements());
+7 -17
View File
@@ -38,6 +38,11 @@
#include <ghoul/opengl/textureunit.h>
namespace {
constexpr const std::array<const char*, 6> UniformNames = {
"modelViewProjectionTransform", "textureOffset", "transparency", "_nightFactor",
"sunPosition", "texture1"
};
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
"Texture",
"Texture",
@@ -183,14 +188,7 @@ void RenderableRings::initializeGL() {
absPath("${MODULE_SPACE}/shaders/rings_fs.glsl")
);
_uniformCache.modelViewProjection = _shader->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.textureOffset = _shader->uniformLocation("textureOffset");
_uniformCache.transparency = _shader->uniformLocation("transparency");
_uniformCache.nightFactor = _shader->uniformLocation("_nightFactor");
_uniformCache.sunPosition = _shader->uniformLocation("sunPosition");
_uniformCache.texture = _shader->uniformLocation("texture1");
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
glGenVertexArrays(1, &_quad);
glGenBuffers(1, &_vertexPositionBuffer);
@@ -250,15 +248,7 @@ void RenderableRings::render(const RenderData& data, RendererTasks&) {
void RenderableRings::update(const UpdateData& data) {
if (_shader->isDirty()) {
_shader->rebuildFromFile();
_uniformCache.modelViewProjection = _shader->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.textureOffset = _shader->uniformLocation("textureOffset");
_uniformCache.transparency = _shader->uniformLocation("transparency");
_uniformCache.nightFactor = _shader->uniformLocation("_nightFactor");
_uniformCache.sunPosition = _shader->uniformLocation("sunPosition");
_uniformCache.texture = _shader->uniformLocation("texture1");
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
if (_planeIsDirty) {
+7 -21
View File
@@ -48,6 +48,11 @@ namespace {
constexpr const char* KeyFile = "File";
constexpr const std::array<const char*, 10> UniformNames = {
"view", "projection", "colorOption", "alphaValue", "scaleFactor",
"minBillboardSize", "screenSize", "scaling", "psfTexture", "colorTexture"
};
constexpr int8_t CurrentCacheVersion = 1;
struct ColorVBOLayout {
@@ -296,16 +301,7 @@ void RenderableStars::initializeGL() {
absPath("${MODULE_SPACE}/shaders/star_ge.glsl")
);
_uniformCache.view = _program->uniformLocation("view");
_uniformCache.projection = _program->uniformLocation("projection");
_uniformCache.colorOption = _program->uniformLocation("colorOption");
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize");
_uniformCache.screenSize = _program->uniformLocation("screenSize");
_uniformCache.scaling = _program->uniformLocation("scaling");
_uniformCache.psfTexture = _program->uniformLocation("psfTexture");
_uniformCache.colorTexture = _program->uniformLocation("colorTexture");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
bool success = loadData();
if (!success) {
@@ -555,17 +551,7 @@ void RenderableStars::update(const UpdateData&) {
if (_program->isDirty()) {
_program->rebuildFromFile();
_uniformCache.view = _program->uniformLocation("view");
_uniformCache.projection = _program->uniformLocation("projection");
_uniformCache.colorOption = _program->uniformLocation("colorOption");
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
_uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize");
_uniformCache.screenSize = _program->uniformLocation("screenSize");
_uniformCache.scaling = _program->uniformLocation("scaling");
_uniformCache.psfTexture = _program->uniformLocation("psfTexture");
_uniformCache.colorTexture = _program->uniformLocation("colorTexture");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
}
@@ -36,20 +36,22 @@
#include <glm/gtx/projection.hpp>
namespace {
constexpr const char* ProgramName = "FovProgram";
constexpr const char* KeyBody = "Body";
constexpr const char* KeyFrame = "Frame";
// const char* KeyColor = "RGB";
constexpr const char* KeyInstrument = "Instrument";
constexpr const char* KeyInstrumentName = "Name";
constexpr const char* ProgramName = "FovProgram";
constexpr const char* KeyBody = "Body";
constexpr const char* KeyFrame = "Frame";
constexpr const char* KeyInstrument = "Instrument";
constexpr const char* KeyInstrumentName = "Name";
constexpr const char* KeyInstrumentAberration = "Aberration";
constexpr const char* KeyPotentialTargets = "PotentialTargets";
constexpr const char* KeyFrameConversions = "FrameConversions";
constexpr const char* KeyPotentialTargets = "PotentialTargets";
constexpr const char* KeyFrameConversions = "FrameConversions";
constexpr const char* KeyBoundsSimplification = "SimplifyBounds";
constexpr const std::array<const char*, 9> UniformNames = {
"modelViewProjectionTransform", "defaultColorStart", "defaultColorEnd",
"activeColor", "targetInFieldOfViewColor", "intersectionStartColor",
"intersectionEndColor", "squareColor", "interpolation"
};
constexpr const int InterpolationSteps = 5;
constexpr const double Epsilon = 1e-4;
@@ -326,7 +328,7 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
}
void RenderableFov::initializeGL() {
_programObject =
_program =
SpacecraftInstrumentsModule::ProgramObjectManager.request(
ProgramName,
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
@@ -338,25 +340,7 @@ void RenderableFov::initializeGL() {
}
);
_uniformCache.modelViewProjection = _programObject->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.defaultColorStart = _programObject->uniformLocation(
"defaultColorStart"
);
_uniformCache.defaultColorEnd = _programObject->uniformLocation("defaultColorEnd");
_uniformCache.activeColor = _programObject->uniformLocation("activeColor");
_uniformCache.targetInFieldOfViewColor = _programObject->uniformLocation(
"targetInFieldOfViewColor"
);
_uniformCache.intersectionStartColor = _programObject->uniformLocation(
"intersectionStartColor"
);
_uniformCache.intersectionEndColor = _programObject->uniformLocation(
"intersectionEndColor"
);
_uniformCache.squareColor = _programObject->uniformLocation("squareColor");
_uniformCache.interpolation = _programObject->uniformLocation("interpolation");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
// Fetch information about the specific instrument
SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView(
@@ -499,7 +483,7 @@ void RenderableFov::deinitializeGL() {
OsEng.renderEngine().removeRenderProgram(p);
}
);
_programObject = nullptr;
_program = nullptr;
glDeleteBuffers(1, &_orthogonalPlane.vbo);
glDeleteVertexArrays(1, &_orthogonalPlane.vao);
@@ -509,7 +493,7 @@ void RenderableFov::deinitializeGL() {
}
bool RenderableFov::isReady() const {
return _programObject != nullptr && !_instrument.bounds.empty();
return _program != nullptr && !_instrument.bounds.empty();
}
// Orthogonal projection next to planets surface
@@ -838,7 +822,7 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string&
void RenderableFov::render(const RenderData& data, RendererTasks&) {
if (_drawFOV) {
_programObject->activate();
_program->activate();
// Model transform and view transform needs to be in double precision
glm::dmat4 modelTransform =
@@ -850,28 +834,28 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) {
data.camera.projectionMatrix() *
glm::mat4(data.camera.combinedViewMatrix() * modelTransform);
_programObject->setUniform(
_program->setUniform(
_uniformCache.modelViewProjection,
modelViewProjectionTransform
);
_programObject->setUniform(_uniformCache.defaultColorStart, _colors.defaultStart);
_programObject->setUniform(_uniformCache.defaultColorEnd, _colors.defaultEnd);
_programObject->setUniform(_uniformCache.activeColor, _colors.active);
_programObject->setUniform(
_program->setUniform(_uniformCache.defaultColorStart, _colors.defaultStart);
_program->setUniform(_uniformCache.defaultColorEnd, _colors.defaultEnd);
_program->setUniform(_uniformCache.activeColor, _colors.active);
_program->setUniform(
_uniformCache.targetInFieldOfViewColor,
_colors.targetInFieldOfView
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.intersectionStartColor,
_colors.intersectionStart
);
_programObject->setUniform(
_program->setUniform(
_uniformCache.intersectionEndColor,
_colors.intersectionEnd
);
_programObject->setUniform(_uniformCache.squareColor, _colors.square);
_programObject->setUniform(_uniformCache.interpolation, _interpolationTime);
_program->setUniform(_uniformCache.squareColor, _colors.square);
_program->setUniform(_uniformCache.interpolation, _interpolationTime);
GLenum mode = _drawSolid ? GL_TRIANGLE_STRIP : GL_LINES;
@@ -885,7 +869,7 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) {
glBindVertexArray(0);
glLineWidth(1.f);
_programObject->deactivate();
_program->deactivate();
}
}
@@ -918,30 +902,9 @@ void RenderableFov::update(const UpdateData& data) {
}
}
if (_programObject->isDirty()) {
_programObject->rebuildFromFile();
_uniformCache.modelViewProjection = _programObject->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.defaultColorStart = _programObject->uniformLocation(
"defaultColorStart"
);
_uniformCache.defaultColorEnd = _programObject->uniformLocation(
"defaultColorEnd"
);
_uniformCache.activeColor = _programObject->uniformLocation("activeColor");
_uniformCache.targetInFieldOfViewColor = _programObject->uniformLocation(
"targetInFieldOfViewColor"
);
_uniformCache.intersectionStartColor = _programObject->uniformLocation(
"intersectionStartColor"
);
_uniformCache.intersectionEndColor = _programObject->uniformLocation(
"intersectionEndColor"
);
_uniformCache.squareColor = _programObject->uniformLocation("squareColor");
_uniformCache.interpolation = _programObject->uniformLocation("interpolation");
if (_program->isDirty()) {
_program->rebuildFromFile();
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
}
@@ -93,7 +93,7 @@ private:
properties::FloatProperty _lineWidth;
properties::BoolProperty _drawSolid;
properties::DoubleProperty _standOffDistance;
ghoul::opengl::ProgramObject* _programObject = nullptr;
ghoul::opengl::ProgramObject* _program = nullptr;
UniformCache(modelViewProjection, defaultColorStart, defaultColorEnd, activeColor,
targetInFieldOfViewColor, intersectionStartColor, intersectionEndColor,
squareColor, interpolation) _uniformCache;
@@ -53,6 +53,20 @@ namespace {
constexpr const char* DestinationFrame = "GALACTIC";
constexpr const std::array<const char*, 7> MainUniformNames = {
"_performShading", "directionToSunViewSpace", "modelViewTransform",
"projectionTransform", "_projectionFading", "baseTexture", "projectionTexture"
};
constexpr const std::array<const char*, 5> FboUniformNames = {
"projectionTexture", "needShadowMap", "ProjectorMatrix", "ModelTransform",
"boresight"
};
constexpr const std::array<const char*, 2> DepthFboUniformNames = {
"ProjectorMatrix", "ModelTransform"
};
constexpr openspace::properties::Property::PropertyInfo ColorTextureInfo = {
"ColorTexture",
"Color Base Texture",
@@ -175,24 +189,10 @@ void RenderableModelProjection::initializeGL() {
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl")
);
_mainUniformCache.performShading = _programObject->uniformLocation("_performShading");
_mainUniformCache.directionToSunViewSpace = _programObject->uniformLocation(
"directionToSunViewSpace"
);
_mainUniformCache.modelViewTransform = _programObject->uniformLocation(
"modelViewTransform"
);
_mainUniformCache.projectionTransform = _programObject->uniformLocation(
"projectionTransform"
);
_mainUniformCache.projectionFading = _programObject->uniformLocation(
"_projectionFading"
);
_mainUniformCache.baseTexture = _programObject->uniformLocation(
"baseTexture"
);
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
"projectionTexture"
ghoul::opengl::updateUniformLocations(
*_programObject,
_mainUniformCache,
MainUniformNames
);
_fboProgramObject = ghoul::opengl::ProgramObject::Build(
@@ -205,18 +205,11 @@ void RenderableModelProjection::initializeGL() {
)
);
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
"projectionTexture"
ghoul::opengl::updateUniformLocations(
*_fboProgramObject,
_fboUniformCache,
FboUniformNames
);
_fboUniformCache.needShadowMap = _fboProgramObject->uniformLocation("needShadowMap");
_fboUniformCache.ProjectorMatrix = _fboProgramObject->uniformLocation(
"ProjectorMatrix"
);
_fboUniformCache.ModelTransform = _fboProgramObject->uniformLocation(
"ModelTransform"
);
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
_depthFboProgramObject = ghoul::opengl::ProgramObject::Build(
"DepthPass",
@@ -224,13 +217,11 @@ void RenderableModelProjection::initializeGL() {
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl")
);
_depthFboUniformCache.ProjectorMatrix = _depthFboProgramObject->uniformLocation(
"ProjectorMatrix"
ghoul::opengl::updateUniformLocations(
*_depthFboProgramObject,
_depthFboUniformCache,
DepthFboUniformNames
);
_depthFboUniformCache.ModelTransform = _depthFboProgramObject->uniformLocation(
"ModelTransform"
);
loadTextures();
_projectionComponent.initializeGL();
@@ -330,45 +321,21 @@ void RenderableModelProjection::update(const UpdateData& data) {
if (_programObject->isDirty()) {
_programObject->rebuildFromFile();
_mainUniformCache.performShading = _programObject->uniformLocation(
"_performShading"
);
_mainUniformCache.directionToSunViewSpace = _programObject->uniformLocation(
"directionToSunViewSpace"
);
_mainUniformCache.modelViewTransform = _programObject->uniformLocation(
"modelViewTransform"
);
_mainUniformCache.projectionTransform = _programObject->uniformLocation(
"projectionTransform"
);
_mainUniformCache.projectionFading = _programObject->uniformLocation(
"_projectionFading"
);
_mainUniformCache.baseTexture = _programObject->uniformLocation(
"baseTexture"
);
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
"projectionTexture"
ghoul::opengl::updateUniformLocations(
*_programObject,
_mainUniformCache,
MainUniformNames
);
}
if (_fboProgramObject->isDirty()) {
_fboProgramObject->rebuildFromFile();
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
"projectionTexture"
ghoul::opengl::updateUniformLocations(
*_fboProgramObject,
_fboUniformCache,
FboUniformNames
);
_fboUniformCache.needShadowMap = _fboProgramObject->uniformLocation(
"needShadowMap"
);
_fboUniformCache.ProjectorMatrix = _fboProgramObject->uniformLocation(
"ProjectorMatrix"
);
_fboUniformCache.ModelTransform = _fboProgramObject->uniformLocation(
"ModelTransform"
);
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
}
_projectionComponent.update();
@@ -376,11 +343,10 @@ void RenderableModelProjection::update(const UpdateData& data) {
if (_depthFboProgramObject->isDirty()) {
_depthFboProgramObject->rebuildFromFile();
_depthFboUniformCache.ProjectorMatrix = _depthFboProgramObject->uniformLocation(
"ProjectorMatrix"
);
_depthFboUniformCache.ModelTransform = _depthFboProgramObject->uniformLocation(
"ModelTransform"
ghoul::opengl::updateUniformLocations(
*_depthFboProgramObject,
_depthFboUniformCache,
DepthFboUniformNames
);
}
@@ -45,12 +45,20 @@ namespace {
constexpr const char* ProjectiveProgramName = "ProjectiveProgram";
constexpr const char* FBOPassProgramName = "FBOPassProgram";
constexpr const std::array<const char*, 12> MainUniformNames = {
"sun_pos", "modelTransform", "modelViewProjectionTransform", "_hasBaseMap",
"_hasHeightMap", "_heightExaggeration", "_meridianShift", "_ambientBrightness",
"_projectionFading", "baseTexture", "projectionTexture", "heightTexture"
};
constexpr const std::array<const char*, 7> FboUniformNames = {
"projectionTexture", "ProjectorMatrix", "ModelTransform", "_scaling",
"boresight", "_radius", "_segments"
};
constexpr const char* KeyGeometry = "Geometry";
constexpr const char* KeyProjection = "Projection";
constexpr const char* KeyRadius = "Geometry.Radius";
// const char* keyShading = "PerformShading";
constexpr const char* _mainFrame = "GALACTIC";
constexpr const char* NoImageText = "No Image";
@@ -364,28 +372,11 @@ void RenderablePlanetProjection::initializeGL() {
}
);
_mainUniformCache.sunPos = _programObject->uniformLocation("sun_pos");
_mainUniformCache.modelTransform = _programObject->uniformLocation("modelTransform");
_mainUniformCache.modelViewProjectionTransform = _programObject->uniformLocation(
"modelViewProjectionTransform"
ghoul::opengl::updateUniformLocations(
*_programObject,
_mainUniformCache,
MainUniformNames
);
_mainUniformCache.hasBaseMap = _programObject->uniformLocation("_hasBaseMap");
_mainUniformCache.hasHeightMap = _programObject->uniformLocation("_hasHeightMap");
_mainUniformCache.heightExaggeration = _programObject->uniformLocation(
"_heightExaggeration"
);
_mainUniformCache.meridianShift = _programObject->uniformLocation("_meridianShift");
_mainUniformCache.ambientBrightness = _programObject->uniformLocation(
"_ambientBrightness"
);
_mainUniformCache.projectionFading = _programObject->uniformLocation(
"_projectionFading"
);
_mainUniformCache.baseTexture = _programObject->uniformLocation("baseTexture");
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
"projectionTexture"
);
_mainUniformCache.heightTexture = _programObject->uniformLocation("heightTexture");
_fboProgramObject =
SpacecraftInstrumentsModule::ProgramObjectManager.request(
@@ -405,19 +396,11 @@ void RenderablePlanetProjection::initializeGL() {
}
);
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
"projectionTexture"
ghoul::opengl::updateUniformLocations(
*_fboProgramObject,
_fboUniformCache,
FboUniformNames
);
_fboUniformCache.projectorMatrix = _fboProgramObject->uniformLocation(
"ProjectorMatrix"
);
_fboUniformCache.modelTransform = _fboProgramObject->uniformLocation(
"ModelTransform"
);
_fboUniformCache.scaling = _fboProgramObject->uniformLocation("_scaling");
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
_fboUniformCache.radius = _fboProgramObject->uniformLocation("_radius");
_fboUniformCache.segments = _fboProgramObject->uniformLocation("_segments");
loadColorTexture();
loadHeightTexture();
@@ -639,8 +622,8 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&)
// Main renderpass
_programObject->activate();
_programObject->setUniform(_mainUniformCache.sunPos, sun_pos.vec3());
//_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
//_programObject->setUniform("ModelTransform" , _transform);
//_program->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
//_program->setUniform("ModelTransform" , _transform);
// Model transform and view transform needs to be in double precision
glm::dmat4 modelTransform =
@@ -714,53 +697,22 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&)
void RenderablePlanetProjection::update(const UpdateData& data) {
if (_programObject->isDirty()) {
_programObject->rebuildFromFile();
_mainUniformCache.sunPos = _programObject->uniformLocation("sun_pos");
_mainUniformCache.modelTransform = _programObject->uniformLocation(
"modelTransform"
);
_mainUniformCache.modelViewProjectionTransform = _programObject->uniformLocation(
"modelViewProjectionTransform"
);
_mainUniformCache.hasBaseMap = _programObject->uniformLocation("_hasBaseMap");
_mainUniformCache.hasHeightMap = _programObject->uniformLocation("_hasHeightMap");
_mainUniformCache.heightExaggeration = _programObject->uniformLocation(
"_heightExaggeration"
);
_mainUniformCache.meridianShift = _programObject->uniformLocation(
"_meridianShift"
);
_mainUniformCache.ambientBrightness = _programObject->uniformLocation(
"_ambientBrightness"
);
_mainUniformCache.projectionFading = _programObject->uniformLocation(
"_projectionFading"
);
_mainUniformCache.baseTexture = _programObject->uniformLocation("baseTexture");
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
"projectionTexture"
);
_mainUniformCache.heightTexture = _programObject->uniformLocation(
"heightTexture"
ghoul::opengl::updateUniformLocations(
*_programObject,
_mainUniformCache,
MainUniformNames
);
}
if (_fboProgramObject->isDirty()) {
_fboProgramObject->rebuildFromFile();
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
"projectionTexture"
ghoul::opengl::updateUniformLocations(
*_fboProgramObject,
_fboUniformCache,
FboUniformNames
);
_fboUniformCache.projectorMatrix = _fboProgramObject->uniformLocation(
"ProjectorMatrix"
);
_fboUniformCache.modelTransform = _fboProgramObject->uniformLocation(
"ModelTransform"
);
_fboUniformCache.scaling = _fboProgramObject->uniformLocation("_scaling");
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
_fboUniformCache.radius = _fboProgramObject->uniformLocation("_radius");
_fboUniformCache.segments = _fboProgramObject->uniformLocation("_segments");
}
if (_colorTextureDirty) {
@@ -39,6 +39,10 @@ namespace {
constexpr const char* ProgramName = "ShadowCylinderProgram";
constexpr const char* MainFrame = "GALACTIC";
constexpr const std::array<const char*, 2> UniformNames = {
"modelViewProjectionTransform", "shadowColor"
};
constexpr openspace::properties::Property::PropertyInfo NumberPointsInfo = {
"AmountOfPoints",
"Points",
@@ -292,12 +296,7 @@ void RenderableShadowCylinder::initializeGL() {
}
);
_uniformCache.modelViewProjectionTransform = _shader->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.shadowColor = _shader->uniformLocation(
"shadowColor"
);
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
void RenderableShadowCylinder::deinitializeGL() {
@@ -352,15 +351,10 @@ void RenderableShadowCylinder::update(const UpdateData& data) {
MainFrame,
data.time.j2000Seconds()
);
if (_shader->isDirty()) {
_shader->rebuildFromFile();
_uniformCache.modelViewProjectionTransform = _shader->uniformLocation(
"modelViewProjectionTransform"
);
_uniformCache.shadowColor = _shader->uniformLocation(
"shadowColor"
);
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
createCylinder(data.time.j2000Seconds());
}
+5 -4
View File
@@ -32,6 +32,10 @@
#include <ghoul/logging/logmanager.h>
namespace {
constexpr const std::array<const char*, 4> UniformNames = {
"radius", "transparency", "thickness", "color"
};
constexpr openspace::properties::Property::PropertyInfo VisibilityInfo = {
"Visibility",
"Toggle visibility of markers",
@@ -97,10 +101,7 @@ void TouchMarker::initialize() {
absPath("${MODULE_TOUCH}/shaders/marker_fs.glsl")
);
_uniformCache.radius = _shader->uniformLocation("radius");
_uniformCache.transparency = _shader->uniformLocation("transparency");
_uniformCache.thickness = _shader->uniformLocation("thickness");
_uniformCache.color = _shader->uniformLocation("color");
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
void TouchMarker::deinitialize() {
+10 -7
View File
@@ -49,6 +49,11 @@
namespace {
constexpr const char* _loggerCat = "FramebufferRenderer";
constexpr const std::array<const char*, 3> UniformNames = {
"mainColorTextures", "blackoutFactor", "nAaSamples"
};
constexpr const char* ExitFragmentShaderPath =
"${SHADERS}/framebuffer/exitframebuffer.frag";
constexpr const char* RaycastFragmentShaderPath =
@@ -222,9 +227,7 @@ void FramebufferRenderer::initialize() {
absPath("${SHADERS}/framebuffer/resolveframebuffer.frag")
);
_uniformCache.mainColorTexture = _resolveProgram->uniformLocation("mainColorTexture");
_uniformCache.blackoutFactor = _resolveProgram->uniformLocation("blackoutFactor");
_uniformCache.nAaSamples = _resolveProgram->uniformLocation("nAaSamples");
ghoul::opengl::updateUniformLocations(*_resolveProgram, _uniformCache, UniformNames);
OsEng.renderEngine().raycasterManager().addListener(*this);
OsEng.renderEngine().deferredcasterManager().addListener(*this);
@@ -294,11 +297,11 @@ void FramebufferRenderer::update() {
if (_resolveProgram->isDirty()) {
_resolveProgram->rebuildFromFile();
_uniformCache.mainColorTexture = _resolveProgram->uniformLocation(
"mainColorTexture"
ghoul::opengl::updateUniformLocations(
*_resolveProgram,
_uniformCache,
UniformNames
);
_uniformCache.blackoutFactor = _resolveProgram->uniformLocation("blackoutFactor");
_uniformCache.nAaSamples = _resolveProgram->uniformLocation("nAaSamples");
}
using K = VolumeRaycaster*;
+5 -3
View File
@@ -110,9 +110,11 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName
absPath("${SHADERS}/loadingscreen.frag")
);
_uniformCache.logoTexture = _program->uniformLocation("logoTexture");
_uniformCache.useTexture = _program->uniformLocation("useTexture");
_uniformCache.color = _program->uniformLocation("color");
ghoul::opengl::updateUniformLocations(
*_program,
_uniformCache,
{ "logoTexture", "useTexture", "color" }
);
_loadingFont = OsEng.fontManager().font(
"Loading",
+6 -8
View File
@@ -66,6 +66,10 @@ namespace {
// when horizontal scrolling is required.
constexpr const int NVisibleCharsAfterCursor = 5;
constexpr std::array<const char*, 4> UniformNames = {
"res", "color", "height", "ortho"
};
constexpr openspace::properties::Property::PropertyInfo VisibleInfo = {
"IsVisible",
"Is Visible",
@@ -242,10 +246,7 @@ void LuaConsole::initialize() {
absPath("${SHADERS}/luaconsole.frag")
);
_uniformCache.res = _program->uniformLocation("res");
_uniformCache.color = _program->uniformLocation("color");
_uniformCache.height = _program->uniformLocation("height");
_uniformCache.ortho = _program->uniformLocation("ortho");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
const GLfloat data[] = {
0.f, 0.f,
@@ -701,10 +702,7 @@ void LuaConsole::render() {
if (_program->isDirty()) {
_program->rebuildFromFile();
_uniformCache.res = _program->uniformLocation("res");
_uniformCache.color = _program->uniformLocation("color");
_uniformCache.height = _program->uniformLocation("height");
_uniformCache.ortho = _program->uniformLocation("ortho");
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
}
const glm::vec2 dpiScaling = OsEng.windowWrapper().dpiScaling();
+5 -6
View File
@@ -42,6 +42,10 @@ namespace {
constexpr const char* KeyTag = "Tag";
constexpr const float PlaneDepth = -2.f;
constexpr const std::array<const char*, 5> UniformNames = {
"OcclusionDepth", "Alpha", "ModelTransform", "ViewProjectionMatrix", "texture1"
};
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
"Enabled",
"Is Enabled",
@@ -471,12 +475,7 @@ void ScreenSpaceRenderable::createShaders() {
dict
);
_uniformCache.occlusionDepth = _shader->uniformLocation("OcclusionDepth");
_uniformCache.alpha = _shader->uniformLocation("Alpha");
_uniformCache.modelTransform = _shader->uniformLocation("ModelTransform");
_uniformCache.viewProj = _shader->uniformLocation("ViewProjectionMatrix");
_uniformCache.texture = _shader->uniformLocation("texture1");
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
glm::mat4 ScreenSpaceRenderable::scaleMatrix() {