Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
4b54ac8a
Commit
4b54ac8a
authored
Jan 19, 2015
by
Christian Schulte zu Berge
Browse files
Further work on AdvOptRaycaster, fixed some bugs but still showing artifacts...
parent
290a9b79
Changes
5
Hide whitespace changes
Inline
Side-by-side
modules/vis/glsl/advoptimizedraycaster.frag
View file @
4b54ac8a
...
...
@@ -83,7 +83,7 @@ uniform float _shadowIntensity;
const
float
SAMPLING_BASE_INTERVAL_RCP
=
200
.
0
;
float
originalTFar
=
-
1
.
0
;
const
int
MAXSTEPS
=
10
0
;
const
int
MAXSTEPS
=
5
0
;
float
OFFSET
=
0
.
001
;
...
...
@@ -109,7 +109,7 @@ bool intersectBits(in uvec4 bitRay, in ivec2 texel, in int level, out uvec4 inte
return
(
intersectionBitmask
!=
uvec4
(
0
));
}
bool
intersectHierarchy2
(
in
vec3
origin
,
in
vec3
direction
,
in
int
level
,
in
vec3
posTNear
,
in
out
float
tFar
,
out
uvec4
intersectionBitmask
)
{
bool
intersectHierarchy2
(
in
vec3
origin
,
in
vec3
direction
,
in
int
level
,
in
vec3
posTNear
,
out
float
tFar
,
out
uvec4
intersectionBitmask
)
{
// Calculate pixel coordinates ([0,width]x[0,height])
// of the current position along the ray
float
res
=
float
(
1
<<
(
_vvMaxMipMapLevel
-
level
));
...
...
@@ -140,6 +140,8 @@ bool intersectHierarchy2(in vec3 origin, in vec3 direction, in int level, in vec
intersectionBitmask
);
}
float
lll
;
float
clipFirstHitpoint
(
in
vec3
origin
,
in
vec3
direction
,
in
float
tNear
,
in
float
tFar
)
{
// Compute the exit position of the ray with the scene’s BB
// tFar = rayBoxIntersection(origin, direction, vec3(0.0), vec3(1.0), tNear);
...
...
@@ -180,6 +182,7 @@ float clipFirstHitpoint(in vec3 origin, in vec3 direction, in float tNear, in fl
}
}
lll
=
float
(
level
);
return
tNear
;
}
...
...
@@ -200,18 +203,17 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
OFFSET
=
(
0
.
25
/
(
1
<<
_vvMaxMipMapLevel
))
/
tFar
;
//< offset value used to avoid self-intersection or previous voxel intersection.
jitterEntryPoint
(
entryPoint
,
direction
,
_samplingStepSize
*
_jitterStepSizeMultiplier
);
//
jitterEntryPoint(entryPoint, direction, _samplingStepSize * _jitterStepSizeMultiplier);
float
firstHitT
=
-
1
.
0
f
;
tNear
=
clipFirstHitpoint
(
entryPoint
,
direction
,
tNear
,
tFar
);
tFar
-=
clipFirstHitpoint
(
exitPoint
,
-
direction
,
tNear
,
tFar
);
tNear
=
clipFirstHitpoint
(
entryPoint
,
direction
,
0
.
0
,
1
.
0
);
tFar
-=
clipFirstHitpoint
(
exitPoint
,
-
direction
,
0
.
0
,
1
.
0
);
originalTFar
=
tFar
;
tNear
*=
length
(
direction
);
tFar
*=
length
(
direction
);
direction
=
normalize
(
direction
);
//
tNear *= length(direction);
//
tFar *= length(direction);
//
direction = normalize(direction);
// compute sample position
vec3
samplePosition
=
entryPoint
.
rgb
+
tNear
*
direction
;
...
...
@@ -219,7 +221,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
out_FHP
=
vec4
(
samplePosition
,
1
.
0
);
out_FHN
=
vec4
(
entryPoint
.
rgb
+
tFar
*
direction
,
1
.
0
);
out_count
=
vec4
(
tNear
,
tFar
,
originalTFar
,
0
.
0
);
out_count
=
vec4
(
tNear
,
tFar
,
lll
,
0
.
0
);
while
(
tNear
<
tFar
)
{
vec3
samplePosition
=
entryPoint
.
rgb
+
tNear
*
direction
;
...
...
@@ -231,9 +233,9 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
if
(
color
.
a
>
0
.
0
)
{
#ifdef ENABLE_SHADING
// compute gradient (needed for shading and normals)
vec3
gradient
=
computeGradient
(
_volume
,
_volumeTextureParams
,
samplePosition
);
vec4
worldPos
=
_volumeTextureParams
.
_textureToWorldMatrix
*
vec4
(
samplePosition
,
1
.
0
);
// calling textureToWorld here crashes Intel HD driver and nVidia driver in debug mode, hence, let's calc it manually...
color
.
rgb
=
calculatePhongShading
(
worldPos
.
xyz
/
worldPos
.
w
,
_lightSource
,
_cameraPosition
,
gradient
,
color
.
rgb
);
//
vec3 gradient = computeGradient(_volume, _volumeTextureParams, samplePosition);
//
vec4 worldPos = _volumeTextureParams._textureToWorldMatrix * vec4(samplePosition, 1.0); // calling textureToWorld here crashes Intel HD driver and nVidia driver in debug mode, hence, let's calc it manually...
//
color.rgb = calculatePhongShading(worldPos.xyz / worldPos.w, _lightSource, _cameraPosition, gradient, color.rgb);
#endif
// accomodate for variable sampling rates
...
...
modules/vis/glsl/hierarchyrenderer.frag
View file @
4b54ac8a
...
...
@@ -66,32 +66,32 @@ void main() {
for
(
int
z
=
-
1
;
z
<
_brickDepth
+
1
;
++
z
)
{
for
(
int
y
=
-
1
;
y
<
_brickSize
+
1
;
++
y
)
{
for
(
int
x
=
-
1
;
x
<
_brickSize
+
1
;
++
x
)
{
vec3
texCoord
=
clamp
(
llf
+
(
vec3
(
x
,
y
,
z
)
/
_volumeTextureParams
.
_size
),
0
.
0
,
1
.
0
);
vec3
addendum
=
(
vec3
(
x
,
y
,
z
)
/
_volumeTextureParams
.
_size
);
vec3
texCoord
=
clamp
(
llf
+
addendum
,
0
.
0
,
1
.
0
);
//float intensity = mapIntensityToTFDomain(_transferFunctionParams._intensityDomain, texture(_volume, texCoord).r);
ivec3
voxel
=
ivec3
(
texCoord
*
_volumeTextureParams
.
_size
);
float
intensity
=
mapIntensityToTFDomain
(
_transferFunctionParams
.
_intensityDomain
,
texelFetch
(
_volume
,
voxel
,
0
).
r
);
//float intensity = texture(_volume, voxel).r;
//vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
//if (color.a > 0) {
//}
// if there was any data in the volume data in that voxel, set the bit.
if
(
intensity
>=
_tfDomain
.
x
&&
intensity
<=
_tfDomain
.
y
)
{
hasData
=
true
;
//result[e] |= (1 << d);
if
(
e
==
0
)
result
.
r
|=
(
1
<<
d
);
else
if
(
e
==
1
)
result
.
g
|=
(
1
<<
d
);
else
if
(
e
==
2
)
result
.
b
|=
(
1
<<
d
);
else
if
(
e
==
3
)
result
.
a
|=
(
1
<<
d
);
break
;
}
}
}
}
if
(
hasData
)
{
if
(
e
==
0
)
result
.
r
|=
(
1
<<
d
);
else
if
(
e
==
1
)
result
.
g
|=
(
1
<<
d
);
else
if
(
e
==
2
)
result
.
b
|=
(
1
<<
d
);
else
if
(
e
==
3
)
result
.
a
|=
(
1
<<
d
);
}
}
}
}
\ No newline at end of file
modules/vis/glsl/xorbitmask.frag
View file @
4b54ac8a
...
...
@@ -22,10 +22,29 @@
//
// ================================================================================================
layout
(
location
=
0
)
out
vec4
result
;
uniform
usampler1D
_bitmaskTexture
;
layout
(
location
=
0
)
out
uvec4
result
;
void
main
()
{
result
=
texelFetch
(
_bitmaskTexture
,
int
(
gl_FragCoord
.
x
),
0
)
^
texelFetch
(
_bitmaskTexture
,
int
(
gl_FragCoord
.
y
)
+
1
,
0
);
const
uint
ALL_ONES
=
uint
(
0xFFFFFFFF
);
uvec4
[
129
]
bitmask
;
for
(
int
e
=
0
;
e
<
4
;
++
e
)
{
for
(
int
b
=
0
;
b
<
32
;
++
b
)
{
int
idx
=
32
*
e
+
b
;
if
(
e
==
0
)
bitmask
[
idx
]
=
uvec4
(
ALL_ONES
<<
b
,
ALL_ONES
,
ALL_ONES
,
ALL_ONES
);
else
if
(
e
==
1
)
bitmask
[
idx
]
=
uvec4
(
0
,
ALL_ONES
<<
b
,
ALL_ONES
,
ALL_ONES
);
else
if
(
e
==
2
)
bitmask
[
idx
]
=
uvec4
(
0
,
0
,
ALL_ONES
<<
b
,
ALL_ONES
);
else
if
(
e
==
3
)
bitmask
[
idx
]
=
uvec4
(
0
,
0
,
0
,
ALL_ONES
<<
b
);
}
}
bitmask
[
128
]
=
uvec4
(
0
);
int
a
=
clamp
(
int
(
gl_FragCoord
.
x
),
0
,
127
);
int
b
=
clamp
(
int
(
gl_FragCoord
.
y
)
+
1
,
0
,
128
);
result
=
bitmask
[
a
]
^
bitmask
[
b
];
}
\ No newline at end of file
modules/vis/pipelines/advdvrvis.cpp
View file @
4b54ac8a
...
...
@@ -67,8 +67,8 @@ namespace campvis {
_resampler
.
p_outputImage
.
setValue
(
"image.resampled"
);
Geometry1DTransferFunction
*
dvrTF
=
new
Geometry1DTransferFunction
(
128
,
cgt
::
vec2
(
0.
f
,
.05
f
));
dvrTF
->
addGeometry
(
TFGeometry1D
::
createQuad
(
cgt
::
vec2
(
.12
f
,
.15
f
),
cgt
::
col4
(
85
,
0
,
0
,
128
),
cgt
::
col4
(
255
,
0
,
0
,
128
)));
dvrTF
->
addGeometry
(
TFGeometry1D
::
createQuad
(
cgt
::
vec2
(
.19
f
,
.28
f
),
cgt
::
col4
(
89
,
89
,
89
,
155
),
cgt
::
col4
(
89
,
89
,
89
,
155
)));
//
dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.12f, .15f), cgt::col4(85, 0, 0, 128), cgt::col4(255, 0, 0, 128)));
//
dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.19f, .28f), cgt::col4(89, 89, 89, 155), cgt::col4(89, 89, 89, 155)));
dvrTF
->
addGeometry
(
TFGeometry1D
::
createQuad
(
cgt
::
vec2
(
.41
f
,
.51
f
),
cgt
::
col4
(
170
,
170
,
128
,
64
),
cgt
::
col4
(
192
,
192
,
128
,
64
)));
static_cast
<
TransferFunctionProperty
*>
(
_ve
.
getNestedProperty
(
"VolumeRendererProperties::RaycasterProps::TransferFunction"
))
->
replaceTF
(
dvrTF
);
static_cast
<
FloatProperty
*>
(
_ve
.
getNestedProperty
(
"VolumeRendererProperties::RaycasterProps::SamplingRate"
))
->
setValue
(
4.
f
);
...
...
modules/vis/tools/voxelhierarchymapper.cpp
View file @
4b54ac8a
...
...
@@ -212,71 +212,12 @@ namespace campvis {
}
void
VoxelHierarchyMapper
::
createXorBitmaskTexture
()
{
int
bits
=
32
;
// bits per texture channel
GLuint
all_1
=
GLuint
(
pow
(
2.0
,
double
(
bits
))
-
1
);
//)0x7FFFFFFFU; // (2^31 -1)
GLuint
shifted_ones
=
all_1
;
GLuint
R
,
G
,
B
,
A
;
int
counter
=
0
;
std
::
vector
<
GLuint
>
bitmaskData
;
for
(
int
i
=
0
;
i
<
4
*
bits
;
i
++
)
{
if
(
counter
==
bits
)
//reset
{
counter
=
0
;
shifted_ones
=
all_1
;
}
if
(
i
<
bits
)
// first 31 texels: 1-bit in R
{
R
=
shifted_ones
;
G
=
all_1
;
B
=
all_1
;
A
=
all_1
;
}
if
(
bits
<=
i
&&
i
<
2
*
bits
)
// G
{
R
=
0
;
G
=
shifted_ones
;
B
=
all_1
;
A
=
all_1
;
}
if
(
2
*
bits
<=
i
&&
i
<
3
*
bits
)
// B
{
R
=
0
;
G
=
0
;
B
=
shifted_ones
;
A
=
all_1
;
}
if
(
3
*
bits
<=
i
&&
i
<
4
*
bits
)
// A
{
R
=
0
;
G
=
0
;
B
=
0
;
A
=
shifted_ones
;
}
bitmaskData
.
push_back
(
R
);
// R
bitmaskData
.
push_back
(
G
);
// G
bitmaskData
.
push_back
(
B
);
// B
bitmaskData
.
push_back
(
A
);
// A
counter
++
;
shifted_ones
=
shifted_ones
>>
1
;
}
GLuint
*
ptr
=
&
bitmaskData
.
front
();
cgt
::
TextureUnit
bitmaskUnit
,
xorUnit
;
bitmaskUnit
.
activate
();
cgt
::
Texture
*
bitmaskTexture
=
new
cgt
::
Texture
(
GL_TEXTURE_1D
,
cgt
::
ivec3
(
128
,
1
,
1
),
GL_RGBA32UI
,
reinterpret_cast
<
GLubyte
*>
(
&
bitmaskData
.
front
()),
GL_RGBA_INTEGER
,
GL_UNSIGNED_INT
,
cgt
::
Texture
::
NEAREST
);
bitmaskTexture
->
bind
();
bitmaskTexture
->
setWrapping
(
cgt
::
Texture
::
CLAMP
);
cgt
::
TextureUnit
xorUnit
;
xorUnit
.
activate
();
_xorBitmaskTexture
=
new
cgt
::
Texture
(
GL_TEXTURE_2D
,
cgt
::
ivec3
(
128
,
128
,
1
),
GL_RGBA32UI
,
cgt
::
Texture
::
NEAREST
);
_xorBitmaskTexture
->
setWrapping
(
cgt
::
Texture
::
CLAMP
);
_xorBitmaskShader
->
activate
();
_xorBitmaskShader
->
setUniform
(
"_bitmaskTexture"
,
bitmaskUnit
.
getUnitNumber
());
_fbo
->
activate
();
_fbo
->
attachTexture
(
_xorBitmaskTexture
,
GL_COLOR_ATTACHMENT0
,
0
,
0
);
_fbo
->
isComplete
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment