Skip to content

Commit 51d0799

Browse files
committed
jsm updates
1 parent 8bf4f29 commit 51d0799

12 files changed

+303
-303
lines changed

examples/jsm/shaders/AfterimageShader.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ var AfterimageShader = {
2424

2525
"void main() {",
2626

27-
"vUv = uv;",
28-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
27+
" vUv = uv;",
28+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
2929

3030
"}"
3131

@@ -39,21 +39,21 @@ var AfterimageShader = {
3939
"uniform sampler2D tNew;",
4040

4141
"varying vec2 vUv;",
42-
42+
4343
"vec4 when_gt( vec4 x, float y ) {",
4444

45-
"return max( sign( x - y ), 0.0 );",
45+
" return max( sign( x - y ), 0.0 );",
4646

4747
"}",
4848

4949
"void main() {",
5050

51-
"vec4 texelOld = texture2D( tOld, vUv );",
52-
"vec4 texelNew = texture2D( tNew, vUv );",
53-
54-
"texelOld *= damp * when_gt( texelOld, 0.1 );",
51+
" vec4 texelOld = texture2D( tOld, vUv );",
52+
" vec4 texelNew = texture2D( tNew, vUv );",
53+
54+
" texelOld *= damp * when_gt( texelOld, 0.1 );",
5555

56-
"gl_FragColor = max(texelNew, texelOld);",
56+
" gl_FragColor = max(texelNew, texelOld);",
5757

5858
"}"
5959

examples/jsm/shaders/BasicShader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var BasicShader = {
1414

1515
"void main() {",
1616

17-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
17+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
1818

1919
"}"
2020

@@ -24,7 +24,7 @@ var BasicShader = {
2424

2525
"void main() {",
2626

27-
"gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
27+
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
2828

2929
"}"
3030

examples/jsm/shaders/BleachBypassShader.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ var BleachBypassShader = {
2323

2424
"void main() {",
2525

26-
"vUv = uv;",
27-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26+
" vUv = uv;",
27+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
2828

2929
"}"
3030

@@ -40,24 +40,24 @@ var BleachBypassShader = {
4040

4141
"void main() {",
4242

43-
"vec4 base = texture2D( tDiffuse, vUv );",
43+
" vec4 base = texture2D( tDiffuse, vUv );",
4444

45-
"vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
46-
"float lum = dot( lumCoeff, base.rgb );",
47-
"vec3 blend = vec3( lum );",
45+
" vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
46+
" float lum = dot( lumCoeff, base.rgb );",
47+
" vec3 blend = vec3( lum );",
4848

49-
"float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );",
49+
" float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );",
5050

51-
"vec3 result1 = 2.0 * base.rgb * blend;",
52-
"vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
51+
" vec3 result1 = 2.0 * base.rgb * blend;",
52+
" vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
5353

54-
"vec3 newColor = mix( result1, result2, L );",
54+
" vec3 newColor = mix( result1, result2, L );",
5555

56-
"float A2 = opacity * base.a;",
57-
"vec3 mixRGB = A2 * newColor.rgb;",
58-
"mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
56+
" float A2 = opacity * base.a;",
57+
" vec3 mixRGB = A2 * newColor.rgb;",
58+
" mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
5959

60-
"gl_FragColor = vec4( mixRGB, base.a );",
60+
" gl_FragColor = vec4( mixRGB, base.a );",
6161

6262
"}"
6363

examples/jsm/shaders/BlendShader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ var BlendShader = {
2323

2424
"void main() {",
2525

26-
"vUv = uv;",
27-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
26+
" vUv = uv;",
27+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
2828

2929
"}"
3030

@@ -42,9 +42,9 @@ var BlendShader = {
4242

4343
"void main() {",
4444

45-
"vec4 texel1 = texture2D( tDiffuse1, vUv );",
46-
"vec4 texel2 = texture2D( tDiffuse2, vUv );",
47-
"gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
45+
" vec4 texel1 = texture2D( tDiffuse1, vUv );",
46+
" vec4 texel2 = texture2D( tDiffuse2, vUv );",
47+
" gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
4848

4949
"}"
5050

examples/jsm/shaders/BokehShader.js

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ var BokehShader = {
3434

3535
"void main() {",
3636

37-
"vUv = uv;",
38-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
37+
" vUv = uv;",
38+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
3939

4040
"}"
4141

@@ -79,67 +79,67 @@ var BokehShader = {
7979

8080
"void main() {",
8181

82-
"vec2 aspectcorrect = vec2( 1.0, aspect );",
83-
84-
"float viewZ = getViewZ( getDepth( vUv ) );",
85-
86-
"float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation
87-
88-
"vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );",
89-
90-
"vec2 dofblur9 = dofblur * 0.9;",
91-
"vec2 dofblur7 = dofblur * 0.7;",
92-
"vec2 dofblur4 = dofblur * 0.4;",
93-
94-
"vec4 col = vec4( 0.0 );",
95-
96-
"col += texture2D( tColor, vUv.xy );",
97-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );",
98-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );",
99-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );",
100-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );",
101-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );",
102-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );",
103-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );",
104-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );",
105-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );",
106-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );",
107-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );",
108-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );",
109-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );",
110-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );",
111-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );",
112-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );",
113-
114-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );",
115-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );",
116-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
117-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
118-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );",
119-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );",
120-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
121-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
122-
123-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );",
124-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );",
125-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
126-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );",
127-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );",
128-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );",
129-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
130-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );",
131-
132-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );",
133-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );",
134-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
135-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );",
136-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );",
137-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );",
138-
"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
139-
"col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );",
140-
141-
"gl_FragColor = col / 41.0;",
142-
"gl_FragColor.a = 1.0;",
82+
" vec2 aspectcorrect = vec2( 1.0, aspect );",
83+
84+
" float viewZ = getViewZ( getDepth( vUv ) );",
85+
86+
" float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation
87+
88+
" vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );",
89+
90+
" vec2 dofblur9 = dofblur * 0.9;",
91+
" vec2 dofblur7 = dofblur * 0.7;",
92+
" vec2 dofblur4 = dofblur * 0.4;",
93+
94+
" vec4 col = vec4( 0.0 );",
95+
96+
" col += texture2D( tColor, vUv.xy );",
97+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );",
98+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );",
99+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );",
100+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );",
101+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );",
102+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );",
103+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );",
104+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );",
105+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );",
106+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );",
107+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );",
108+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );",
109+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );",
110+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );",
111+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );",
112+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );",
113+
114+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );",
115+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );",
116+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
117+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
118+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );",
119+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );",
120+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
121+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
122+
123+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );",
124+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );",
125+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
126+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );",
127+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );",
128+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );",
129+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
130+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );",
131+
132+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );",
133+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );",
134+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
135+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );",
136+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );",
137+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );",
138+
" col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
139+
" col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );",
140+
141+
" gl_FragColor = col / 41.0;",
142+
" gl_FragColor.a = 1.0;",
143143

144144
"}"
145145

0 commit comments

Comments
 (0)