WMImageSpaceLIC-ClipBlend-fragment.glsl 3.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

#version 120

27 28
#include "WGEUtils.glsl"

29 30 31 32 33 34 35 36 37 38
/**
 * The texture Unit for the advection texture
 */
uniform sampler2D u_texture0Sampler;

/**
 * The texture Unit for the edge, depht texture
 */
uniform sampler2D u_texture1Sampler;

39 40 41 42 43
/**
 * The texture Unit for the edge, depht texture
 */
uniform sampler2D u_texture2Sampler;

44 45 46 47 48 49 50 51 52 53
/**
 * Used to en-/disable lighting.
 */
uniform bool u_useLight;

/**
 * Used to en-/disable blending of edges.
 */
uniform bool u_useEdges;

54 55 56 57 58
/**
 * If true, the depth is blended in
 */
uniform bool u_useDepthCueing;

59 60 61 62 63
/**
 * Ratio between colormap and advected noise
 */
uniform float u_cmapRatio;

64 65 66 67 68
/**
 * How intensive should contrast enhancement be?
 */
uniform bool u_useHighContrast;

69 70 71 72 73 74
/**
 * Main. Clips and Blends the final image space rendering with the previously acquired 3D information
 */
void main()
{
    vec2 texCoord = gl_TexCoord[0].st;
75
    float edge  = texture2D( u_texture1Sampler, texCoord ).r * ( u_useEdges ? 1.0 : 0.0 );
76
    float light  = texture2D( u_texture1Sampler, texCoord ).a * ( u_useLight ? 1.0 : 0.0 );
77 78
    float depth  = texture2D( u_texture1Sampler, texCoord ).g;
    float advected  = texture2D( u_texture0Sampler, texCoord ).r;
79 80 81 82
    vec3 cmap = texture2D( u_texture2Sampler, texCoord ).rgb;

    float u_contrastingS = u_useHighContrast ? 64.0 : 2.5;
    float u_contrastingP = u_useHighContrast ? 8 : 2.5;
Sebastian Eichelbaum's avatar
[STYLE]  
Sebastian Eichelbaum committed
83
    vec3 plainColor = u_cmapRatio * cmap + ( 1.0 - u_cmapRatio ) * vec3( u_contrastingS * pow( advected, u_contrastingP ) );
84

85
    // MPI Paper Hack: {
Sebastian Eichelbaum's avatar
Sebastian Eichelbaum committed
86 87 88 89
    // plainColor = u_cmapRatio * cmap;
    // plainColor += 1.5*( 1.0 - u_cmapRatio ) * vec3( u_contrastingS * pow( advected, u_contrastingP ), 0.0, 0.0 );
    // if ( isZero( cmap.r, 0.1 ) )
    //     discard;
90 91
    // }

Sebastian Eichelbaum's avatar
[STYLE]  
Sebastian Eichelbaum committed
92
    gl_FragColor = vec4(
93 94 95 96 97
        ( vec3( edge ) + plainColor ) // plain color mapped advection texture with edges
         * clamp( 1.0 - ( float( u_useDepthCueing ) * depth * depth ), 0.4, 1.0 ) // scaled by depth if enabled
         * ( u_useLight ? light * 1.3: 1.0 ),
        1.0
    );
98 99 100
    gl_FragDepth = depth;
}