Skip to content

Commit b6dcc7a

Browse files
authored
Merge pull request #17537 from gkjohnson/lint-example-shaders-2
Linting: Lint Example Shaders PR 2
2 parents 6751313 + e342df4 commit b6dcc7a

30 files changed

+684
-684
lines changed

examples/js/shaders/DOFMipMapShader.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ THREE.DOFMipMapShader = {
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,14 +42,14 @@ THREE.DOFMipMapShader = {
4242

4343
"void main() {",
4444

45-
"vec4 depth = texture2D( tDepth, vUv );",
45+
" vec4 depth = texture2D( tDepth, vUv );",
4646

47-
"float factor = depth.x - focus;",
47+
" float factor = depth.x - focus;",
4848

49-
"vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );",
49+
" vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );",
5050

51-
"gl_FragColor = col;",
52-
"gl_FragColor.a = 1.0;",
51+
" gl_FragColor = col;",
52+
" gl_FragColor.a = 1.0;",
5353

5454
"}"
5555

examples/js/shaders/DotScreenShader.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ THREE.DotScreenShader = {
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

@@ -44,22 +44,22 @@ THREE.DotScreenShader = {
4444

4545
"float pattern() {",
4646

47-
"float s = sin( angle ), c = cos( angle );",
47+
" float s = sin( angle ), c = cos( angle );",
4848

49-
"vec2 tex = vUv * tSize - center;",
50-
"vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;",
49+
" vec2 tex = vUv * tSize - center;",
50+
" vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;",
5151

52-
"return ( sin( point.x ) * sin( point.y ) ) * 4.0;",
52+
" return ( sin( point.x ) * sin( point.y ) ) * 4.0;",
5353

5454
"}",
5555

5656
"void main() {",
5757

58-
"vec4 color = texture2D( tDiffuse, vUv );",
58+
" vec4 color = texture2D( tDiffuse, vUv );",
5959

60-
"float average = ( color.r + color.g + color.b ) / 3.0;",
60+
" float average = ( color.r + color.g + color.b ) / 3.0;",
6161

62-
"gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );",
62+
" gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );",
6363

6464
"}"
6565

examples/js/shaders/FXAAShader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ THREE.FXAAShader = {
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

examples/js/shaders/FilmShader.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ THREE.FilmShader = {
3939

4040
"void main() {",
4141

42-
"vUv = uv;",
43-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
42+
" vUv = uv;",
43+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
4444

4545
"}"
4646

@@ -71,31 +71,31 @@ THREE.FilmShader = {
7171
"void main() {",
7272

7373
// sample the source
74-
"vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
74+
" vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
7575

7676
// make some noise
77-
"float dx = rand( vUv + time );",
77+
" float dx = rand( vUv + time );",
7878

7979
// add noise
80-
"vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );",
80+
" vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );",
8181

8282
// get us a sine and cosine
83-
"vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );",
83+
" vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );",
8484

8585
// add scanlines
86-
"cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;",
86+
" cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;",
8787

8888
// interpolate between source and result by intensity
89-
"cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
89+
" cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
9090

9191
// convert to grayscale if desired
92-
"if( grayscale ) {",
92+
" if( grayscale ) {",
9393

94-
"cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
94+
" cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
9595

96-
"}",
96+
" }",
9797

98-
"gl_FragColor = vec4( cResult, cTextureScreen.a );",
98+
" gl_FragColor = vec4( cResult, cTextureScreen.a );",
9999

100100
"}"
101101

examples/js/shaders/FocusShader.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ THREE.FocusShader = {
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

@@ -44,45 +44,45 @@ THREE.FocusShader = {
4444

4545
"void main() {",
4646

47-
"vec4 color, org, tmp, add;",
48-
"float sample_dist, f;",
49-
"vec2 vin;",
50-
"vec2 uv = vUv;",
47+
" vec4 color, org, tmp, add;",
48+
" float sample_dist, f;",
49+
" vec2 vin;",
50+
" vec2 uv = vUv;",
5151

52-
"add = color = org = texture2D( tDiffuse, uv );",
52+
" add = color = org = texture2D( tDiffuse, uv );",
5353

54-
"vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );",
55-
"sample_dist = dot( vin, vin ) * 2.0;",
54+
" vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );",
55+
" sample_dist = dot( vin, vin ) * 2.0;",
5656

57-
"f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;",
57+
" f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;",
5858

59-
"vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );",
59+
" vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );",
6060

61-
"add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );",
62-
"if( tmp.b < color.b ) color = tmp;",
61+
" add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );",
62+
" if( tmp.b < color.b ) color = tmp;",
6363

64-
"add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );",
65-
"if( tmp.b < color.b ) color = tmp;",
64+
" add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );",
65+
" if( tmp.b < color.b ) color = tmp;",
6666

67-
"add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );",
68-
"if( tmp.b < color.b ) color = tmp;",
67+
" add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );",
68+
" if( tmp.b < color.b ) color = tmp;",
6969

70-
"add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );",
71-
"if( tmp.b < color.b ) color = tmp;",
70+
" add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );",
71+
" if( tmp.b < color.b ) color = tmp;",
7272

73-
"add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );",
74-
"if( tmp.b < color.b ) color = tmp;",
73+
" add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );",
74+
" if( tmp.b < color.b ) color = tmp;",
7575

76-
"add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );",
77-
"if( tmp.b < color.b ) color = tmp;",
76+
" add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );",
77+
" if( tmp.b < color.b ) color = tmp;",
7878

79-
"add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );",
80-
"if( tmp.b < color.b ) color = tmp;",
79+
" add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );",
80+
" if( tmp.b < color.b ) color = tmp;",
8181

82-
"color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );",
83-
"color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );",
82+
" color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );",
83+
" color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );",
8484

85-
"gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );",
85+
" gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );",
8686

8787
"}"
8888

examples/js/shaders/FreiChenShader.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ THREE.FreiChenShader = {
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

@@ -55,38 +55,38 @@ THREE.FreiChenShader = {
5555
"void main(void)",
5656
"{",
5757

58-
"G[0] = g0,",
59-
"G[1] = g1,",
60-
"G[2] = g2,",
61-
"G[3] = g3,",
62-
"G[4] = g4,",
63-
"G[5] = g5,",
64-
"G[6] = g6,",
65-
"G[7] = g7,",
66-
"G[8] = g8;",
67-
68-
"mat3 I;",
69-
"float cnv[9];",
70-
"vec3 sample;",
71-
72-
/* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */
73-
"for (float i=0.0; i<3.0; i++) {",
74-
"for (float j=0.0; j<3.0; j++) {",
75-
"sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;",
76-
"I[int(i)][int(j)] = length(sample);",
77-
"}",
78-
"}",
79-
80-
/* calculate the convolution values for all the masks */
81-
"for (int i=0; i<9; i++) {",
82-
"float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);",
83-
"cnv[i] = dp3 * dp3;",
84-
"}",
85-
86-
"float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);",
87-
"float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);",
88-
89-
"gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);",
58+
" G[0] = g0,",
59+
" G[1] = g1,",
60+
" G[2] = g2,",
61+
" G[3] = g3,",
62+
" G[4] = g4,",
63+
" G[5] = g5,",
64+
" G[6] = g6,",
65+
" G[7] = g7,",
66+
" G[8] = g8;",
67+
68+
" mat3 I;",
69+
" float cnv[9];",
70+
" vec3 sample;",
71+
72+
/* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */
73+
" for (float i=0.0; i<3.0; i++) {",
74+
" for (float j=0.0; j<3.0; j++) {",
75+
" sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;",
76+
" I[int(i)][int(j)] = length(sample);",
77+
" }",
78+
" }",
79+
80+
/* calculate the convolution values for all the masks */
81+
" for (int i=0; i<9; i++) {",
82+
" float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);",
83+
" cnv[i] = dp3 * dp3;",
84+
" }",
85+
86+
" float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);",
87+
" float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);",
88+
89+
" gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);",
9090
"}"
9191

9292
].join( "\n" )

examples/js/shaders/FresnelShader.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ THREE.FresnelShader = {
2929

3030
"void main() {",
3131

32-
"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
33-
"vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
32+
" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
33+
" vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
3434

35-
"vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
35+
" vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
3636

37-
"vec3 I = worldPosition.xyz - cameraPosition;",
37+
" vec3 I = worldPosition.xyz - cameraPosition;",
3838

39-
"vReflect = reflect( I, worldNormal );",
40-
"vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );",
41-
"vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );",
42-
"vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );",
43-
"vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );",
39+
" vReflect = reflect( I, worldNormal );",
40+
" vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );",
41+
" vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );",
42+
" vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );",
43+
" vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );",
4444

45-
"gl_Position = projectionMatrix * mvPosition;",
45+
" gl_Position = projectionMatrix * mvPosition;",
4646

4747
"}"
4848

@@ -58,14 +58,14 @@ THREE.FresnelShader = {
5858

5959
"void main() {",
6060

61-
"vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
62-
"vec4 refractedColor = vec4( 1.0 );",
61+
" vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
62+
" vec4 refractedColor = vec4( 1.0 );",
6363

64-
"refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
65-
"refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
66-
"refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
64+
" refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
65+
" refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
66+
" refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
6767

68-
"gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
68+
" gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
6969

7070
"}"
7171

examples/js/shaders/GammaCorrectionShader.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ THREE.GammaCorrectionShader = {
1919

2020
"void main() {",
2121

22-
"vUv = uv;",
23-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
22+
" vUv = uv;",
23+
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
2424

2525
"}"
2626

@@ -34,9 +34,9 @@ THREE.GammaCorrectionShader = {
3434

3535
"void main() {",
3636

37-
"vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
37+
" vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
3838

39-
"gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );",
39+
" gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );",
4040

4141
"}"
4242

0 commit comments

Comments
 (0)