diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 8597c7a5e0..9dfe003559 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -124,6 +124,12 @@ namespace { "This value set the downscaling factor" " when rendering the current volume." }; + + constexpr openspace::properties::Property::PropertyInfo NumberOfRayCastingStepsInfo = { + "Steps", + "Number of RayCasting Steps", + "This value set the number of integration steps during the raycasting procedure." + }; } // namespace namespace openspace { @@ -143,6 +149,7 @@ namespace openspace { , _translation(TranslationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f)) , _rotation(RotationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(6.28f)) , _downScaleVolumeRendering(DownscaleVolumeRenderingInfo, 1.f, 0.1f, 1.f) + , _numberOfRayCastingSteps(NumberOfRayCastingStepsInfo, 1000.f, 1.f, 1000.f) { dictionary.getValue("VolumeRenderingEnabled", _volumeRenderingEnabled); dictionary.getValue("StarRenderingEnabled", _starRenderingEnabled); @@ -232,8 +239,10 @@ namespace openspace { LERROR("No volume dimensions specified."); } - if (volumeDictionary.hasKey("Steps")) { - _rayCastSteps = static_cast(volumeDictionary.value("Steps")); + if (volumeDictionary.hasKey(NumberOfRayCastingStepsInfo.identifier)) { + _numberOfRayCastingSteps = static_cast( + volumeDictionary.value(NumberOfRayCastingStepsInfo.identifier) + ); } else { LINFO("Number of raycasting steps not specified for Milkway Galaxy." @@ -243,8 +252,9 @@ namespace openspace { _downScaleVolumeRendering.setVisibility( openspace::properties::Property::Visibility::Developer ); - if (volumeDictionary.hasKey("Downscale")) { - _downScaleVolumeRendering = volumeDictionary.value("Downscale"); + if (volumeDictionary.hasKey(DownscaleVolumeRenderingInfo.identifier)) { + _downScaleVolumeRendering = + volumeDictionary.value(DownscaleVolumeRenderingInfo.identifier); } if (!dictionary.hasKeyAndValue("Points")) { @@ -331,6 +341,7 @@ void RenderableGalaxy::initializeGL() { addProperty(_translation); addProperty(_rotation); addProperty(_downScaleVolumeRendering); + addProperty(_numberOfRayCastingSteps); // initialize points. if (!_pointsFilename.empty()) { @@ -495,7 +506,7 @@ void RenderableGalaxy::update(const UpdateData& data) { _pointTransform[3] += translation; _raycaster->setDownscaleRender(_downScaleVolumeRendering); - _raycaster->setMaxSteps(_rayCastSteps); + _raycaster->setMaxSteps(_numberOfRayCastingSteps); _raycaster->setStepSize(_stepSize); _raycaster->setAspect(_aspect); _raycaster->setModelTransform(volumeTransform); diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index ea7ddcb824..d074bd848b 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -72,6 +72,7 @@ private: properties::Vec3Property _translation; properties::Vec3Property _rotation; properties::FloatProperty _downScaleVolumeRendering; + properties::FloatProperty _numberOfRayCastingSteps; std::unique_ptr _pointSpreadFunctionTexture; std::unique_ptr _pointSpreadFunctionFile; @@ -80,7 +81,6 @@ private: glm::ivec3 _volumeDimensions; std::string _pointsFilename; std::string _pointSpreadFunctionTexturePath; - int _rayCastSteps = 1000; std::unique_ptr _raycaster; std::unique_ptr>> _volume; diff --git a/openspace.cfg b/openspace.cfg index 996fa99556..b47a47aa89 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -27,7 +27,7 @@ SGCTConfig = sgct.config.single{} -- SGCTConfig = sgct.config.fisheye{1024, 1024} -- A 4k fisheye rendering in a 1024x1024 window -SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27} +-- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27} -- Streaming OpenSpace via Spout to OBS -- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"} diff --git a/shaders/framebuffer/raycastframebuffer.frag b/shaders/framebuffer/raycastframebuffer.frag index 120bcdd2b8..4cb79d25a0 100644 --- a/shaders/framebuffer/raycastframebuffer.frag +++ b/shaders/framebuffer/raycastframebuffer.frag @@ -28,7 +28,6 @@ uniform sampler2D exitColorTexture; uniform sampler2D exitDepthTexture; uniform sampler2D mainDepthTexture; -uniform bool insideRaycaster; uniform vec3 cameraPosInRaycaster; uniform vec2 windowSize; @@ -53,6 +52,7 @@ out vec4 finalColor; void main() { vec2 texCoord = vec2(gl_FragCoord.xy / windowSize); + // Boundary position in view space vec4 exitColorTexture = texture(exitColorTexture, texCoord); // If we don't have an exit, discard the ray @@ -80,7 +80,7 @@ void main() { vec3 direction = normalize(diff); float raycastDepth = length(diff); - float geoDepth = denormalizeFloat(texelFetch(mainDepthTexture, ivec2(gl_FragCoord), 0).x); + float geoDepth = denormalizeFloat((texture(mainDepthTexture, texCoord).x)); float geoRatio = clamp((geoDepth - entryDepth) / (exitDepth - entryDepth), 0.f, 1.f); raycastDepth = geoRatio * raycastDepth; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index f45c618b76..76f571cf01 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -1116,7 +1116,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector exitProgram->deactivate(); } - if (raycaster->downscaleRender() != 1.f) { + if (raycaster->downscaleRender() < 1.f) { float scaleDown = raycaster->downscaleRender(); glBindFramebuffer(GL_FRAMEBUFFER, _downscaleVolumeRendering.framebuffer); glViewport(0, 0, _resolution.x * scaleDown, _resolution.y * scaleDown); @@ -1180,7 +1180,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector glBindTexture(GL_TEXTURE_2D, _gBuffers.depthTexture); raycastProgram->setUniform("mainDepthTexture", mainDepthTextureUnit); - if (raycaster->downscaleRender() != 1.f) { + if (raycaster->downscaleRender() < 1.f) { float scaleDown = raycaster->downscaleRender(); raycastProgram->setUniform( "windowSize", @@ -1211,7 +1211,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector LWARNING("Raycaster is not attached when trying to perform raycaster task"); } - if (raycaster->downscaleRender() != 1.f) { + if (raycaster->downscaleRender() < 1.f) { float scaleDown = raycaster->downscaleRender(); glViewport(0, 0, _resolution.x, _resolution.y); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _gBuffers.framebuffer);