mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-26 14:08:53 -05:00
Add the ability to specify a custom shader for the RenderableGalaxy class
This commit is contained in:
@@ -43,10 +43,12 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture)
|
||||
GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture,
|
||||
std::optional<std::filesystem::path> raycastingShader)
|
||||
: _boundingBox(glm::vec3(1.f))
|
||||
, _texture(texture)
|
||||
, _textureUnit(nullptr)
|
||||
, _raycastingShader(raycastingShader.value_or(GlslRaycastPath))
|
||||
{}
|
||||
|
||||
void GalaxyRaycaster::initialize() {
|
||||
@@ -149,7 +151,7 @@ std::string GalaxyRaycaster::boundsFragmentShaderPath() const {
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::raycasterPath() const {
|
||||
return std::string(GlslRaycastPath);
|
||||
return _raycastingShader.string();
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::helperPath() const {
|
||||
|
||||
@@ -45,7 +45,8 @@ struct RaycastData;
|
||||
|
||||
class GalaxyRaycaster : public VolumeRaycaster {
|
||||
public:
|
||||
GalaxyRaycaster(ghoul::opengl::Texture& texture);
|
||||
GalaxyRaycaster(ghoul::opengl::Texture& texture,
|
||||
std::optional<std::filesystem::path> raycastingShader = std::nullopt);
|
||||
~GalaxyRaycaster() override = default;
|
||||
|
||||
void initialize();
|
||||
@@ -87,6 +88,7 @@ private:
|
||||
float _emissionMultiply = 0.f;
|
||||
ghoul::opengl::Texture& _texture;
|
||||
std::unique_ptr<ghoul::opengl::TextureUnit> _textureUnit;
|
||||
std::filesystem::path _raycastingShader;
|
||||
|
||||
}; // GalaxyRaycaster
|
||||
|
||||
|
||||
@@ -175,6 +175,10 @@ namespace {
|
||||
// [[codegen::verbatim(EmissionMultiplyInfo.description)]]
|
||||
std::optional<float> emissionMultiply;
|
||||
|
||||
// If this value is specified, the default raycasting shader is overwritten and
|
||||
// the shader found at the provided location is used instead
|
||||
std::optional<std::filesystem::path> raycastingShader;
|
||||
|
||||
enum class [[codegen::map(StarRenderingMethod)]] StarRenderingMethod {
|
||||
Points,
|
||||
Billboards
|
||||
@@ -285,6 +289,7 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary)
|
||||
_stepSize = p.stepSizeInfo.value_or(_stepSize);
|
||||
_absorptionMultiply = p.absorptionMultiply.value_or(_absorptionMultiply);
|
||||
_emissionMultiply = p.emissionMultiply.value_or(_emissionMultiply);
|
||||
_raycastingShader = p.raycastingShader.value_or(_raycastingShader);
|
||||
|
||||
_starRenderingMethod.addOptions({
|
||||
{ StarRenderingMethod::Points, "Points" },
|
||||
@@ -417,7 +422,12 @@ void RenderableGalaxy::initializeGL() {
|
||||
_texture->setDimensions(_volume->dimensions());
|
||||
_texture->uploadTexture();
|
||||
|
||||
_raycaster = std::make_unique<GalaxyRaycaster>(*_texture);
|
||||
if (_raycastingShader.empty()) {
|
||||
_raycaster = std::make_unique<GalaxyRaycaster>(*_texture);
|
||||
}
|
||||
else {
|
||||
_raycaster = std::make_unique<GalaxyRaycaster>(*_texture, _raycastingShader);
|
||||
}
|
||||
_raycaster->initialize();
|
||||
|
||||
// We no longer need the data
|
||||
|
||||
@@ -88,6 +88,7 @@ private:
|
||||
glm::ivec3 _volumeDimensions = glm::ivec3(0);
|
||||
std::string _pointsFilename;
|
||||
std::string _pointSpreadFunctionTexturePath;
|
||||
std::filesystem::path _raycastingShader;
|
||||
|
||||
std::unique_ptr<GalaxyRaycaster> _raycaster;
|
||||
std::unique_ptr<volume::RawVolume<glm::tvec4<GLubyte>>> _volume;
|
||||
|
||||
Reference in New Issue
Block a user