Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From b695c3a3fa3f4cd48c13aa26542110de27075518 Mon Sep 17 00:00:00 2001 |
| 2 | From: Drew Moseley <drew_moseley@mentor.com> |
| 3 | Date: Mon, 12 May 2014 15:22:32 -0400 |
| 4 | Subject: [PATCH 1/9] mesa-demos: Add missing data files. |
| 5 | |
| 6 | Add some data files that are present in the git repository: |
| 7 | http://cgit.freedesktop.org/mesa/demos/tree/?id=mesa-demos-8.1.0 |
| 8 | but not in the release tarball |
| 9 | ftp://ftp.freedesktop.org/pub/mesa/demos/8.1.0/mesa-demos-8.1.0.tar.bz2 |
| 10 | |
| 11 | Upstream-Status: Backport |
| 12 | Signed-off-by: Drew Moseley <drew_moseley@mentor.com> |
| 13 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 14 | --- |
| 15 | src/fpglsl/depth-read.glsl | 4 + |
| 16 | src/fpglsl/infinite-loop.glsl | 7 + |
| 17 | src/glsl/CH11-bumpmaptex.frag | 47 +++++++ |
| 18 | src/glsl/blinking-teapot.frag | 31 +++++ |
| 19 | src/glsl/blinking-teapot.vert | 16 +++ |
| 20 | src/glsl/convolution.frag | 21 +++ |
| 21 | src/glsl/simplex-noise.glsl | 279 ++++++++++++++++++++++++++++++++++++++++ |
| 22 | src/glsl/skinning.vert | 24 ++++ |
| 23 | src/perf/glslstateschange1.frag | 19 +++ |
| 24 | src/perf/glslstateschange1.vert | 14 ++ |
| 25 | src/perf/glslstateschange2.frag | 17 +++ |
| 26 | src/perf/glslstateschange2.vert | 14 ++ |
| 27 | src/vpglsl/infinite-loop.glsl | 8 ++ |
| 28 | 13 files changed, 501 insertions(+) |
| 29 | create mode 100644 src/fpglsl/depth-read.glsl |
| 30 | create mode 100644 src/fpglsl/infinite-loop.glsl |
| 31 | create mode 100644 src/glsl/CH11-bumpmaptex.frag |
| 32 | create mode 100644 src/glsl/blinking-teapot.frag |
| 33 | create mode 100644 src/glsl/blinking-teapot.vert |
| 34 | create mode 100644 src/glsl/convolution.frag |
| 35 | create mode 100644 src/glsl/simplex-noise.glsl |
| 36 | create mode 100644 src/glsl/skinning.vert |
| 37 | create mode 100644 src/perf/glslstateschange1.frag |
| 38 | create mode 100644 src/perf/glslstateschange1.vert |
| 39 | create mode 100644 src/perf/glslstateschange2.frag |
| 40 | create mode 100644 src/perf/glslstateschange2.vert |
| 41 | create mode 100644 src/vpglsl/infinite-loop.glsl |
| 42 | |
| 43 | diff --git a/src/fpglsl/depth-read.glsl b/src/fpglsl/depth-read.glsl |
| 44 | new file mode 100644 |
| 45 | index 0000000..86d298e |
| 46 | --- /dev/null |
| 47 | +++ b/src/fpglsl/depth-read.glsl |
| 48 | @@ -0,0 +1,4 @@ |
| 49 | +void main() |
| 50 | +{ |
| 51 | + gl_FragColor = gl_FragCoord.zzzz; |
| 52 | +} |
| 53 | diff --git a/src/fpglsl/infinite-loop.glsl b/src/fpglsl/infinite-loop.glsl |
| 54 | new file mode 100644 |
| 55 | index 0000000..c6dc6ee |
| 56 | --- /dev/null |
| 57 | +++ b/src/fpglsl/infinite-loop.glsl |
| 58 | @@ -0,0 +1,7 @@ |
| 59 | +void main() { |
| 60 | + vec4 sum = vec4(0); |
| 61 | + for (int i = 1; i != 2; i += 2) { |
| 62 | + sum += vec4(0.1, 0.1, 0.1, 0.1); |
| 63 | + } |
| 64 | + gl_FragColor = sum; |
| 65 | +} |
| 66 | diff --git a/src/glsl/CH11-bumpmaptex.frag b/src/glsl/CH11-bumpmaptex.frag |
| 67 | new file mode 100644 |
| 68 | index 0000000..b5dabb4 |
| 69 | --- /dev/null |
| 70 | +++ b/src/glsl/CH11-bumpmaptex.frag |
| 71 | @@ -0,0 +1,47 @@ |
| 72 | +// |
| 73 | +// Fragment shader for procedural bumps |
| 74 | +// |
| 75 | +// Authors: John Kessenich, Randi Rost |
| 76 | +// |
| 77 | +// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. |
| 78 | +// |
| 79 | +// See 3Dlabs-License.txt for license information |
| 80 | +// |
| 81 | +// Texture mapping/modulation added by Brian Paul |
| 82 | +// |
| 83 | + |
| 84 | +varying vec3 LightDir; |
| 85 | +varying vec3 EyeDir; |
| 86 | + |
| 87 | +uniform float BumpDensity; // = 16.0 |
| 88 | +uniform float BumpSize; // = 0.15 |
| 89 | +uniform float SpecularFactor; // = 0.5 |
| 90 | + |
| 91 | +uniform sampler2D Tex; |
| 92 | + |
| 93 | +void main() |
| 94 | +{ |
| 95 | + vec3 ambient = vec3(0.25); |
| 96 | + vec3 litColor; |
| 97 | + vec2 c = BumpDensity * gl_TexCoord[0].st; |
| 98 | + vec2 p = fract(c) - vec2(0.5); |
| 99 | + |
| 100 | + float d, f; |
| 101 | + d = p.x * p.x + p.y * p.y; |
| 102 | + f = inversesqrt(d + 1.0); |
| 103 | + |
| 104 | + if (d >= BumpSize) |
| 105 | + { p = vec2(0.0); f = 1.0; } |
| 106 | + |
| 107 | + vec3 SurfaceColor = texture2D(Tex, gl_TexCoord[0].st).xyz; |
| 108 | + |
| 109 | + vec3 normDelta = vec3(p.x, p.y, 1.0) * f; |
| 110 | + litColor = SurfaceColor * (ambient + max(dot(normDelta, LightDir), 0.0)); |
| 111 | + vec3 reflectDir = reflect(LightDir, normDelta); |
| 112 | + |
| 113 | + float spec = max(dot(EyeDir, reflectDir), 0.0); |
| 114 | + spec *= SpecularFactor; |
| 115 | + litColor = min(litColor + spec, vec3(1.0)); |
| 116 | + |
| 117 | + gl_FragColor = vec4(litColor, 1.0); |
| 118 | +} |
| 119 | diff --git a/src/glsl/blinking-teapot.frag b/src/glsl/blinking-teapot.frag |
| 120 | new file mode 100644 |
| 121 | index 0000000..0db060b |
| 122 | --- /dev/null |
| 123 | +++ b/src/glsl/blinking-teapot.frag |
| 124 | @@ -0,0 +1,31 @@ |
| 125 | +#extension GL_ARB_uniform_buffer_object : enable |
| 126 | + |
| 127 | +layout(std140) uniform colors0 |
| 128 | +{ |
| 129 | + float DiffuseCool; |
| 130 | + float DiffuseWarm; |
| 131 | + vec3 SurfaceColor; |
| 132 | + vec3 WarmColor; |
| 133 | + vec3 CoolColor; |
| 134 | + vec4 some[8]; |
| 135 | +}; |
| 136 | + |
| 137 | +varying float NdotL; |
| 138 | +varying vec3 ReflectVec; |
| 139 | +varying vec3 ViewVec; |
| 140 | + |
| 141 | +void main (void) |
| 142 | +{ |
| 143 | + |
| 144 | + vec3 kcool = min(CoolColor + DiffuseCool * SurfaceColor, 1.0); |
| 145 | + vec3 kwarm = min(WarmColor + DiffuseWarm * SurfaceColor, 1.0); |
| 146 | + vec3 kfinal = mix(kcool, kwarm, NdotL); |
| 147 | + |
| 148 | + vec3 nreflect = normalize(ReflectVec); |
| 149 | + vec3 nview = normalize(ViewVec); |
| 150 | + |
| 151 | + float spec = max(dot(nreflect, nview), 0.0); |
| 152 | + spec = pow(spec, 32.0); |
| 153 | + |
| 154 | + gl_FragColor = vec4 (min(kfinal + spec, 1.0), 1.0); |
| 155 | +} |
| 156 | diff --git a/src/glsl/blinking-teapot.vert b/src/glsl/blinking-teapot.vert |
| 157 | new file mode 100644 |
| 158 | index 0000000..397d733 |
| 159 | --- /dev/null |
| 160 | +++ b/src/glsl/blinking-teapot.vert |
| 161 | @@ -0,0 +1,16 @@ |
| 162 | +vec3 LightPosition = vec3(0.0, 10.0, 4.0); |
| 163 | + |
| 164 | +varying float NdotL; |
| 165 | +varying vec3 ReflectVec; |
| 166 | +varying vec3 ViewVec; |
| 167 | + |
| 168 | +void main(void) |
| 169 | +{ |
| 170 | + vec3 ecPos = vec3 (gl_ModelViewMatrix * gl_Vertex); |
| 171 | + vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal); |
| 172 | + vec3 lightVec = normalize(LightPosition - ecPos); |
| 173 | + ReflectVec = normalize(reflect(-lightVec, tnorm)); |
| 174 | + ViewVec = normalize(-ecPos); |
| 175 | + NdotL = (dot(lightVec, tnorm) + 1.0) * 0.5; |
| 176 | + gl_Position = ftransform(); |
| 177 | +} |
| 178 | diff --git a/src/glsl/convolution.frag b/src/glsl/convolution.frag |
| 179 | new file mode 100644 |
| 180 | index 0000000..e49b8ac |
| 181 | --- /dev/null |
| 182 | +++ b/src/glsl/convolution.frag |
| 183 | @@ -0,0 +1,21 @@ |
| 184 | + |
| 185 | +const int KernelSize = 9; |
| 186 | + |
| 187 | +//texture offsets |
| 188 | +uniform vec2 Offset[KernelSize]; |
| 189 | +//convolution kernel |
| 190 | +uniform vec4 KernelValue[KernelSize]; |
| 191 | +uniform sampler2D srcTex; |
| 192 | +uniform vec4 ScaleFactor; |
| 193 | +uniform vec4 BaseColor; |
| 194 | + |
| 195 | +void main(void) |
| 196 | +{ |
| 197 | + int i; |
| 198 | + vec4 sum = vec4(0.0); |
| 199 | + for (i = 0; i < KernelSize; ++i) { |
| 200 | + vec4 tmp = texture2D(srcTex, gl_TexCoord[0].st + Offset[i]); |
| 201 | + sum += tmp * KernelValue[i]; |
| 202 | + } |
| 203 | + gl_FragColor = sum * ScaleFactor + BaseColor; |
| 204 | +} |
| 205 | diff --git a/src/glsl/simplex-noise.glsl b/src/glsl/simplex-noise.glsl |
| 206 | new file mode 100644 |
| 207 | index 0000000..b6833cb |
| 208 | --- /dev/null |
| 209 | +++ b/src/glsl/simplex-noise.glsl |
| 210 | @@ -0,0 +1,279 @@ |
| 211 | +// |
| 212 | +// Description : Array and textureless GLSL 2D/3D/4D simplex |
| 213 | +// noise functions. |
| 214 | +// Author : Ian McEwan, Ashima Arts. |
| 215 | +// Maintainer : ijm |
| 216 | +// Lastmod : 20110223 |
| 217 | +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. |
| 218 | +// Distributed under the Artistic License 2.0; See LICENCE file. |
| 219 | +// |
| 220 | + |
| 221 | +#define NORMALIZE_GRADIENTS |
| 222 | +#undef USE_CIRCLE |
| 223 | +#define COLLAPSE_SORTNET |
| 224 | + |
| 225 | +float permute(float x0,vec3 p) { |
| 226 | + float x1 = mod(x0 * p.y, p.x); |
| 227 | + return floor( mod( (x1 + p.z) *x0, p.x )); |
| 228 | + } |
| 229 | +vec2 permute(vec2 x0,vec3 p) { |
| 230 | + vec2 x1 = mod(x0 * p.y, p.x); |
| 231 | + return floor( mod( (x1 + p.z) *x0, p.x )); |
| 232 | + } |
| 233 | +vec3 permute(vec3 x0,vec3 p) { |
| 234 | + vec3 x1 = mod(x0 * p.y, p.x); |
| 235 | + return floor( mod( (x1 + p.z) *x0, p.x )); |
| 236 | + } |
| 237 | +vec4 permute(vec4 x0,vec3 p) { |
| 238 | + vec4 x1 = mod(x0 * p.y, p.x); |
| 239 | + return floor( mod( (x1 + p.z) *x0, p.x )); |
| 240 | + } |
| 241 | + |
| 242 | +uniform vec4 pParam; |
| 243 | +// Example |
| 244 | +// const vec4 pParam = vec4( 17.* 17., 34., 1., 7.); |
| 245 | + |
| 246 | +float taylorInvSqrt(float r) |
| 247 | + { |
| 248 | + return ( 0.83666002653408 + 0.7*0.85373472095314 - 0.85373472095314 * r ); |
| 249 | + } |
| 250 | + |
| 251 | +float simplexNoise2(vec2 v) |
| 252 | + { |
| 253 | + const vec2 C = vec2(0.211324865405187134, // (3.0-sqrt(3.0))/6.; |
| 254 | + 0.366025403784438597); // 0.5*(sqrt(3.0)-1.); |
| 255 | + const vec3 D = vec3( 0., 0.5, 2.0) * 3.14159265358979312; |
| 256 | +// First corner |
| 257 | + vec2 i = floor(v + dot(v, C.yy) ); |
| 258 | + vec2 x0 = v - i + dot(i, C.xx); |
| 259 | + |
| 260 | +// Other corners |
| 261 | + vec2 i1 = (x0.x > x0.y) ? vec2(1.,0.) : vec2(0.,1.) ; |
| 262 | + |
| 263 | + // x0 = x0 - 0. + 0. * C |
| 264 | + vec2 x1 = x0 - i1 + 1. * C.xx ; |
| 265 | + vec2 x2 = x0 - 1. + 2. * C.xx ; |
| 266 | + |
| 267 | +// Permutations |
| 268 | + i = mod(i, pParam.x); |
| 269 | + vec3 p = permute( permute( |
| 270 | + i.y + vec3(0., i1.y, 1. ), pParam.xyz) |
| 271 | + + i.x + vec3(0., i1.x, 1. ), pParam.xyz); |
| 272 | + |
| 273 | +#ifndef USE_CIRCLE |
| 274 | +// ( N points uniformly over a line, mapped onto a diamond.) |
| 275 | + vec3 x = fract(p / pParam.w) ; |
| 276 | + vec3 h = 0.5 - abs(x) ; |
| 277 | + |
| 278 | + vec3 sx = vec3(lessThan(x,D.xxx)) *2. -1.; |
| 279 | + vec3 sh = vec3(lessThan(h,D.xxx)); |
| 280 | + |
| 281 | + vec3 a0 = x + sx*sh; |
| 282 | + vec2 p0 = vec2(a0.x,h.x); |
| 283 | + vec2 p1 = vec2(a0.y,h.y); |
| 284 | + vec2 p2 = vec2(a0.z,h.z); |
| 285 | + |
| 286 | +#ifdef NORMALISE_GRADIENTS |
| 287 | + p0 *= taylorInvSqrt(dot(p0,p0)); |
| 288 | + p1 *= taylorInvSqrt(dot(p1,p1)); |
| 289 | + p2 *= taylorInvSqrt(dot(p2,p2)); |
| 290 | +#endif |
| 291 | + |
| 292 | + vec3 g = 2.0 * vec3( dot(p0, x0), dot(p1, x1), dot(p2, x2) ); |
| 293 | +#else |
| 294 | +// N points around a unit circle. |
| 295 | + vec3 phi = D.z * mod(p,pParam.w) /pParam.w ; |
| 296 | + vec4 a0 = sin(phi.xxyy+D.xyxy); |
| 297 | + vec2 a1 = sin(phi.zz +D.xy); |
| 298 | + vec3 g = vec3( dot(a0.xy, x0), dot(a0.zw, x1), dot(a1.xy, x2) ); |
| 299 | +#endif |
| 300 | +// mix |
| 301 | + vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.); |
| 302 | + m = m*m ; |
| 303 | + return 1.66666* 70.*dot(m*m, g); |
| 304 | + } |
| 305 | + |
| 306 | +float simplexNoise3(vec3 v) |
| 307 | + { |
| 308 | + const vec2 C = vec2(1./6. , 1./3. ) ; |
| 309 | + const vec4 D = vec4(0., 0.5, 1.0, 2.0); |
| 310 | + |
| 311 | +// First corner |
| 312 | + vec3 i = floor(v + dot(v, C.yyy) ); |
| 313 | + vec3 x0 = v - i + dot(i, C.xxx) ; |
| 314 | + |
| 315 | +// Other corners |
| 316 | +#ifdef COLLAPSE_SORTNET |
| 317 | + vec3 g = vec3( greaterThan( x0.xyz, x0.yzx) ); |
| 318 | + vec3 l = vec3( lessThanEqual( x0.xyz, x0.yzx) ); |
| 319 | + |
| 320 | + vec3 i1 = g.xyz * l.zxy; |
| 321 | + vec3 i2 = max( g.xyz, l.zxy); |
| 322 | +#else |
| 323 | +// Keeping this clean - let the compiler optimize. |
| 324 | + vec3 q1; |
| 325 | + q1.x = max(x0.x, x0.y); |
| 326 | + q1.y = min(x0.x, x0.y); |
| 327 | + q1.z = x0.z; |
| 328 | + |
| 329 | + vec3 q2; |
| 330 | + q2.x = max(q1.x,q1.z); |
| 331 | + q2.z = min(q1.x,q1.z); |
| 332 | + q2.y = q1.y; |
| 333 | + |
| 334 | + vec3 q3; |
| 335 | + q3.y = max(q2.y, q2.z); |
| 336 | + q3.z = min(q2.y, q2.z); |
| 337 | + q3.x = q2.x; |
| 338 | + |
| 339 | + vec3 i1 = vec3(equal(q3.xxx, x0)); |
| 340 | + vec3 i2 = i1 + vec3(equal(q3.yyy, x0)); |
| 341 | +#endif |
| 342 | + |
| 343 | + // x0 = x0 - 0. + 0. * C |
| 344 | + vec3 x1 = x0 - i1 + 1. * C.xxx; |
| 345 | + vec3 x2 = x0 - i2 + 2. * C.xxx; |
| 346 | + vec3 x3 = x0 - 1. + 3. * C.xxx; |
| 347 | + |
| 348 | +// Permutations |
| 349 | + i = mod(i, pParam.x ); |
| 350 | + vec4 p = permute( permute( permute( |
| 351 | + i.z + vec4(0., i1.z, i2.z, 1. ), pParam.xyz) |
| 352 | + + i.y + vec4(0., i1.y, i2.y, 1. ), pParam.xyz) |
| 353 | + + i.x + vec4(0., i1.x, i2.x, 1. ), pParam.xyz); |
| 354 | + |
| 355 | +// Gradients |
| 356 | +// ( N*N points uniformly over a square, mapped onto a octohedron.) |
| 357 | + float n_ = 1.0/pParam.w ; |
| 358 | + vec3 ns = n_ * D.wyz - D.xzx ; |
| 359 | + |
| 360 | + vec4 j = p - pParam.w*pParam.w*floor(p * ns.z *ns.z); // mod(p,N*N) |
| 361 | + |
| 362 | + vec4 x_ = floor(j * ns.z) ; |
| 363 | + vec4 y_ = floor(j - pParam.w * x_ ) ; // mod(j,N) |
| 364 | + |
| 365 | + vec4 x = x_ *ns.x + ns.yyyy; |
| 366 | + vec4 y = y_ *ns.x + ns.yyyy; |
| 367 | + vec4 h = 1. - abs(x) - abs(y); |
| 368 | + |
| 369 | + vec4 b0 = vec4( x.xy, y.xy ); |
| 370 | + vec4 b1 = vec4( x.zw, y.zw ); |
| 371 | + |
| 372 | + vec4 s0 = vec4(lessThan(b0,D.xxxx)) *2. -1.; |
| 373 | + vec4 s1 = vec4(lessThan(b1,D.xxxx)) *2. -1.; |
| 374 | + vec4 sh = vec4(lessThan(h, D.xxxx)); |
| 375 | + |
| 376 | + vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ; |
| 377 | + vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ; |
| 378 | + |
| 379 | + vec3 p0 = vec3(a0.xy,h.x); |
| 380 | + vec3 p1 = vec3(a0.zw,h.y); |
| 381 | + vec3 p2 = vec3(a1.xy,h.z); |
| 382 | + vec3 p3 = vec3(a1.zw,h.w); |
| 383 | + |
| 384 | +#ifdef NORMALISE_GRADIENTS |
| 385 | + p0 *= taylorInvSqrt(dot(p0,p0)); |
| 386 | + p1 *= taylorInvSqrt(dot(p1,p1)); |
| 387 | + p2 *= taylorInvSqrt(dot(p2,p2)); |
| 388 | + p3 *= taylorInvSqrt(dot(p3,p3)); |
| 389 | +#endif |
| 390 | + |
| 391 | +// Mix |
| 392 | + vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.); |
| 393 | + m = m * m; |
| 394 | +//used to be 64. |
| 395 | + return 48.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), |
| 396 | + dot(p2,x2), dot(p3,x3) ) ); |
| 397 | + } |
| 398 | + |
| 399 | +vec4 grad4(float j, vec4 ip) |
| 400 | + { |
| 401 | + const vec4 ones = vec4(1.,1.,1.,-1.); |
| 402 | + vec4 p,s; |
| 403 | + |
| 404 | + p.xyz = floor( fract (vec3(j) * ip.xyz) *pParam.w) * ip.z -1.0; |
| 405 | + p.w = 1.5 - dot(abs(p.xyz), ones.xyz); |
| 406 | + s = vec4(lessThan(p,vec4(0.))); |
| 407 | + p.xyz = p.xyz + (s.xyz*2.-1.) * s.www; |
| 408 | + |
| 409 | + return p; |
| 410 | + } |
| 411 | + |
| 412 | +float simplexNoise4(vec4 v) |
| 413 | + { |
| 414 | + const vec2 C = vec2( 0.138196601125010504, // (5 - sqrt(5))/20 G4 |
| 415 | + 0.309016994374947451); // (sqrt(5) - 1)/4 F4 |
| 416 | +// First corner |
| 417 | + vec4 i = floor(v + dot(v, C.yyyy) ); |
| 418 | + vec4 x0 = v - i + dot(i, C.xxxx); |
| 419 | + |
| 420 | +// Other corners |
| 421 | + |
| 422 | +// Force existance of strict total ordering in sort. |
| 423 | + vec4 q0 = floor(x0 * 1024.0) + vec4( 0., 1./4., 2./4. , 3./4.); |
| 424 | + vec4 q1; |
| 425 | + q1.xy = max(q0.xy,q0.zw); // x:z y:w |
| 426 | + q1.zw = min(q0.xy,q0.zw); |
| 427 | + |
| 428 | + vec4 q2; |
| 429 | + q2.xz = max(q1.xz,q1.yw); // x:y z:w |
| 430 | + q2.yw = min(q1.xz,q1.yw); |
| 431 | + |
| 432 | + vec4 q3; |
| 433 | + q3.y = max(q2.y,q2.z); // y:z |
| 434 | + q3.z = min(q2.y,q2.z); |
| 435 | + q3.xw = q2.xw; |
| 436 | + |
| 437 | + vec4 i1 = vec4(lessThanEqual(q3.xxxx, q0)); |
| 438 | + vec4 i2 = vec4(lessThanEqual(q3.yyyy, q0)); |
| 439 | + vec4 i3 = vec4(lessThanEqual(q3.zzzz, q0)); |
| 440 | + |
| 441 | + // x0 = x0 - 0. + 0. * C |
| 442 | + vec4 x1 = x0 - i1 + 1. * C.xxxx; |
| 443 | + vec4 x2 = x0 - i2 + 2. * C.xxxx; |
| 444 | + vec4 x3 = x0 - i3 + 3. * C.xxxx; |
| 445 | + vec4 x4 = x0 - 1. + 4. * C.xxxx; |
| 446 | + |
| 447 | +// Permutations |
| 448 | + i = mod(i, pParam.x ); |
| 449 | + float j0 = permute( permute( permute( permute ( |
| 450 | + i.w, pParam.xyz) + i.z, pParam.xyz) |
| 451 | + + i.y, pParam.xyz) + i.x, pParam.xyz); |
| 452 | + vec4 j1 = permute( permute( permute( permute ( |
| 453 | + i.w + vec4(i1.w, i2.w, i3.w, 1. ), pParam.xyz) |
| 454 | + + i.z + vec4(i1.z, i2.z, i3.z, 1. ), pParam.xyz) |
| 455 | + + i.y + vec4(i1.y, i2.y, i3.y, 1. ), pParam.xyz) |
| 456 | + + i.x + vec4(i1.x, i2.x, i3.x, 1. ), pParam.xyz); |
| 457 | +// Gradients |
| 458 | +// ( N*N*N points uniformly over a cube, mapped onto a 4-octohedron.) |
| 459 | + vec4 ip = pParam ; |
| 460 | + ip.xy *= pParam.w ; |
| 461 | + ip.x *= pParam.w ; |
| 462 | + ip = vec4(1.,1.,1.,2.) / ip ; |
| 463 | + |
| 464 | + vec4 p0 = grad4(j0, ip); |
| 465 | + vec4 p1 = grad4(j1.x, ip); |
| 466 | + vec4 p2 = grad4(j1.y, ip); |
| 467 | + vec4 p3 = grad4(j1.z, ip); |
| 468 | + vec4 p4 = grad4(j1.w, ip); |
| 469 | + |
| 470 | +#ifdef NORMALISE_GRADIENTS |
| 471 | + p0 *= taylorInvSqrt(dot(p0,p0)); |
| 472 | + p1 *= taylorInvSqrt(dot(p1,p1)); |
| 473 | + p2 *= taylorInvSqrt(dot(p2,p2)); |
| 474 | + p3 *= taylorInvSqrt(dot(p3,p3)); |
| 475 | + p4 *= taylorInvSqrt(dot(p4,p4)); |
| 476 | +#endif |
| 477 | + |
| 478 | +// Mix |
| 479 | + vec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.); |
| 480 | + vec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.); |
| 481 | + m0 = m0 * m0; |
| 482 | + m1 = m1 * m1; |
| 483 | + return 32. * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ))) |
| 484 | + + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ; |
| 485 | + |
| 486 | + } |
| 487 | + |
| 488 | + |
| 489 | + |
| 490 | diff --git a/src/glsl/skinning.vert b/src/glsl/skinning.vert |
| 491 | new file mode 100644 |
| 492 | index 0000000..28970ee |
| 493 | --- /dev/null |
| 494 | +++ b/src/glsl/skinning.vert |
| 495 | @@ -0,0 +1,24 @@ |
| 496 | +// Vertex weighting/blendin shader |
| 497 | +// Brian Paul |
| 498 | +// 4 Nov 2008 |
| 499 | + |
| 500 | +uniform mat4 mat0, mat1; |
| 501 | +attribute float weight; |
| 502 | + |
| 503 | +void main() |
| 504 | +{ |
| 505 | + // simple diffuse shading |
| 506 | + // Note that we should really transform the normal vector along with |
| 507 | + // the postion below... someday. |
| 508 | + vec3 lightVec = vec3(0, 0, 1); |
| 509 | + vec3 norm = gl_NormalMatrix * gl_Normal; |
| 510 | + float dot = 0.2 + max(0.0, dot(norm, lightVec)); |
| 511 | + gl_FrontColor = vec4(dot); |
| 512 | + |
| 513 | + // compute sum of weighted transformations |
| 514 | + vec4 pos0 = mat0 * gl_Vertex; |
| 515 | + vec4 pos1 = mat1 * gl_Vertex; |
| 516 | + vec4 pos = mix(pos0, pos1, weight); |
| 517 | + |
| 518 | + gl_Position = gl_ModelViewProjectionMatrix * pos; |
| 519 | +} |
| 520 | diff --git a/src/perf/glslstateschange1.frag b/src/perf/glslstateschange1.frag |
| 521 | new file mode 100644 |
| 522 | index 0000000..0839436 |
| 523 | --- /dev/null |
| 524 | +++ b/src/perf/glslstateschange1.frag |
| 525 | @@ -0,0 +1,19 @@ |
| 526 | +// Multi-texture fragment shader |
| 527 | +// Brian Paul |
| 528 | + |
| 529 | +// Composite second texture over first. |
| 530 | +// We're assuming the 2nd texture has a meaningful alpha channel. |
| 531 | + |
| 532 | +uniform sampler2D tex1; |
| 533 | +uniform sampler2D tex2; |
| 534 | +uniform vec4 UniV1; |
| 535 | +uniform vec4 UniV2; |
| 536 | + |
| 537 | +void main() |
| 538 | +{ |
| 539 | + vec4 t3; |
| 540 | + vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy); |
| 541 | + vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy); |
| 542 | + t3 = mix(t1, t2, t2.w); |
| 543 | + gl_FragColor = t3 + UniV1 + UniV2; |
| 544 | +} |
| 545 | diff --git a/src/perf/glslstateschange1.vert b/src/perf/glslstateschange1.vert |
| 546 | new file mode 100644 |
| 547 | index 0000000..cef50db |
| 548 | --- /dev/null |
| 549 | +++ b/src/perf/glslstateschange1.vert |
| 550 | @@ -0,0 +1,14 @@ |
| 551 | +// Multi-texture vertex shader |
| 552 | +// Brian Paul |
| 553 | + |
| 554 | + |
| 555 | +attribute vec4 TexCoord0, TexCoord1; |
| 556 | +attribute vec4 VertCoord; |
| 557 | + |
| 558 | +void main() |
| 559 | +{ |
| 560 | + gl_TexCoord[0] = TexCoord0; |
| 561 | + gl_TexCoord[1] = TexCoord1; |
| 562 | + // note: may use gl_Vertex or VertCoord here for testing: |
| 563 | + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
| 564 | +} |
| 565 | diff --git a/src/perf/glslstateschange2.frag b/src/perf/glslstateschange2.frag |
| 566 | new file mode 100644 |
| 567 | index 0000000..0df0319 |
| 568 | --- /dev/null |
| 569 | +++ b/src/perf/glslstateschange2.frag |
| 570 | @@ -0,0 +1,17 @@ |
| 571 | +// Multi-texture fragment shader |
| 572 | +// Brian Paul |
| 573 | + |
| 574 | +// Composite second texture over first. |
| 575 | +// We're assuming the 2nd texture has a meaningful alpha channel. |
| 576 | + |
| 577 | +uniform sampler2D tex1; |
| 578 | +uniform sampler2D tex2; |
| 579 | +uniform vec4 UniV1; |
| 580 | +uniform vec4 UniV2; |
| 581 | + |
| 582 | +void main() |
| 583 | +{ |
| 584 | + vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy); |
| 585 | + vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy); |
| 586 | + gl_FragColor = t1 + t2 + UniV1 + UniV2; |
| 587 | +} |
| 588 | diff --git a/src/perf/glslstateschange2.vert b/src/perf/glslstateschange2.vert |
| 589 | new file mode 100644 |
| 590 | index 0000000..cef50db |
| 591 | --- /dev/null |
| 592 | +++ b/src/perf/glslstateschange2.vert |
| 593 | @@ -0,0 +1,14 @@ |
| 594 | +// Multi-texture vertex shader |
| 595 | +// Brian Paul |
| 596 | + |
| 597 | + |
| 598 | +attribute vec4 TexCoord0, TexCoord1; |
| 599 | +attribute vec4 VertCoord; |
| 600 | + |
| 601 | +void main() |
| 602 | +{ |
| 603 | + gl_TexCoord[0] = TexCoord0; |
| 604 | + gl_TexCoord[1] = TexCoord1; |
| 605 | + // note: may use gl_Vertex or VertCoord here for testing: |
| 606 | + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; |
| 607 | +} |
| 608 | diff --git a/src/vpglsl/infinite-loop.glsl b/src/vpglsl/infinite-loop.glsl |
| 609 | new file mode 100644 |
| 610 | index 0000000..bc7ae4b |
| 611 | --- /dev/null |
| 612 | +++ b/src/vpglsl/infinite-loop.glsl |
| 613 | @@ -0,0 +1,8 @@ |
| 614 | +void main() { |
| 615 | + gl_Position = gl_Vertex; |
| 616 | + vec4 sum = vec4(0); |
| 617 | + for (int i = 1; i != 2; i += 2) { |
| 618 | + sum += vec4(0.1, 0.1, 0.1, 0.1); |
| 619 | + } |
| 620 | + gl_FrontColor = sum; |
| 621 | +} |
| 622 | -- |
| 623 | 2.0.0 |
| 624 | |