lavavu-osmesa 1.8.43__cp311-cp311-manylinux_2_24_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. lavavu/LavaVuPython.py +578 -0
  2. lavavu/_LavaVuPython.cpython-311-x86_64-linux-gnu.so +0 -0
  3. lavavu/__init__.py +15 -0
  4. lavavu/__main__.py +12 -0
  5. lavavu/amalgamate.py +11 -0
  6. lavavu/aserver.py +357 -0
  7. lavavu/control.py +1699 -0
  8. lavavu/convert.py +853 -0
  9. lavavu/dict.json +2485 -0
  10. lavavu/font.bin +0 -0
  11. lavavu/html/LavaVu-amalgamated.css +282 -0
  12. lavavu/html/OK-min.js +99 -0
  13. lavavu/html/baseviewer.js +307 -0
  14. lavavu/html/control.css +104 -0
  15. lavavu/html/control.js +335 -0
  16. lavavu/html/dat-gui-light-theme.css +68 -0
  17. lavavu/html/dat.gui.min.js +2 -0
  18. lavavu/html/draw.js +2259 -0
  19. lavavu/html/drawbox.js +1030 -0
  20. lavavu/html/emscripten-template.js +184 -0
  21. lavavu/html/emscripten.css +92 -0
  22. lavavu/html/favicon.ico +0 -0
  23. lavavu/html/gl-matrix-min.js +47 -0
  24. lavavu/html/gui.css +25 -0
  25. lavavu/html/menu.js +609 -0
  26. lavavu/html/server.js +226 -0
  27. lavavu/html/stats.min.js +5 -0
  28. lavavu/html/styles.css +58 -0
  29. lavavu/html/webview-template.html +43 -0
  30. lavavu/html/webview.html +43 -0
  31. lavavu/lavavu.py +5635 -0
  32. lavavu/points.py +191 -0
  33. lavavu/server.py +343 -0
  34. lavavu/shaders/default.frag +20 -0
  35. lavavu/shaders/default.vert +17 -0
  36. lavavu/shaders/fontShader.frag +25 -0
  37. lavavu/shaders/fontShader.vert +18 -0
  38. lavavu/shaders/lineShader.frag +43 -0
  39. lavavu/shaders/lineShader.vert +28 -0
  40. lavavu/shaders/pointShader.frag +132 -0
  41. lavavu/shaders/pointShader.vert +57 -0
  42. lavavu/shaders/triShader.frag +170 -0
  43. lavavu/shaders/triShader.vert +55 -0
  44. lavavu/shaders/volumeShader.frag +463 -0
  45. lavavu/shaders/volumeShader.vert +5 -0
  46. lavavu/tracers.py +124 -0
  47. lavavu/vutils.py +213 -0
  48. lavavu_osmesa-1.8.43.dist-info/LICENSE.md +179 -0
  49. lavavu_osmesa-1.8.43.dist-info/METADATA +33 -0
  50. lavavu_osmesa-1.8.43.dist-info/RECORD +138 -0
  51. lavavu_osmesa-1.8.43.dist-info/WHEEL +5 -0
  52. lavavu_osmesa-1.8.43.dist-info/entry_points.txt +3 -0
  53. lavavu_osmesa-1.8.43.dist-info/top_level.txt +1 -0
  54. lavavu_osmesa.libs/libLLVM-3-6d00db57.8.so.1 +0 -0
  55. lavavu_osmesa.libs/libOSMesa-29f606eb.so.8.0.0 +0 -0
  56. lavavu_osmesa.libs/libXau-6ab8808d.so.6.0.0 +0 -0
  57. lavavu_osmesa.libs/libXdmcp-911ecd1c.so.6.0.0 +0 -0
  58. lavavu_osmesa.libs/libXfixes-af4baa9b.so.3.1.0 +0 -0
  59. lavavu_osmesa.libs/libavcodec-10cacdd4.so.57.64.101 +0 -0
  60. lavavu_osmesa.libs/libavformat-afa92877.so.57.56.101 +0 -0
  61. lavavu_osmesa.libs/libavutil-837eb790.so.55.34.101 +0 -0
  62. lavavu_osmesa.libs/libbluray-0b5d9dbd.so.1.10.0 +0 -0
  63. lavavu_osmesa.libs/libbsd-4a4ec721.so.0.8.3 +0 -0
  64. lavavu_osmesa.libs/libbz2-9ebec8ea.so.1.0.4 +0 -0
  65. lavavu_osmesa.libs/libcairo-4217ca50.so.2.11400.8 +0 -0
  66. lavavu_osmesa.libs/libchromaprint-c4f82352.so.1.4.2 +0 -0
  67. lavavu_osmesa.libs/libcom_err-b4bd5c72.so.2.1 +0 -0
  68. lavavu_osmesa.libs/libcrystalhd-e4ea0de0.so.3.6 +0 -0
  69. lavavu_osmesa.libs/libdrm-28f5b5e7.so.2.4.0 +0 -0
  70. lavavu_osmesa.libs/libedit-7f8577df.so.2.0.55 +0 -0
  71. lavavu_osmesa.libs/libffi-1c6807d3.so.6.0.4 +0 -0
  72. lavavu_osmesa.libs/libfontconfig-e9a06300.so.1.8.0 +0 -0
  73. lavavu_osmesa.libs/libfreetype-851758a3.so.6.12.3 +0 -0
  74. lavavu_osmesa.libs/libgcrypt-0005395c.so.20.1.6 +0 -0
  75. lavavu_osmesa.libs/libglapi-cf95372b.so.0.0.0 +0 -0
  76. lavavu_osmesa.libs/libgme-5f850ce8.so.0.6.0 +0 -0
  77. lavavu_osmesa.libs/libgmp-742f5e74.so.10.3.2 +0 -0
  78. lavavu_osmesa.libs/libgnutls-1ec2cd13.so.30.13.1 +0 -0
  79. lavavu_osmesa.libs/libgomp-ce6cf6a9.so.1.0.0 +0 -0
  80. lavavu_osmesa.libs/libgpg-error-24781f22.so.0.21.0 +0 -0
  81. lavavu_osmesa.libs/libgsm-aa736f52.so.1.0.12 +0 -0
  82. lavavu_osmesa.libs/libgssapi_krb5-e296a08d.so.2.2 +0 -0
  83. lavavu_osmesa.libs/libhogweed-9d325a8d.so.4.3 +0 -0
  84. lavavu_osmesa.libs/libicudata-79cf9efa.so.57.1 +0 -0
  85. lavavu_osmesa.libs/libicui18n-03536ef3.so.57.1 +0 -0
  86. lavavu_osmesa.libs/libicuuc-5743fca1.so.57.1 +0 -0
  87. lavavu_osmesa.libs/libidn-fd653b64.so.11.6.16 +0 -0
  88. lavavu_osmesa.libs/libjbig-b30cd8bd.so.0 +0 -0
  89. lavavu_osmesa.libs/libjpeg-8afa139c.so.62.2.0 +0 -0
  90. lavavu_osmesa.libs/libk5crypto-93afd15e.so.3.1 +0 -0
  91. lavavu_osmesa.libs/libkeyutils-46318358.so.1.5 +0 -0
  92. lavavu_osmesa.libs/libkrb5-061fe33b.so.3.3 +0 -0
  93. lavavu_osmesa.libs/libkrb5support-86ac49ad.so.0.1 +0 -0
  94. lavavu_osmesa.libs/liblzma-9c0610aa.so.5.2.2 +0 -0
  95. lavavu_osmesa.libs/libmp3lame-249ae4b0.so.0.0.0 +0 -0
  96. lavavu_osmesa.libs/libmpg123-13a39b0e.so.0.42.3 +0 -0
  97. lavavu_osmesa.libs/libncurses-09dfda50.so.5.9 +0 -0
  98. lavavu_osmesa.libs/libnettle-2482db45.so.6.3 +0 -0
  99. lavavu_osmesa.libs/libnuma-c8473f23.so.1.0.0 +0 -0
  100. lavavu_osmesa.libs/libogg-b6ceea65.so.0.8.2 +0 -0
  101. lavavu_osmesa.libs/libopenjp2-a0c5d12e.so.2.1.2 +0 -0
  102. lavavu_osmesa.libs/libopenmpt-58b855da.so.0.0.20 +0 -0
  103. lavavu_osmesa.libs/libopus-37a3229e.so.0.5.3 +0 -0
  104. lavavu_osmesa.libs/libp11-kit-d06ac4a7.so.0.2.0 +0 -0
  105. lavavu_osmesa.libs/libpixman-1-7369dbb3.so.0.34.0 +0 -0
  106. lavavu_osmesa.libs/libpng16-121b9de7.so.16.28.0 +0 -0
  107. lavavu_osmesa.libs/libshine-b48eced9.so.3.0.1 +0 -0
  108. lavavu_osmesa.libs/libsnappy-1125e350.so.1.3.0 +0 -0
  109. lavavu_osmesa.libs/libsoxr-e0d4d3e4.so.0.1.1 +0 -0
  110. lavavu_osmesa.libs/libspeex-6f258c6c.so.1.5.0 +0 -0
  111. lavavu_osmesa.libs/libssh-gcrypt-90c7dd19.so.4.5.1 +0 -0
  112. lavavu_osmesa.libs/libswresample-cb1bf771.so.2.3.100 +0 -0
  113. lavavu_osmesa.libs/libswscale-876dcddb.so.4.2.100 +0 -0
  114. lavavu_osmesa.libs/libtasn1-44938221.so.6.5.3 +0 -0
  115. lavavu_osmesa.libs/libtheoradec-02a81176.so.1.1.4 +0 -0
  116. lavavu_osmesa.libs/libtheoraenc-b508ccf1.so.1.1.2 +0 -0
  117. lavavu_osmesa.libs/libtiff-e2a5092b.so.5.2.6 +0 -0
  118. lavavu_osmesa.libs/libtinfo-33626a82.so.5.9 +0 -0
  119. lavavu_osmesa.libs/libtwolame-6fcc2d32.so.0.0.0 +0 -0
  120. lavavu_osmesa.libs/libva-0f7a824e.so.1.3904.0 +0 -0
  121. lavavu_osmesa.libs/libva-drm-178eb7ac.so.1.3904.0 +0 -0
  122. lavavu_osmesa.libs/libva-x11-d220c497.so.1.3904.0 +0 -0
  123. lavavu_osmesa.libs/libvdpau-0391b780.so.1.0.0 +0 -0
  124. lavavu_osmesa.libs/libvorbis-378bad15.so.0.4.8 +0 -0
  125. lavavu_osmesa.libs/libvorbisenc-d605e0e1.so.2.0.11 +0 -0
  126. lavavu_osmesa.libs/libvorbisfile-5692671f.so.3.3.7 +0 -0
  127. lavavu_osmesa.libs/libvpx-560f7a88.so.4.1.0 +0 -0
  128. lavavu_osmesa.libs/libwavpack-8339806a.so.1.2.0 +0 -0
  129. lavavu_osmesa.libs/libwebp-63152597.so.6.0.2 +0 -0
  130. lavavu_osmesa.libs/libwebpmux-38ab8eb3.so.2.0.2 +0 -0
  131. lavavu_osmesa.libs/libx264-1c898326.so.148 +0 -0
  132. lavavu_osmesa.libs/libx265-51947861.so.95 +0 -0
  133. lavavu_osmesa.libs/libxcb-ffedb2d4.so.1.1.0 +0 -0
  134. lavavu_osmesa.libs/libxcb-render-f7692d1d.so.0.0.0 +0 -0
  135. lavavu_osmesa.libs/libxcb-shm-5702672e.so.0.0.0 +0 -0
  136. lavavu_osmesa.libs/libxml2-b8b306ab.so.2.9.4 +0 -0
  137. lavavu_osmesa.libs/libxvidcore-a773eded.so.4.3 +0 -0
  138. lavavu_osmesa.libs/libzvbi-2db02ce4.so.0.13.2 +0 -0
@@ -0,0 +1,132 @@
1
+ uniform int uPointType;
2
+ uniform float uOpacity;
3
+ uniform float uBrightness;
4
+ uniform float uContrast;
5
+ uniform float uSaturation;
6
+ uniform float uAmbient;
7
+ uniform float uDiffuse;
8
+ uniform float uSpecular;
9
+ uniform bool uOpaque;
10
+ uniform bool uTextured;
11
+ uniform sampler2D uTexture;
12
+ uniform vec3 uClipMin;
13
+ uniform vec3 uClipMax;
14
+ uniform vec3 uLightPos;
15
+
16
+ in vec4 vColour;
17
+ in vec3 vVertex;
18
+ in vec2 vTexCoord;
19
+ in float vPointSize;
20
+ in vec3 vPosEye;
21
+ in float vPointType;
22
+
23
+ #ifdef WEBGL
24
+ #define outColour gl_FragColor
25
+ #define texture(a,b) texture2D(a,b)
26
+ #else
27
+ out vec4 outColour;
28
+ #endif
29
+
30
+ void calcColour(vec3 colour, float alpha)
31
+ {
32
+ //Brightness adjust
33
+ colour += uBrightness;
34
+ //Saturation & Contrast adjust
35
+ const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
36
+ vec3 AvgLumin = vec3(0.5, 0.5, 0.5);
37
+ vec3 intensity = vec3(dot(colour, LumCoeff));
38
+ colour = mix(intensity, colour, uSaturation);
39
+ colour = mix(AvgLumin, colour, uContrast);
40
+
41
+ if (uOpaque)
42
+ alpha = 1.0;
43
+
44
+ outColour = vec4(colour, alpha);
45
+ }
46
+
47
+ void main(void)
48
+ {
49
+ //Clip planes in X/Y/Z
50
+ if (any(lessThan(vVertex, uClipMin)) || any(greaterThan(vVertex, uClipMax))) discard;
51
+
52
+ float alpha = vColour.a;
53
+ if (uOpacity > 0.0) alpha *= uOpacity;
54
+ outColour = vColour;
55
+
56
+ int pointType = uPointType;
57
+ if (vPointType >= 0.0) pointType = int(floor(vPointType + 0.5)); //Round back to nearest int
58
+
59
+ //Textured?
60
+ if (uTextured && vTexCoord.y >= 0.0)
61
+ {
62
+ vec4 tColour;
63
+ if (vTexCoord.x < 0.0)
64
+ tColour = texture(uTexture, gl_PointCoord); //Point sprite mode
65
+ else
66
+ tColour = texture(uTexture, vTexCoord);
67
+
68
+ //Blend with colour
69
+ outColour = mix(tColour, outColour, 1.0-tColour.a);
70
+ alpha = outColour.a;
71
+ }
72
+
73
+ //Flat, square points, fastest, skip lighting
74
+ if (pointType == 4)
75
+ {
76
+ calcColour(outColour.rgb, alpha);
77
+ return;
78
+ }
79
+
80
+ //Circular points...
81
+ //Calculate normal from point/tex coordinates
82
+ vec3 N;
83
+ N.xy = gl_PointCoord * 2.0 - vec2(1.0);
84
+ float R = dot(N.xy, N.xy);
85
+ //Discard if outside circle
86
+ if (R > 1.0) discard;
87
+ //Anti-aliased edges for sphere types
88
+ if (pointType > 1)
89
+ {
90
+ float edge = vPointSize - R * vPointSize;
91
+ if (edge <= 4.0)
92
+ alpha *= (0.25 * edge);
93
+ }
94
+
95
+ //Discard if transparent (outside circle)
96
+ if (alpha < 0.01) discard;
97
+
98
+ if (pointType < 2)
99
+ {
100
+ //Circular with no light/shading, just blur
101
+ if (pointType == 0)
102
+ alpha *= 1.0-sqrt(R); //Gaussian
103
+ else //TODO: allow disable blur for circular points
104
+ alpha *= 1.0-R; //Linear
105
+
106
+ calcColour(outColour.rgb, alpha);
107
+ return;
108
+ }
109
+
110
+ //Calculate diffuse lighting component
111
+ N.z = sqrt(1.0-R);
112
+ float diffuse = 1.0;
113
+ vec3 lightDir = normalize(uLightPos - vPosEye);
114
+ diffuse = max(0.0, dot(lightDir, N));
115
+
116
+ //Calculate specular lighting component
117
+ if (pointType == 3 && diffuse > 0.0)
118
+ {
119
+ vec3 specular = vec3(0.0,0.0,0.0);
120
+ float shininess = 200.0; //Size of highlight
121
+ vec3 specolour = vec3(1.0, 1.0, 1.0); //Color of light
122
+ //Normalize the half-vector
123
+ //vec3 halfVector = normalize(vPosEye + lightDir);
124
+ vec3 halfVector = normalize(vec3(0.0, 0.0, 1.0) + lightDir);
125
+ //Compute cosine (dot product) with the normal
126
+ float NdotHV = max(dot(N, halfVector), 0.0);
127
+ specular = specolour * pow(NdotHV, shininess);
128
+ calcColour(outColour.rgb * diffuse + specular, alpha);
129
+ }
130
+ else
131
+ calcColour(outColour.rgb * diffuse, alpha);
132
+ }
@@ -0,0 +1,57 @@
1
+ in vec3 aVertexPosition;
2
+ in vec4 aVertexColour;
3
+ in vec2 aVertexTexCoord;
4
+
5
+ uniform mat4 uMVMatrix;
6
+ uniform mat4 uPMatrix;
7
+
8
+ out vec4 vColour;
9
+
10
+ #ifdef WEBGL
11
+ const int uPointDist = 1; // Scale by distance
12
+ #else
13
+ uniform int uPointDist; // Scale by distance
14
+ #endif
15
+
16
+ in float aSize;
17
+ in float aPointType;
18
+
19
+ uniform float uPointScale; // scale to calculate size in pixels
20
+
21
+ uniform vec4 uColour;
22
+ uniform float uOpacity;
23
+
24
+ out vec3 vVertex;
25
+ out vec2 vTexCoord;
26
+ out float vPointSize;
27
+ out vec3 vPosEye;
28
+ out float vPointType;
29
+
30
+ void main(void)
31
+ {
32
+ float pSize = abs(aSize);
33
+
34
+ // calculate window-space point size
35
+ vec4 mvPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
36
+ vec3 posEye = mvPosition.xyz;
37
+ float dist = 1.0;
38
+ if (uPointDist > 0)
39
+ dist = length(posEye);
40
+ //Limit scaling, overly large points are very slow to render
41
+ //gl_PointSize = max(1.0, min(40.0, uPointScale * pSize / dist));
42
+
43
+ gl_PointSize = uPointScale * pSize / dist;
44
+ gl_Position = uPMatrix * mvPosition;
45
+
46
+ vPosEye = posEye;
47
+ vPointType = aPointType;
48
+ vPointSize = gl_PointSize;
49
+ vVertex = aVertexPosition.xyz;
50
+ vTexCoord = aVertexTexCoord;
51
+
52
+ if (uColour.a > 0.0)
53
+ vColour = uColour;
54
+ else
55
+ vColour = vec4(aVertexColour.rgb, aVertexColour.a);
56
+ }
57
+
@@ -0,0 +1,170 @@
1
+ in vec4 vColour;
2
+ in vec3 vNormal;
3
+ in vec3 vPosEye;
4
+ in vec3 vVertex;
5
+ in vec2 vTexCoord;
6
+ in vec3 vLightPos;
7
+
8
+ uniform float uOpacity;
9
+ uniform bool uLighting;
10
+ uniform float uBrightness;
11
+ uniform float uContrast;
12
+ uniform float uSaturation;
13
+ uniform float uAmbient;
14
+ uniform float uDiffuse;
15
+ uniform float uSpecular;
16
+ uniform float uShininess;
17
+
18
+ uniform bool uTextured;
19
+ uniform sampler2D uTexture;
20
+ uniform vec3 uClipMin;
21
+ uniform vec3 uClipMax;
22
+ uniform bool uOpaque;
23
+ uniform vec4 uLight;
24
+
25
+ #ifdef WEBGL
26
+ #define outColour gl_FragColor
27
+ #define texture(a,b) texture2D(a,b)
28
+
29
+ //Before OpenGL 3+ we need our own isnan function
30
+ bool isnan3(vec3 val)
31
+ {
32
+ if (!(val.x < 0.0 || 0.0 < val.x || val.x == 0.0)) return true;
33
+ if (!(val.y < 0.0 || 0.0 < val.y || val.y == 0.0)) return true;
34
+ if (!(val.z < 0.0 || 0.0 < val.z || val.z == 0.0)) return true;
35
+ return false;
36
+ }
37
+
38
+ #else
39
+ #define isnan3(v) any(isnan(v))
40
+ flat in vec4 vFlatColour;
41
+ uniform bool uFlat;
42
+ out vec4 outColour;
43
+ #endif
44
+
45
+ uniform bool uCalcNormal;
46
+
47
+ void calcColour(vec3 colour, float alpha)
48
+ {
49
+ //Brightness adjust
50
+ colour += uBrightness;
51
+ //Saturation & Contrast adjust
52
+ const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
53
+ vec3 AvgLumin = vec3(0.5, 0.5, 0.5);
54
+ vec3 intensity = vec3(dot(colour, LumCoeff));
55
+ colour = mix(intensity, colour, uSaturation);
56
+ colour = mix(AvgLumin, colour, uContrast);
57
+
58
+ //Gamma correction
59
+ //https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_reflection_model#OpenGL_Shading_Language_code_sample
60
+ //const float screenGamma = 2.2; // Assume the monitor is calibrated to the sRGB color space
61
+ //vec3 colorGammaCorrected = pow(color, vec3(1.0 / screenGamma));
62
+
63
+ outColour = vec4(colour, alpha);
64
+ }
65
+
66
+ void main(void)
67
+ {
68
+ //Clip planes in X/Y/Z
69
+ if (any(lessThan(vVertex, uClipMin)) || any(greaterThan(vVertex, uClipMax))) discard;
70
+
71
+ vec4 fColour = vColour;
72
+ #ifndef WEBGL
73
+ if (uFlat)
74
+ fColour = vFlatColour;
75
+ #endif
76
+ float alpha = fColour.a;
77
+ if (uTextured && vTexCoord.x > -1.0) //Null texcoord (-1,-1)
78
+ {
79
+ //With this blending mode, texture is blended over base colour,
80
+ //and colour opacity has no effect on texture opacity
81
+ //All desired texture opacity must be built in to the texture data
82
+ //(Could add another blend mode if we want a dynamic texture opacity)
83
+ vec4 tColour = texture(uTexture, vTexCoord);
84
+ if (fColour.a > 0.01)
85
+ {
86
+ //Additive blend alpha channel
87
+ alpha = fColour.a + tColour.a * (1.0 - fColour.a);
88
+
89
+ //Blend the texure colour with the fragment colour using texture alpha
90
+ fColour.rgb = vec3(mix(fColour.rgb, tColour.rgb, tColour.a));
91
+ }
92
+ else
93
+ {
94
+ //Disable all blending if the base colour opacity <= 0.01
95
+ fColour = tColour;
96
+ alpha = tColour.a;
97
+ }
98
+ }
99
+
100
+ if (uOpacity > 0.0) alpha *= uOpacity;
101
+ if (uOpaque) alpha = 1.0;
102
+ if (alpha < 0.01) discard;
103
+
104
+ if (!uLighting)
105
+ {
106
+ calcColour(fColour.rgb, alpha);
107
+ return;
108
+ }
109
+
110
+ vec3 lightColour = uLight.xyz;
111
+
112
+ //Light direction
113
+ vec3 lightDir = normalize(vLightPos - vPosEye);
114
+
115
+ //Calculate diffuse lighting
116
+ vec3 N = normalize(vNormal);
117
+
118
+ //Default normal...
119
+ if (uCalcNormal || dot(N,N) < 0.01 || isnan3(N))
120
+ {
121
+ //Requires extension in WebGL: OES_standard_derivatives
122
+ vec3 fdx = vec3(dFdx(vPosEye.x),dFdx(vPosEye.y),dFdx(vPosEye.z));
123
+ vec3 fdy = vec3(dFdy(vPosEye.x),dFdy(vPosEye.y),dFdy(vPosEye.z));
124
+ N = normalize(cross(fdx,fdy));
125
+ }
126
+
127
+ //Modified to use energy conservation adjustment
128
+ //https://learnopengl.com/Advanced-Lighting/Advanced-Lighting
129
+ const float kPi8 = 3.14159265 * 8.0;
130
+
131
+ //Calculate diffuse component
132
+ //Single side or two-sided lighting with abs()?
133
+ float diffuse = dot(N, lightDir);
134
+ if (uLight.w < 0.5)
135
+ diffuse = abs(diffuse);
136
+ else
137
+ diffuse = max(diffuse, 0.0);
138
+
139
+ //Compute the specular term
140
+ if (diffuse > 0.0 && uSpecular > 0.0)
141
+ {
142
+ //Specular power, higher is more focused/shiny
143
+ float shininess = 256.0 * clamp(uShininess, 0.0, 1.0);
144
+ vec3 specolour = lightColour; //Color of light - use the same as diffuse/ambient
145
+ //Blinn-Phong
146
+ vec3 viewDir = normalize(-vPosEye);
147
+ //Normalize the half-vector
148
+ vec3 halfVector = normalize(lightDir + viewDir);
149
+
150
+ //Compute cosine (dot product) with the normal
151
+ float NdotHV = dot(N, halfVector);
152
+ //Single side or two-sided lighting with abs()?
153
+ if (uLight.w < 0.5)
154
+ NdotHV = abs(NdotHV);
155
+ else
156
+ NdotHV = max(NdotHV, 0.0);
157
+
158
+ //Energy conservation adjustment (more focused/shiny highlight will be brighter)
159
+ float energyConservation = ( 8.0 + shininess) / kPi8;
160
+ //Multiplying specular by diffuse prevents bands at edges for low shininess
161
+ float spec = diffuse * uSpecular * energyConservation * pow(NdotHV, shininess);
162
+
163
+ //Final colour - specular + diffuse + ambient
164
+ calcColour(lightColour * (fColour.rgb * (uAmbient + uDiffuse * diffuse) + vec3(spec)), alpha);
165
+ }
166
+ else
167
+ //Final colour - diffuse + ambient only
168
+ calcColour(lightColour * fColour.rgb * (uAmbient + diffuse * uDiffuse), alpha);
169
+ }
170
+
@@ -0,0 +1,55 @@
1
+ in vec3 aVertexPosition;
2
+ in vec3 aVertexNormal;
3
+ in vec4 aVertexColour;
4
+ in vec2 aVertexTexCoord;
5
+ #ifndef WEBGL
6
+ flat out vec4 vFlatColour;
7
+ #endif
8
+
9
+ uniform mat4 uMVMatrix;
10
+ uniform mat4 uPMatrix;
11
+ uniform mat4 uNMatrix;
12
+
13
+ uniform vec4 uColour;
14
+ uniform vec4 uLightPos;
15
+
16
+ out vec4 vColour;
17
+ out vec3 vNormal;
18
+ out vec3 vPosEye;
19
+ out vec2 vTexCoord;
20
+ out vec3 vVertex;
21
+ out vec3 vLightPos;
22
+
23
+ void main(void)
24
+ {
25
+ vec4 mvPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
26
+ vPosEye = vec3(mvPosition) / mvPosition.w;
27
+ gl_Position = uPMatrix * mvPosition;
28
+
29
+ vNormal = normalize(mat3(uNMatrix) * aVertexNormal);
30
+
31
+ if (uColour.a > 0.0)
32
+ vColour = uColour;
33
+ else
34
+ vColour = aVertexColour;
35
+
36
+ vTexCoord = aVertexTexCoord;
37
+ #ifndef WEBGL
38
+ vFlatColour = vColour;
39
+ #endif
40
+ vVertex = aVertexPosition;
41
+
42
+ //Head light, lightPos=(0,0,0) - vPosEye
43
+ //vec3 lightDir = normalize(uLightPos.xyz - vPosEye);
44
+ if (uLightPos.w < 0.5)
45
+ {
46
+ //Light follows camera - default mode
47
+ vLightPos = uLightPos.xyz;
48
+ }
49
+ else
50
+ {
51
+ //Fixed Scene Light, when lightpos.w set to 1.0
52
+ vLightPos = (uMVMatrix * vec4(uLightPos.xyz, 1.0)).xyz;
53
+ }
54
+ }
55
+