1//========================================================================= 2// 3// Program: Visualization Toolkit 4// Module: vtkLineIntegralConvolution2D_AAV.glsl 5// 6// Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7// All rights reserved. 8// See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9// 10// This software is distributed WITHOUT ANY WARRANTY; without even 11// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12// PURPOSE. See the above copyright notice for more information. 13// 14//========================================================================= 15 16// Anti-alias stage in vtkLineIntegralConvolution2D 17// vertical pass of a Gaussian convolution 18 19#version 120 // for arrays 20 21uniform sampler2D texLIC; // input texture 22uniform float uDy; // fragment size 23 24// neighbor offsets 25vec2 fragDy[3] = vec2[3](vec2(0.0,-uDy), vec2(0.0,0.0), vec2(0.0,uDy)); 26 27// factored 3x3 Gaussian kernel 28// K^T*K = G 29float K[3] = float[3](0.141421356, 0.707106781, 0.141421356); 30 31// determine if the fragment was masked 32bool Masked(float val){ return val != 0.0; } 33 34void main(void) 35{ 36 vec2 lictc = gl_TexCoord[0].st; 37 vec4 lic[3]; 38 bool dontUse = false; 39 float conv = 0.0; 40 for (int i=0; i<3; ++i) 41 { 42 vec2 tc = lictc + fragDy[i]; 43 lic[i] = texture2D(texLIC, tc); 44 dontUse = dontUse || Masked(lic[i].g); 45 conv = conv + K[i] * lic[i].r; 46 } 47 // output is (conv, mask, skip, 1) 48 if (dontUse) 49 { 50 gl_FragData[0] = vec4(lic[1].rg, 1.0, 1.0); 51 } 52 else 53 { 54 gl_FragData[0] = vec4(conv, lic[1].gb, 1.0); 55 } 56} 57