File: vtkLineIntegralConvolution2D_LIC0.glsl

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,972 kB
  • sloc: cpp: 1,442,790; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 68; objc: 17
file content (96 lines) | stat: -rw-r--r-- 2,621 bytes parent folder | download | duplicates (3)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//=========================================================================
//
//  Program:   Visualization Toolkit
//  Module:    vtkLineIntegralConvolution2D_LIC0.glsl
//
//  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
//  All rights reserved.
//  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
//
//     This software is distributed WITHOUT ANY WARRANTY; without even
//     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//     PURPOSE.  See the above copyright notice for more information.
//
//=========================================================================

/**
This shader initializes the convolution for the LIC computation.
*/

// The following line handles system declarations such as
// default precisions, or defining precisions to null
//VTK::System::Dec

// the output of this shader
//VTK::Output::Dec

uniform sampler2D texMaskVectors;
uniform sampler2D texNoise;
uniform sampler2D texLIC;

uniform int   uStepNo;         // in step 0 initialize lic and seeds, else just seeds
uniform int   uPassNo;         // in pass 1 hpf of pass 0 is convolved.
uniform float uMaskThreshold;  // if |V| < uMaskThreshold render transparent
uniform vec2  uNoiseBoundsPt1; // tc of upper right pt of noise texture

varying vec2 tcoordVC;

// convert from vector coordinate space to noise coordinate space.
// the noise texture is tiled across the *whole* domain
vec2 VectorTCToNoiseTC(vec2 vectc)
{
  return vectc/uNoiseBoundsPt1;
}

// get the texture coordidnate to lookup noise value. this
// depends on the pass number.
vec2 getNoiseTC(vec2 vectc)
{
  // in pass 1 : convert from vector tc to noise tc
  // in pass 2 : use vector tc
  if (uPassNo == 0)
    {
    return VectorTCToNoiseTC(vectc);
    }
  else
    {
    return vectc;
    }
}

// look up noise value at the given location. The location
// is supplied in vector texture coordinates, hence the
// need to convert to noise texture coordinates.
float getNoise(vec2 vectc)
{
  return texture2D(texNoise, getNoiseTC(vectc)).r;
}

void main(void)
{
  vec2 vectc = tcoordVC.st;

  // lic => (convolution, mask, 0, step count)
  if (uStepNo == 0)
    {
    float maskCriteria = length(texture2D(texMaskVectors, vectc).xyz);
    float maskFlag;
    if (maskCriteria <= uMaskThreshold)
      {
      maskFlag = 1.0;
      }
    else
      {
      maskFlag = 0.0;
      }
    float noise = getNoise(vectc);
    gl_FragData[0] = vec4(noise, maskFlag, 0.0, 1.0);
    }
  else
    {
    gl_FragData[0] = texture2D(texLIC, vectc);
    }

  // initial seed
  gl_FragData[1] = vec4(vectc, 0.0, 1.0);
}