three-stdlib 2.8.11 → 2.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. package/index.cjs.js +1 -1
  2. package/index.d.ts +1 -52
  3. package/index.js +52 -52
  4. package/lines/LineMaterial.d.ts +7 -6
  5. package/modifiers/CurveModifier.cjs.js +1 -1
  6. package/modifiers/CurveModifier.d.ts +13 -9
  7. package/modifiers/CurveModifier.js +27 -30
  8. package/objects/Lensflare.cjs.js +1 -1
  9. package/objects/Lensflare.js +11 -3
  10. package/package.json +2 -2
  11. package/postprocessing/AfterimagePass.d.ts +2 -30
  12. package/shaders/ACESFilmicToneMappingShader.cjs.js +1 -1
  13. package/shaders/ACESFilmicToneMappingShader.d.ts +9 -0
  14. package/shaders/ACESFilmicToneMappingShader.js +1 -1
  15. package/shaders/AfterimageShader.d.ts +9 -15
  16. package/shaders/BasicShader.cjs.js +1 -1
  17. package/shaders/BasicShader.d.ts +5 -5
  18. package/shaders/BasicShader.js +1 -1
  19. package/shaders/BleachBypassShader.cjs.js +1 -1
  20. package/shaders/BleachBypassShader.d.ts +8 -9
  21. package/shaders/BleachBypassShader.js +1 -1
  22. package/shaders/BlendShader.cjs.js +1 -1
  23. package/shaders/BlendShader.d.ts +13 -7
  24. package/shaders/BlendShader.js +1 -1
  25. package/shaders/BokehShader.cjs.js +1 -1
  26. package/shaders/BokehShader.d.ts +18 -19
  27. package/shaders/BokehShader.js +1 -1
  28. package/shaders/BokehShader2.cjs.js +1 -1
  29. package/shaders/BokehShader2.d.ts +80 -34
  30. package/shaders/BokehShader2.js +2 -2
  31. package/shaders/BrightnessContrastShader.cjs.js +1 -1
  32. package/shaders/BrightnessContrastShader.d.ts +10 -6
  33. package/shaders/BrightnessContrastShader.js +1 -1
  34. package/shaders/ColorCorrectionShader.cjs.js +1 -1
  35. package/shaders/ColorCorrectionShader.d.ts +14 -7
  36. package/shaders/ColorCorrectionShader.js +1 -1
  37. package/shaders/ColorifyShader.cjs.js +1 -1
  38. package/shaders/ColorifyShader.d.ts +8 -5
  39. package/shaders/ColorifyShader.js +1 -1
  40. package/shaders/ConvolutionShader.cjs.js +1 -1
  41. package/shaders/ConvolutionShader.d.ts +15 -16
  42. package/shaders/ConvolutionShader.js +9 -14
  43. package/shaders/CopyShader.d.ts +8 -12
  44. package/shaders/DOFMipMapShader.cjs.js +1 -1
  45. package/shaders/DOFMipMapShader.d.ts +13 -7
  46. package/shaders/DOFMipMapShader.js +1 -1
  47. package/shaders/DepthLimitedBlurShader.cjs.js +1 -1
  48. package/shaders/DepthLimitedBlurShader.d.ts +26 -25
  49. package/shaders/DepthLimitedBlurShader.js +12 -16
  50. package/shaders/DigitalGlitch.cjs.js +1 -1
  51. package/shaders/DigitalGlitch.d.ts +34 -14
  52. package/shaders/DigitalGlitch.js +1 -10
  53. package/shaders/DotScreenShader.cjs.js +1 -1
  54. package/shaders/DotScreenShader.d.ts +17 -8
  55. package/shaders/DotScreenShader.js +1 -1
  56. package/shaders/FXAAShader.cjs.js +1 -1
  57. package/shaders/FXAAShader.d.ts +8 -5
  58. package/shaders/FXAAShader.js +1 -1
  59. package/shaders/FilmShader.cjs.js +1 -1
  60. package/shaders/FilmShader.d.ts +19 -9
  61. package/shaders/FilmShader.js +1 -1
  62. package/shaders/FocusShader.cjs.js +1 -1
  63. package/shaders/FocusShader.d.ts +16 -8
  64. package/shaders/FocusShader.js +1 -1
  65. package/shaders/FreiChenShader.cjs.js +1 -1
  66. package/shaders/FreiChenShader.d.ts +8 -5
  67. package/shaders/FreiChenShader.js +1 -1
  68. package/shaders/FresnelShader.cjs.js +1 -1
  69. package/shaders/FresnelShader.d.ts +21 -0
  70. package/shaders/FresnelShader.js +1 -1
  71. package/shaders/GammaCorrectionShader.d.ts +7 -7
  72. package/shaders/GodRaysShader.cjs.js +1 -1
  73. package/shaders/GodRaysShader.d.ts +38 -20
  74. package/shaders/GodRaysShader.js +4 -4
  75. package/shaders/HalftoneShader.cjs.js +1 -1
  76. package/shaders/HalftoneShader.d.ts +40 -16
  77. package/shaders/HalftoneShader.js +1 -1
  78. package/shaders/HorizontalBlurShader.d.ts +8 -8
  79. package/shaders/HorizontalTiltShiftShader.cjs.js +1 -1
  80. package/shaders/HorizontalTiltShiftShader.d.ts +10 -6
  81. package/shaders/HorizontalTiltShiftShader.js +1 -1
  82. package/shaders/HueSaturationShader.cjs.js +1 -1
  83. package/shaders/HueSaturationShader.d.ts +10 -6
  84. package/shaders/HueSaturationShader.js +1 -1
  85. package/shaders/KaleidoShader.cjs.js +1 -1
  86. package/shaders/KaleidoShader.d.ts +10 -6
  87. package/shaders/KaleidoShader.js +1 -1
  88. package/shaders/LuminosityHighPassShader.cjs.js +1 -1
  89. package/shaders/LuminosityHighPassShader.d.ts +17 -8
  90. package/shaders/LuminosityHighPassShader.js +1 -1
  91. package/shaders/LuminosityShader.cjs.js +1 -1
  92. package/shaders/LuminosityShader.d.ts +4 -4
  93. package/shaders/LuminosityShader.js +1 -1
  94. package/shaders/MirrorShader.cjs.js +1 -1
  95. package/shaders/MirrorShader.d.ts +7 -5
  96. package/shaders/MirrorShader.js +1 -1
  97. package/shaders/NormalMapShader.cjs.js +1 -1
  98. package/shaders/NormalMapShader.d.ts +14 -7
  99. package/shaders/NormalMapShader.js +1 -1
  100. package/shaders/ParallaxShader.cjs.js +1 -1
  101. package/shaders/ParallaxShader.d.ts +28 -0
  102. package/shaders/ParallaxShader.js +1 -1
  103. package/shaders/PixelShader.cjs.js +1 -1
  104. package/shaders/PixelShader.d.ts +10 -6
  105. package/shaders/PixelShader.js +1 -1
  106. package/shaders/RGBShiftShader.cjs.js +1 -1
  107. package/shaders/RGBShiftShader.d.ts +10 -6
  108. package/shaders/RGBShiftShader.js +1 -1
  109. package/shaders/SAOShader.cjs.js +1 -1
  110. package/shaders/SAOShader.d.ts +24 -29
  111. package/shaders/SAOShader.js +1 -5
  112. package/shaders/SMAAShader.cjs.js +1 -1
  113. package/shaders/SMAAShader.d.ts +31 -16
  114. package/shaders/SMAAShader.js +3 -3
  115. package/shaders/SSAOShader.cjs.js +1 -1
  116. package/shaders/SSAOShader.d.ts +58 -25
  117. package/shaders/SSAOShader.js +3 -3
  118. package/shaders/SSRShader.cjs.js +1 -1
  119. package/shaders/SSRShader.d.ts +67 -36
  120. package/shaders/SSRShader.js +3 -3
  121. package/shaders/SepiaShader.cjs.js +1 -1
  122. package/shaders/SepiaShader.d.ts +7 -5
  123. package/shaders/SepiaShader.js +1 -1
  124. package/shaders/SobelOperatorShader.cjs.js +1 -1
  125. package/shaders/SobelOperatorShader.d.ts +8 -5
  126. package/shaders/SobelOperatorShader.js +1 -1
  127. package/shaders/SubsurfaceScatteringShader.cjs.js +1 -1
  128. package/shaders/SubsurfaceScatteringShader.d.ts +2 -34
  129. package/shaders/SubsurfaceScatteringShader.js +3 -3
  130. package/shaders/TechnicolorShader.cjs.js +1 -1
  131. package/shaders/TechnicolorShader.d.ts +4 -4
  132. package/shaders/TechnicolorShader.js +1 -1
  133. package/shaders/ToneMapShader.cjs.js +1 -1
  134. package/shaders/ToneMapShader.d.ts +19 -9
  135. package/shaders/ToneMapShader.js +1 -1
  136. package/shaders/ToonShader.cjs.js +1 -1
  137. package/shaders/ToonShader.d.ts +80 -34
  138. package/shaders/ToonShader.js +4 -4
  139. package/shaders/TriangleBlurShader.cjs.js +1 -1
  140. package/shaders/TriangleBlurShader.d.ts +8 -5
  141. package/shaders/TriangleBlurShader.js +1 -1
  142. package/shaders/UnpackDepthRGBAShader.cjs.js +1 -1
  143. package/shaders/UnpackDepthRGBAShader.d.ts +7 -5
  144. package/shaders/UnpackDepthRGBAShader.js +1 -1
  145. package/shaders/VerticalBlurShader.cjs.js +1 -1
  146. package/shaders/VerticalBlurShader.d.ts +8 -8
  147. package/shaders/VerticalBlurShader.js +1 -1
  148. package/shaders/VerticalTiltShiftShader.cjs.js +1 -1
  149. package/shaders/VerticalTiltShiftShader.d.ts +10 -6
  150. package/shaders/VerticalTiltShiftShader.js +1 -1
  151. package/shaders/VignetteShader.cjs.js +1 -1
  152. package/shaders/VignetteShader.d.ts +10 -6
  153. package/shaders/VignetteShader.js +1 -1
  154. package/shaders/VolumeShader.cjs.js +1 -1
  155. package/shaders/VolumeShader.d.ts +20 -9
  156. package/shaders/VolumeShader.js +1 -1
  157. package/shaders/WaterRefractionShader.cjs.js +1 -1
  158. package/shaders/WaterRefractionShader.d.ts +16 -8
  159. package/shaders/WaterRefractionShader.js +1 -1
  160. package/shaders/index.cjs.js +1 -0
  161. package/shaders/index.d.ts +53 -0
  162. package/shaders/index.js +53 -0
  163. package/shaders/types.cjs.js +1 -0
  164. package/shaders/types.d.ts +14 -0
  165. package/shaders/types.js +1 -0
  166. package/types/shared.d.ts +0 -20
@@ -1,46 +1,79 @@
1
- import { Uniform } from 'three';
2
-
3
- export const SSAOShader: {
1
+ import { Matrix4, Vector2 } from 'three';
2
+ export declare const SSAOShader: {
4
3
  defines: {
5
4
  PERSPECTIVE_CAMERA: number;
6
5
  KERNEL_SIZE: number;
7
6
  };
8
7
  uniforms: {
9
- tDiffuse: Uniform;
10
- tNormal: Uniform;
11
- tDepth: Uniform;
12
- tNoise: Uniform;
13
- kernel: Uniform;
14
- cameraNear: Uniform;
15
- cameraFar: Uniform;
16
- resolution: Uniform;
17
- cameraProjectionMatrix: Uniform;
18
- cameraInverseProjectionMatrix: Uniform;
19
- kernelRadius: Uniform;
20
- minDistance: Uniform;
21
- maxDistance: Uniform;
8
+ tDiffuse: {
9
+ value: null;
10
+ };
11
+ tNormal: {
12
+ value: null;
13
+ };
14
+ tDepth: {
15
+ value: null;
16
+ };
17
+ tNoise: {
18
+ value: null;
19
+ };
20
+ kernel: {
21
+ value: null;
22
+ };
23
+ cameraNear: {
24
+ value: null;
25
+ };
26
+ cameraFar: {
27
+ value: null;
28
+ };
29
+ resolution: {
30
+ value: Vector2;
31
+ };
32
+ cameraProjectionMatrix: {
33
+ value: Matrix4;
34
+ };
35
+ cameraInverseProjectionMatrix: {
36
+ value: Matrix4;
37
+ };
38
+ kernelRadius: {
39
+ value: number;
40
+ };
41
+ minDistance: {
42
+ value: number;
43
+ };
44
+ maxDistance: {
45
+ value: number;
46
+ };
22
47
  };
23
48
  vertexShader: string;
24
49
  fragmentShader: string;
25
50
  };
26
-
27
- export const SSAODepthShader: {
51
+ export declare const SSAODepthShader: {
28
52
  defines: {
29
53
  PERSPECTIVE_CAMERA: number;
30
54
  };
31
55
  uniforms: {
32
- tDepth: Uniform;
33
- cameraNear: Uniform;
34
- cameraFar: Uniform;
56
+ tDepth: {
57
+ value: null;
58
+ };
59
+ cameraNear: {
60
+ value: null;
61
+ };
62
+ cameraFar: {
63
+ value: null;
64
+ };
35
65
  };
36
66
  vertexShader: string;
37
67
  fragmentShader: string;
38
68
  };
39
-
40
- export const SSAOBlurShader: {
69
+ export declare const SSAOBlurShader: {
41
70
  uniforms: {
42
- tDiffuse: Uniform;
43
- resolution: Uniform;
71
+ tDiffuse: {
72
+ value: null;
73
+ };
74
+ resolution: {
75
+ value: Vector2;
76
+ };
44
77
  };
45
78
  vertexShader: string;
46
79
  fragmentShader: string;
@@ -7,7 +7,7 @@ import { Vector2, Matrix4 } from 'three';
7
7
  * https://github.com/McNopper/OpenGL/blob/master/Example28/shader/ssao.frag.glsl
8
8
  */
9
9
 
10
- var SSAOShader = {
10
+ const SSAOShader = {
11
11
  defines: {
12
12
  PERSPECTIVE_CAMERA: 1,
13
13
  KERNEL_SIZE: 32
@@ -66,7 +66,7 @@ var SSAOShader = {
66
66
  ' float delta = sampleDepth - realDepth;', ' if ( delta > minDistance && delta < maxDistance ) {', // if fragment is before sample point, increase occlusion
67
67
  ' occlusion += 1.0;', ' }', ' }', ' occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );', ' gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );', '}'].join('\n')
68
68
  };
69
- var SSAODepthShader = {
69
+ const SSAODepthShader = {
70
70
  defines: {
71
71
  PERSPECTIVE_CAMERA: 1
72
72
  },
@@ -84,7 +84,7 @@ var SSAODepthShader = {
84
84
  vertexShader: ['varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}'].join('\n'),
85
85
  fragmentShader: ['uniform sampler2D tDepth;', 'uniform float cameraNear;', 'uniform float cameraFar;', 'varying vec2 vUv;', '#include <packing>', 'float getLinearDepth( const in vec2 screenPosition ) {', ' #if PERSPECTIVE_CAMERA == 1', ' float fragCoordZ = texture2D( tDepth, screenPosition ).x;', ' float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );', ' return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );', ' #else', ' return texture2D( tDepth, screenPosition ).x;', ' #endif', '}', 'void main() {', ' float depth = getLinearDepth( vUv );', ' gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );', '}'].join('\n')
86
86
  };
87
- var SSAOBlurShader = {
87
+ const SSAOBlurShader = {
88
88
  uniforms: {
89
89
  tDiffuse: {
90
90
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three"),e={defines:{MAX_STEP:0,isPerspectiveCamera:!0,isDistanceAttenuation:!0,isFresnel:!0,isInfiniteThick:!1,isSelective:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new t.Vector2},cameraProjectionMatrix:{value:new t.Matrix4},cameraInverseProjectionMatrix:{value:new t.Matrix4},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},surfDist:{value:.007},thickTolerance:{value:.03}},vertexShader:"\n\n varying vec2 vUv;\n\n void main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",fragmentShader:"\n\t\t// precision highp float;\n\t\tprecision highp sampler2D;\n\t\tvarying vec2 vUv;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tMetalness;\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float cameraRange;\n\t\tuniform vec2 resolution;\n\t\tuniform float opacity;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float maxDistance;\n\t\tuniform float surfDist;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\tuniform float thickTolerance;\n\t\t#include <packing>\n\t\tfloat pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {\n\t\t\t//x0: point, x1: linePointA, x2: linePointB\n\t\t\t//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n\t\t\treturn length(cross(x0-x1,x0-x2))/length(x2-x1);\n\t\t}\n\t\tfloat pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){\n\t\t\t// https://mathworld.wolfram.com/Point-PlaneDistance.html\n\t\t\t//// https://en.wikipedia.org/wiki/Plane_(geometry)\n\t\t\t//// http://paulbourke.net/geometry/pointlineplane/\n\t\t\tfloat a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;\n\t\t\tfloat x0=point.x,y0=point.y,z0=point.z;\n\t\t\tfloat x=planePoint.x,y=planePoint.y,z=planePoint.z;\n\t\t\tfloat d=-(a*x+b*y+c*z);\n\t\t\tfloat distance=(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c);\n\t\t\treturn distance;\n\t\t}\n\t\tfloat getDepth( const in vec2 uv ) {\n\t\t\treturn texture2D( tDepth, uv ).x;\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n\t\t\tvec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n\t\t\tclipPosition *= clipW; //clip\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view\n\t\t}\n\t\tvec3 getViewNormal( const in vec2 uv ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, uv ).xyz );\n\t\t}\n\t\tvec2 viewPositionToXY(vec3 viewPosition){\n\t\t\tvec2 xy;\n\t\t\tvec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);\n\t\t\txy=clip.xy;//clip\n\t\t\tfloat clipW=clip.w;\n\t\t\txy/=clipW;//NDC\n\t\t\txy=(xy+1.)/2.;//uv\n\t\t\txy*=resolution;//screen\n\t\t\treturn xy;\n\t\t}\n\t\tvoid main(){\n\t\t\t#ifdef isSelective\n\t\t\t\tfloat metalness=texture2D(tMetalness,vUv).r;\n\t\t\t\tif(metalness==0.) return;\n\t\t\t#endif\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\t\t\tif(-viewZ>=cameraFar) return;\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];\n\t\t\tvec3 viewPosition=getViewPosition( vUv, depth, clipW );\n\n\t\t\tvec2 d0=gl_FragCoord.xy;\n\t\t\tvec2 d1;\n\n\t\t\tvec3 viewNormal=getViewNormal( vUv );\n\n\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\tvec3 viewIncidenceDir=normalize(viewPosition);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidenceDir,viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 viewIncidenceDir=vec3(0,0,-1);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidenceDir,viewNormal);\n\t\t\t#endif\n\n\t\t\tfloat maxReflectRayLen=maxDistance/dot(-viewIncidenceDir,viewNormal);\n\t\t\t// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\t\t\t// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen=cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen==dot(a,b)\n\t\t\t// maxReflectRayLen==maxDistance/dot(a,b)\n\n\t\t\tvec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;\n\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\tif(d1viewPosition.z>-cameraNear){\n\t\t\t\t\t//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx\n\t\t\t\t\tfloat t=(-cameraNear-viewPosition.z)/viewReflectDir.z;\n\t\t\t\t\td1viewPosition=viewPosition+viewReflectDir*t;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\td1=viewPositionToXY(d1viewPosition);\n\n\t\t\tfloat totalLen=length(d1-d0);\n\t\t\tfloat xLen=d1.x-d0.x;\n\t\t\tfloat yLen=d1.y-d0.y;\n\t\t\tfloat totalStep=max(abs(xLen),abs(yLen));\n\t\t\tfloat xSpan=xLen/totalStep;\n\t\t\tfloat ySpan=yLen/totalStep;\n\t\t\tfor(float i=0.;i<MAX_STEP;i++){\n\t\t\t\tif(i>=totalStep) break;\n\t\t\t\tvec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);\n\t\t\t\tif(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;\n\t\t\t\tfloat s=length(xy-d0)/totalLen;\n\t\t\t\tvec2 uv=xy/resolution;\n\n\t\t\t\tfloat d = getDepth(uv);\n\t\t\t\tfloat vZ = getViewZ( d );\n\t\t\t\tif(-vZ>=cameraFar) continue;\n\t\t\t\tfloat cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];\n\t\t\t\tvec3 vP=getViewPosition( uv, d, cW );\n\n\t\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\t\t// https://www.comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf\n\t\t\t\t\tfloat recipVPZ=1./viewPosition.z;\n\t\t\t\t\tfloat viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));\n\t\t\t\t\tfloat sD=surfDist*cW;\n\t\t\t\t#else\n\t\t\t\t\tfloat viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);\n\t\t\t\t\tfloat sD=surfDist;\n\t\t\t\t#endif\n\t\t\t\tif(viewReflectRayZ-sD>vZ) continue;\n\n\t\t\t\t#ifdef isInfiniteThick\n\t\t\t\t\tif(viewReflectRayZ+thickTolerance*clipW<vP.z) break;\n\t\t\t\t#endif\n\t\t\t\tfloat away=pointToLineDistance(vP,viewPosition,d1viewPosition);\n\n\t\t\t\tfloat op=opacity;\n\n\t\t\t\tif(away<sD){\n\t\t\t\t\tvec3 vN=getViewNormal( uv );\n\t\t\t\t\tif(dot(viewReflectDir,vN)>=0.) continue;\n\t\t\t\t\tfloat distance=pointPlaneDistance(vP,viewPosition,viewNormal);\n\t\t\t\t\tif(distance>maxDistance) break;\n\t\t\t\t\t#ifdef isDistanceAttenuation\n\t\t\t\t\t\tfloat ratio=1.-(distance/maxDistance);\n\t\t\t\t\t\tfloat attenuation=ratio*ratio;\n\t\t\t\t\t\top=opacity*attenuation;\n\t\t\t\t\t#endif\n\t\t\t\t\t#ifdef isFresnel\n\t\t\t\t\t\tfloat fresnel=(dot(viewIncidenceDir,viewReflectDir)+1.)/2.;\n\t\t\t\t\t\top*=fresnel;\n\t\t\t\t\t#endif\n\t\t\t\t\tvec4 reflectColor=texture2D(tDiffuse,uv);\n\t\t\t\t\tgl_FragColor.xyz=reflectColor.xyz;\n\t\t\t\t\tgl_FragColor.a=op;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t"},n={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:"\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",fragmentShader:"\n\n uniform sampler2D tDepth;\n\n uniform float cameraNear;\n uniform float cameraFar;\n\n varying vec2 vUv;\n\n #include <packing>\n\n\t\tfloat getLinearDepth( const in vec2 uv ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, uv ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, uv ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n void main() {\n\n \tfloat depth = getLinearDepth( vUv );\n\t\t\tfloat d = 1.0 - depth;\n\t\t\t// d=(d-.999)*1000.;\n \tgl_FragColor = vec4( vec3( d ), 1.0 );\n\n }\n\n "},i={uniforms:{tDiffuse:{value:null},resolution:{value:new t.Vector2},opacity:{value:.5}},vertexShader:"\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",fragmentShader:"\n\n uniform sampler2D tDiffuse;\n uniform vec2 resolution;\n varying vec2 vUv;\n void main() {\n\t\t\t//reverse engineering from PhotoShop blur filter, then change coefficient\n\n \tvec2 texelSize = ( 1.0 / resolution );\n\n\t\t\tvec4 c=texture2D(tDiffuse,vUv);\n\n\t\t\tvec2 offset;\n\n\t\t\toffset=(vec2(-1,0))*texelSize;\n\t\t\tvec4 cl=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(1,0))*texelSize;\n\t\t\tvec4 cr=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,-1))*texelSize;\n\t\t\tvec4 cb=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,1))*texelSize;\n\t\t\tvec4 ct=texture2D(tDiffuse,vUv+offset);\n\n\t\t\t// float coeCenter=.5;\n\t\t\t// float coeSide=.125;\n\t\t\tfloat coeCenter=.2;\n\t\t\tfloat coeSide=.2;\n\t\t\tfloat a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;\n\t\t\tvec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;\n\t\t\tgl_FragColor=vec4(rgb,a);\n\n\t\t}\n\t"};exports.SSRBlurShader=i,exports.SSRDepthShader=n,exports.SSRShader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");const e={defines:{MAX_STEP:0,isPerspectiveCamera:!0,isDistanceAttenuation:!0,isFresnel:!0,isInfiniteThick:!1,isSelective:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new t.Vector2},cameraProjectionMatrix:{value:new t.Matrix4},cameraInverseProjectionMatrix:{value:new t.Matrix4},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},surfDist:{value:.007},thickTolerance:{value:.03}},vertexShader:"\n\n varying vec2 vUv;\n\n void main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",fragmentShader:"\n\t\t// precision highp float;\n\t\tprecision highp sampler2D;\n\t\tvarying vec2 vUv;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tMetalness;\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float cameraRange;\n\t\tuniform vec2 resolution;\n\t\tuniform float opacity;\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float maxDistance;\n\t\tuniform float surfDist;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\t\tuniform float thickTolerance;\n\t\t#include <packing>\n\t\tfloat pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {\n\t\t\t//x0: point, x1: linePointA, x2: linePointB\n\t\t\t//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html\n\t\t\treturn length(cross(x0-x1,x0-x2))/length(x2-x1);\n\t\t}\n\t\tfloat pointPlaneDistance(vec3 point,vec3 planePoint,vec3 planeNormal){\n\t\t\t// https://mathworld.wolfram.com/Point-PlaneDistance.html\n\t\t\t//// https://en.wikipedia.org/wiki/Plane_(geometry)\n\t\t\t//// http://paulbourke.net/geometry/pointlineplane/\n\t\t\tfloat a=planeNormal.x,b=planeNormal.y,c=planeNormal.z;\n\t\t\tfloat x0=point.x,y0=point.y,z0=point.z;\n\t\t\tfloat x=planePoint.x,y=planePoint.y,z=planePoint.z;\n\t\t\tfloat d=-(a*x+b*y+c*z);\n\t\t\tfloat distance=(a*x0+b*y0+c*z0+d)/sqrt(a*a+b*b+c*c);\n\t\t\treturn distance;\n\t\t}\n\t\tfloat getDepth( const in vec2 uv ) {\n\t\t\treturn texture2D( tDepth, uv ).x;\n\t\t}\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\t\tvec3 getViewPosition( const in vec2 uv, const in float depth/*clip space*/, const in float clipW ) {\n\t\t\tvec4 clipPosition = vec4( ( vec3( uv, depth ) - 0.5 ) * 2.0, 1.0 );//ndc\n\t\t\tclipPosition *= clipW; //clip\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;//view\n\t\t}\n\t\tvec3 getViewNormal( const in vec2 uv ) {\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, uv ).xyz );\n\t\t}\n\t\tvec2 viewPositionToXY(vec3 viewPosition){\n\t\t\tvec2 xy;\n\t\t\tvec4 clip=cameraProjectionMatrix*vec4(viewPosition,1);\n\t\t\txy=clip.xy;//clip\n\t\t\tfloat clipW=clip.w;\n\t\t\txy/=clipW;//NDC\n\t\t\txy=(xy+1.)/2.;//uv\n\t\t\txy*=resolution;//screen\n\t\t\treturn xy;\n\t\t}\n\t\tvoid main(){\n\t\t\t#ifdef isSelective\n\t\t\t\tfloat metalness=texture2D(tMetalness,vUv).r;\n\t\t\t\tif(metalness==0.) return;\n\t\t\t#endif\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\t\t\tif(-viewZ>=cameraFar) return;\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ+cameraProjectionMatrix[3][3];\n\t\t\tvec3 viewPosition=getViewPosition( vUv, depth, clipW );\n\n\t\t\tvec2 d0=gl_FragCoord.xy;\n\t\t\tvec2 d1;\n\n\t\t\tvec3 viewNormal=getViewNormal( vUv );\n\n\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\tvec3 viewIncidenceDir=normalize(viewPosition);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidenceDir,viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 viewIncidenceDir=vec3(0,0,-1);\n\t\t\t\tvec3 viewReflectDir=reflect(viewIncidenceDir,viewNormal);\n\t\t\t#endif\n\n\t\t\tfloat maxReflectRayLen=maxDistance/dot(-viewIncidenceDir,viewNormal);\n\t\t\t// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html\n\t\t\t// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen=cos(theta)\n\t\t\t// maxDistance/maxReflectRayLen==dot(a,b)\n\t\t\t// maxReflectRayLen==maxDistance/dot(a,b)\n\n\t\t\tvec3 d1viewPosition=viewPosition+viewReflectDir*maxReflectRayLen;\n\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\tif(d1viewPosition.z>-cameraNear){\n\t\t\t\t\t//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx\n\t\t\t\t\tfloat t=(-cameraNear-viewPosition.z)/viewReflectDir.z;\n\t\t\t\t\td1viewPosition=viewPosition+viewReflectDir*t;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\td1=viewPositionToXY(d1viewPosition);\n\n\t\t\tfloat totalLen=length(d1-d0);\n\t\t\tfloat xLen=d1.x-d0.x;\n\t\t\tfloat yLen=d1.y-d0.y;\n\t\t\tfloat totalStep=max(abs(xLen),abs(yLen));\n\t\t\tfloat xSpan=xLen/totalStep;\n\t\t\tfloat ySpan=yLen/totalStep;\n\t\t\tfor(float i=0.;i<MAX_STEP;i++){\n\t\t\t\tif(i>=totalStep) break;\n\t\t\t\tvec2 xy=vec2(d0.x+i*xSpan,d0.y+i*ySpan);\n\t\t\t\tif(xy.x<0.||xy.x>resolution.x||xy.y<0.||xy.y>resolution.y) break;\n\t\t\t\tfloat s=length(xy-d0)/totalLen;\n\t\t\t\tvec2 uv=xy/resolution;\n\n\t\t\t\tfloat d = getDepth(uv);\n\t\t\t\tfloat vZ = getViewZ( d );\n\t\t\t\tif(-vZ>=cameraFar) continue;\n\t\t\t\tfloat cW = cameraProjectionMatrix[2][3] * vZ+cameraProjectionMatrix[3][3];\n\t\t\t\tvec3 vP=getViewPosition( uv, d, cW );\n\n\t\t\t\t#ifdef isPerspectiveCamera\n\t\t\t\t\t// https://www.comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf\n\t\t\t\t\tfloat recipVPZ=1./viewPosition.z;\n\t\t\t\t\tfloat viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));\n\t\t\t\t\tfloat sD=surfDist*cW;\n\t\t\t\t#else\n\t\t\t\t\tfloat viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);\n\t\t\t\t\tfloat sD=surfDist;\n\t\t\t\t#endif\n\t\t\t\tif(viewReflectRayZ-sD>vZ) continue;\n\n\t\t\t\t#ifdef isInfiniteThick\n\t\t\t\t\tif(viewReflectRayZ+thickTolerance*clipW<vP.z) break;\n\t\t\t\t#endif\n\t\t\t\tfloat away=pointToLineDistance(vP,viewPosition,d1viewPosition);\n\n\t\t\t\tfloat op=opacity;\n\n\t\t\t\tif(away<sD){\n\t\t\t\t\tvec3 vN=getViewNormal( uv );\n\t\t\t\t\tif(dot(viewReflectDir,vN)>=0.) continue;\n\t\t\t\t\tfloat distance=pointPlaneDistance(vP,viewPosition,viewNormal);\n\t\t\t\t\tif(distance>maxDistance) break;\n\t\t\t\t\t#ifdef isDistanceAttenuation\n\t\t\t\t\t\tfloat ratio=1.-(distance/maxDistance);\n\t\t\t\t\t\tfloat attenuation=ratio*ratio;\n\t\t\t\t\t\top=opacity*attenuation;\n\t\t\t\t\t#endif\n\t\t\t\t\t#ifdef isFresnel\n\t\t\t\t\t\tfloat fresnel=(dot(viewIncidenceDir,viewReflectDir)+1.)/2.;\n\t\t\t\t\t\top*=fresnel;\n\t\t\t\t\t#endif\n\t\t\t\t\tvec4 reflectColor=texture2D(tDiffuse,uv);\n\t\t\t\t\tgl_FragColor.xyz=reflectColor.xyz;\n\t\t\t\t\tgl_FragColor.a=op;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t"},n={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:"\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",fragmentShader:"\n\n uniform sampler2D tDepth;\n\n uniform float cameraNear;\n uniform float cameraFar;\n\n varying vec2 vUv;\n\n #include <packing>\n\n\t\tfloat getLinearDepth( const in vec2 uv ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, uv ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, uv ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n void main() {\n\n \tfloat depth = getLinearDepth( vUv );\n\t\t\tfloat d = 1.0 - depth;\n\t\t\t// d=(d-.999)*1000.;\n \tgl_FragColor = vec4( vec3( d ), 1.0 );\n\n }\n\n "},i={uniforms:{tDiffuse:{value:null},resolution:{value:new t.Vector2},opacity:{value:.5}},vertexShader:"\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n\n ",fragmentShader:"\n\n uniform sampler2D tDiffuse;\n uniform vec2 resolution;\n varying vec2 vUv;\n void main() {\n\t\t\t//reverse engineering from PhotoShop blur filter, then change coefficient\n\n \tvec2 texelSize = ( 1.0 / resolution );\n\n\t\t\tvec4 c=texture2D(tDiffuse,vUv);\n\n\t\t\tvec2 offset;\n\n\t\t\toffset=(vec2(-1,0))*texelSize;\n\t\t\tvec4 cl=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(1,0))*texelSize;\n\t\t\tvec4 cr=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,-1))*texelSize;\n\t\t\tvec4 cb=texture2D(tDiffuse,vUv+offset);\n\n\t\t\toffset=(vec2(0,1))*texelSize;\n\t\t\tvec4 ct=texture2D(tDiffuse,vUv+offset);\n\n\t\t\t// float coeCenter=.5;\n\t\t\t// float coeSide=.125;\n\t\t\tfloat coeCenter=.2;\n\t\t\tfloat coeSide=.2;\n\t\t\tfloat a=c.a*coeCenter+cl.a*coeSide+cr.a*coeSide+cb.a*coeSide+ct.a*coeSide;\n\t\t\tvec3 rgb=(c.rgb*c.a*coeCenter+cl.rgb*cl.a*coeSide+cr.rgb*cr.a*coeSide+cb.rgb*cb.a*coeSide+ct.rgb*ct.a*coeSide)/a;\n\t\t\tgl_FragColor=vec4(rgb,a);\n\n\t\t}\n\t"};exports.SSRBlurShader=i,exports.SSRDepthShader=n,exports.SSRShader=e;
@@ -1,11 +1,5 @@
1
- import { Matrix4, Vector2, Texture, IUniform } from 'three';
2
- /**
3
- * References:
4
- * https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html
5
- */
6
-
7
- export const SSRShader: SSRShader;
8
- export interface SSRShader {
1
+ import { Matrix4, Vector2 } from 'three';
2
+ export declare const SSRShader: {
9
3
  defines: {
10
4
  MAX_STEP: number;
11
5
  isPerspectiveCamera: boolean;
@@ -15,45 +9,82 @@ export interface SSRShader {
15
9
  isSelective: boolean;
16
10
  };
17
11
  uniforms: {
18
- tDiffuse: IUniform<Texture | null>;
19
- tNormal: IUniform<Texture | null>;
20
- tMetalness: IUniform<Texture | null>;
21
- tDepth: IUniform<Texture | null>;
22
- cameraNear: IUniform<number>;
23
- cameraFar: IUniform<number>;
24
- resolution: IUniform<Vector2>;
25
- cameraProjectionMatrix: IUniform<Matrix4>;
26
- cameraInverseProjectionMatrix: IUniform<Matrix4>;
27
- opacity: IUniform<number>;
28
- maxDistance: IUniform<number>;
29
- cameraRange: IUniform<number>;
30
- thickness: IUniform<number>;
12
+ tDiffuse: {
13
+ value: null;
14
+ };
15
+ tNormal: {
16
+ value: null;
17
+ };
18
+ tMetalness: {
19
+ value: null;
20
+ };
21
+ tDepth: {
22
+ value: null;
23
+ };
24
+ cameraNear: {
25
+ value: null;
26
+ };
27
+ cameraFar: {
28
+ value: null;
29
+ };
30
+ resolution: {
31
+ value: Vector2;
32
+ };
33
+ cameraProjectionMatrix: {
34
+ value: Matrix4;
35
+ };
36
+ cameraInverseProjectionMatrix: {
37
+ value: Matrix4;
38
+ };
39
+ opacity: {
40
+ value: number;
41
+ };
42
+ maxDistance: {
43
+ value: number;
44
+ };
45
+ cameraRange: {
46
+ value: number;
47
+ };
48
+ surfDist: {
49
+ value: number;
50
+ };
51
+ thickTolerance: {
52
+ value: number;
53
+ };
31
54
  };
32
55
  vertexShader: string;
33
56
  fragmentShader: string;
34
- }
35
-
36
- export const SSRDepthShader: SSRDepthShader;
37
- export interface SSRDepthShader {
57
+ };
58
+ export declare const SSRDepthShader: {
38
59
  defines: {
39
60
  PERSPECTIVE_CAMERA: number;
40
61
  };
41
62
  uniforms: {
42
- tDepth: IUniform<Texture | null>;
43
- cameraNear: IUniform<number>;
44
- cameraFar: IUniform<number>;
63
+ tDepth: {
64
+ value: null;
65
+ };
66
+ cameraNear: {
67
+ value: null;
68
+ };
69
+ cameraFar: {
70
+ value: null;
71
+ };
45
72
  };
46
73
  vertexShader: string;
47
74
  fragmentShader: string;
48
- }
49
-
50
- export const SSRBlurShader: SSRBlurShader;
51
- export interface SSRBlurShader {
75
+ };
76
+ export declare const SSRBlurShader: {
52
77
  uniforms: {
53
- tDiffuse: IUniform<Texture | null>;
54
- resolution: IUniform<Vector2>;
55
- opacity: IUniform<number>;
78
+ tDiffuse: {
79
+ value: null;
80
+ };
81
+ resolution: {
82
+ value: Vector2;
83
+ };
84
+ opacity: {
85
+ value: number;
86
+ };
56
87
  };
57
88
  vertexShader: string;
58
89
  fragmentShader: string;
59
- }
90
+ };
@@ -5,7 +5,7 @@ import { Vector2, Matrix4 } from 'three';
5
5
  * https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html
6
6
  */
7
7
 
8
- var SSRShader = {
8
+ const SSRShader = {
9
9
  defines: {
10
10
  MAX_STEP: 0,
11
11
  isPerspectiveCamera: true,
@@ -241,7 +241,7 @@ var SSRShader = {
241
241
  }
242
242
  `
243
243
  };
244
- var SSRDepthShader = {
244
+ const SSRDepthShader = {
245
245
  defines: {
246
246
  PERSPECTIVE_CAMERA: 1
247
247
  },
@@ -310,7 +310,7 @@ var SSRDepthShader = {
310
310
 
311
311
  `
312
312
  };
313
- var SSRBlurShader = {
313
+ const SSRBlurShader = {
314
314
  uniforms: {
315
315
  tDiffuse: {
316
316
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o={uniforms:{tDiffuse:{value:null},amount:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float amount;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 color = texture2D( tDiffuse, vUv );","\tvec3 c = color.rgb;","\tcolor.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );","\tcolor.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );","\tcolor.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );","\tgl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );","}"].join("\n")};exports.SepiaShader=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const o={uniforms:{tDiffuse:{value:null},amount:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float amount;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 color = texture2D( tDiffuse, vUv );","\tvec3 c = color.rgb;","\tcolor.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );","\tcolor.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );","\tcolor.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );","\tgl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );","}"].join("\n")};exports.SepiaShader=o;
@@ -1,9 +1,11 @@
1
- import { Uniform } from 'three';
2
-
3
- export const SepiaShader: {
1
+ export declare const SepiaShader: {
4
2
  uniforms: {
5
- tDiffuse: Uniform;
6
- amount: Uniform;
3
+ tDiffuse: {
4
+ value: null;
5
+ };
6
+ amount: {
7
+ value: number;
8
+ };
7
9
  };
8
10
  vertexShader: string;
9
11
  fragmentShader: string;
@@ -3,7 +3,7 @@
3
3
  * based on glfx.js sepia shader
4
4
  * https://github.com/evanw/glfx.js
5
5
  */
6
- var SepiaShader = {
6
+ const SepiaShader = {
7
7
  uniforms: {
8
8
  tDiffuse: {
9
9
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={uniforms:{tDiffuse:{value:null},resolution:{value:new(require("three").Vector2)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","void main() {","\tvec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );","\tconst mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );","\tconst mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );","\tfloat tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;","\tfloat tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;","\tfloat tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;","\tfloat tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;","\tfloat tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;","\tfloat tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;","\tfloat tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;","\tfloat tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;","\tfloat tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;","\tfloat valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ","\t\tGx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ","\t\tGx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ","\tfloat valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ","\t\tGy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ","\t\tGy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ","\tfloat G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );","\tgl_FragColor = vec4( vec3( G ), 1 );","}"].join("\n")};exports.SobelOperatorShader=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={uniforms:{tDiffuse:{value:null},resolution:{value:new(require("three").Vector2)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","void main() {","\tvec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );","\tconst mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );","\tconst mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );","\tfloat tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;","\tfloat tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;","\tfloat tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;","\tfloat tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;","\tfloat tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;","\tfloat tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;","\tfloat tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;","\tfloat tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;","\tfloat tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;","\tfloat valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ","\t\tGx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ","\t\tGx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ","\tfloat valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ","\t\tGy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ","\t\tGy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ","\tfloat G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );","\tgl_FragColor = vec4( vec3( G ), 1 );","}"].join("\n")};exports.SobelOperatorShader=t;
@@ -1,9 +1,12 @@
1
- import { Uniform } from 'three';
2
-
3
- export const SobelOperatorShader: {
1
+ import { Vector2 } from 'three';
2
+ export declare const SobelOperatorShader: {
4
3
  uniforms: {
5
- tDiffuse: Uniform;
6
- resolution: Uniform;
4
+ tDiffuse: {
5
+ value: null;
6
+ };
7
+ resolution: {
8
+ value: Vector2;
9
+ };
7
10
  };
8
11
  vertexShader: string;
9
12
  fragmentShader: string;
@@ -7,7 +7,7 @@ import { Vector2 } from 'three';
7
7
  *
8
8
  */
9
9
 
10
- var SobelOperatorShader = {
10
+ const SobelOperatorShader = {
11
11
  uniforms: {
12
12
  tDiffuse: {
13
13
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");var t,i,n,r=e.ShaderChunk.meshphong_frag.slice(0,e.ShaderChunk.meshphong_frag.indexOf("void main() {")),s=e.ShaderChunk.meshphong_frag.slice(e.ShaderChunk.meshphong_frag.indexOf("void main() {")),o={uniforms:e.UniformsUtils.merge([e.ShaderLib.phong.uniforms,{thicknessMap:{value:null},thicknessColor:{value:new e.Color(16777215)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),vertexShader:["#define USE_UV",e.ShaderChunk.meshphong_vert].join("\n"),fragmentShader:["#define USE_UV","#define SUBSURFACE",r,"uniform sampler2D thicknessMap;","uniform float thicknessPower;","uniform float thicknessScale;","uniform float thicknessDistortion;","uniform float thicknessAmbient;","uniform float thicknessAttenuation;","uniform vec3 thicknessColor;","void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in GeometricContext geometry, inout ReflectedLight reflectedLight) {","\tvec3 thickness = thicknessColor * texture2D(thicknessMap, uv).r;","\tvec3 scatteringHalf = normalize(directLight.direction + (geometry.normal * thicknessDistortion));","\tfloat scatteringDot = pow(saturate(dot(geometry.viewDir, -scatteringHalf)), thicknessPower) * thicknessScale;","\tvec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;","\treflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;","}",s.replace("#include <lights_fragment_begin>",(t=e.ShaderChunk.lights_fragment_begin,i="RE_Direct( directLight, geometry, material, reflectedLight );",n=["RE_Direct( directLight, geometry, material, reflectedLight );","#if defined( SUBSURFACE ) && defined( USE_UV )"," RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);","#endif"].join("\n"),t.split(i).join(n)))].join("\n")};exports.SubsurfaceScatteringShader=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");const t=e.ShaderChunk.meshphong_frag.slice(0,e.ShaderChunk.meshphong_frag.indexOf("void main() {")),i=e.ShaderChunk.meshphong_frag.slice(e.ShaderChunk.meshphong_frag.indexOf("void main() {")),n={uniforms:e.UniformsUtils.merge([e.ShaderLib.phong.uniforms,{thicknessMap:{value:null},thicknessColor:{value:new e.Color(16777215)},thicknessDistortion:{value:.1},thicknessAmbient:{value:0},thicknessAttenuation:{value:.1},thicknessPower:{value:2},thicknessScale:{value:10}}]),vertexShader:["#define USE_UV",e.ShaderChunk.meshphong_vert].join("\n"),fragmentShader:["#define USE_UV","#define SUBSURFACE",t,"uniform sampler2D thicknessMap;","uniform float thicknessPower;","uniform float thicknessScale;","uniform float thicknessDistortion;","uniform float thicknessAmbient;","uniform float thicknessAttenuation;","uniform vec3 thicknessColor;","void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in GeometricContext geometry, inout ReflectedLight reflectedLight) {","\tvec3 thickness = thicknessColor * texture2D(thicknessMap, uv).r;","\tvec3 scatteringHalf = normalize(directLight.direction + (geometry.normal * thicknessDistortion));","\tfloat scatteringDot = pow(saturate(dot(geometry.viewDir, -scatteringHalf)), thicknessPower) * thicknessScale;","\tvec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;","\treflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;","}",i.replace("#include <lights_fragment_begin>",(r=e.ShaderChunk.lights_fragment_begin,s="RE_Direct( directLight, geometry, material, reflectedLight );",o=["RE_Direct( directLight, geometry, material, reflectedLight );","#if defined( SUBSURFACE ) && defined( USE_UV )"," RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);","#endif"].join("\n"),r.split(s).join(o)))].join("\n")};var r,s,o;exports.SubsurfaceScatteringShader=n;
@@ -1,37 +1,5 @@
1
- import { Uniform } from 'three';
2
-
3
- export const SubsurfaceScatteringShader: {
4
- uniforms: {
5
- alphaMap: Uniform;
6
- ambientLightColor: Uniform;
7
- color: Uniform;
8
- diffuse: Uniform;
9
- directionalLights: Uniform;
10
- directionalShadowMap: Uniform;
11
- directionalShadowMatrix: Uniform;
12
- emissive: Uniform;
13
- hemisphereLights: Uniform;
14
- lightProbe: Uniform;
15
- map: Uniform;
16
- opacity: Uniform;
17
- pointLights: Uniform;
18
- pointShadowMap: Uniform;
19
- pointShadowMatrix: Uniform;
20
- rectAreaLights: Uniform;
21
- shininess: Uniform;
22
- specular: Uniform;
23
- spotLights: Uniform;
24
- spotShadowMap: Uniform;
25
- spotShadowMatrix: Uniform;
26
- thicknessAmbient: Uniform;
27
- thicknessAttenuation: Uniform;
28
- thicknessColor: Uniform;
29
- thicknessDistortion: Uniform;
30
- thicknessMap: Uniform;
31
- thicknessPower: Uniform;
32
- thicknessScale: Uniform;
33
- uvTransform: Uniform;
34
- };
1
+ export declare const SubsurfaceScatteringShader: {
2
+ uniforms: any;
35
3
  vertexShader: string;
36
4
  fragmentShader: string;
37
5
  };
@@ -12,9 +12,9 @@ function replaceAll(string, find, replace) {
12
12
  return string.split(find).join(replace);
13
13
  }
14
14
 
15
- var meshphong_frag_head = ShaderChunk['meshphong_frag'].slice(0, ShaderChunk['meshphong_frag'].indexOf('void main() {'));
16
- var meshphong_frag_body = ShaderChunk['meshphong_frag'].slice(ShaderChunk['meshphong_frag'].indexOf('void main() {'));
17
- var SubsurfaceScatteringShader = {
15
+ const meshphong_frag_head = ShaderChunk['meshphong_frag'].slice(0, ShaderChunk['meshphong_frag'].indexOf('void main() {'));
16
+ const meshphong_frag_body = ShaderChunk['meshphong_frag'].slice(ShaderChunk['meshphong_frag'].indexOf('void main() {'));
17
+ const SubsurfaceScatteringShader = {
18
18
  uniforms: UniformsUtils.merge([ShaderLib['phong'].uniforms, {
19
19
  thicknessMap: {
20
20
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );","\tvec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);","\tgl_FragColor = newTex;","}"].join("\n")};exports.TechnicolorShader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );","\tvec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);","\tgl_FragColor = newTex;","}"].join("\n")};exports.TechnicolorShader=e;
@@ -1,8 +1,8 @@
1
- import { Uniform } from 'three';
2
-
3
- export const TechnicolorShader: {
1
+ export declare const TechnicolorShader: {
4
2
  uniforms: {
5
- tDiffuse: Uniform;
3
+ tDiffuse: {
4
+ value: null;
5
+ };
6
6
  };
7
7
  vertexShader: string;
8
8
  fragmentShader: string;
@@ -4,7 +4,7 @@
4
4
  * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm
5
5
  * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html
6
6
  */
7
- var TechnicolorShader = {
7
+ const TechnicolorShader = {
8
8
  uniforms: {
9
9
  tDiffuse: {
10
10
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={uniforms:{tDiffuse:{value:null},averageLuminance:{value:1},luminanceMap:{value:null},maxLuminance:{value:16},minLuminance:{value:.01},middleGrey:{value:.6}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","uniform sampler2D tDiffuse;","varying vec2 vUv;","uniform float middleGrey;","uniform float minLuminance;","uniform float maxLuminance;","#ifdef ADAPTED_LUMINANCE","\tuniform sampler2D luminanceMap;","#else","\tuniform float averageLuminance;","#endif","vec3 ToneMap( vec3 vColor ) {","\t#ifdef ADAPTED_LUMINANCE","\t\tfloat fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;","\t#else","\t\tfloat fLumAvg = averageLuminance;","\t#endif","\tfloat fLumPixel = linearToRelativeLuminance( vColor );","\tfloat fLumScaled = (fLumPixel * middleGrey) / max( minLuminance, fLumAvg );","\tfloat fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (maxLuminance * maxLuminance)))) / (1.0 + fLumScaled);","\treturn fLumCompressed * vColor;","}","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tgl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );","}"].join("\n")};exports.ToneMapShader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={uniforms:{tDiffuse:{value:null},averageLuminance:{value:1},luminanceMap:{value:null},maxLuminance:{value:16},minLuminance:{value:.01},middleGrey:{value:.6}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","uniform sampler2D tDiffuse;","varying vec2 vUv;","uniform float middleGrey;","uniform float minLuminance;","uniform float maxLuminance;","#ifdef ADAPTED_LUMINANCE","\tuniform sampler2D luminanceMap;","#else","\tuniform float averageLuminance;","#endif","vec3 ToneMap( vec3 vColor ) {","\t#ifdef ADAPTED_LUMINANCE","\t\tfloat fLumAvg = texture2D(luminanceMap, vec2(0.5, 0.5)).r;","\t#else","\t\tfloat fLumAvg = averageLuminance;","\t#endif","\tfloat fLumPixel = linearToRelativeLuminance( vColor );","\tfloat fLumScaled = (fLumPixel * middleGrey) / max( minLuminance, fLumAvg );","\tfloat fLumCompressed = (fLumScaled * (1.0 + (fLumScaled / (maxLuminance * maxLuminance)))) / (1.0 + fLumScaled);","\treturn fLumCompressed * vColor;","}","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tgl_FragColor = vec4( ToneMap( texel.xyz ), texel.w );","}"].join("\n")};exports.ToneMapShader=e;
@@ -1,13 +1,23 @@
1
- import { Uniform } from 'three';
2
-
3
- export const ToneMapShader: {
1
+ export declare const ToneMapShader: {
4
2
  uniforms: {
5
- tDiffuse: Uniform;
6
- averageLuminance: Uniform;
7
- luminanceMap: Uniform;
8
- maxLuminance: Uniform;
9
- minLuminance: Uniform;
10
- middleGrey: Uniform;
3
+ tDiffuse: {
4
+ value: null;
5
+ };
6
+ averageLuminance: {
7
+ value: number;
8
+ };
9
+ luminanceMap: {
10
+ value: null;
11
+ };
12
+ maxLuminance: {
13
+ value: number;
14
+ };
15
+ minLuminance: {
16
+ value: number;
17
+ };
18
+ middleGrey: {
19
+ value: number;
20
+ };
11
21
  };
12
22
  vertexShader: string;
13
23
  fragmentShader: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Full-screen tone-mapping shader based on http://www.cis.rit.edu/people/faculty/ferwerda/publications/sig02_paper.pdf
3
3
  */
4
- var ToneMapShader = {
4
+ const ToneMapShader = {
5
5
  uniforms: {
6
6
  tDiffuse: {
7
7
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("three"),i={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(16777215)}},vertexShader:["varying vec3 vNormal;","varying vec3 vRefract;","void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );","\tvNormal = normalize( normalMatrix * normal );","\tvec3 I = worldPosition.xyz - cameraPosition;","\tvRefract = refract( normalize( I ), worldNormal, 1.02 );","\tgl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","varying vec3 vRefract;","void main() {","\tfloat directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","\tvec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","\tfloat intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );","\tintensity += length(lightWeighting) * 0.2;","\tfloat cameraWeighting = dot( normalize( vNormal ), vRefract );","\tintensity += pow( 1.0 - length( cameraWeighting ), 6.0 );","\tintensity = intensity * 0.2 + 0.3;","\tif ( intensity < 0.50 ) {","\t\tgl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );","\t} else {","\t\tgl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );","}","}"].join("\n")},r={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(15658734)},uLineColor1:{value:new o.Color(8421504)},uLineColor2:{value:new o.Color(0)},uLineColor3:{value:new o.Color(0)},uLineColor4:{value:new o.Color(0)}},vertexShader:["varying vec3 vNormal;","void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tvNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","\tfloat camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);","\tfloat light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","\tgl_FragColor = vec4( uBaseColor, 1.0 );","\tif ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {","\t\tgl_FragColor *= vec4( uLineColor1, 1.0 );","\t}","\tif ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {","\t\tgl_FragColor *= vec4( uLineColor2, 1.0 );","\t}","}"].join("\n")},e={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(16777215)},uLineColor1:{value:new o.Color(0)},uLineColor2:{value:new o.Color(0)},uLineColor3:{value:new o.Color(0)},uLineColor4:{value:new o.Color(0)}},vertexShader:["varying vec3 vNormal;","void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tvNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","\tfloat directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","\tvec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","\tgl_FragColor = vec4( uBaseColor, 1.0 );","\tif ( length(lightWeighting) < 1.00 ) {","\t\tif ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor1, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.75 ) {","\t\tif (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor2, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.50 ) {","\t\tif (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor3, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.3465 ) {","\t\tif (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor4, 1.0 );","\t}","\t}","}"].join("\n")},t={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(16777215)},uLineColor1:{value:new o.Color(0)}},vertexShader:["varying vec3 vNormal;","void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tvNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(lightWeighting) < 1.00 ) {","\t\tif ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {","\t\t\tgl_FragColor = vec4( uLineColor1, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.50 ) {","\t\tif ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {","\t\t\tgl_FragColor = vec4( uLineColor1, 1.0 );","\t\t}","\t}","}"].join("\n")};exports.ToonShader1=i,exports.ToonShader2=r,exports.ToonShaderDotted=t,exports.ToonShaderHatching=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("three");const i={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(16777215)}},vertexShader:["varying vec3 vNormal;","varying vec3 vRefract;","void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tvec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );","\tvNormal = normalize( normalMatrix * normal );","\tvec3 I = worldPosition.xyz - cameraPosition;","\tvRefract = refract( normalize( I ), worldNormal, 1.02 );","\tgl_Position = projectionMatrix * mvPosition;","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","varying vec3 vRefract;","void main() {","\tfloat directionalLightWeighting = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","\tvec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","\tfloat intensity = smoothstep( - 0.5, 1.0, pow( length(lightWeighting), 20.0 ) );","\tintensity += length(lightWeighting) * 0.2;","\tfloat cameraWeighting = dot( normalize( vNormal ), vRefract );","\tintensity += pow( 1.0 - length( cameraWeighting ), 6.0 );","\tintensity = intensity * 0.2 + 0.3;","\tif ( intensity < 0.50 ) {","\t\tgl_FragColor = vec4( 2.0 * intensity * uBaseColor, 1.0 );","\t} else {","\t\tgl_FragColor = vec4( 1.0 - 2.0 * ( 1.0 - intensity ) * ( 1.0 - uBaseColor ), 1.0 );","}","}"].join("\n")},r={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(15658734)},uLineColor1:{value:new o.Color(8421504)},uLineColor2:{value:new o.Color(0)},uLineColor3:{value:new o.Color(0)},uLineColor4:{value:new o.Color(0)}},vertexShader:["varying vec3 vNormal;","void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tvNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","\tfloat camera = max( dot( normalize( vNormal ), vec3( 0.0, 0.0, 1.0 ) ), 0.4);","\tfloat light = max( dot( normalize( vNormal ), uDirLightPos ), 0.0);","\tgl_FragColor = vec4( uBaseColor, 1.0 );","\tif ( length(uAmbientLightColor + uDirLightColor * light) < 1.00 ) {","\t\tgl_FragColor *= vec4( uLineColor1, 1.0 );","\t}","\tif ( length(uAmbientLightColor + uDirLightColor * camera) < 0.50 ) {","\t\tgl_FragColor *= vec4( uLineColor2, 1.0 );","\t}","}"].join("\n")},e={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(16777215)},uLineColor1:{value:new o.Color(0)},uLineColor2:{value:new o.Color(0)},uLineColor3:{value:new o.Color(0)},uLineColor4:{value:new o.Color(0)}},vertexShader:["varying vec3 vNormal;","void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tvNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","\tfloat directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","\tvec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","\tgl_FragColor = vec4( uBaseColor, 1.0 );","\tif ( length(lightWeighting) < 1.00 ) {","\t\tif ( mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor1, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.75 ) {","\t\tif (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor2, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.50 ) {","\t\tif (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor3, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.3465 ) {","\t\tif (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {","\t\t\tgl_FragColor = vec4( uLineColor4, 1.0 );","\t}","\t}","}"].join("\n")},t={uniforms:{uDirLightPos:{value:new o.Vector3},uDirLightColor:{value:new o.Color(15658734)},uAmbientLightColor:{value:new o.Color(328965)},uBaseColor:{value:new o.Color(16777215)},uLineColor1:{value:new o.Color(0)}},vertexShader:["varying vec3 vNormal;","void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tvNormal = normalize( normalMatrix * normal );","}"].join("\n"),fragmentShader:["uniform vec3 uBaseColor;","uniform vec3 uLineColor1;","uniform vec3 uLineColor2;","uniform vec3 uLineColor3;","uniform vec3 uLineColor4;","uniform vec3 uDirLightPos;","uniform vec3 uDirLightColor;","uniform vec3 uAmbientLightColor;","varying vec3 vNormal;","void main() {","float directionalLightWeighting = max( dot( normalize(vNormal), uDirLightPos ), 0.0);","vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;","gl_FragColor = vec4( uBaseColor, 1.0 );","if ( length(lightWeighting) < 1.00 ) {","\t\tif ( ( mod(gl_FragCoord.x, 4.001) + mod(gl_FragCoord.y, 4.0) ) > 6.00 ) {","\t\t\tgl_FragColor = vec4( uLineColor1, 1.0 );","\t\t}","\t}","\tif ( length(lightWeighting) < 0.50 ) {","\t\tif ( ( mod(gl_FragCoord.x + 2.0, 4.001) + mod(gl_FragCoord.y + 2.0, 4.0) ) > 6.00 ) {","\t\t\tgl_FragColor = vec4( uLineColor1, 1.0 );","\t\t}","\t}","}"].join("\n")};exports.ToonShader1=i,exports.ToonShader2=r,exports.ToonShaderDotted=t,exports.ToonShaderHatching=e;