Skip to content

Commit 0978e03

Browse files
authored
Examples: Convert shaders to ES6. (#21619)
1 parent 3452a4e commit 0978e03

File tree

104 files changed

+8558
-4513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+8558
-4513
lines changed

examples/js/shaders/ACESFilmicToneMappingShader.js

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* this implementation of ACES is modified to accommodate a brighter viewing environment.
88
* the scale factor of 1/0.6 is subjective. see discussion in #19621.
99
*/
10-
var ACESFilmicToneMappingShader = {
10+
const ACESFilmicToneMappingShader = {
1111
uniforms: {
1212
'tDiffuse': {
1313
value: null
@@ -16,15 +16,67 @@
1616
value: 1.0
1717
}
1818
},
19-
vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
20-
fragmentShader: [ '#define saturate(a) clamp( a, 0.0, 1.0 )', 'uniform sampler2D tDiffuse;', 'uniform float exposure;', 'varying vec2 vUv;', 'vec3 RRTAndODTFit( vec3 v ) {', ' vec3 a = v * ( v + 0.0245786 ) - 0.000090537;', ' vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;', ' return a / b;', '}', 'vec3 ACESFilmicToneMapping( vec3 color ) {', // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
21-
' const mat3 ACESInputMat = mat3(', ' vec3( 0.59719, 0.07600, 0.02840 ),', // transposed from source
22-
' vec3( 0.35458, 0.90834, 0.13383 ),', ' vec3( 0.04823, 0.01566, 0.83777 )', ' );', // ODT_SAT => XYZ => D60_2_D65 => sRGB
23-
' const mat3 ACESOutputMat = mat3(', ' vec3( 1.60475, -0.10208, -0.00327 ),', // transposed from source
24-
' vec3( -0.53108, 1.10813, -0.07276 ),', ' vec3( -0.07367, -0.00605, 1.07602 )', ' );', ' color = ACESInputMat * color;', // Apply RRT and ODT
25-
' color = RRTAndODTFit( color );', ' color = ACESOutputMat * color;', // Clamp to [0, 1]
26-
' return saturate( color );', '}', 'void main() {', ' vec4 tex = texture2D( tDiffuse, vUv );', ' tex.rgb *= exposure / 0.6;', // pre-exposed, outside of the tone mapping function
27-
' gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );', '}' ].join( '\n' )
19+
vertexShader: `varying vec2 vUv;
20+
21+
void main() {
22+
23+
vUv = uv;
24+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
25+
26+
}`,
27+
fragmentShader: `#define saturate(a) clamp( a, 0.0, 1.0 )
28+
29+
uniform sampler2D tDiffuse;
30+
31+
uniform float exposure;
32+
33+
varying vec2 vUv;
34+
35+
vec3 RRTAndODTFit( vec3 v ) {
36+
37+
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
38+
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
39+
return a / b;
40+
41+
}
42+
43+
vec3 ACESFilmicToneMapping( vec3 color ) {
44+
45+
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
46+
const mat3 ACESInputMat = mat3(
47+
vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
48+
vec3( 0.35458, 0.90834, 0.13383 ),
49+
vec3( 0.04823, 0.01566, 0.83777 )
50+
);
51+
52+
// ODT_SAT => XYZ => D60_2_D65 => sRGB
53+
const mat3 ACESOutputMat = mat3(
54+
vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source
55+
vec3( -0.53108, 1.10813, -0.07276 ),
56+
vec3( -0.07367, -0.00605, 1.07602 )
57+
);
58+
59+
color = ACESInputMat * color;
60+
61+
// Apply RRT and ODT
62+
color = RRTAndODTFit( color );
63+
64+
color = ACESOutputMat * color;
65+
66+
// Clamp to [0, 1]
67+
return saturate( color );
68+
69+
}
70+
71+
void main() {
72+
73+
vec4 tex = texture2D( tDiffuse, vUv );
74+
75+
tex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function
76+
77+
gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );
78+
79+
}`
2880
};
2981

3082
THREE.ACESFilmicToneMappingShader = ACESFilmicToneMappingShader;

examples/js/shaders/AfterimageShader.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* I created this effect inspired by a demo on codepen:
66
* https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&
77
*/
8-
var AfterimageShader = {
8+
const AfterimageShader = {
99
uniforms: {
1010
'damp': {
1111
value: 0.96
@@ -17,8 +17,37 @@
1717
value: null
1818
}
1919
},
20-
vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
21-
fragmentShader: [ 'uniform float damp;', 'uniform sampler2D tOld;', 'uniform sampler2D tNew;', 'varying vec2 vUv;', 'vec4 when_gt( vec4 x, float y ) {', ' return max( sign( x - y ), 0.0 );', '}', 'void main() {', ' vec4 texelOld = texture2D( tOld, vUv );', ' vec4 texelNew = texture2D( tNew, vUv );', ' texelOld *= damp * when_gt( texelOld, 0.1 );', ' gl_FragColor = max(texelNew, texelOld);', '}' ].join( '\n' )
20+
vertexShader: `varying vec2 vUv;
21+
22+
void main() {
23+
24+
vUv = uv;
25+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
26+
27+
}`,
28+
fragmentShader: `uniform float damp;
29+
30+
uniform sampler2D tOld;
31+
uniform sampler2D tNew;
32+
33+
varying vec2 vUv;
34+
35+
vec4 when_gt( vec4 x, float y ) {
36+
37+
return max( sign( x - y ), 0.0 );
38+
39+
}
40+
41+
void main() {
42+
43+
vec4 texelOld = texture2D( tOld, vUv );
44+
vec4 texelNew = texture2D( tNew, vUv );
45+
46+
texelOld *= damp * when_gt( texelOld, 0.1 );
47+
48+
gl_FragColor = max(texelNew, texelOld);
49+
50+
}`
2251
};
2352

2453
THREE.AfterimageShader = AfterimageShader;

examples/js/shaders/BasicShader.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
/**
44
* Simple test shader
55
*/
6-
var BasicShader = {
6+
const BasicShader = {
77
uniforms: {},
8-
vertexShader: [ 'void main() {', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
9-
fragmentShader: [ 'void main() {', ' gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );', '}' ].join( '\n' )
8+
vertexShader: `void main() {
9+
10+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
11+
12+
}`,
13+
fragmentShader: `void main() {
14+
15+
gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );
16+
17+
}`
1018
};
1119

1220
THREE.BasicShader = BasicShader;

examples/js/shaders/BleachBypassShader.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* - based on Nvidia example
66
* http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
77
*/
8-
var BleachBypassShader = {
8+
const BleachBypassShader = {
99
uniforms: {
1010
'tDiffuse': {
1111
value: null
@@ -14,8 +14,42 @@
1414
value: 1.0
1515
}
1616
},
17-
vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
18-
fragmentShader: [ 'uniform float opacity;', 'uniform sampler2D tDiffuse;', 'varying vec2 vUv;', 'void main() {', ' vec4 base = texture2D( tDiffuse, vUv );', ' vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );', ' float lum = dot( lumCoeff, base.rgb );', ' vec3 blend = vec3( lum );', ' float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );', ' vec3 result1 = 2.0 * base.rgb * blend;', ' vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );', ' vec3 newColor = mix( result1, result2, L );', ' float A2 = opacity * base.a;', ' vec3 mixRGB = A2 * newColor.rgb;', ' mixRGB += ( ( 1.0 - A2 ) * base.rgb );', ' gl_FragColor = vec4( mixRGB, base.a );', '}' ].join( '\n' )
17+
vertexShader: `varying vec2 vUv;
18+
19+
void main() {
20+
21+
vUv = uv;
22+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
23+
24+
}`,
25+
fragmentShader: `uniform float opacity;
26+
27+
uniform sampler2D tDiffuse;
28+
29+
varying vec2 vUv;
30+
31+
void main() {
32+
33+
vec4 base = texture2D( tDiffuse, vUv );
34+
35+
vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );
36+
float lum = dot( lumCoeff, base.rgb );
37+
vec3 blend = vec3( lum );
38+
39+
float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );
40+
41+
vec3 result1 = 2.0 * base.rgb * blend;
42+
vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );
43+
44+
vec3 newColor = mix( result1, result2, L );
45+
46+
float A2 = opacity * base.a;
47+
vec3 mixRGB = A2 * newColor.rgb;
48+
mixRGB += ( ( 1.0 - A2 ) * base.rgb );
49+
50+
gl_FragColor = vec4( mixRGB, base.a );
51+
52+
}`
1953
};
2054

2155
THREE.BleachBypassShader = BleachBypassShader;

examples/js/shaders/BlendShader.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Blend two textures
55
*/
6-
var BlendShader = {
6+
const BlendShader = {
77
uniforms: {
88
'tDiffuse1': {
99
value: null
@@ -18,8 +18,29 @@
1818
value: 1.0
1919
}
2020
},
21-
vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
22-
fragmentShader: [ 'uniform float opacity;', 'uniform float mixRatio;', 'uniform sampler2D tDiffuse1;', 'uniform sampler2D tDiffuse2;', 'varying vec2 vUv;', 'void main() {', ' vec4 texel1 = texture2D( tDiffuse1, vUv );', ' vec4 texel2 = texture2D( tDiffuse2, vUv );', ' gl_FragColor = opacity * mix( texel1, texel2, mixRatio );', '}' ].join( '\n' )
21+
vertexShader: `varying vec2 vUv;
22+
23+
void main() {
24+
25+
vUv = uv;
26+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
27+
28+
}`,
29+
fragmentShader: `uniform float opacity;
30+
uniform float mixRatio;
31+
32+
uniform sampler2D tDiffuse1;
33+
uniform sampler2D tDiffuse2;
34+
35+
varying vec2 vUv;
36+
37+
void main() {
38+
39+
vec4 texel1 = texture2D( tDiffuse1, vUv );
40+
vec4 texel2 = texture2D( tDiffuse2, vUv );
41+
gl_FragColor = opacity * mix( texel1, texel2, mixRatio );
42+
43+
}`
2344
};
2445

2546
THREE.BlendShader = BlendShader;

examples/js/shaders/BokehShader.js

Lines changed: 109 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* ported from GLSL shader by Martins Upitis
66
* http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
77
*/
8-
var BokehShader = {
8+
const BokehShader = {
99
defines: {
1010
'DEPTH_PACKING': 1,
1111
'PERSPECTIVE_CAMERA': 1
@@ -36,11 +36,114 @@
3636
value: 1000.0
3737
}
3838
},
39-
vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
40-
fragmentShader: [ '#include <common>', 'varying vec2 vUv;', 'uniform sampler2D tColor;', 'uniform sampler2D tDepth;', 'uniform float maxblur;', // max blur amount
41-
'uniform float aperture;', // aperture - bigger values for shallower depth of field
42-
'uniform float nearClip;', 'uniform float farClip;', 'uniform float focus;', 'uniform float aspect;', '#include <packing>', 'float getDepth( const in vec2 screenPosition ) {', ' #if DEPTH_PACKING == 1', ' return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );', ' #else', ' return texture2D( tDepth, screenPosition ).x;', ' #endif', '}', 'float getViewZ( const in float depth ) {', ' #if PERSPECTIVE_CAMERA == 1', ' return perspectiveDepthToViewZ( depth, nearClip, farClip );', ' #else', ' return orthographicDepthToViewZ( depth, nearClip, farClip );', ' #endif', '}', 'void main() {', ' vec2 aspectcorrect = vec2( 1.0, aspect );', ' float viewZ = getViewZ( getDepth( vUv ) );', ' float factor = ( focus + viewZ );', // viewZ is <= 0, so this is a difference equation
43-
' vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );', ' vec2 dofblur9 = dofblur * 0.9;', ' vec2 dofblur7 = dofblur * 0.7;', ' vec2 dofblur4 = dofblur * 0.4;', ' vec4 col = vec4( 0.0 );', ' col += texture2D( tColor, vUv.xy );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );', ' col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );', ' gl_FragColor = col / 41.0;', ' gl_FragColor.a = 1.0;', '}' ].join( '\n' )
39+
vertexShader: `varying vec2 vUv;
40+
41+
void main() {
42+
43+
vUv = uv;
44+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
45+
46+
}`,
47+
fragmentShader: `#include <common>
48+
49+
varying vec2 vUv;
50+
51+
uniform sampler2D tColor;
52+
uniform sampler2D tDepth;
53+
54+
uniform float maxblur; // max blur amount
55+
uniform float aperture; // aperture - bigger values for shallower depth of field
56+
57+
uniform float nearClip;
58+
uniform float farClip;
59+
60+
uniform float focus;
61+
uniform float aspect;
62+
63+
#include <packing>
64+
65+
float getDepth( const in vec2 screenPosition ) {
66+
#if DEPTH_PACKING == 1
67+
return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );
68+
#else
69+
return texture2D( tDepth, screenPosition ).x;
70+
#endif
71+
}
72+
73+
float getViewZ( const in float depth ) {
74+
#if PERSPECTIVE_CAMERA == 1
75+
return perspectiveDepthToViewZ( depth, nearClip, farClip );
76+
#else
77+
return orthographicDepthToViewZ( depth, nearClip, farClip );
78+
#endif
79+
}
80+
81+
82+
void main() {
83+
84+
vec2 aspectcorrect = vec2( 1.0, aspect );
85+
86+
float viewZ = getViewZ( getDepth( vUv ) );
87+
88+
float factor = ( focus + viewZ ); // viewZ is <= 0, so this is a difference equation
89+
90+
vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );
91+
92+
vec2 dofblur9 = dofblur * 0.9;
93+
vec2 dofblur7 = dofblur * 0.7;
94+
vec2 dofblur4 = dofblur * 0.4;
95+
96+
vec4 col = vec4( 0.0 );
97+
98+
col += texture2D( tColor, vUv.xy );
99+
col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );
100+
col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );
101+
col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );
102+
col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );
103+
col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );
104+
col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );
105+
col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );
106+
col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );
107+
col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );
108+
col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );
109+
col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );
110+
col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );
111+
col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );
112+
col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );
113+
col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );
114+
col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );
115+
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+
col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );
121+
col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );
122+
col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );
123+
col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );
124+
125+
col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );
126+
col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 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+
col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );
130+
col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );
131+
col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );
132+
col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );
133+
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+
col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );
139+
col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );
140+
col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );
141+
col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );
142+
143+
gl_FragColor = col / 41.0;
144+
gl_FragColor.a = 1.0;
145+
146+
}`
44147
};
45148

46149
THREE.BokehShader = BokehShader;

0 commit comments

Comments
 (0)