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 3.49 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-2013, 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 10
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
// 
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
const vec4 checkerboardColor1 = vec4(0.90, 0.90, 0.90, 1.0);
50 51
const vec4 checkerboardColor2 = vec4(0.50, 0.50, 0.50, 1.0);

52
void main() {
53 54 55 56
    if (_is3d) {
        if (_sliceNumber < 0) {
            // perform MIP
            out_Color = vec4(0.0);
57
            for (float slice = 0.0; slice < 1.0; slice += _3dTextureParams._sizeRCP.z) {
58
                out_Color = max(out_Color, lookupTF(_transferFunction, _transferFunctionParams, texture(_texture3d, vec3(ex_TexCoord.xy, slice)).r));
59 60 61 62
            }
        }
        else {
            // render the corresponding slice
63
            vec3 coord = vec3(ex_TexCoord.xy, (_sliceNumber + 0.5) / (_3dTextureParams._size.z));
64
            out_Color = lookupTF(_transferFunction, _transferFunctionParams, texture(_texture3d, coord).r);
65 66 67
        }
    }
    else {
68
        vec4 texel = texture(_texture2d, ex_TexCoord.xy);
69
        if (_2dTextureParams._numChannels == 1) {
70
            out_Color = lookupTF(_transferFunction, _transferFunctionParams, texel.r);
71
        }
72
        else if (_2dTextureParams._numChannels == 3) {
73 74
            out_Color = vec4(abs(texel.rgb), 1.0);
        }
75 76
        else if (_2dTextureParams._numChannels == 4) {
            out_Color = (abs(texel) - vec4(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x);
77 78 79 80
        }
        else {
            out_Color = vec4(0.1, 0.6, 1.0, 0.75);
        }
81
    }
82 83 84 85 86 87

    // 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);
88
}