Clean up. Added the raycasting number of steps as a slider for user's control.

This commit is contained in:
Jonathas Costa
2019-11-12 17:19:23 -05:00
parent b0ad104bc8
commit caa02ca20a
5 changed files with 23 additions and 12 deletions

View File

@@ -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<int>(volumeDictionary.value<float>("Steps"));
if (volumeDictionary.hasKey(NumberOfRayCastingStepsInfo.identifier)) {
_numberOfRayCastingSteps = static_cast<int>(
volumeDictionary.value<float>(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<float>("Downscale");
if (volumeDictionary.hasKey(DownscaleVolumeRenderingInfo.identifier)) {
_downScaleVolumeRendering =
volumeDictionary.value<float>(DownscaleVolumeRenderingInfo.identifier);
}
if (!dictionary.hasKeyAndValue<ghoul::Dictionary>("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);

View File

@@ -72,6 +72,7 @@ private:
properties::Vec3Property _translation;
properties::Vec3Property _rotation;
properties::FloatProperty _downScaleVolumeRendering;
properties::FloatProperty _numberOfRayCastingSteps;
std::unique_ptr<ghoul::opengl::Texture> _pointSpreadFunctionTexture;
std::unique_ptr<ghoul::filesystem::File> _pointSpreadFunctionFile;
@@ -80,7 +81,6 @@ private:
glm::ivec3 _volumeDimensions;
std::string _pointsFilename;
std::string _pointSpreadFunctionTexturePath;
int _rayCastSteps = 1000;
std::unique_ptr<GalaxyRaycaster> _raycaster;
std::unique_ptr<volume::RawVolume<glm::tvec4<GLubyte>>> _volume;

View File

@@ -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"}

View File

@@ -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;

View File

@@ -1116,7 +1116,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector<RaycasterTask>
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<RaycasterTask>
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<RaycasterTask>
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);