/usr/include/paraview/Quadrics_fs.cxx is in paraview-dev 5.0.1+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | /* DO NOT EDIT.
* Generated by ../../../bin/vtkEncodeString
*
* Define the Quadrics_fs string.
*
* Generated from file: /build/paraview-arsa8T/paraview-5.0.1+dfsg1/Plugins/PointSprite/Rendering/Resources/Shaders/Quadrics_fs.glsl
*/
const char *Quadrics_fs =
"/*=========================================================================\n"
"\n"
" Program: Visualization Toolkit\n"
" Module: Quadrics_fs.glsl\n"
"\n"
" Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\n"
" All rights reserved.\n"
" See Copyright.txt or http://www.kitware.com/Copyright.htm for details.\n"
"\n"
" This software is distributed WITHOUT ANY WARRANTY; without even\n"
" the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n"
" PURPOSE. See the above copyright notice for more information.\n"
"\n"
" =========================================================================*/\n"
"\n"
"// .NAME Quadrics_fs.glsl\n"
"// .SECTION Thanks\n"
"// <verbatim>\n"
"//\n"
"// This file is part of the PointSprites plugin developed and contributed by\n"
"//\n"
"// Copyright (c) CSCS - Swiss National Supercomputing Centre\n"
"// EDF - Electricite de France\n"
"//\n"
"// John Biddiscombe, Ugo Varetto (CSCS)\n"
"// Stephane Ploix (EDF)\n"
"//\n"
"// </verbatim>\n"
"\n"
"//\n"
"// IN:\n"
"// - vertex position\n"
"// - point size\n"
"// - ray origin\n"
"// - perspective flag\n"
"// - quadric equation coefficients\n"
"// - color\n"
"// - viewport (width and height only)\n"
"// - min point size (pointThreshold)\n"
"//\n"
"// OUT:\n"
"// - fragment color computed from point intersected by ray shot from\n"
"// viewpoint through point computed from current fragment coordinate\n"
"// - fragment depth computed by projecting the intersection point into screen\n"
"// coordinates\n"
"\n"
"\n"
"// OPTIMAL\n"
"#define ELLIPSOID\n"
"//#define CYLINDER\n"
"//#define CONE\n"
"//#define HYPERBOLOID1\n"
"//#define HYPERBOLOID2\n"
"//#define PARABOLOID\n"
"\n"
"// SUB OPTIMAL\n"
"//#define HYPER_PARABOLOID\n"
"\n"
"uniform vec2 viewport; // only width and height passed, no origin\n"
"uniform float pointSizeThreshold; // minimum point size\n"
"\n"
"varying vec4 color;\n"
"varying float a;\n"
"varying float b;\n"
"varying float c;\n"
"varying float d;\n"
"varying float e;\n"
"varying float f;\n"
"varying float g;\n"
"varying float h;\n"
"varying float i;\n"
"varying float j;\n"
"varying float pointSize;\n"
"varying float perspective;\n"
"\n"
"vec3 raydir; // ray direction in screen space\n"
"vec3 rayorigin; // ray origin in screen space\n"
"\n"
"#ifndef ELLIPSOID\n"
"varying mat4 Ti;\n"
"#endif\n"
"\n"
"const float FLAT_SHADE_POINT_SIZE = 1.0; //if point size < 1 use flat shading\n"
"\n"
"const float FEPS = 0.0001;\n"
"\n"
"const float BOUND = 1.0 + FEPS;\n"
"\n"
"const vec3 MIN_BOUND = vec3(-BOUND);\n"
"\n"
"const vec3 MAX_BOUND = vec3(BOUND);\n"
"\n"
"//------------------------------------------------------------------------------\n"
"// BOUNDS CHECK\n"
"// in general it makes sense to check only along the z direction for:\n"
"// - paraboloids\n"
"// - hyperboloids of one sheet\n"
"// - cylinders\n"
"// - cones\n"
"// and no checking at all is required for ellipsoids\n"
"#ifndef ELLIPSOID\n"
"bool InBounds( vec3 P )\n"
" {\n"
" vec4 v = Ti * gl_ModelViewMatrixInverse * vec4( P, 1. );\n"
"#if defined( CYLINDER ) || defined( CONE ) || defined( HYPERBOLOID1 ) || defined( PARABOLOID )\n"
" return v.z >= -BOUND && v.z <= BOUND;\n"
"#else\n"
" return all( greaterThanEqual( v.xyz, MIN_BOUND ) ) &&\n"
" all( lessThanEqual( v.xyz, MAX_BOUND ) );\n"
"#endif\n"
" }\n"
"#endif\n"
"//------------------------------------------------------------------------------\n"
"// INTERSECTION\n"
"struct I\n"
"{\n"
" vec3 P;\n"
" vec3 N;\n"
" float t;\n"
"};\n"
"\n"
"// compute unit normal from gradient\n"
"vec3 ComputeNormal(vec3 P)\n"
"{\n"
" return normalize(vec3(dot(vec4(a, d, e, 1.), vec4(P, g)), // should multiply by 2 for actual gradient\n"
" dot(vec4(d, b, f, 1.), vec4(P, h)), // should multiply by 2 for actual gradient\n"
" dot(vec4(e, f, c, 1.), vec4(P, i)) // should multiply by 2 for actual gradient\n"
" ));\n"
"}\n"
"\n"
"// compute ray quadric intersection; if no intersection occurs I.t is < 0\n"
"// main axis length and orientation are used to clip the quadric; not\n"
"// required for closed quadrics (ellipsoids)\n"
"// | a d e g |\n"
"// | d b f h |\n"
"// | e f c i |\n"
"// | g h i j |\n"
"// ax^2 + by^2 + cz^2 + 2dxy +2exz + 2fyz + 2gx + 2hy + 2iz + j = 0\n"
"/// @todo pass vec3(a, b, c), vec3( d, e, f ) and vec3( g, h, i ) instead of single coefficients\n"
"I ComputeRayQuadricIntersection()\n"
"{\n"
" I ip;\n"
" ip.t = -1.0;\n"
" vec3 P = rayorigin;\n"
" vec3 D = raydir;\n"
" float A = 0.0;\n"
" float B = 0.0;\n"
" float C = 0.0;\n"
" if (bool(perspective))\n"
" {\n"
" A = dot(vec3(a, b, c), D * D) + 2. * dot(vec3(d, e, f), D.xxy * D.yzz);\n"
" B = 2. * dot(vec3(g, h, i), D);\n"
" C = j;\n"
" }\n"
" else\n"
" {\n"
" A = c;\n"
" //B = -2. * dot( vec4( c, e, f, 1. ), vec4( P.zxy, 1. ) );\n"
" B = -2. * dot(vec4(d, e, f, i), vec4(P.zxy, 1.));\n"
" C = dot(vec3(a, b, c), P * P) + 2. * (dot(vec3(d, e, f), P.xxy * P.yzz)\n"
" + dot(vec3(g, h, i), P)) + j;\n"
" }\n"
" float delta = B * B - 4. * A * C;\n"
" if (delta < 0.0)\n"
" return ip;\n"
" float d = sqrt(delta);\n"
" A = 1. / A;\n"
" A *= 0.5;\n"
" float t2 = A * (-B + d);\n"
" float t1 = A * (-B - d);\n"
"#ifdef ELLIPSOID\n"
" ip.P = rayorigin + D * min(t1, t2);\n"
" ip.N = ComputeNormal(ip.P);\n"
" ip.t = 0.;\n"
"#else\n"
" vec3 P1 = rayorigin + D * min( t1, t2 );\n"
" vec3 P2 = rayorigin + D * max( t1, t2 );\n"
" if( InBounds( P1 ) )\n"
" {\n"
" ip.P = P1;\n"
" ip.N = ComputeNormal( P1 );\n"
" ip.t = 0.;\n"
" }\n"
" else if( InBounds( P2 ) )\n"
" {\n"
" ip.P = P2;\n"
" ip.N = ComputeNormal( P2 );\n"
" ip.t = 0.;\n"
" }\n"
"#endif\n"
" return ip;\n"
"}\n"
"\n"
"//------------------------------------------------------------------------------\n"
"// LIGHTING, standard phong lighting model\n"
"vec3 lightDir = normalize(vec3(0.1, 0.1, 1.));\n"
"float kd = 1.0;\n"
"float ka = 0.01;\n"
"float ks = .5;\n"
"float sh = 90.0;\n"
"vec4 refcolor = vec4(1., 1., 1., 1.);\n"
"vec4 ComputeColor(vec4 color, vec3 n, vec3 P)\n"
"{\n"
" if (pointSize < FLAT_SHADE_POINT_SIZE)\n"
" return color;\n"
"\n"
" vec3 col = (0, 0, 0);\n"
" vec3 N;\n"
" float d;\n"
" vec3 viewdir;\n"
" float vl;\n"
" float s;\n"
"\n"
" for (int li = 0; li < 4; li++)\n"
" {\n"
" lightDir = normalize(gl_LightSource[li].position);\n"
" N = faceforward(-n, lightDir, n);\n"
" d = dot(N, lightDir);\n"
" viewdir = normalize(-P);\n"
" vl = max(0., dot(reflect(-lightDir, N), viewdir));\n"
" s = pow(vl, gl_FrontMaterial.shininess);\n"
" col += gl_FrontMaterial.specular * s * gl_LightSource[li].specular.rgb + kd\n"
" * d * color.rgb * gl_LightSource[li].diffuse.rgb + ka * color.rgb\n"
" * gl_LightSource[li].ambient.rgb;\n"
" }\n"
"\n"
" return vec4(col, color.a);\n"
"\n"
"}\n"
"\n"
"//------------------------------------------------------------------------------\n"
"// MAIN\n"
"void propFuncFS(void)\n"
"{\n"
" if (pointSize < pointSizeThreshold || color.a <= 0.0)\n"
" discard;\n"
" vec3 fc = gl_FragCoord.xyz;\n"
" fc.xy /= viewport;\n"
" fc *= 2.0;\n"
" fc -= 1.0;\n"
" vec4 p = gl_ProjectionMatrixInverse * vec4(fc, 1.);\n"
" if (bool(perspective))\n"
" {\n"
" // in perspective mode, rayorigin is always at (0, 0, 0)\n"
" rayorigin = vec3(0., 0., 0.);\n"
" raydir = vec3(p) / p.w;\n"
" }\n"
" else\n"
" {\n"
" // in orthographic mode, raydir is always ( 0., 0., -1. );\n"
" raydir = vec3(0., 0., -1.);\n"
" rayorigin = vec3(p.x / p.w, p.y / p.w, 0.);\n"
" }\n"
" // compute intersection\n"
" I i = ComputeRayQuadricIntersection();\n"
" if (i.t < 0.0)\n"
" discard;\n"
" // compute color\n"
" gl_FragColor = ComputeColor(color, i.N, i.P);\n"
" // update depth by projecting point and updating depth coordinate\n"
" // the transposed version of the projection matrix is used to\n"
" // perform vector, matrix row product in one line:\n"
" // M[2][*] x V = Vt x Mt[*][2] where:\n"
" // % V is a column vector\n"
" // % Vt is a row vector\n"
" // % M is a square matrix\n"
" // % Mt is the transpose of M\n"
" float z = dot(vec4(i.P, 1.), gl_ProjectionMatrixTranspose[2]);\n"
" float w = dot(vec4(i.P, 1.), gl_ProjectionMatrixTranspose[3]);\n"
" gl_FragDepth = 0.5 * (z / w + 1.0);\n"
"}\n"
"\n";
|