@luma.gl/shadertools 9.1.0-alpha.15 → 9.1.0-alpha.17

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 (155) hide show
  1. package/dist/dist.dev.js +322 -389
  2. package/dist/dist.min.js +229 -336
  3. package/dist/index.cjs +321 -391
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -1
  8. package/dist/lib/shader-module/shader-module.d.ts +25 -15
  9. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  10. package/dist/lib/shader-module/shader-module.js +18 -4
  11. package/dist/lib/shader-module/shader-pass.d.ts +4 -2
  12. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  13. package/dist/lib/utils/uniform-types.d.ts +11 -0
  14. package/dist/lib/utils/uniform-types.d.ts.map +1 -0
  15. package/dist/lib/utils/uniform-types.js +1 -0
  16. package/dist/module-injectors.d.ts +1 -1
  17. package/dist/module-injectors.d.ts.map +1 -1
  18. package/dist/module-injectors.js +5 -5
  19. package/dist/modules/engine/picking/picking.d.ts +7 -7
  20. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  21. package/dist/modules/engine/picking/picking.js +2 -2
  22. package/dist/modules/engine/project/project.d.ts +9 -8
  23. package/dist/modules/engine/project/project.d.ts.map +1 -1
  24. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +3 -57
  25. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  26. package/dist/modules/lighting/gouraud-material/gouraud-material.js +9 -6
  27. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
  28. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  29. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +35 -12
  30. package/dist/modules/lighting/lights/lighting.d.ts +55 -29
  31. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  32. package/dist/modules/lighting/lights/lighting.js +47 -35
  33. package/dist/modules/lighting/no-material/dirlight.d.ts +3 -3
  34. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  35. package/dist/modules/lighting/no-material/dirlight.js +1 -1
  36. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
  37. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
  38. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +56 -60
  39. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +56 -98
  40. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  41. package/dist/modules/lighting/pbr-material/pbr-material.js +14 -22
  42. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
  43. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
  44. package/dist/modules/lighting/pbr-material/pbr-projection.js +24 -0
  45. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
  46. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
  47. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +8 -16
  48. package/dist/modules/lighting/phong-material/phong-material.d.ts +5 -59
  49. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  50. package/dist/modules/lighting/phong-material/phong-material.js +6 -4
  51. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -40
  52. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  53. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +8 -87
  54. package/dist/modules/module-injectors.d.ts +1 -1
  55. package/dist/modules/module-injectors.d.ts.map +1 -1
  56. package/dist/modules/module-injectors.js +5 -5
  57. package/dist/modules-webgl1/project/project.d.ts +6 -4
  58. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  59. package/dist/passes/postprocessing/fxaa/fxaa.d.ts +2 -2
  60. package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
  61. package/dist/passes/postprocessing/fxaa/fxaa.js +2 -2
  62. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +7 -4
  63. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
  64. package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +7 -4
  65. package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +1 -1
  66. package/dist/passes/postprocessing/image-adjust-filters/denoise.js +1 -1
  67. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +2 -3
  68. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
  69. package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +2 -3
  70. package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +2 -2
  71. package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
  72. package/dist/passes/postprocessing/image-adjust-filters/noise.js +2 -6
  73. package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +2 -2
  74. package/dist/passes/postprocessing/image-adjust-filters/sepia.js +2 -2
  75. package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +5 -2
  76. package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
  77. package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +5 -2
  78. package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +6 -2
  79. package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
  80. package/dist/passes/postprocessing/image-adjust-filters/vignette.js +6 -6
  81. package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +3 -3
  82. package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  83. package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +1 -1
  84. package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +2 -2
  85. package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  86. package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +1 -1
  87. package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +2 -2
  88. package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  89. package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +1 -1
  90. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +3 -3
  91. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  92. package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +2 -2
  93. package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +3 -3
  94. package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  95. package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +2 -2
  96. package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +16 -12
  97. package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
  98. package/dist/passes/postprocessing/image-fun-filters/edgework.js +25 -13
  99. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +2 -2
  100. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  101. package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +1 -1
  102. package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +1 -1
  103. package/dist/passes/postprocessing/image-fun-filters/ink.js +1 -1
  104. package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +3 -3
  105. package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  106. package/dist/passes/postprocessing/image-fun-filters/magnify.js +1 -1
  107. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +2 -2
  108. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  109. package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +1 -1
  110. package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +1 -1
  111. package/dist/passes/postprocessing/image-warp-filters/swirl.js +1 -1
  112. package/package.json +3 -3
  113. package/src/index.ts +9 -3
  114. package/src/lib/shader-module/shader-module.ts +51 -21
  115. package/src/lib/shader-module/shader-pass.ts +7 -4
  116. package/src/lib/utils/uniform-types.ts +66 -0
  117. package/src/module-injectors.ts +5 -5
  118. package/src/modules/engine/picking/README.md +9 -9
  119. package/src/modules/engine/picking/picking.ts +9 -9
  120. package/src/modules/engine/project/project.ts +10 -9
  121. package/src/modules/lighting/gouraud-material/gouraud-material.ts +14 -12
  122. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +35 -12
  123. package/src/modules/lighting/lights/lighting.ts +84 -54
  124. package/src/modules/lighting/no-material/dirlight.ts +3 -3
  125. package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +56 -60
  126. package/src/modules/lighting/pbr-material/pbr-material.ts +40 -74
  127. package/src/modules/lighting/pbr-material/pbr-projection.ts +39 -0
  128. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +8 -16
  129. package/src/modules/lighting/phong-material/phong-material.ts +12 -12
  130. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +8 -88
  131. package/src/modules/module-injectors.ts +5 -5
  132. package/src/modules-webgl1/project/project.ts +8 -7
  133. package/src/passes/postprocessing/fxaa/fxaa.ts +3 -3
  134. package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +7 -4
  135. package/src/passes/postprocessing/image-adjust-filters/denoise.ts +1 -1
  136. package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -3
  137. package/src/passes/postprocessing/image-adjust-filters/noise.ts +2 -6
  138. package/src/passes/postprocessing/image-adjust-filters/sepia.ts +2 -2
  139. package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +5 -2
  140. package/src/passes/postprocessing/image-adjust-filters/vignette.ts +6 -6
  141. package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +3 -3
  142. package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +2 -2
  143. package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +2 -2
  144. package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +3 -3
  145. package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +3 -3
  146. package/src/passes/postprocessing/image-fun-filters/edgework.ts +27 -16
  147. package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +2 -2
  148. package/src/passes/postprocessing/image-fun-filters/ink.ts +1 -1
  149. package/src/passes/postprocessing/image-fun-filters/magnify.ts +3 -3
  150. package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +2 -2
  151. package/src/passes/postprocessing/image-warp-filters/swirl.ts +1 -1
  152. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +0 -42
  153. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +0 -1
  154. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +0 -134
  155. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +0 -137
@@ -0,0 +1,24 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ const uniformBlock = /* glsl */ `\
5
+ uniform pbrProjectionUniforms {
6
+ mat4 modelViewProjectionMatrix;
7
+ mat4 modelMatrix;
8
+ mat4 normalMatrix;
9
+ vec3 camera;
10
+ } pbrProjection;
11
+ `;
12
+ export const pbrProjection = {
13
+ name: 'pbrProjection',
14
+ vs: uniformBlock,
15
+ fs: uniformBlock,
16
+ // TODO why is this needed?
17
+ getUniforms: props => props,
18
+ uniformTypes: {
19
+ modelViewProjectionMatrix: 'mat4x4<f32>',
20
+ modelMatrix: 'mat4x4<f32>',
21
+ normalMatrix: 'mat4x4<f32>',
22
+ camera: 'vec3<i32>'
23
+ }
24
+ };
@@ -1,2 +1,2 @@
1
- export declare const vs = "uniform projection {\n mat4 u_MVPMatrix;\n mat4 u_ModelMatrix;\n mat4 u_NormalMatrix;\n // Projection\n vec3 u_Camera;\n}\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
1
+ export declare const vs = "out vec3 pbr_vPosition;\nout vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = pbrProjection.modelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
2
2
  //# sourceMappingURL=pbr-vertex-glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pbr-vertex-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-vertex-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,EAAE,q9BA0Cd,CAAC"}
1
+ {"version":3,"file":"pbr-vertex-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-vertex-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,EAAE,m3BAkCd,CAAC"}
@@ -2,38 +2,30 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  export const vs = /* glsl */ `\
5
- uniform projection {
6
- mat4 u_MVPMatrix;
7
- mat4 u_ModelMatrix;
8
- mat4 u_NormalMatrix;
9
- // Projection
10
- vec3 u_Camera;
11
- }
12
-
13
- varying vec3 pbr_vPosition;
14
- varying vec2 pbr_vUV;
5
+ out vec3 pbr_vPosition;
6
+ out vec2 pbr_vUV;
15
7
 
16
8
  #ifdef HAS_NORMALS
17
9
  # ifdef HAS_TANGENTS
18
- varying mat3 pbr_vTBN;
10
+ out mat3 pbr_vTBN;
19
11
  # else
20
- varying vec3 pbr_vNormal;
12
+ out vec3 pbr_vNormal;
21
13
  # endif
22
14
  #endif
23
15
 
24
16
  void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
25
17
  {
26
- vec4 pos = u_ModelMatrix * position;
18
+ vec4 pos = pbrProjection.modelMatrix * position;
27
19
  pbr_vPosition = vec3(pos.xyz) / pos.w;
28
20
 
29
21
  #ifdef HAS_NORMALS
30
22
  #ifdef HAS_TANGENTS
31
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
32
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
23
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
24
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
33
25
  vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
34
26
  pbr_vTBN = mat3(tangentW, bitangentW, normalW);
35
27
  #else // HAS_TANGENTS != 1
36
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
28
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
37
29
  #endif
38
30
  #endif
39
31
 
@@ -1,66 +1,12 @@
1
- export type PhongMaterialProps = PhongMaterialUniforms;
2
- export type PhongMaterialUniforms = {
1
+ import { NumberArray3 } from '@math.gl/types';
2
+ import { ShaderModule } from "../../../lib/shader-module/shader-module.js";
3
+ export type PhongMaterialProps = {
3
4
  ambient?: number;
4
5
  diffuse?: number;
5
6
  /** Specularity exponent */
6
7
  shininess?: number;
7
- specularColor?: [number, number, number];
8
+ specularColor?: NumberArray3;
8
9
  };
9
10
  /** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
10
- export declare const phongMaterial: {
11
- readonly props: PhongMaterialProps;
12
- readonly uniforms: PhongMaterialUniforms;
13
- readonly name: "phong-lighting";
14
- readonly dependencies: [{
15
- readonly props: import("../lights/lighting").LightingProps;
16
- readonly uniforms: import("../lights/lighting").LightingUniforms;
17
- readonly name: "lighting";
18
- readonly defines: {
19
- readonly MAX_LIGHTS: 5;
20
- };
21
- readonly uniformTypes: {
22
- readonly enabled: "i32";
23
- readonly ambientLightColor: "vec3<f32>";
24
- readonly numberOfLights: "i32";
25
- readonly lightType: "i32";
26
- readonly lightColor: "vec3<f32>";
27
- readonly lightPosition: "vec3<f32>";
28
- readonly lightDirection: "vec3<f32>";
29
- readonly lightAttenuation: "vec3<f32>";
30
- };
31
- readonly defaultUniforms: {
32
- readonly enabled: 1;
33
- readonly ambientLightColor: readonly [0.1, 0.1, 0.1];
34
- readonly numberOfLights: 0;
35
- readonly lightType: import("../lights/lighting").LIGHT_TYPE.POINT;
36
- readonly lightColor: readonly [1, 1, 1];
37
- readonly lightPosition: readonly [1, 1, 2];
38
- readonly lightDirection: readonly [1, 1, 1];
39
- readonly lightAttenuation: readonly [1, 1, 1];
40
- };
41
- readonly source: "// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n poightCount: i32,\n directionalLightCount: i32,\n\n ambientColor: vec3<f32>,\n\n // TODO - support multiple lights by uncommenting arrays below\n lightType: i32,\n lightColor: vec3<f32>,\n lightDirection: vec3<f32>,\n lightPosition: vec3<f32>,\n lightAttenuation: vec3<f32>,\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n};\n\n// Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)\n@binding(1) @group(0) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n";
42
- readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
43
- readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
44
- readonly getUniforms: (props?: import("../lights/lighting").LightingProps, prevUniforms?: Partial<import("../lights/lighting").LightingUniforms>) => import("../lights/lighting").LightingUniforms;
45
- }];
46
- readonly source: "struct phongMaterialUniforms {\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@binding(2) @group(0) var<uniform> material : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n let pointLight: PointLight = lighting_getPointLight(0);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n var directionalLight: DirectionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled == 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0, default: {\n let pointLight: PointLight = lighting_getPointLight(0);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n case 1: {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n }\n return lightColor;\n}\n";
47
- readonly vs: "uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
48
- readonly fs: "uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting.enabled == 0) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0:\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n break;\n\n case 1:\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n break;\n }\n }\n return lightColor;\n}\n";
49
- readonly defines: {
50
- readonly LIGHTING_FRAGMENT: 1;
51
- };
52
- readonly uniformTypes: {
53
- readonly ambient: "f32";
54
- readonly diffuse: "f32";
55
- readonly shininess: "f32";
56
- readonly specularColor: "vec3<f32>";
57
- };
58
- readonly defaultUniforms: {
59
- readonly ambient: 0.35;
60
- readonly diffuse: 0.6;
61
- readonly shininess: 32;
62
- readonly specularColor: [0.15, 0.15, 0.15];
63
- };
64
- readonly getUniforms: (props?: PhongMaterialProps) => PhongMaterialUniforms;
65
- };
11
+ export declare const phongMaterial: ShaderModule<PhongMaterialProps>;
66
12
  //# sourceMappingURL=phong-material.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,aAAa;oBACX,kBAAkB;uBACf,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAuBjB,kBAAkB,KAAG,qBAAqB;CAGY,CAAC"}
1
+ {"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAKtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CA6B1D,CAAC"}
@@ -6,9 +6,7 @@ import { PHONG_WGSL } from "./phong-shaders-wgsl.js";
6
6
  import { PHONG_VS, PHONG_FS } from "./phong-shaders-glsl.js";
7
7
  /** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
8
8
  export const phongMaterial = {
9
- props: {},
10
- uniforms: {},
11
- name: 'phong-lighting',
9
+ name: 'phongMaterial',
12
10
  dependencies: [lighting],
13
11
  // Note these are switched between phong and gouraud
14
12
  source: PHONG_WGSL,
@@ -30,6 +28,10 @@ export const phongMaterial = {
30
28
  specularColor: [0.15, 0.15, 0.15]
31
29
  },
32
30
  getUniforms(props) {
33
- return { ...phongMaterial.defaultUniforms, ...props };
31
+ const uniforms = { ...props };
32
+ if (uniforms.specularColor) {
33
+ uniforms.specularColor = uniforms.specularColor.map(x => x / 255);
34
+ }
35
+ return { ...phongMaterial.defaultUniforms, ...uniforms };
34
36
  }
35
37
  };
@@ -1,42 +1,3 @@
1
1
  export declare const PHONG_VS = "uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
2
- export declare const PHONG_FS = "uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting.enabled == 0) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0:\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n break;\n\n case 1:\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n break;\n }\n }\n return lightColor;\n}\n";
3
- /**
4
- for (int i = 0; i < MAX_LIGHTS; i++) {
5
- if (i >= lighting.pointLightCount) {
6
- break;
7
- }
8
- PointLight pointLight = lighting_getPointLight(i);
9
- vec3 light_position_worldspace = pointLight.position;
10
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
11
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
12
- }
13
-
14
- for (int i = 0; i < MAX_LIGHTS; i++) {
15
- if (i >= lighting.directionalLightCount) {
16
- break;
17
- }
18
- PointLight pointLight = lighting_getDirectionalLight(i);
19
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
20
- }
21
- }
22
- /**
23
- for (int i = 0; i < MAX_LIGHTS; i++) {
24
- if (i >= lighting.pointLightCount) {
25
- break;
26
- }
27
- PointLight pointLight = lighting_getPointLight(i);
28
- vec3 light_position_worldspace = pointLight.position;
29
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
30
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
31
- }
32
-
33
- for (int i = 0; i < MAX_LIGHTS; i++) {
34
- if (i >= lighting.directionalLightCount) {
35
- break;
36
- }
37
- PointLight pointLight = lighting_getDirectionalLight(i);
38
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
39
- }
40
- }
41
- */
2
+ export declare const PHONG_FS = "uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);\n for (int i = lighting.pointLightCount; i < totalLights; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n";
42
3
  //# sourceMappingURL=phong-shaders-glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,mKAOpB,CAAC;AAEF,eAAO,MAAM,QAAQ,ogHAqFpB,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsCI"}
1
+ {"version":3,"file":"phong-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,mKAOpB,CAAC;AAEF,eAAO,MAAM,QAAQ,gjEA8CpB,CAAC"}
@@ -39,99 +39,20 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
39
39
  vec3 view_direction = normalize(cameraPosition - position_worldspace);
40
40
  lightColor = material.ambient * surfaceColor * lighting.ambientColor;
41
41
 
42
- if (lighting.lightType == 0) {
43
- PointLight pointLight = lighting_getPointLight(0);
42
+ for (int i = 0; i < lighting.pointLightCount; i++) {
43
+ PointLight pointLight = lighting_getPointLight(i);
44
44
  vec3 light_position_worldspace = pointLight.position;
45
45
  vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
46
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
47
- } else if (lighting.lightType == 1) {
48
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
49
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
50
- }
51
-
52
- /*
53
- for (int i = 0; i < MAX_LIGHTS; i++) {
54
- if (i >= lighting.pointLightCount) {
55
- break;
56
- }
57
- PointLight pointLight = lighting.pointLight[i];
58
- vec3 light_position_worldspace = pointLight.position;
59
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
60
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
46
+ float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
47
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
61
48
  }
62
49
 
63
- for (int i = 0; i < MAX_LIGHTS; i++) {
64
- if (i >= lighting.directionalLightCount) {
65
- break;
66
- }
67
- DirectionalLight directionalLight = lighting.directionalLight[i];
50
+ int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
51
+ for (int i = lighting.pointLightCount; i < totalLights; i++) {
52
+ DirectionalLight directionalLight = lighting_getDirectionalLight(i);
68
53
  lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
69
54
  }
70
- */
71
- return lightColor;
72
- }
73
-
74
- vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
75
- vec3 lightColor = vec3(0, 0, 0);
76
- vec3 surfaceColor = vec3(0, 0, 0);
77
-
78
- if (lighting.enabled == 0) {
79
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
80
-
81
- switch (lighting.lightType) {
82
- case 0:
83
- PointLight pointLight = lighting_getPointLight(0);
84
- vec3 light_position_worldspace = pointLight.position;
85
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
86
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
87
- break;
88
-
89
- case 1:
90
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
91
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
92
- break;
93
- }
94
- }
55
+
95
56
  return lightColor;
96
57
  }
97
58
  `;
98
- // TODO - handle multiple lights
99
- /**
100
- for (int i = 0; i < MAX_LIGHTS; i++) {
101
- if (i >= lighting.pointLightCount) {
102
- break;
103
- }
104
- PointLight pointLight = lighting_getPointLight(i);
105
- vec3 light_position_worldspace = pointLight.position;
106
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
107
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
108
- }
109
-
110
- for (int i = 0; i < MAX_LIGHTS; i++) {
111
- if (i >= lighting.directionalLightCount) {
112
- break;
113
- }
114
- PointLight pointLight = lighting_getDirectionalLight(i);
115
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
116
- }
117
- }
118
- /**
119
- for (int i = 0; i < MAX_LIGHTS; i++) {
120
- if (i >= lighting.pointLightCount) {
121
- break;
122
- }
123
- PointLight pointLight = lighting_getPointLight(i);
124
- vec3 light_position_worldspace = pointLight.position;
125
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
126
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
127
- }
128
-
129
- for (int i = 0; i < MAX_LIGHTS; i++) {
130
- if (i >= lighting.directionalLightCount) {
131
- break;
132
- }
133
- PointLight pointLight = lighting_getDirectionalLight(i);
134
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
135
- }
136
- }
137
- */
@@ -1,3 +1,3 @@
1
1
  export declare const MODULE_INJECTORS_VS = "#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n";
2
- export declare const MODULE_INJECTORS_FS = "#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n";
2
+ export declare const MODULE_INJECTORS_FS = "#ifdef MODULE_MATERIAL\n fragColor = material_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n fragColor = lighting_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_FOG\n fragColor = fog_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_PICKING\n fragColor = picking_filterHighlightColor(fragColor);\n fragColor = picking_filterPickingColor(fragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n";
3
3
  //# sourceMappingURL=module-injectors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module-injectors.d.ts","sourceRoot":"","sources":["../../src/modules/module-injectors.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,8EAI/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,0dAqB/B,CAAC"}
1
+ {"version":3,"file":"module-injectors.d.ts","sourceRoot":"","sources":["../../src/modules/module-injectors.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,8EAI/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,4bAqB/B,CAAC"}
@@ -8,20 +8,20 @@ export const MODULE_INJECTORS_VS = /* glsl */ `\
8
8
  `;
9
9
  export const MODULE_INJECTORS_FS = /* glsl */ `\
10
10
  #ifdef MODULE_MATERIAL
11
- gl_FragColor = material_filterColor(gl_FragColor);
11
+ fragColor = material_filterColor(fragColor);
12
12
  #endif
13
13
 
14
14
  #ifdef MODULE_LIGHTING
15
- gl_FragColor = lighting_filterColor(gl_FragColor);
15
+ fragColor = lighting_filterColor(fragColor);
16
16
  #endif
17
17
 
18
18
  #ifdef MODULE_FOG
19
- gl_FragColor = fog_filterColor(gl_FragColor);
19
+ fragColor = fog_filterColor(fragColor);
20
20
  #endif
21
21
 
22
22
  #ifdef MODULE_PICKING
23
- gl_FragColor = picking_filterHighlightColor(gl_FragColor);
24
- gl_FragColor = picking_filterPickingColor(gl_FragColor);
23
+ fragColor = picking_filterHighlightColor(fragColor);
24
+ fragColor = picking_filterPickingColor(fragColor);
25
25
  #endif
26
26
 
27
27
  #ifdef MODULE_LOGDEPTH
@@ -1,8 +1,10 @@
1
+ import { Vector3, Matrix4 } from '@math.gl/core';
2
+ import type { NumberArray3, NumberArray16 } from '@math.gl/core';
1
3
  type ProjectionProps = {
2
- modelMatrix?: readonly number[];
3
- viewMatrix?: readonly number[];
4
- projectionMatrix?: readonly number[];
5
- cameraPositionWorld?: readonly number[];
4
+ modelMatrix?: Readonly<Matrix4 | NumberArray16>;
5
+ viewMatrix?: Readonly<Matrix4 | NumberArray16>;
6
+ projectionMatrix?: Readonly<Matrix4 | NumberArray16>;
7
+ cameraPositionWorld?: Readonly<Vector3 | NumberArray3>;
6
8
  };
7
9
  declare function getUniforms(opts?: ProjectionProps, prevUniforms?: {}): Record<string, any>;
8
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/project/project.ts"],"names":[],"mappings":"AAOA,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAWF,iBAAS,WAAW,CAAC,IAAI,GAAE,eAAwC,EAAE,YAAY,KAAK,uBA2BrF;AA2ED;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;CAK+C,CAAC"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAE/D,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;CACxD,CAAC;AAWF,iBAAS,WAAW,CAAC,IAAI,GAAE,eAAwC,EAAE,YAAY,KAAK,uBA2BrF;AA2ED;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;CAK+C,CAAC"}
@@ -5,11 +5,11 @@ export type FXAAUniforms = {};
5
5
  */
6
6
  export declare const fxaa: {
7
7
  readonly name: "fxaa";
8
- readonly uniformPropTypes: {};
8
+ readonly propTypes: {};
9
9
  readonly fs: "\n#define FXAA_QUALITY_PRESET 29\n\n#if (FXAA_QUALITY_PRESET == 10)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 3.0\n #define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 3.0\n #define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 4.0\n #define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 4.0\n #define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 4.0\n #define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 2.0\n #define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 3.0\n #define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n #define FXAA_QUALITY_PS 9\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 4.0\n #define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n #define FXAA_QUALITY_PS 10\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 4.0\n #define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n #define FXAA_QUALITY_PS 11\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 4.0\n #define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.0\n #define FXAA_QUALITY_P2 1.0\n #define FXAA_QUALITY_P3 1.0\n #define FXAA_QUALITY_P4 1.0\n #define FXAA_QUALITY_P5 1.5\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n\n#define FxaaBool bool\n#define FxaaFloat float\n#define FxaaFloat2 vec2\n#define FxaaFloat3 vec3\n#define FxaaFloat4 vec4\n#define FxaaHalf float\n#define FxaaHalf2 vec2\n#define FxaaHalf3 vec3\n#define FxaaHalf4 vec4\n#define FxaaInt2 vec2\n#define FxaaTex sampler2D\n\n#define FxaaSat(x) clamp(x, 0.0, 1.0)\n#define FxaaTexTop(t, p) texture(t, p)\n#define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))\n\nFxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }\n\nFxaaFloat4 FxaaPixelShader_(\n //\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Input color texture.\n // {rgb_} = color in linear or perceptual color space\n // if (FXAA_GREEN_AS_LUMA == 0)\n // {___a} = luma in perceptual color space (not linear)\n FxaaTex tex,\n //\n // Only used on FXAA Quality.\n // This must be from a constant/uniform.\n // {x_} = 1.0/screenWidthInPixels\n // {_y} = 1.0/screenHeightInPixels\n FxaaFloat2 fxaaQualityRcpFrame,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_SUBPIX define.\n // It is here now to allow easier tuning.\n // Choose the amount of sub-pixel aliasing removal.\n // This can effect sharpness.\n // 1.00 - upper limit (softer)\n // 0.75 - default amount of filtering\n // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n // 0.25 - almost off\n // 0.00 - completely off\n FxaaFloat fxaaQualitySubpix,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // The minimum amount of local contrast required to apply algorithm.\n // 0.333 - too little (faster)\n // 0.250 - low quality\n // 0.166 - default\n // 0.125 - high quality\n // 0.063 - overkill (slower)\n FxaaFloat fxaaQualityEdgeThreshold,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // 0.0833 - upper limit (default, the start of visible unfiltered edges)\n // 0.0625 - high quality (faster)\n // 0.0312 - visible limit (slower)\n // Special notes when using FXAA_GREEN_AS_LUMA,\n // Likely want to set this to zero.\n // As colors that are mostly not-green\n // will appear very dark in the green channel!\n // Tune by looking at mostly non-green content,\n // then start at zero and increase until aliasing is a problem.\n FxaaFloat fxaaQualityEdgeThresholdMin\n) {\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #define lumaM rgbyM.y\n FxaaFloat lumaS = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat maxSM = max(lumaS, lumaM);\n FxaaFloat minSM = min(lumaS, lumaM);\n FxaaFloat maxESM = max(lumaE, maxSM);\n FxaaFloat minESM = min(lumaE, minSM);\n FxaaFloat maxWN = max(lumaN, lumaW);\n FxaaFloat minWN = min(lumaN, lumaW);\n FxaaFloat rangeMax = max(maxWN, maxESM);\n FxaaFloat rangeMin = min(minWN, minESM);\n FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n FxaaFloat range = rangeMax - rangeMin;\n FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n FxaaBool earlyExit = range < rangeMaxClamped;\n/*--------------------------------------------------------------------------*/\n if(earlyExit)\n return rgbyM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNS = lumaN + lumaS;\n FxaaFloat lumaWE = lumaW + lumaE;\n FxaaFloat subpixRcpRange = 1.0/range;\n FxaaFloat subpixNSWE = lumaNS + lumaWE;\n FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNESE = lumaNE + lumaSE;\n FxaaFloat lumaNWNE = lumaNW + lumaNE;\n FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNWSW = lumaNW + lumaSW;\n FxaaFloat lumaSWSE = lumaSW + lumaSE;\n FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n/*--------------------------------------------------------------------------*/\n FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n FxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n FxaaBool horzSpan = edgeHorz >= edgeVert;\n FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n/*--------------------------------------------------------------------------*/\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat gradientN = lumaN - lumaM;\n FxaaFloat gradientS = lumaS - lumaM;\n FxaaFloat lumaNN = lumaN + lumaM;\n FxaaFloat lumaSS = lumaS + lumaM;\n FxaaBool pairN = abs(gradientN) >= abs(gradientS);\n FxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n FxaaFloat2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posN;\n posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n FxaaFloat2 posP;\n posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n FxaaFloat lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN));\n FxaaFloat subpixE = subpixC * subpixC;\n FxaaFloat lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP));\n/*--------------------------------------------------------------------------*/\n if(!pairN) lumaNN = lumaSS;\n FxaaFloat gradientScaled = gradient * 1.0/4.0;\n FxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n FxaaFloat subpixF = subpixD * subpixE;\n FxaaBool lumaMLTZero = lumaMM < 0.0;\n/*--------------------------------------------------------------------------*/\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n FxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n FxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n FxaaBool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n/*--------------------------------------------------------------------------*/\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 3)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 4)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 5)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 6)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 7)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 8)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 9)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 10)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 11)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 12)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n/*--------------------------------------------------------------------------*/\n FxaaFloat dstN = posM.x - posN.x;\n FxaaFloat dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n/*--------------------------------------------------------------------------*/\n FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n FxaaFloat spanLength = (dstP + dstN);\n FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n FxaaFloat spanLengthRcp = 1.0/spanLength;\n/*--------------------------------------------------------------------------*/\n FxaaBool directionN = dstN < dstP;\n FxaaFloat dst = min(dstN, dstP);\n FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n FxaaFloat subpixG = subpixF * subpixF;\n FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n FxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n/*--------------------------------------------------------------------------*/\n FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n return FxaaTexTop(tex, posM);\n}\n\nvec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n const float fxaa_QualitySubpix = 0.5;\n const float fxaa_QualityEdgeThreshold = 0.125;\n const float fxaa_QualityEdgeThresholdMin = 0.0833;\n\n return FxaaPixelShader_(\n texCoord,\n source,\n vec2(1.0) / texSize,\n fxaa_QualitySubpix,\n fxaa_QualityEdgeThreshold,\n fxaa_QualityEdgeThresholdMin\n );\n}\n";
10
10
  readonly passes: [{
11
11
  readonly sampler: true;
12
12
  }];
13
- readonly getUniforms: (props: any) => any;
13
+ readonly getUniforms: (props: Partial<FXAAProps>) => Partial<FXAAProps>;
14
14
  };
15
15
  //# sourceMappingURL=fxaa.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fxaa.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/fxaa/fxaa.ts"],"names":[],"mappings":"AAyqBA,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAC3B,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;CAMuC,CAAC"}
1
+ {"version":3,"file":"fxaa.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/fxaa/fxaa.ts"],"names":[],"mappings":"AAyqBA,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAC3B,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;CAM2C,CAAC"}
@@ -91,7 +91,7 @@
91
91
  // _ = the lowest digit is directly related to performance
92
92
  // _ = the highest digit is directly related to style
93
93
  //
94
- const fs = `
94
+ const fs = /* glsl */ `
95
95
  #define FXAA_QUALITY_PRESET 29
96
96
 
97
97
  #if (FXAA_QUALITY_PRESET == 10)
@@ -677,7 +677,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
677
677
  */
678
678
  export const fxaa = {
679
679
  name: 'fxaa',
680
- uniformPropTypes: {},
680
+ propTypes: {},
681
681
  fs,
682
682
  passes: [{ sampler: true }],
683
683
  getUniforms: props => props
@@ -11,13 +11,16 @@ export type BrightnessContrastUniforms = BrightnessContrastProps;
11
11
  */
12
12
  export declare const brightnessContrast: {
13
13
  readonly props: BrightnessContrastProps;
14
- readonly uniforms: BrightnessContrastUniforms;
15
14
  readonly name: "brightnessContrast";
16
15
  readonly uniformTypes: {
17
16
  readonly brightness: "f32";
18
17
  readonly contrast: "f32";
19
18
  };
20
- readonly uniformPropTypes: {
19
+ readonly defaultUniforms: {
20
+ readonly brightness: 0;
21
+ readonly contrast: 0;
22
+ };
23
+ readonly propTypes: {
21
24
  readonly brightness: {
22
25
  readonly format: "f32";
23
26
  readonly value: 0;
@@ -34,7 +37,7 @@ export declare const brightnessContrast: {
34
37
  readonly passes: [{
35
38
  readonly filter: true;
36
39
  }];
37
- readonly source: "struct brightnessContrastUniforms {\n float brightness;\n float contrast;\n};\n\n// Binding 0:1 is reserved for shader passes\n@binding(1) @group(0) var<uniform> brightnessContrast : brightnessContrastUniforms;\n\nfn brightnessContrast_filterColor(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {\n color.rgb += brightnessContrast.brightness;\n if (brightnessContrast.contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;\n }\n return color;\n}\n";
38
- readonly fs: "uniform brightnessContrastUniforms {\n float brightness;\n float contrast;\n} brightnessContrast;\n\nvec4 brightnessContrast_filterColor(vec4 color) {\n color.rgb += brightnessContrast.brightness;\n if (brightnessContrast.contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;\n }\n return color;\n}\n\nvec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {\n return brightnessContrast_filterColor(color);\n}\n";
40
+ readonly source: "struct brightnessContrastUniforms {\n float brightness;\n float contrast;\n};\n\n// Binding 0:1 is reserved for shader passes\n@binding(1) @group(0) var<uniform> brightnessContrast : brightnessContrastUniforms;\n\nfn brightnessContrast_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {\n color.rgb += brightnessContrast.brightness;\n if (brightnessContrast.contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;\n }\n return color;\n}\n";
41
+ readonly fs: "uniform brightnessContrastUniforms {\n float brightness;\n float contrast;\n} brightnessContrast;\n\nvec4 brightnessContrast_filterColor(vec4 color) {\n color.rgb += brightnessContrast.brightness;\n if (brightnessContrast.contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;\n }\n return color;\n}\n\nvec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return brightnessContrast_filterColor(color);\n}\n";
39
42
  };
40
43
  //# sourceMappingURL=brightnesscontrast.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brightnesscontrast.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts"],"names":[],"mappings":"AA+CA,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;oBAChB,uBAAuB;uBACpB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;CAeY,CAAC"}
1
+ {"version":3,"file":"brightnesscontrast.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts"],"names":[],"mappings":"AA+CA,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;oBAChB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBkB,CAAC"}
@@ -10,7 +10,7 @@ struct brightnessContrastUniforms {
10
10
  // Binding 0:1 is reserved for shader passes
11
11
  @binding(1) @group(0) var<uniform> brightnessContrast : brightnessContrastUniforms;
12
12
 
13
- fn brightnessContrast_filterColor(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {
13
+ fn brightnessContrast_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4<f32> {
14
14
  color.rgb += brightnessContrast.brightness;
15
15
  if (brightnessContrast.contrast > 0.0) {
16
16
  color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
@@ -36,7 +36,7 @@ vec4 brightnessContrast_filterColor(vec4 color) {
36
36
  return color;
37
37
  }
38
38
 
39
- vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
39
+ vec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
40
40
  return brightnessContrast_filterColor(color);
41
41
  }
42
42
  `;
@@ -48,13 +48,16 @@ vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
48
48
  */
49
49
  export const brightnessContrast = {
50
50
  props: {},
51
- uniforms: {},
52
51
  name: 'brightnessContrast',
53
52
  uniformTypes: {
54
53
  brightness: 'f32',
55
54
  contrast: 'f32'
56
55
  },
57
- uniformPropTypes: {
56
+ defaultUniforms: {
57
+ brightness: 0,
58
+ contrast: 0
59
+ },
60
+ propTypes: {
58
61
  brightness: { format: 'f32', value: 0, min: -1, max: 1 },
59
62
  contrast: { format: 'f32', value: 0, min: -1, max: 1 }
60
63
  },