Commit ef39dee4 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

removed getElementXD() and getElementXDNormalized() from core GLSL headers...

removed getElementXD() and getElementXDNormalized() from core GLSL headers since the same functionality is directly provided by GLSL with texture() and texelFetch() in a much cleaner way.
parent 0f093954
...@@ -60,17 +60,17 @@ void main() { ...@@ -60,17 +60,17 @@ void main() {
// perform MIP // perform MIP
out_Color = vec4(0.0); out_Color = vec4(0.0);
for (float slice = 0.0; slice < 1.0; slice += _3dTextureParams._sizeRCP.z) { for (float slice = 0.0; slice < 1.0; slice += _3dTextureParams._sizeRCP.z) {
out_Color = max(out_Color, lookupTF(_transferFunction, _transferFunctionParams, getElement3DNormalized(_texture3d, _3dTextureParams, vec3(ex_TexCoord.xy, slice)).r)); out_Color = max(out_Color, lookupTF(_transferFunction, _transferFunctionParams, texture(_texture3d, vec3(ex_TexCoord.xy, slice)).r));
} }
} }
else { else {
// render the corresponding slice // render the corresponding slice
vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber + 0.5) / (_3dTextureParams._size.z)); vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber + 0.5) / (_3dTextureParams._size.z));
out_Color = lookupTF(_transferFunction, _transferFunctionParams, getElement3DNormalized(_texture3d, _3dTextureParams, coord).r); out_Color = lookupTF(_transferFunction, _transferFunctionParams, texture(_texture3d, coord).r);
} }
} }
else { else {
vec4 texel = getElement2DNormalized(_texture2d, _2dTextureParams, ex_TexCoord.xy); vec4 texel = texture(_texture2d, ex_TexCoord.xy);
if (_2dTextureParams._numChannels == 1) { if (_2dTextureParams._numChannels == 1) {
out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.r); out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.r);
} }
......
...@@ -42,9 +42,9 @@ uniform sampler2D _depthTexture; ...@@ -42,9 +42,9 @@ uniform sampler2D _depthTexture;
void main() { void main() {
vec2 fragCoord = gl_FragCoord.xy * _viewportSizeRCP; vec2 fragCoord = gl_FragCoord.xy * _viewportSizeRCP;
out_Color = getElement2DNormalized(_colorTexture, _texParams, fragCoord); out_Color = texture(_colorTexture, fragCoord);
#ifndef NO_DEPTH #ifndef NO_DEPTH
gl_FragDepth = getElement2DNormalized(_depthTexture, _texParams, fragCoord).r; gl_FragDepth = texture(_depthTexture, fragCoord).r;
#endif #endif
} }
...@@ -35,7 +35,7 @@ uniform TextureParameters2D _maskTexParams; ...@@ -35,7 +35,7 @@ uniform TextureParameters2D _maskTexParams;
uniform vec4 _maskColor; ///< mask color uniform vec4 _maskColor; ///< mask color
#define MASKING_PROLOG(COORDS) \ #define MASKING_PROLOG(COORDS) \
vec4 maskValue = getElement2DNormalized(_maskImage, _maskTexParams, (COORDS) ); \ vec4 maskValue = texture(_maskImage, (COORDS) ); \
if (distance(maskValue, _maskColor) > 0.01) { if (distance(maskValue, _maskColor) > 0.01) {
#define MASKING_EPILOG \ #define MASKING_EPILOG \
......
...@@ -34,28 +34,3 @@ struct TextureParameters2D { ...@@ -34,28 +34,3 @@ struct TextureParameters2D {
vec2 _sizeRCP; vec2 _sizeRCP;
int _numChannels; int _numChannels;
}; };
/**
* Texture lookup function for 2D textures using pixel coordinates, i.e [(0,0) , textureSize].
* \param tex Sampler to texture
* \param texParams TextureParameters2D struct with texture for lookup
* \param texCoords Lookup coordinates in pixel coordinates
* \return The texel at the given coordinates.
*/
vec4 getElement2D(in sampler2D tex, in TextureParameters2D texParams, in vec2 texCoords) {
vec2 texCoordsNormalized = texCoords * texParams._sizeRCP;
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoordsNormalized, 0.0, 1.0)).xy;
return texture(tex, texCoordsNormalized);
}
/**
* Texture lookup function for 2D textures using normalized texture coordinates, i.e. [0,1].
* \param tex Sampler to texture
* \param texParams TextureParameters2D struct with texture for lookup
* \param texCoords Lookup coordinates in normlized texture coordinates
* \return The texel at the given coordinates.
*/
vec4 getElement2DNormalized(in sampler2D tex, in TextureParameters2D texParams, in vec2 texCoords) {
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoords, 0.0, 1.0)).xy;
return texture(tex, texCoords);
}
...@@ -48,31 +48,6 @@ struct TextureParameters3D { ...@@ -48,31 +48,6 @@ struct TextureParameters3D {
vec2 _realWorldMapping; vec2 _realWorldMapping;
}; };
/**
* Texture lookup function for 3D textures using voxel coordinates, i.e [(0,0) , textureSize].
* \param tex Sampler to texture
* \param texParams TextureParameters3D struct with texture for lookup
* \param texCoords Lookup coordinates in pixel coordinates
* \return The texel at the given coordinates.
*/
vec4 getElement3D(in sampler3D tex, in TextureParameters3D texParams, in vec3 texCoords) {
vec3 texCoordsNormalized = texCoords * texParams._sizeRCP;
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoordsNormalized, 0.0, 1.0)).xy;
return texture(tex, texCoordsNormalized);
}
/**
* Texture lookup function for 3D textures using normalized texture coordinates, i.e. [0,1].
* \param tex Sampler to texture
* \param texParams TextureParameters3D struct with texture for lookup
* \param texCoords Lookup coordinates in normlized texture coordinates
* \return The texel at the given coordinates.
*/
vec4 getElement3DNormalized(in sampler3D tex, in TextureParameters3D texParams, in vec3 texCoords) {
//vec2 texCoordsTransformed = (texParams.matrix_ * vec4(texCoords, 0.0, 1.0)).xy;
return texture(tex, texCoords);
}
/** /**
* Transforms texture coordinates for texture \a tex to world coordinates using the texture's * Transforms texture coordinates for texture \a tex to world coordinates using the texture's
* texture-to-world matrix. * texture-to-world matrix.
......
...@@ -38,11 +38,11 @@ out vec4 out_Color; ...@@ -38,11 +38,11 @@ out vec4 out_Color;
#ifdef USE_3D_TEX #ifdef USE_3D_TEX
#define SAMPLER_TYPE sampler3D #define SAMPLER_TYPE sampler3D
#define TEXPARAMS_TYPE TextureParameters3D #define TEXPARAMS_TYPE TextureParameters3D
#define TEXTURE_LOOKUP_FUNC getElement3DNormalized #define TEXTURE_LOOKUP_FUNC texture
#else #else
#define SAMPLER_TYPE sampler2D #define SAMPLER_TYPE sampler2D
#define TEXPARAMS_TYPE TextureParameters2D #define TEXPARAMS_TYPE TextureParameters2D
#define TEXTURE_LOOKUP_FUNC getElement2DNormalized #define TEXTURE_LOOKUP_FUNC texture
#endif #endif
uniform SAMPLER_TYPE _usImage; uniform SAMPLER_TYPE _usImage;
...@@ -73,9 +73,9 @@ void main() { ...@@ -73,9 +73,9 @@ void main() {
vec2 texCoord = ex_TexCoord.xy; vec2 texCoord = ex_TexCoord.xy;
#endif #endif
vec4 texel = TEXTURE_LOOKUP_FUNC(_usImage, _usTextureParams, texCoord); vec4 texel = TEXTURE_LOOKUP_FUNC(_usImage, texCoord);
vec4 blurred = TEXTURE_LOOKUP_FUNC(_blurredImage, _blurredTextureParams, texCoord) * _blurredScale; vec4 blurred = TEXTURE_LOOKUP_FUNC(_blurredImage, texCoord) * _blurredScale;
float confidence = clamp(TEXTURE_LOOKUP_FUNC(_confidenceMap, _confidenceTextureParams, texCoord).r * _confidenceScaling, 0.0, 1.0); float confidence = clamp(TEXTURE_LOOKUP_FUNC(_confidenceMap, texCoord).r * _confidenceScaling, 0.0, 1.0);
float uncertainty = lookupTF(_confidenceTF, _confidenceTFParams, confidence).a; float uncertainty = lookupTF(_confidenceTF, _confidenceTFParams, confidence).a;
if (confidence <= 0.0) { if (confidence <= 0.0) {
......
...@@ -47,12 +47,12 @@ void main() { ...@@ -47,12 +47,12 @@ void main() {
vec3 worldCoords = ex_Position.xyz / ex_Position.z; vec3 worldCoords = ex_Position.xyz / ex_Position.z;
vec3 texCoords = worldToTexture(_textureParameters, worldCoords); vec3 texCoords = worldToTexture(_textureParameters, worldCoords);
out_Color = getElement3DNormalized(_strainTexture, _textureParameters, texCoords); out_Color = texture(_strainTexture, texCoords);
while (length(out_Color) == 0.0) { while (length(out_Color) == 0.0) {
worldCoords -= normalize(ex_TexCoord) * 0.1; worldCoords -= normalize(ex_TexCoord) * 0.1;
texCoords = worldToTexture(_textureParameters, worldCoords); texCoords = worldToTexture(_textureParameters, worldCoords);
out_Color = getElement3DNormalized(_strainTexture, _textureParameters, texCoords); out_Color = texture(_strainTexture, texCoords);
} }
#ifdef ENABLE_SHADING #ifdef ENABLE_SHADING
......
...@@ -94,7 +94,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -94,7 +94,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
vec3 samplePosition = entryPoint.rgb + t * direction; vec3 samplePosition = entryPoint.rgb + t * direction;
// lookup intensity and TF // lookup intensity and TF
vec4 strain = getElement3DNormalized(_volume, _volumeTextureParams, samplePosition); vec4 strain = texture(_volume, samplePosition);
vec4 color = (_volumeTextureParams._numChannels == 4) ? strain : vec4(strain.xyz, 0.0); vec4 color = (_volumeTextureParams._numChannels == 4) ? strain : vec4(strain.xyz, 0.0);
color.a = clamp(length(strain.xyz)/1.0, 0.0, 1.0); color.a = clamp(length(strain.xyz)/1.0, 0.0, 1.0);
...@@ -114,7 +114,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -114,7 +114,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
vec3 newSamplePosition = entryPoint.rgb + newT * direction; vec3 newSamplePosition = entryPoint.rgb + newT * direction;
// lookup refined intensity + TF // lookup refined intensity + TF
vec4 newStrain = getElement3DNormalized(_volume, _volumeTextureParams, newSamplePosition); vec4 newStrain = texture(_volume, newSamplePosition);
vec4 newColor = (_volumeTextureParams._numChannels == 4) ? newStrain : vec4(newStrain.xyz, 0.0); vec4 newColor = (_volumeTextureParams._numChannels == 4) ? newStrain : vec4(newStrain.xyz, 0.0);
newColor.a = clamp(length(newColor.xyz)/1.0, 0.0, 1.0); newColor.a = clamp(length(newColor.xyz)/1.0, 0.0, 1.0);
...@@ -168,8 +168,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -168,8 +168,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
// calculate depth value from ray parameter // calculate depth value from ray parameter
gl_FragDepth = 1.0; gl_FragDepth = 1.0;
if (firstHitT >= 0.0) { if (firstHitT >= 0.0) {
float depthEntry = getElement2DNormalized(_entryPointsDepth, _entryParams, texCoords).z; float depthEntry = texture(_entryPointsDepth, texCoords).z;
float depthExit = getElement2DNormalized(_exitPointsDepth, _exitParams, texCoords).z; float depthExit = texture(_exitPointsDepth, texCoords).z;
gl_FragDepth = calculateDepthValue(firstHitT/tend, depthEntry, depthExit); gl_FragDepth = calculateDepthValue(firstHitT/tend, depthEntry, depthExit);
} }
return result; return result;
...@@ -180,8 +180,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -180,8 +180,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
***/ ***/
void main() { void main() {
vec2 p = gl_FragCoord.xy * _viewportSizeRCP; vec2 p = gl_FragCoord.xy * _viewportSizeRCP;
vec3 frontPos = getElement2DNormalized(_entryPoints, _entryParams, p).rgb; vec3 frontPos = texture(_entryPoints, p).rgb;
vec3 backPos = getElement2DNormalized(_exitPoints, _exitParams, p).rgb; vec3 backPos = texture(_exitPoints, p).rgb;
//determine whether the ray has to be casted //determine whether the ray has to be casted
if (frontPos == backPos) { if (frontPos == backPos) {
......
...@@ -52,13 +52,13 @@ uniform TextureParameters2D _drrClippedTexParams; ...@@ -52,13 +52,13 @@ uniform TextureParameters2D _drrClippedTexParams;
***/ ***/
void main() { void main() {
// fetch input textures // fetch input textures
vec4 xRayColor = getElement2DNormalized(_xRayColor, _xRayTexParams, ex_TexCoord.xy); vec4 xRayColor = texture(_xRayColor, ex_TexCoord.xy);
float xRayDepth = getElement2DNormalized(_xRayDepth, _xRayTexParams, ex_TexCoord.xy).r; float xRayDepth = texture(_xRayDepth, ex_TexCoord.xy).r;
vec4 sliceColor = getElement2DNormalized(_sliceColor, _sliceTexParams, ex_TexCoord.xy); vec4 sliceColor = texture(_sliceColor, ex_TexCoord.xy);
float sliceDepth = getElement2DNormalized(_sliceDepth, _sliceTexParams, ex_TexCoord.xy).r; float sliceDepth = texture(_sliceDepth, ex_TexCoord.xy).r;
float drrFull = getElement2DNormalized(_drrFullColor, _drrFullTexParams, ex_TexCoord.xy).r; float drrFull = texture(_drrFullColor, ex_TexCoord.xy).r;
float drrClipped = getElement2DNormalized(_drrClippedColor, _drrClippedTexParams, ex_TexCoord.xy).r; float drrClipped = texture(_drrClippedColor, ex_TexCoord.xy).r;
float weightingFactor = 0.0; float weightingFactor = 0.0;
if (drrClipped > 0) if (drrClipped > 0)
......
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
out_Color = vec4(1.0); out_Color = vec4(1.0);
} }
else { else {
float intensity = getElement2DNormalized(_texture, _textureParameters, ex_TexCoord.xy).a; float intensity = texture(_texture, ex_TexCoord.xy).a;
out_Color = lookupTF(_transferFunction, _transferFunctionParams, intensity); out_Color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
// don't write fragment if fully transparent (in particular don't write to depth buffer!) // don't write fragment if fully transparent (in particular don't write to depth buffer!)
......
...@@ -89,7 +89,7 @@ float applyDepthGaussFilter(in vec2 texCoord) { ...@@ -89,7 +89,7 @@ float applyDepthGaussFilter(in vec2 texCoord) {
for (int i = -_halfKernelDimension; i <= _halfKernelDimension; ++i) { for (int i = -_halfKernelDimension; i <= _halfKernelDimension; ++i) {
// TODO: why the fuck does abs(i) not work here?!? // TODO: why the fuck does abs(i) not work here?!?
int absi = (i < 0) ? -i : i; int absi = (i < 0) ? -i : i;
float curDepth = getElement2DNormalized(_depthPass2Texture, _pass2TexParams, texCoord + (_direction * _viewportSizeRCP * i)).r; float curDepth = texture(_depthPass2Texture, texCoord + (_direction * _viewportSizeRCP * i)).r;
result += curDepth * _gaussKernel[absi]; result += curDepth * _gaussKernel[absi];
} }
result /= _norm; result /= _norm;
...@@ -110,11 +110,11 @@ void main() { ...@@ -110,11 +110,11 @@ void main() {
gl_FragDepth = filteredDepth; gl_FragDepth = filteredDepth;
} else { } else {
// we are in the second vertical pass and have to modulate the color // we are in the second vertical pass and have to modulate the color
float curDepth = getElement2DNormalized(_depthTexture, _texParams, texCoord).r; float curDepth = texture(_depthTexture, texCoord).r;
float deltaD = normalizeDepth(filteredDepth) - normalizeDepth(curDepth); float deltaD = normalizeDepth(filteredDepth) - normalizeDepth(curDepth);
// apply depth darkening // apply depth darkening
vec4 curColor = getElement2DNormalized(_colorTexture, _texParams, texCoord); vec4 curColor = texture(_colorTexture, texCoord);
if (curColor.a == 0) if (curColor.a == 0)
discard; discard;
......
...@@ -79,7 +79,7 @@ vec4 raycastDRR(in vec3 entryPoint, in vec3 exitPoint) { ...@@ -79,7 +79,7 @@ vec4 raycastDRR(in vec3 entryPoint, in vec3 exitPoint) {
vec3 samplePosition = entryPoint.rgb + t * direction; vec3 samplePosition = entryPoint.rgb + t * direction;
// lookup intensity and TF // lookup intensity and TF
float intensity = getElement3DNormalized(_volume, _volumeTextureParams, samplePosition).r; float intensity = texture(_volume, samplePosition).r;
vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity); vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
#ifdef DEPTH_MAPPING #ifdef DEPTH_MAPPING
...@@ -130,8 +130,8 @@ vec4 raycastDRR(in vec3 entryPoint, in vec3 exitPoint) { ...@@ -130,8 +130,8 @@ vec4 raycastDRR(in vec3 entryPoint, in vec3 exitPoint) {
***/ ***/
void main() { void main() {
vec2 p = gl_FragCoord.xy * _viewportSizeRCP; vec2 p = gl_FragCoord.xy * _viewportSizeRCP;
vec3 frontPos = getElement2DNormalized(_entryPoints, _entryParams, p).rgb; vec3 frontPos = texture(_entryPoints, p).rgb;
vec3 backPos = getElement2DNormalized(_exitPoints, _exitParams, p).rgb; vec3 backPos = texture(_exitPoints, p).rgb;
//determine whether the ray has to be casted //determine whether the ray has to be casted
if (frontPos == backPos) { if (frontPos == backPos) {
......
...@@ -57,7 +57,7 @@ void main() { ...@@ -57,7 +57,7 @@ void main() {
float fragDepth = gl_FragCoord.z; float fragDepth = gl_FragCoord.z;
if (_integrateGeometry) { if (_integrateGeometry) {
float geometryDepth = getElement2DNormalized(_geometryDepthTexture, _geometryDepthTexParams, fragCoordNormalized).r; float geometryDepth = texture(_geometryDepthTexture, fragCoordNormalized).r;
if (_isEntrypoint) { if (_isEntrypoint) {
// integrating geometry into Entrypoints // integrating geometry into Entrypoints
...@@ -76,7 +76,7 @@ void main() { ...@@ -76,7 +76,7 @@ void main() {
} }
else { else {
// integrating geometry into Exitpoints // integrating geometry into Exitpoints
float entryDepth = getElement2DNormalized(_entryDepthTexture, _entryDepthTexParams, fragCoordNormalized).r; float entryDepth = texture(_entryDepthTexture, fragCoordNormalized).r;
float exitDepth = gl_FragCoord.z; float exitDepth = gl_FragCoord.z;
if (geometryDepth <= entryDepth) { if (geometryDepth <= entryDepth) {
......
...@@ -153,7 +153,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -153,7 +153,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
} }
// lookup intensity and TF // lookup intensity and TF
float intensity = getElement3DNormalized(_volume, _volumeTextureParams, samplePosition).r; float intensity = texture(_volume, samplePosition).r;
vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity); vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
#ifdef INTERSECTION_REFINEMENT #ifdef INTERSECTION_REFINEMENT
...@@ -172,7 +172,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -172,7 +172,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
vec3 newSamplePosition = entryPoint.rgb + newT * direction; vec3 newSamplePosition = entryPoint.rgb + newT * direction;
// lookup refined intensity + TF // lookup refined intensity + TF
float newIntensity = getElement3DNormalized(_volume, _volumeTextureParams, newSamplePosition).r; float newIntensity = texture(_volume, newSamplePosition).r;
vec4 newColor = lookupTF(_transferFunction, _transferFunctionParams, newIntensity); vec4 newColor = lookupTF(_transferFunction, _transferFunctionParams, newIntensity);
if (newColor.a <= 0.0) { if (newColor.a <= 0.0) {
...@@ -225,8 +225,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -225,8 +225,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
// calculate depth value from ray parameter // calculate depth value from ray parameter
gl_FragDepth = 1.0; gl_FragDepth = 1.0;
if (firstHitT >= 0.0) { if (firstHitT >= 0.0) {
float depthEntry = getElement2DNormalized(_entryPointsDepth, _entryParams, texCoords).z; float depthEntry = texture(_entryPointsDepth, texCoords).z;
float depthExit = getElement2DNormalized(_exitPointsDepth, _exitParams, texCoords).z; float depthExit = texture(_exitPointsDepth, texCoords).z;
gl_FragDepth = calculateDepthValue(firstHitT/tend, depthEntry, depthExit); gl_FragDepth = calculateDepthValue(firstHitT/tend, depthEntry, depthExit);
} }
...@@ -238,8 +238,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -238,8 +238,8 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
***/ ***/
void main() { void main() {
vec2 p = gl_FragCoord.xy * _viewportSizeRCP; vec2 p = gl_FragCoord.xy * _viewportSizeRCP;
vec3 frontPos = getElement2DNormalized(_entryPoints, _entryParams, p).rgb; vec3 frontPos = texture(_entryPoints, p).rgb;
vec3 backPos = getElement2DNormalized(_exitPoints, _exitParams, p).rgb; vec3 backPos = texture(_exitPoints, p).rgb;
//determine whether the ray has to be casted //determine whether the ray has to be casted
if (frontPos == backPos) { if (frontPos == backPos) {
......
...@@ -37,6 +37,6 @@ uniform sampler2D _depthTexture; ...@@ -37,6 +37,6 @@ uniform sampler2D _depthTexture;
uniform TextureParameters2D _texParams; uniform TextureParameters2D _texParams;
void main() { void main() {
out_Color = getElement2DNormalized(_colorTexture, _texParams, ex_TexCoord.xy); out_Color = texture(_colorTexture, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_depthTexture, _texParams, ex_TexCoord.xy).r; gl_FragDepth = texture(_depthTexture, ex_TexCoord.xy).r;
} }
...@@ -47,45 +47,45 @@ uniform float _alpha; ...@@ -47,45 +47,45 @@ uniform float _alpha;
void main() { void main() {
if (_compositingMethod == 0) { if (_compositingMethod == 0) {
// only first // only first
out_Color = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); out_Color = texture(_firstColor, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r; gl_FragDepth = texture(_firstDepth, ex_TexCoord.xy).r;
} }
else if (_compositingMethod == 1) { else if (_compositingMethod == 1) {
// only second // only second
out_Color = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); out_Color = texture(_secondColor, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r; gl_FragDepth = texture(_secondDepth, ex_TexCoord.xy).r;
} }
else if (_compositingMethod == 2) { else if (_compositingMethod == 2) {
// alpha blending // alpha blending
vec4 firstColor = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); vec4 firstColor = texture(_firstColor, ex_TexCoord.xy);
float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r; float firstDepth = texture(_firstDepth, ex_TexCoord.xy).r;
vec4 secondColor = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); vec4 secondColor = texture(_secondColor, ex_TexCoord.xy);
float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r; float secondDepth = texture(_secondDepth, ex_TexCoord.xy).r;
out_Color = mix(firstColor, secondColor, _alpha); out_Color = mix(firstColor, secondColor, _alpha);
gl_FragDepth = min(firstDepth, secondDepth); gl_FragDepth = min(firstDepth, secondDepth);
} }
else if (_compositingMethod == 3) { else if (_compositingMethod == 3) {
// difference // difference
vec4 firstColor = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); vec4 firstColor = texture(_firstColor, ex_TexCoord.xy);
float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r; float firstDepth = texture(_firstDepth, ex_TexCoord.xy).r;
vec4 secondColor = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); vec4 secondColor = texture(_secondColor, ex_TexCoord.xy);
float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r; float secondDepth = texture(_secondDepth, ex_TexCoord.xy).r;
out_Color = vec4(vec3(1.0) - abs(firstColor - secondColor).xyz, max(firstColor.w, secondColor.w)); out_Color = vec4(vec3(1.0) - abs(firstColor - secondColor).xyz, max(firstColor.w, secondColor.w));
gl_FragDepth = min(firstDepth, secondDepth); gl_FragDepth = min(firstDepth, secondDepth);
} }
else if (_compositingMethod == 4) { else if (_compositingMethod == 4) {
// depth test // depth test
float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r; float firstDepth = texture(_firstDepth, ex_TexCoord.xy).r;
float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r; float secondDepth = texture(_secondDepth, ex_TexCoord.xy).r;
if (firstDepth > secondDepth) { if (firstDepth > secondDepth) {
out_Color = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); out_Color = texture(_secondColor, ex_TexCoord.xy);
gl_FragDepth = secondDepth; gl_FragDepth = secondDepth;
} }
else { else {
out_Color = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); out_Color = texture(_firstColor, ex_TexCoord.xy);
gl_FragDepth = firstDepth; gl_FragDepth = firstDepth;
} }
} }
......
...@@ -93,7 +93,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -93,7 +93,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
vec3 samplePosition = entryPoint.rgb + t * direction; vec3 samplePosition = entryPoint.rgb + t * direction;
// lookup intensity and TF // lookup intensity and TF
float intensity = getElement3DNormalized(_volume, _volumeTextureParams, samplePosition).r; float intensity = texture(_volume, samplePosition).r;
vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity); vec4 color = lookupTF(_transferFunction, _transferFunctionParams, intensity);
#ifdef ENABLE_SHADOWING #ifdef ENABLE_SHADOWING
...@@ -109,7 +109,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) ...@@ -109,7 +109,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
// traverse ray from sample to light // traverse ray from sample to light
while (! finished) { while (! finished) {
// grab intensity and TF opacity // grab intensity and TF opacity
intensity = getElement3DNormalized(_volume, _volumeTextureParams, position).r; intensity = texture(_volume, position).r;
shadowFactor += lookupTF(_transferFunction, _transferFunctionParams, intensity).a; shadowFactor += lookupTF(_transferFunction, _transferFunctionParams, intensity).a;