In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

datacontainerinspector.frag 4.9 KB
Newer Older
1 2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8 9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13 14 15 16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18 19 20 21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22 23 24 25 26 27 28
// 
// ================================================================================================

in vec3 ex_TexCoord;
out vec4 out_Color;

#include "tools/texture2d.frag"
29
#include "tools/texture3d.frag"
30
#include "tools/transferfunction.frag"
31

32 33 34 35 36 37 38 39 40 41 42 43
// 2D texture
uniform sampler2D _texture2d;
uniform TextureParameters2D _2dTextureParams;

// 3D texture
uniform sampler3D _texture3d;
uniform TextureParameters3D _3dTextureParams;

// Transfer Function
uniform sampler1D _transferFunction;
uniform TFParameters1D _transferFunctionParams;

44 45
uniform bool _is3d;
uniform int _sliceNumber;
46
uniform vec4 _color;
47
uniform bool _isDepthTexture;
48

49 50 51 52 53
uniform bool _renderRChannel;
uniform bool _renderGChannel;
uniform bool _renderBChannel;
uniform bool _renderAChannel;

54
const vec4 checkerboardColor1 = vec4(0.90, 0.90, 0.90, 1.0);
55 56
const vec4 checkerboardColor2 = vec4(0.50, 0.50, 0.50, 1.0);

57
void main() {
58 59 60 61
    if (_is3d) {
        if (_sliceNumber < 0) {
            // perform MIP
            out_Color = vec4(0.0);
62
            for (float slice = _3dTextureParams._sizeRCP.z/2.0; slice < 1.0; slice += _3dTextureParams._sizeRCP.z) {
63
                out_Color = max(out_Color, lookupTF(_transferFunction, _transferFunctionParams, texture(_texture3d, vec3(ex_TexCoord.xy, slice)).r));
64 65 66 67
            }
        }
        else {
            // render the corresponding slice
68
            vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber * _3dTextureParams._sizeRCP.z) + (_3dTextureParams._sizeRCP.z / 2.0));
69 70 71 72 73 74 75 76 77
            vec4 texel = texture(_texture3d, coord);

            if (_3dTextureParams._numChannels == 1) {
                out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.r);
            }
            else if (_3dTextureParams._numChannels == 3) {
                out_Color = vec4((abs(texel.rgb) - vec3(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x), 1.0);
            }
            else if (_3dTextureParams._numChannels == 4) {
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
78
                out_Color = vec4((abs(texel.rgb) - vec3(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x), texel.a);
79 80 81 82 83
            }
            else {
                out_Color = vec4(0.1, 0.6, 1.0, 0.75);
            }
            //out_Color = lookupTF(_transferFunction, _transferFunctionParams, texture(_texture3d, coord).r);
84 85 86
        }
    }
    else {
87
        vec4 texel = texture(_texture2d, ex_TexCoord.xy);
88
        if (_2dTextureParams._numChannels == 1) {
89
            out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.r);
90
        }
91
        else if (_2dTextureParams._numChannels == 3) {
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
92
            out_Color = vec4((abs(texel.rgb) - vec3(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x), 1.0);
93
        }
94
        else if (_2dTextureParams._numChannels == 4) {
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
95
            out_Color = vec4((abs(texel.rgb) - vec3(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x), texel.a);
96 97 98 99
        }
        else {
            out_Color = vec4(0.1, 0.6, 1.0, 0.75);
        }
100
    }
101

102 103 104 105 106 107 108 109 110
    if (! _renderRChannel)
        out_Color.r = 0.0;
    if (! _renderGChannel)
        out_Color.g = 0.0;
    if (! _renderBChannel)
        out_Color.b = 0.0;
    if (! _renderAChannel)
        out_Color.a = 1.0;

111 112 113 114 115
    // mix with fancy checkerboard pattern:
    if ((mod(ex_TexCoord.x * 10.0, 2.0) > 1.0) ^^ (mod(ex_TexCoord.y * 10.0, 2.0) > 1.0))
        out_Color = mix(checkerboardColor1, out_Color, out_Color.a);
    else
        out_Color = mix(checkerboardColor2, out_Color, out_Color.a);
116
}