The name of the initial branch for new projects is now "main" instead of "master". Existing projects remain unchanged. More information: https://doku.lrz.de/display/PUBLIC/GitLab

Commit ae2ad28d authored by schultezub's avatar schultezub
Browse files

more work on SimpleRaycaster

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@348 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 837aba76
...@@ -71,7 +71,7 @@ const float SAMPLING_BASE_INTERVAL_RCP = 200.0; ...@@ -71,7 +71,7 @@ const float SAMPLING_BASE_INTERVAL_RCP = 200.0;
/** /**
* Computes the DRR by simple raycasting and returns the final fragment color. * Performs the raycasting and returns the final fragment color.
*/ */
vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) { vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) {
vec4 result = vec4(0.0); vec4 result = vec4(0.0);
...@@ -89,8 +89,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -89,8 +89,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
while (t < tend) { while (t < tend) {
// compute sample position // compute sample position
#ifdef ENABLE_ADAPTIVE_STEPSIZE #ifdef ENABLE_ADAPTIVE_STEPSIZE
vec3 singleStep = direction * _samplingStepSize; vec3 samplePosition = entryPoint.rgb + direction * _samplingStepSize;
vec3 samplePosition = entryPoint.rgb + singleStep * exp2(_stepPower);
#else #else
vec3 samplePosition = entryPoint.rgb + t * direction; vec3 samplePosition = entryPoint.rgb + t * direction;
#endif #endif
...@@ -100,29 +99,28 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -100,29 +99,28 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
vec4 color = lookupTF(_transferFunction, intensity); vec4 color = lookupTF(_transferFunction, intensity);
#ifdef ENABLE_ADAPTIVE_STEPSIZE #ifdef ENABLE_ADAPTIVE_STEPSIZE
if (color.a == 0.0) { if (color.a <= 0.0) {
// we're within void, make the steps bigger // we're within void, make the steps bigger
_inVoid = true; _inVoid = true;
if (_stepPower < 5.0)
_stepPower += 1.0;
} }
else { else {
// we're outside void, perform compositing but make sure we didn't miss anything => perform intersection refinement if (_inVoid) {
// we try to find the intersection point using binary search until _stepPower is back to 0: // we just left the void, perform intersection refinement
while (_stepPower > 0.0) { for (_stepPower = 1.0; _stepPower < 5.0; _stepPower += 1.0) {
_stepPower -= 1.0; vec3 newSamplePosition = entryPoint.rgb + direction * (_samplingStepSize / exp2(_stepPower));
float newIntensity = getElement3DNormalized(_volume, newSamplePosition).a;
samplePosition = entryPoint.rgb + singleStep * exp2(_stepPower); vec4 newColor = lookupTF(_transferFunction, newIntensity);
intensity = getElement3DNormalized(_volume, samplePosition).a;
color = lookupTF(_transferFunction, intensity); if (newColor.a <= 0.0) {
// we're back in the void - look on the right-hand side
if (color.a == 0.0) { entryPoint.rgb = newSamplePosition;
// we're back in the void - look on the right-hand side }
entryPoint.rgb = samplePosition; else {
} // we're still in the matter - look on the left-hand side
else { samplePosition = newSamplePosition;
// we're still in the matter - look on the left-hand side color = newColor;
// nothing to do here... t -= _samplingStepSize / exp2(_stepPower);
}
} }
} }
_inVoid = false; _inVoid = false;
...@@ -183,7 +181,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -183,7 +181,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
#ifdef ENABLE_ADAPTIVE_STEPSIZE #ifdef ENABLE_ADAPTIVE_STEPSIZE
entryPoint.rgb = samplePosition; entryPoint.rgb = samplePosition;
t += _samplingStepSize * exp2(_stepPower); t += _samplingStepSize;
#else #else
t += _samplingStepSize; t += _samplingStepSize;
#endif #endif
......
...@@ -41,7 +41,7 @@ namespace campvis { ...@@ -41,7 +41,7 @@ namespace campvis {
, p_targetImageID("targetImageID", "Output Image", "", DataNameProperty::WRITE) , p_targetImageID("targetImageID", "Output Image", "", DataNameProperty::WRITE)
, p_enableShadowing("EnableShadowing", "Enable Hard Shadows", false, InvalidationLevel::INVALID_SHADER) , p_enableShadowing("EnableShadowing", "Enable Hard Shadows", false, InvalidationLevel::INVALID_SHADER)
, p_shadowIntensity("ShadowIntensity", "Shadow Intensity", .5f, .0f, 1.f) , p_shadowIntensity("ShadowIntensity", "Shadow Intensity", .5f, .0f, 1.f)
, p_enableAdaptiveStepsize("EnableAdaptiveStepSize", "Enable Adaptive Step Size", false, InvalidationLevel::INVALID_SHADER) , p_enableAdaptiveStepsize("EnableAdaptiveStepSize", "Enable Adaptive Step Size", true, InvalidationLevel::INVALID_SHADER)
{ {
addDecorator(new ProcessorDecoratorShading()); addDecorator(new ProcessorDecoratorShading());
......
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