Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting: Lint Example Shaders PR 1 #17533

Merged
merged 4 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/js/shaders/AfterimageShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ THREE.AfterimageShader = {

"void main() {",

"vUv = uv;",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
" vUv = uv;",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

"}"

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

"varying vec2 vUv;",

"vec4 when_gt( vec4 x, float y ) {",

"return max( sign( x - y ), 0.0 );",
" 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 );",
" vec4 texelOld = texture2D( tOld, vUv );",
" vec4 texelNew = texture2D( tNew, vUv );",

" texelOld *= damp * when_gt( texelOld, 0.1 );",

"gl_FragColor = max(texelNew, texelOld);",
" gl_FragColor = max(texelNew, texelOld);",

"}"

Expand Down
4 changes: 2 additions & 2 deletions examples/js/shaders/BasicShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ THREE.BasicShader = {

"void main() {",

"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

"}"

Expand All @@ -22,7 +22,7 @@ THREE.BasicShader = {

"void main() {",

"gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",

"}"

Expand Down
28 changes: 14 additions & 14 deletions examples/js/shaders/BleachBypassShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ THREE.BleachBypassShader = {

"void main() {",

"vUv = uv;",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
" vUv = uv;",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

"}"

Expand All @@ -38,24 +38,24 @@ THREE.BleachBypassShader = {

"void main() {",

"vec4 base = texture2D( tDiffuse, vUv );",
" vec4 base = texture2D( tDiffuse, vUv );",

"vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
"float lum = dot( lumCoeff, base.rgb );",
"vec3 blend = vec3( lum );",
" 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 ) ) );",
" 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 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 );",
" vec3 newColor = mix( result1, result2, L );",

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

"gl_FragColor = vec4( mixRGB, base.a );",
" gl_FragColor = vec4( mixRGB, base.a );",

"}"

Expand Down
10 changes: 5 additions & 5 deletions examples/js/shaders/BlendShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ THREE.BlendShader = {

"void main() {",

"vUv = uv;",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
" vUv = uv;",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

"}"

Expand All @@ -40,9 +40,9 @@ THREE.BlendShader = {

"void main() {",

"vec4 texel1 = texture2D( tDiffuse1, vUv );",
"vec4 texel2 = texture2D( tDiffuse2, vUv );",
"gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
" vec4 texel1 = texture2D( tDiffuse1, vUv );",
" vec4 texel2 = texture2D( tDiffuse2, vUv );",
" gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",

"}"

Expand Down
126 changes: 63 additions & 63 deletions examples/js/shaders/BokehShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ THREE.BokehShader = {

"void main() {",

"vUv = uv;",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
" vUv = uv;",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

"}"

Expand Down Expand Up @@ -77,67 +77,67 @@ THREE.BokehShader = {

"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

"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;",
" vec2 aspectcorrect = vec2( 1.0, aspect );",

" float viewZ = getViewZ( getDepth( vUv ) );",

" float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation

" 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;",

"}"

Expand Down
Loading