The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit b1e97719 authored by schultezub's avatar schultezub
Browse files

* finished adaptive sampling implementation in SimpleRaycaster

 * changed samplingStepSize property to more convenient samplingRate

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@349 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent ae2ad28d
......@@ -50,7 +50,7 @@ namespace campvis {
, p_exitImageID("exitImageID", "Input Exit Points Image", "", DataNameProperty::READ)
, p_camera("camera", "Camera")
, p_transferFunction("transferFunction", "Transfer Function", new SimpleTransferFunction(256))
, p_samplingStepSize("samplingStepSize", "Sampling Step Size", .05f, 0.001f, 1.f)
, p_samplingRate("SamplingRate", "Sampling Rate", 2.f, 0.1f, 10.f)
, p_jitterEntryPoints("jitterEntryPoints", "Jitter Entry Points", true)
, p_jitterStepSizeMultiplier("jitterStepSizeMultiplier", "Jitter Step Size Multiplier", .5f, .1f, 1.f)
, _fragmentShaderFilename(fragmentShaderFileName)
......@@ -62,7 +62,7 @@ namespace campvis {
addProperty(&p_exitImageID);
addProperty(&p_camera);
addProperty(&p_transferFunction);
addProperty(&p_samplingStepSize);
addProperty(&p_samplingRate);
addProperty(&p_jitterEntryPoints);
addProperty(&p_jitterStepSizeMultiplier);
}
......@@ -107,12 +107,14 @@ namespace campvis {
_shader->setUniform("_viewportSizeRCP", 1.f / tgt::vec2(_renderTargetSize.getValue()));
_shader->setUniform("_jitterEntryPoints", p_jitterEntryPoints.getValue());
_shader->setUniform("_jitterStepSizeMultiplier", p_jitterStepSizeMultiplier.getValue());
_shader->setUniform("_samplingStepSize", p_samplingStepSize.getValue() * .1f);
float samplingStepSize = 1.f / (p_samplingRate.getValue() * tgt::max(img->getSize()));
_shader->setUniform("_samplingStepSize", samplingStepSize);
const tgt::Camera& cam = p_camera.getValue();
float n = cam.getNearDist();
float f = cam.getFarDist();
_shader->setUniform("_cameraPosition", p_camera.getValue().getPosition());
_shader->setUniform("_cameraPosition", cam.getPosition());
_shader->setUniform("const_to_z_e_1", 0.5f + 0.5f*((f+n)/(f-n)));
_shader->setUniform("const_to_z_e_2", ((f-n)/(f*n)));
_shader->setUniform("const_to_z_w_1", ((f*n)/(f-n)));
......
......@@ -104,7 +104,7 @@ namespace campvis {
CameraProperty p_camera; ///< Camera used for ray casting
TransferFunctionProperty p_transferFunction; ///< Transfer function
FloatProperty p_samplingStepSize; ///< Ray casting step size
FloatProperty p_samplingRate; ///< Ray casting sampling rate
BoolProperty p_jitterEntryPoints; ///< Flag whether to jitter the entry points
FloatProperty p_jitterStepSizeMultiplier; ///< Step size multiplier for entry points jitter
......
......@@ -58,7 +58,6 @@ uniform vec3 _cameraPosition;
uniform float _samplingStepSize;
#ifdef ENABLE_ADAPTIVE_STEPSIZE
float _stepPower = 0.0;
bool _inVoid = false;
#endif
......@@ -88,11 +87,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
while (t < tend) {
// compute sample position
#ifdef ENABLE_ADAPTIVE_STEPSIZE
vec3 samplePosition = entryPoint.rgb + direction * _samplingStepSize;
#else
vec3 samplePosition = entryPoint.rgb + t * direction;
#endif
// lookup intensity and TF
float intensity = getElement3DNormalized(_volume, samplePosition).a;
......@@ -105,25 +100,31 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
}
else {
if (_inVoid) {
float formerT = t - _samplingStepSize;
// we just left the void, perform intersection refinement
for (_stepPower = 1.0; _stepPower < 5.0; _stepPower += 1.0) {
vec3 newSamplePosition = entryPoint.rgb + direction * (_samplingStepSize / exp2(_stepPower));
for (float stepPower = 0.5; stepPower > 0.05; stepPower /= 2.0) {
// compute refined sample position
float newT = formerT + _samplingStepSize * stepPower;
vec3 newSamplePosition = entryPoint.rgb + newT * direction;
// lookup refined intensity + TF
float newIntensity = getElement3DNormalized(_volume, newSamplePosition).a;
vec4 newColor = lookupTF(_transferFunction, newIntensity);
if (newColor.a <= 0.0) {
// we're back in the void - look on the right-hand side
entryPoint.rgb = newSamplePosition;
formerT = newT;
}
else {
// we're still in the matter - look on the left-hand side
samplePosition = newSamplePosition;
color = newColor;
t -= _samplingStepSize / exp2(_stepPower);
t -= _samplingStepSize * stepPower;
}
}
_inVoid = false;
}
_inVoid = false;
}
#endif
......@@ -180,8 +181,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
}
#ifdef ENABLE_ADAPTIVE_STEPSIZE
entryPoint.rgb = samplePosition;
t += _samplingStepSize;
t += _samplingStepSize * (_inVoid ? 1.0 : 0.125);
#else
t += _samplingStepSize;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment