Skip to content

Commit f8a0aee

Browse files
authored
Merge pull request #17533 from gkjohnson/lint-example-shaders-1
Linting: Lint Example Shaders PR 1
2 parents aaf5534 + 51d0799 commit f8a0aee

24 files changed

+606
-606
lines changed

examples/js/shaders/AfterimageShader.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ THREE.AfterimageShader = {
2222

2323
"void main() {",
2424

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

2828
"}"
2929

@@ -37,21 +37,21 @@ THREE.AfterimageShader = {
3737
"uniform sampler2D tNew;",
3838

3939
"varying vec2 vUv;",
40-
40+
4141
"vec4 when_gt( vec4 x, float y ) {",
4242

43-
"return max( sign( x - y ), 0.0 );",
43+
" return max( sign( x - y ), 0.0 );",
4444

4545
"}",
4646

4747
"void main() {",
4848

49-
"vec4 texelOld = texture2D( tOld, vUv );",
50-
"vec4 texelNew = texture2D( tNew, vUv );",
51-
52-
"texelOld *= damp * when_gt( texelOld, 0.1 );",
49+
" vec4 texelOld = texture2D( tOld, vUv );",
50+
" vec4 texelNew = texture2D( tNew, vUv );",
51+
52+
" texelOld *= damp * when_gt( texelOld, 0.1 );",
5353

54-
"gl_FragColor = max(texelNew, texelOld);",
54+
" gl_FragColor = max(texelNew, texelOld);",
5555

5656
"}"
5757

examples/js/shaders/BasicShader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ THREE.BasicShader = {
1212

1313
"void main() {",
1414

15-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
15+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
1616

1717
"}"
1818

@@ -22,7 +22,7 @@ THREE.BasicShader = {
2222

2323
"void main() {",
2424

25-
"gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
25+
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
2626

2727
"}"
2828

examples/js/shaders/BleachBypassShader.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ THREE.BleachBypassShader = {
2121

2222
"void main() {",
2323

24-
"vUv = uv;",
25-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
24+
" vUv = uv;",
25+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
2626

2727
"}"
2828

@@ -38,24 +38,24 @@ THREE.BleachBypassShader = {
3838

3939
"void main() {",
4040

41-
"vec4 base = texture2D( tDiffuse, vUv );",
41+
" vec4 base = texture2D( tDiffuse, vUv );",
4242

43-
"vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
44-
"float lum = dot( lumCoeff, base.rgb );",
45-
"vec3 blend = vec3( lum );",
43+
" vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
44+
" float lum = dot( lumCoeff, base.rgb );",
45+
" vec3 blend = vec3( lum );",
4646

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

49-
"vec3 result1 = 2.0 * base.rgb * blend;",
50-
"vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
49+
" vec3 result1 = 2.0 * base.rgb * blend;",
50+
" vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
5151

52-
"vec3 newColor = mix( result1, result2, L );",
52+
" vec3 newColor = mix( result1, result2, L );",
5353

54-
"float A2 = opacity * base.a;",
55-
"vec3 mixRGB = A2 * newColor.rgb;",
56-
"mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
54+
" float A2 = opacity * base.a;",
55+
" vec3 mixRGB = A2 * newColor.rgb;",
56+
" mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
5757

58-
"gl_FragColor = vec4( mixRGB, base.a );",
58+
" gl_FragColor = vec4( mixRGB, base.a );",
5959

6060
"}"
6161

examples/js/shaders/BlendShader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ THREE.BlendShader = {
2121

2222
"void main() {",
2323

24-
"vUv = uv;",
25-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
24+
" vUv = uv;",
25+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
2626

2727
"}"
2828

@@ -40,9 +40,9 @@ THREE.BlendShader = {
4040

4141
"void main() {",
4242

43-
"vec4 texel1 = texture2D( tDiffuse1, vUv );",
44-
"vec4 texel2 = texture2D( tDiffuse2, vUv );",
45-
"gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
43+
" vec4 texel1 = texture2D( tDiffuse1, vUv );",
44+
" vec4 texel2 = texture2D( tDiffuse2, vUv );",
45+
" gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
4646

4747
"}"
4848

examples/js/shaders/BokehShader.js

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ THREE.BokehShader = {
3232

3333
"void main() {",
3434

35-
"vUv = uv;",
36-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
35+
" vUv = uv;",
36+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
3737

3838
"}"
3939

@@ -77,67 +77,67 @@ THREE.BokehShader = {
7777

7878
"void main() {",
7979

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

142142
"}"
143143

0 commit comments

Comments
 (0)