Favivon - Correção

This commit is contained in:
2026-05-30 19:59:39 -03:00
parent 76ddaa815d
commit d7dfd221f0
32859 changed files with 5459654 additions and 404 deletions
+81
View File
@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const ACESFilmicToneMappingShader = {
uniforms: {
tDiffuse: { value: null },
exposure: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#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
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
// ODT_SAT => XYZ => D60_2_D65 => sRGB
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source
vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color = ACESInputMat * color;
// Apply RRT and ODT
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
// Clamp to [0, 1]
return saturate( color );
}
void main() {
vec4 tex = texture2D( tDiffuse, vUv );
tex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function
gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );
}
`
)
};
exports.ACESFilmicToneMappingShader = ACESFilmicToneMappingShader;
//# sourceMappingURL=ACESFilmicToneMappingShader.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"ACESFilmicToneMappingShader.cjs","sources":["../../src/shaders/ACESFilmicToneMappingShader.ts"],"sourcesContent":["/**\n * ACES Filmic Tone Mapping Shader by Stephen Hill\n * source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs\n *\n * this implementation of ACES is modified to accommodate a brighter viewing environment.\n * the scale factor of 1/0.6 is subjective. see discussion in #19621.\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type ACESFilmicToneMappingShaderUniforms = {\n exposure: IUniform<number>\n tDiffuse: IUniform<Texture | null>\n}\n\nexport interface IACESFilmicToneMappingShader extends IShader<ACESFilmicToneMappingShaderUniforms> {}\n\nexport const ACESFilmicToneMappingShader: IACESFilmicToneMappingShader = {\n uniforms: {\n tDiffuse: { value: null },\n exposure: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n fragmentShader: /* glsl */ `\n #define saturate(a) clamp( a, 0.0, 1.0 )\n\n uniform sampler2D tDiffuse;\n\n uniform float exposure;\n\n varying vec2 vUv;\n\n vec3 RRTAndODTFit( vec3 v ) {\n\n \tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n \tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n \treturn a / b;\n\n }\n\n vec3 ACESFilmicToneMapping( vec3 color ) {\n\n // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n \tconst mat3 ACESInputMat = mat3(\n \t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n \t\tvec3( 0.35458, 0.90834, 0.13383 ),\n \t\tvec3( 0.04823, 0.01566, 0.83777 )\n \t);\n\n // ODT_SAT => XYZ => D60_2_D65 => sRGB\n \tconst mat3 ACESOutputMat = mat3(\n \t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n \t\tvec3( -0.53108, 1.10813, -0.07276 ),\n \t\tvec3( -0.07367, -0.00605, 1.07602 )\n \t);\n\n \tcolor = ACESInputMat * color;\n\n // Apply RRT and ODT\n \tcolor = RRTAndODTFit( color );\n\n \tcolor = ACESOutputMat * color;\n\n // Clamp to [0, 1]\n \treturn saturate( color );\n\n }\n\n void main() {\n\n \tvec4 tex = texture2D( tDiffuse, vUv );\n\n \ttex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function\n\n \tgl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAkBO,MAAM,8BAA4D;AAAA,EACvE,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,UAAU,EAAE,OAAO,EAAI;AAAA,EACzB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuD7B;;"}
+16
View File
@@ -0,0 +1,16 @@
/**
* ACES Filmic Tone Mapping Shader by Stephen Hill
* source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
*
* this implementation of ACES is modified to accommodate a brighter viewing environment.
* the scale factor of 1/0.6 is subjective. see discussion in #19621.
*/
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type ACESFilmicToneMappingShaderUniforms = {
exposure: IUniform<number>;
tDiffuse: IUniform<Texture | null>;
};
export interface IACESFilmicToneMappingShader extends IShader<ACESFilmicToneMappingShaderUniforms> {
}
export declare const ACESFilmicToneMappingShader: IACESFilmicToneMappingShader;
+81
View File
@@ -0,0 +1,81 @@
const ACESFilmicToneMappingShader = {
uniforms: {
tDiffuse: { value: null },
exposure: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#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
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
// ODT_SAT => XYZ => D60_2_D65 => sRGB
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source
vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color = ACESInputMat * color;
// Apply RRT and ODT
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
// Clamp to [0, 1]
return saturate( color );
}
void main() {
vec4 tex = texture2D( tDiffuse, vUv );
tex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function
gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );
}
`
)
};
export {
ACESFilmicToneMappingShader
};
//# sourceMappingURL=ACESFilmicToneMappingShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ACESFilmicToneMappingShader.js","sources":["../../src/shaders/ACESFilmicToneMappingShader.ts"],"sourcesContent":["/**\n * ACES Filmic Tone Mapping Shader by Stephen Hill\n * source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs\n *\n * this implementation of ACES is modified to accommodate a brighter viewing environment.\n * the scale factor of 1/0.6 is subjective. see discussion in #19621.\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type ACESFilmicToneMappingShaderUniforms = {\n exposure: IUniform<number>\n tDiffuse: IUniform<Texture | null>\n}\n\nexport interface IACESFilmicToneMappingShader extends IShader<ACESFilmicToneMappingShaderUniforms> {}\n\nexport const ACESFilmicToneMappingShader: IACESFilmicToneMappingShader = {\n uniforms: {\n tDiffuse: { value: null },\n exposure: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n fragmentShader: /* glsl */ `\n #define saturate(a) clamp( a, 0.0, 1.0 )\n\n uniform sampler2D tDiffuse;\n\n uniform float exposure;\n\n varying vec2 vUv;\n\n vec3 RRTAndODTFit( vec3 v ) {\n\n \tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n \tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n \treturn a / b;\n\n }\n\n vec3 ACESFilmicToneMapping( vec3 color ) {\n\n // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n \tconst mat3 ACESInputMat = mat3(\n \t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n \t\tvec3( 0.35458, 0.90834, 0.13383 ),\n \t\tvec3( 0.04823, 0.01566, 0.83777 )\n \t);\n\n // ODT_SAT => XYZ => D60_2_D65 => sRGB\n \tconst mat3 ACESOutputMat = mat3(\n \t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n \t\tvec3( -0.53108, 1.10813, -0.07276 ),\n \t\tvec3( -0.07367, -0.00605, 1.07602 )\n \t);\n\n \tcolor = ACESInputMat * color;\n\n // Apply RRT and ODT\n \tcolor = RRTAndODTFit( color );\n\n \tcolor = ACESOutputMat * color;\n\n // Clamp to [0, 1]\n \treturn saturate( color );\n\n }\n\n void main() {\n\n \tvec4 tex = texture2D( tDiffuse, vUv );\n\n \ttex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function\n\n \tgl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );\n\n }\n `,\n}\n"],"names":[],"mappings":"AAkBO,MAAM,8BAA4D;AAAA,EACvE,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,UAAU,EAAE,OAAO,EAAI;AAAA,EACzB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuD7B;"}
+52
View File
@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const AfterimageShader = {
uniforms: {
damp: { value: 0.96 },
tOld: { value: null },
tNew: { value: null }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
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);
}
`
)
};
exports.AfterimageShader = AfterimageShader;
//# sourceMappingURL=AfterimageShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"AfterimageShader.cjs","sources":["../../src/shaders/AfterimageShader.ts"],"sourcesContent":["/**\n * Afterimage shader\n * I created this effect inspired by a demo on codepen:\n * https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type AfterimageShaderUniforms = {\n damp: IUniform<number>\n tNew: IUniform<Texture | null>\n tOld: IUniform<Texture | null>\n}\n\nexport interface IAfterimageShader extends IShader<AfterimageShaderUniforms> {}\n\nexport const AfterimageShader: IAfterimageShader = {\n uniforms: {\n damp: { value: 0.96 },\n tOld: { value: null },\n tNew: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float damp;\n\n uniform sampler2D tOld;\n uniform sampler2D tNew;\n\n varying vec2 vUv;\n\n vec4 when_gt( vec4 x, float y ) {\n\n \treturn max( sign( x - y ), 0.0 );\n\n }\n\n void main() {\n\n \tvec4 texelOld = texture2D( tOld, vUv );\n \tvec4 texelNew = texture2D( tNew, vUv );\n\n \ttexelOld *= damp * when_gt( texelOld, 0.1 );\n\n \tgl_FragColor = max(texelNew, texelOld);\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,mBAAsC;AAAA,EACjD,UAAU;AAAA,IACR,MAAM,EAAE,OAAO,KAAK;AAAA,IACpB,MAAM,EAAE,OAAO,KAAK;AAAA,IACpB,MAAM,EAAE,OAAO,KAAK;AAAA,EACtB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyB7B;;"}
+15
View File
@@ -0,0 +1,15 @@
/**
* Afterimage shader
* I created this effect inspired by a demo on codepen:
* https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&
*/
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type AfterimageShaderUniforms = {
damp: IUniform<number>;
tNew: IUniform<Texture | null>;
tOld: IUniform<Texture | null>;
};
export interface IAfterimageShader extends IShader<AfterimageShaderUniforms> {
}
export declare const AfterimageShader: IAfterimageShader;
+52
View File
@@ -0,0 +1,52 @@
const AfterimageShader = {
uniforms: {
damp: { value: 0.96 },
tOld: { value: null },
tNew: { value: null }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
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);
}
`
)
};
export {
AfterimageShader
};
//# sourceMappingURL=AfterimageShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"AfterimageShader.js","sources":["../../src/shaders/AfterimageShader.ts"],"sourcesContent":["/**\n * Afterimage shader\n * I created this effect inspired by a demo on codepen:\n * https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type AfterimageShaderUniforms = {\n damp: IUniform<number>\n tNew: IUniform<Texture | null>\n tOld: IUniform<Texture | null>\n}\n\nexport interface IAfterimageShader extends IShader<AfterimageShaderUniforms> {}\n\nexport const AfterimageShader: IAfterimageShader = {\n uniforms: {\n damp: { value: 0.96 },\n tOld: { value: null },\n tNew: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float damp;\n\n uniform sampler2D tOld;\n uniform sampler2D tNew;\n\n varying vec2 vUv;\n\n vec4 when_gt( vec4 x, float y ) {\n\n \treturn max( sign( x - y ), 0.0 );\n\n }\n\n void main() {\n\n \tvec4 texelOld = texture2D( tOld, vUv );\n \tvec4 texelNew = texture2D( tNew, vUv );\n\n \ttexelOld *= damp * when_gt( texelOld, 0.1 );\n\n \tgl_FragColor = max(texelNew, texelOld);\n\n }\n `,\n}\n"],"names":[],"mappings":"AAiBO,MAAM,mBAAsC;AAAA,EACjD,UAAU;AAAA,IACR,MAAM,EAAE,OAAO,KAAK;AAAA,IACpB,MAAM,EAAE,OAAO,KAAK;AAAA,IACpB,MAAM,EAAE,OAAO,KAAK;AAAA,EACtB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyB7B;"}
+27
View File
@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const BasicShader = {
uniforms: {},
vertexShader: (
/* glsl */
`
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );
}
`
)
};
exports.BasicShader = BasicShader;
//# sourceMappingURL=BasicShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BasicShader.cjs","sources":["../../src/shaders/BasicShader.ts"],"sourcesContent":["/**\n * Simple test shader\n */\n\nimport type { IShader } from './types'\n\nexport type BasicShaderUniforms = {}\n\nexport interface IBasicShader extends IShader<BasicShaderUniforms> {}\n\nexport const BasicShader: IBasicShader = {\n uniforms: {},\n\n vertexShader: /* glsl */ `\n void main() {\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n void main() {\n\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAUO,MAAM,cAA4B;AAAA,EACvC,UAAU,CAAC;AAAA,EAEX;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO7B;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* Simple test shader
*/
import type { IShader } from './types';
export type BasicShaderUniforms = {};
export interface IBasicShader extends IShader<BasicShaderUniforms> {
}
export declare const BasicShader: IBasicShader;
+27
View File
@@ -0,0 +1,27 @@
const BasicShader = {
uniforms: {},
vertexShader: (
/* glsl */
`
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );
}
`
)
};
export {
BasicShader
};
//# sourceMappingURL=BasicShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BasicShader.js","sources":["../../src/shaders/BasicShader.ts"],"sourcesContent":["/**\n * Simple test shader\n */\n\nimport type { IShader } from './types'\n\nexport type BasicShaderUniforms = {}\n\nexport interface IBasicShader extends IShader<BasicShaderUniforms> {}\n\nexport const BasicShader: IBasicShader = {\n uniforms: {},\n\n vertexShader: /* glsl */ `\n void main() {\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n void main() {\n\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n\n }\n `,\n}\n"],"names":[],"mappings":"AAUO,MAAM,cAA4B;AAAA,EACvC,UAAU,CAAC;AAAA,EAEX;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO7B;"}
+56
View File
@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const BleachBypassShader = {
uniforms: {
tDiffuse: { value: null },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
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 );
}
`
)
};
exports.BleachBypassShader = BleachBypassShader;
//# sourceMappingURL=BleachBypassShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BleachBypassShader.cjs","sources":["../../src/shaders/BleachBypassShader.ts"],"sourcesContent":["/**\n * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]\n * - based on Nvidia example\n * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type BleachBypassShaderUniforms = {\n opacity: IUniform<number>\n tDiffuse: IUniform<Texture | null>\n}\n\nexport interface IBleachBypassShader extends IShader<BleachBypassShaderUniforms> {}\n\nexport const BleachBypassShader: IBleachBypassShader = {\n uniforms: {\n tDiffuse: { value: null },\n opacity: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 base = texture2D( tDiffuse, vUv );\n\n \tvec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );\n \tfloat lum = dot( lumCoeff, base.rgb );\n \tvec3 blend = vec3( lum );\n\n \tfloat L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );\n\n \tvec3 result1 = 2.0 * base.rgb * blend;\n \tvec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );\n\n \tvec3 newColor = mix( result1, result2, L );\n\n \tfloat A2 = opacity * base.a;\n \tvec3 mixRGB = A2 * newColor.rgb;\n \tmixRGB += ( ( 1.0 - A2 ) * base.rgb );\n\n \tgl_FragColor = vec4( mixRGB, base.a );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAgBO,MAAM,qBAA0C;AAAA,EACrD,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8B7B;;"}
+14
View File
@@ -0,0 +1,14 @@
/**
* Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]
* - based on Nvidia example
* http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
*/
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type BleachBypassShaderUniforms = {
opacity: IUniform<number>;
tDiffuse: IUniform<Texture | null>;
};
export interface IBleachBypassShader extends IShader<BleachBypassShaderUniforms> {
}
export declare const BleachBypassShader: IBleachBypassShader;
+56
View File
@@ -0,0 +1,56 @@
const BleachBypassShader = {
uniforms: {
tDiffuse: { value: null },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
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 );
}
`
)
};
export {
BleachBypassShader
};
//# sourceMappingURL=BleachBypassShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BleachBypassShader.js","sources":["../../src/shaders/BleachBypassShader.ts"],"sourcesContent":["/**\n * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]\n * - based on Nvidia example\n * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type BleachBypassShaderUniforms = {\n opacity: IUniform<number>\n tDiffuse: IUniform<Texture | null>\n}\n\nexport interface IBleachBypassShader extends IShader<BleachBypassShaderUniforms> {}\n\nexport const BleachBypassShader: IBleachBypassShader = {\n uniforms: {\n tDiffuse: { value: null },\n opacity: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 base = texture2D( tDiffuse, vUv );\n\n \tvec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );\n \tfloat lum = dot( lumCoeff, base.rgb );\n \tvec3 blend = vec3( lum );\n\n \tfloat L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );\n\n \tvec3 result1 = 2.0 * base.rgb * blend;\n \tvec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );\n\n \tvec3 newColor = mix( result1, result2, L );\n\n \tfloat A2 = opacity * base.a;\n \tvec3 mixRGB = A2 * newColor.rgb;\n \tmixRGB += ( ( 1.0 - A2 ) * base.rgb );\n\n \tgl_FragColor = vec4( mixRGB, base.a );\n\n }\n `,\n}\n"],"names":[],"mappings":"AAgBO,MAAM,qBAA0C;AAAA,EACrD,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8B7B;"}
+45
View File
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const BlendShader = {
uniforms: {
tDiffuse1: { value: null },
tDiffuse2: { value: null },
mixRatio: { value: 0.5 },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
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 );
}
`
)
};
exports.BlendShader = BlendShader;
//# sourceMappingURL=BlendShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BlendShader.cjs","sources":["../../src/shaders/BlendShader.ts"],"sourcesContent":["/**\n * Blend two textures\n */\n\nexport const BlendShader = {\n uniforms: {\n tDiffuse1: { value: null },\n tDiffuse2: { value: null },\n mixRatio: { value: 0.5 },\n opacity: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float opacity;\n uniform float mixRatio;\n\n uniform sampler2D tDiffuse1;\n uniform sampler2D tDiffuse2;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 texel1 = texture2D( tDiffuse1, vUv );\n \tvec4 texel2 = texture2D( tDiffuse2, vUv );\n \tgl_FragColor = opacity * mix( texel1, texel2, mixRatio );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAIO,MAAM,cAAc;AAAA,EACzB,UAAU;AAAA,IACR,WAAW,EAAE,OAAO,KAAK;AAAA,IACzB,WAAW,EAAE,OAAO,KAAK;AAAA,IACzB,UAAU,EAAE,OAAO,IAAI;AAAA,IACvB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB7B;;"}
+21
View File
@@ -0,0 +1,21 @@
/**
* Blend two textures
*/
export declare const BlendShader: {
uniforms: {
tDiffuse1: {
value: null;
};
tDiffuse2: {
value: null;
};
mixRatio: {
value: number;
};
opacity: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+45
View File
@@ -0,0 +1,45 @@
const BlendShader = {
uniforms: {
tDiffuse1: { value: null },
tDiffuse2: { value: null },
mixRatio: { value: 0.5 },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
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 );
}
`
)
};
export {
BlendShader
};
//# sourceMappingURL=BlendShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BlendShader.js","sources":["../../src/shaders/BlendShader.ts"],"sourcesContent":["/**\n * Blend two textures\n */\n\nexport const BlendShader = {\n uniforms: {\n tDiffuse1: { value: null },\n tDiffuse2: { value: null },\n mixRatio: { value: 0.5 },\n opacity: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float opacity;\n uniform float mixRatio;\n\n uniform sampler2D tDiffuse1;\n uniform sampler2D tDiffuse2;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 texel1 = texture2D( tDiffuse1, vUv );\n \tvec4 texel2 = texture2D( tDiffuse2, vUv );\n \tgl_FragColor = opacity * mix( texel1, texel2, mixRatio );\n\n }\n `,\n}\n"],"names":[],"mappings":"AAIO,MAAM,cAAc;AAAA,EACzB,UAAU;AAAA,IACR,WAAW,EAAE,OAAO,KAAK;AAAA,IACzB,WAAW,EAAE,OAAO,KAAK;AAAA,IACzB,UAAU,EAAE,OAAO,IAAI;AAAA,IACvB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB7B;"}
+137
View File
@@ -0,0 +1,137 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const BokehShader = {
defines: {
DEPTH_PACKING: 1,
PERSPECTIVE_CAMERA: 1
},
uniforms: {
tColor: { value: null },
tDepth: { value: null },
focus: { value: 1 },
aspect: { value: 1 },
aperture: { value: 0.025 },
maxblur: { value: 0.01 },
nearClip: { value: 1 },
farClip: { value: 1e3 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
varying vec2 vUv;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform float maxblur; // max blur amount
uniform float aperture; // aperture - bigger values for shallower depth of field
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
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;
}
`
)
};
exports.BokehShader = BokehShader;
//# sourceMappingURL=BokehShader.cjs.map
File diff suppressed because one or more lines are too long
+24
View File
@@ -0,0 +1,24 @@
/**
* Depth-of-field shader with bokeh
* ported from GLSL shader by Martins Upitis
* http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
*/
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type BokehShaderDefines = {
DEPTH_PACKING: number;
PERSPECTIVE_CAMERA: number;
};
export type BokehShaderUniforms = {
aperture: IUniform<number>;
aspect: IUniform<number>;
farClip: IUniform<number>;
focus: IUniform<number>;
maxblur: IUniform<number>;
nearClip: IUniform<number>;
tColor: IUniform<Texture | null>;
tDepth: IUniform<Texture | null>;
};
export interface IBokehShader extends IShader<BokehShaderUniforms, BokehShaderDefines> {
}
export declare const BokehShader: IBokehShader;
+137
View File
@@ -0,0 +1,137 @@
const BokehShader = {
defines: {
DEPTH_PACKING: 1,
PERSPECTIVE_CAMERA: 1
},
uniforms: {
tColor: { value: null },
tDepth: { value: null },
focus: { value: 1 },
aspect: { value: 1 },
aperture: { value: 0.025 },
maxblur: { value: 0.01 },
nearClip: { value: 1 },
farClip: { value: 1e3 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
varying vec2 vUv;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform float maxblur; // max blur amount
uniform float aperture; // aperture - bigger values for shallower depth of field
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
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;
}
`
)
};
export {
BokehShader
};
//# sourceMappingURL=BokehShader.js.map
File diff suppressed because one or more lines are too long
+371
View File
@@ -0,0 +1,371 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const BokehShader2 = {
uniforms: {
textureWidth: { value: 1 },
textureHeight: { value: 1 },
focalDepth: { value: 1 },
focalLength: { value: 24 },
fstop: { value: 0.9 },
tColor: { value: null },
tDepth: { value: null },
maxblur: { value: 1 },
showFocus: { value: 0 },
manualdof: { value: 0 },
vignetting: { value: 0 },
depthblur: { value: 0 },
threshold: { value: 0.5 },
gain: { value: 2 },
bias: { value: 0.5 },
fringe: { value: 0.7 },
znear: { value: 0.1 },
zfar: { value: 100 },
noise: { value: 1 },
dithering: { value: 1e-4 },
pentagon: { value: 0 },
shaderFocus: { value: 1 },
focusCoords: { value: /* @__PURE__ */ new THREE.Vector2() }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
varying vec2 vUv;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform float textureWidth;
uniform float textureHeight;
uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below
uniform float focalLength; //focal length in mm
uniform float fstop; //f-stop value
uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)
/*
make sure that these two values are the same for your camera, otherwise distances will be wrong.
*/
uniform float znear; // camera clipping start
uniform float zfar; // camera clipping end
//------------------------------------------
//user variables
const int samples = SAMPLES; //samples on the first ring
const int rings = RINGS; //ring count
const int maxringsamples = rings * samples;
uniform bool manualdof; // manual dof calculation
float ndofstart = 1.0; // near dof blur start
float ndofdist = 2.0; // near dof blur falloff distance
float fdofstart = 1.0; // far dof blur start
float fdofdist = 3.0; // far dof blur falloff distance
float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)
uniform bool vignetting; // use optical lens vignetting
float vignout = 1.3; // vignetting outer border
float vignin = 0.0; // vignetting inner border
float vignfade = 22.0; // f-stops till vignete fades
uniform bool shaderFocus;
// disable if you use external focalDepth value
uniform vec2 focusCoords;
// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)
// if center of screen use vec2(0.5, 0.5);
uniform float maxblur;
//clamp value of max blur (0.0 = no blur, 1.0 default)
uniform float threshold; // highlight threshold;
uniform float gain; // highlight gain;
uniform float bias; // bokeh edge bias
uniform float fringe; // bokeh chromatic aberration / fringing
uniform bool noise; //use noise instead of pattern for sample dithering
uniform float dithering;
uniform bool depthblur; // blur the depth buffer
float dbsize = 1.25; // depth blur size
/*
next part is experimental
not looking good with small sample and ring count
looks okay starting from samples = 4, rings = 4
*/
uniform bool pentagon; //use pentagon as bokeh shape?
float feather = 0.4; //pentagon shape feather
//------------------------------------------
float penta(vec2 coords) {
//pentagonal shape
float scale = float(rings) - 1.3;
vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);
vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);
vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);
vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);
vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);
vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);
vec4 one = vec4( 1.0 );
vec4 P = vec4((coords),vec2(scale, scale));
vec4 dist = vec4(0.0);
float inorout = -4.0;
dist.x = dot( P, HS0 );
dist.y = dot( P, HS1 );
dist.z = dot( P, HS2 );
dist.w = dot( P, HS3 );
dist = smoothstep( -feather, feather, dist );
inorout += dot( dist, one );
dist.x = dot( P, HS4 );
dist.y = HS5.w - abs( P.z );
dist = smoothstep( -feather, feather, dist );
inorout += dist.x;
return clamp( inorout, 0.0, 1.0 );
}
float bdepth(vec2 coords) {
// Depth buffer blur
float d = 0.0;
float kernel[9];
vec2 offset[9];
vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;
offset[0] = vec2(-wh.x,-wh.y);
offset[1] = vec2( 0.0, -wh.y);
offset[2] = vec2( wh.x -wh.y);
offset[3] = vec2(-wh.x, 0.0);
offset[4] = vec2( 0.0, 0.0);
offset[5] = vec2( wh.x, 0.0);
offset[6] = vec2(-wh.x, wh.y);
offset[7] = vec2( 0.0, wh.y);
offset[8] = vec2( wh.x, wh.y);
kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;
kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;
kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;
for( int i=0; i<9; i++ ) {
float tmp = texture2D(tDepth, coords + offset[i]).r;
d += tmp * kernel[i];
}
return d;
}
vec3 color(vec2 coords,float blur) {
//processing the sample
vec3 col = vec3(0.0);
vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);
col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;
col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;
col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;
vec3 lumcoeff = vec3(0.299,0.587,0.114);
float lum = dot(col.rgb, lumcoeff);
float thresh = max((lum-threshold)*gain, 0.0);
return col+mix(vec3(0.0),col,thresh*blur);
}
vec3 debugFocus(vec3 col, float blur, float depth) {
float edge = 0.002*depth; //distance based edge smoothing
float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);
float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);
col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);
col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);
return col;
}
float linearize(float depth) {
return -zfar * znear / (depth * (zfar - znear) - zfar);
}
float vignette() {
float dist = distance(vUv.xy, vec2(0.5,0.5));
dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);
return clamp(dist,0.0,1.0);
}
float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {
float rings2 = float(rings);
float step = PI*2.0 / float(ringsamples);
float pw = cos(j*step)*i;
float ph = sin(j*step)*i;
float p = 1.0;
if (pentagon) {
p = penta(vec2(pw,ph));
}
col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;
return 1.0 * mix(1.0, i /rings2, bias) * p;
}
void main() {
//scene depth calculation
float depth = linearize(texture2D(tDepth,vUv.xy).x);
// Blur depth?
if ( depthblur ) {
depth = linearize(bdepth(vUv.xy));
}
//focal plane calculation
float fDepth = focalDepth;
if (shaderFocus) {
fDepth = linearize(texture2D(tDepth,focusCoords).x);
}
// dof blur factor calculation
float blur = 0.0;
if (manualdof) {
float a = depth-fDepth; // Focal plane
float b = (a-fdofstart)/fdofdist; // Far DoF
float c = (-a-ndofstart)/ndofdist; // Near Dof
blur = (a>0.0) ? b : c;
} else {
float f = focalLength; // focal length in mm
float d = fDepth*1000.0; // focal plane in mm
float o = depth*1000.0; // depth in mm
float a = (o*f)/(o-f);
float b = (d*f)/(d-f);
float c = (d-f)/(d*fstop*CoC);
blur = abs(a-b)*c;
}
blur = clamp(blur,0.0,1.0);
// calculation of pattern for dithering
vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;
// getting blur x and y step factor
float w = (1.0/textureWidth)*blur*maxblur+noise.x;
float h = (1.0/textureHeight)*blur*maxblur+noise.y;
// calculation of final color
vec3 col = vec3(0.0);
if(blur < 0.05) {
//some optimization thingy
col = texture2D(tColor, vUv.xy).rgb;
} else {
col = texture2D(tColor, vUv.xy).rgb;
float s = 1.0;
int ringsamples;
for (int i = 1; i <= rings; i++) {
/*unboxstart*/
ringsamples = i * samples;
for (int j = 0 ; j < maxringsamples ; j++) {
if (j >= ringsamples) break;
s += gather(float(i), float(j), ringsamples, col, w, h, blur);
}
/*unboxend*/
}
col /= s; //divide by sample count
}
if (showFocus) {
col = debugFocus(col, blur, depth);
}
if (vignetting) {
col *= vignette();
}
gl_FragColor.rgb = col;
gl_FragColor.a = 1.0;
}
`
)
};
const BokehDepthShader = {
uniforms: {
mNear: { value: 1 },
mFar: { value: 1e3 }
},
vertexShader: (
/* glsl */
`
varying float vViewZDepth;
void main() {
#include <begin_vertex>
#include <project_vertex>
vViewZDepth = - mvPosition.z;
}
`
),
fragmentShader: (
/* glsl */
`
uniform float mNear;
uniform float mFar;
varying float vViewZDepth;
void main() {
float color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );
gl_FragColor = vec4( vec3( color ), 1.0 );
}
`
)
};
exports.BokehDepthShader = BokehDepthShader;
exports.BokehShader2 = BokehShader2;
//# sourceMappingURL=BokehShader2.cjs.map
File diff suppressed because one or more lines are too long
+50
View File
@@ -0,0 +1,50 @@
import { IUniform, Texture, Vector2 } from 'three';
export interface BokehShader2Uniforms {
textureWidth: IUniform<number>;
textureHeight: IUniform<number>;
focalDepth: IUniform<number>;
focalLength: IUniform<number>;
fstop: IUniform<number>;
tColor: IUniform<Texture | null>;
tDepth: IUniform<Texture | null>;
maxblur: IUniform<number>;
showFocus: IUniform<number>;
manualdof: IUniform<number>;
vignetting: IUniform<number>;
depthblur: IUniform<number>;
threshold: IUniform<number>;
gain: IUniform<number>;
bias: IUniform<number>;
fringe: IUniform<number>;
znear: IUniform<number>;
zfar: IUniform<number>;
noise: IUniform<number>;
dithering: IUniform<number>;
pentagon: IUniform<number>;
shaderFocus: IUniform<number>;
focusCoords: IUniform<Vector2>;
}
/**
* Depth-of-field shader with bokeh
* ported from GLSL shader by Martins Upitis
* http://blenderartists.org/forum/showthread.php?237488-GLSL-depth-of-field-with-bokeh-v2-4-(update)
*
* Requires #define RINGS and SAMPLES integers
*/
export declare const BokehShader2: {
uniforms: BokehShader2Uniforms;
vertexShader: string;
fragmentShader: string;
};
export declare const BokehDepthShader: {
uniforms: {
mNear: {
value: number;
};
mFar: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+371
View File
@@ -0,0 +1,371 @@
import { Vector2 } from "three";
const BokehShader2 = {
uniforms: {
textureWidth: { value: 1 },
textureHeight: { value: 1 },
focalDepth: { value: 1 },
focalLength: { value: 24 },
fstop: { value: 0.9 },
tColor: { value: null },
tDepth: { value: null },
maxblur: { value: 1 },
showFocus: { value: 0 },
manualdof: { value: 0 },
vignetting: { value: 0 },
depthblur: { value: 0 },
threshold: { value: 0.5 },
gain: { value: 2 },
bias: { value: 0.5 },
fringe: { value: 0.7 },
znear: { value: 0.1 },
zfar: { value: 100 },
noise: { value: 1 },
dithering: { value: 1e-4 },
pentagon: { value: 0 },
shaderFocus: { value: 1 },
focusCoords: { value: /* @__PURE__ */ new Vector2() }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
varying vec2 vUv;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform float textureWidth;
uniform float textureHeight;
uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below
uniform float focalLength; //focal length in mm
uniform float fstop; //f-stop value
uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)
/*
make sure that these two values are the same for your camera, otherwise distances will be wrong.
*/
uniform float znear; // camera clipping start
uniform float zfar; // camera clipping end
//------------------------------------------
//user variables
const int samples = SAMPLES; //samples on the first ring
const int rings = RINGS; //ring count
const int maxringsamples = rings * samples;
uniform bool manualdof; // manual dof calculation
float ndofstart = 1.0; // near dof blur start
float ndofdist = 2.0; // near dof blur falloff distance
float fdofstart = 1.0; // far dof blur start
float fdofdist = 3.0; // far dof blur falloff distance
float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)
uniform bool vignetting; // use optical lens vignetting
float vignout = 1.3; // vignetting outer border
float vignin = 0.0; // vignetting inner border
float vignfade = 22.0; // f-stops till vignete fades
uniform bool shaderFocus;
// disable if you use external focalDepth value
uniform vec2 focusCoords;
// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)
// if center of screen use vec2(0.5, 0.5);
uniform float maxblur;
//clamp value of max blur (0.0 = no blur, 1.0 default)
uniform float threshold; // highlight threshold;
uniform float gain; // highlight gain;
uniform float bias; // bokeh edge bias
uniform float fringe; // bokeh chromatic aberration / fringing
uniform bool noise; //use noise instead of pattern for sample dithering
uniform float dithering;
uniform bool depthblur; // blur the depth buffer
float dbsize = 1.25; // depth blur size
/*
next part is experimental
not looking good with small sample and ring count
looks okay starting from samples = 4, rings = 4
*/
uniform bool pentagon; //use pentagon as bokeh shape?
float feather = 0.4; //pentagon shape feather
//------------------------------------------
float penta(vec2 coords) {
//pentagonal shape
float scale = float(rings) - 1.3;
vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);
vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);
vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);
vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);
vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);
vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);
vec4 one = vec4( 1.0 );
vec4 P = vec4((coords),vec2(scale, scale));
vec4 dist = vec4(0.0);
float inorout = -4.0;
dist.x = dot( P, HS0 );
dist.y = dot( P, HS1 );
dist.z = dot( P, HS2 );
dist.w = dot( P, HS3 );
dist = smoothstep( -feather, feather, dist );
inorout += dot( dist, one );
dist.x = dot( P, HS4 );
dist.y = HS5.w - abs( P.z );
dist = smoothstep( -feather, feather, dist );
inorout += dist.x;
return clamp( inorout, 0.0, 1.0 );
}
float bdepth(vec2 coords) {
// Depth buffer blur
float d = 0.0;
float kernel[9];
vec2 offset[9];
vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;
offset[0] = vec2(-wh.x,-wh.y);
offset[1] = vec2( 0.0, -wh.y);
offset[2] = vec2( wh.x -wh.y);
offset[3] = vec2(-wh.x, 0.0);
offset[4] = vec2( 0.0, 0.0);
offset[5] = vec2( wh.x, 0.0);
offset[6] = vec2(-wh.x, wh.y);
offset[7] = vec2( 0.0, wh.y);
offset[8] = vec2( wh.x, wh.y);
kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;
kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;
kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;
for( int i=0; i<9; i++ ) {
float tmp = texture2D(tDepth, coords + offset[i]).r;
d += tmp * kernel[i];
}
return d;
}
vec3 color(vec2 coords,float blur) {
//processing the sample
vec3 col = vec3(0.0);
vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);
col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;
col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;
col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;
vec3 lumcoeff = vec3(0.299,0.587,0.114);
float lum = dot(col.rgb, lumcoeff);
float thresh = max((lum-threshold)*gain, 0.0);
return col+mix(vec3(0.0),col,thresh*blur);
}
vec3 debugFocus(vec3 col, float blur, float depth) {
float edge = 0.002*depth; //distance based edge smoothing
float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);
float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);
col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);
col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);
return col;
}
float linearize(float depth) {
return -zfar * znear / (depth * (zfar - znear) - zfar);
}
float vignette() {
float dist = distance(vUv.xy, vec2(0.5,0.5));
dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);
return clamp(dist,0.0,1.0);
}
float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {
float rings2 = float(rings);
float step = PI*2.0 / float(ringsamples);
float pw = cos(j*step)*i;
float ph = sin(j*step)*i;
float p = 1.0;
if (pentagon) {
p = penta(vec2(pw,ph));
}
col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;
return 1.0 * mix(1.0, i /rings2, bias) * p;
}
void main() {
//scene depth calculation
float depth = linearize(texture2D(tDepth,vUv.xy).x);
// Blur depth?
if ( depthblur ) {
depth = linearize(bdepth(vUv.xy));
}
//focal plane calculation
float fDepth = focalDepth;
if (shaderFocus) {
fDepth = linearize(texture2D(tDepth,focusCoords).x);
}
// dof blur factor calculation
float blur = 0.0;
if (manualdof) {
float a = depth-fDepth; // Focal plane
float b = (a-fdofstart)/fdofdist; // Far DoF
float c = (-a-ndofstart)/ndofdist; // Near Dof
blur = (a>0.0) ? b : c;
} else {
float f = focalLength; // focal length in mm
float d = fDepth*1000.0; // focal plane in mm
float o = depth*1000.0; // depth in mm
float a = (o*f)/(o-f);
float b = (d*f)/(d-f);
float c = (d-f)/(d*fstop*CoC);
blur = abs(a-b)*c;
}
blur = clamp(blur,0.0,1.0);
// calculation of pattern for dithering
vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;
// getting blur x and y step factor
float w = (1.0/textureWidth)*blur*maxblur+noise.x;
float h = (1.0/textureHeight)*blur*maxblur+noise.y;
// calculation of final color
vec3 col = vec3(0.0);
if(blur < 0.05) {
//some optimization thingy
col = texture2D(tColor, vUv.xy).rgb;
} else {
col = texture2D(tColor, vUv.xy).rgb;
float s = 1.0;
int ringsamples;
for (int i = 1; i <= rings; i++) {
/*unboxstart*/
ringsamples = i * samples;
for (int j = 0 ; j < maxringsamples ; j++) {
if (j >= ringsamples) break;
s += gather(float(i), float(j), ringsamples, col, w, h, blur);
}
/*unboxend*/
}
col /= s; //divide by sample count
}
if (showFocus) {
col = debugFocus(col, blur, depth);
}
if (vignetting) {
col *= vignette();
}
gl_FragColor.rgb = col;
gl_FragColor.a = 1.0;
}
`
)
};
const BokehDepthShader = {
uniforms: {
mNear: { value: 1 },
mFar: { value: 1e3 }
},
vertexShader: (
/* glsl */
`
varying float vViewZDepth;
void main() {
#include <begin_vertex>
#include <project_vertex>
vViewZDepth = - mvPosition.z;
}
`
),
fragmentShader: (
/* glsl */
`
uniform float mNear;
uniform float mFar;
varying float vViewZDepth;
void main() {
float color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );
gl_FragColor = vec4( vec3( color ), 1.0 );
}
`
)
};
export {
BokehDepthShader,
BokehShader2
};
//# sourceMappingURL=BokehShader2.js.map
File diff suppressed because one or more lines are too long
+49
View File
@@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const BrightnessContrastShader = {
uniforms: {
tDiffuse: { value: null },
brightness: { value: 0 },
contrast: { value: 0 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
uniform float brightness;
uniform float contrast;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
gl_FragColor.rgb += brightness;
if (contrast > 0.0) {
gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;
} else {
gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;
}
}
`
)
};
exports.BrightnessContrastShader = BrightnessContrastShader;
//# sourceMappingURL=BrightnessContrastShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BrightnessContrastShader.cjs","sources":["../../src/shaders/BrightnessContrastShader.ts"],"sourcesContent":["/**\n * Brightness and contrast adjustment\n * https://github.com/evanw/glfx.js\n * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)\n * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)\n */\n\nexport const BrightnessContrastShader = {\n uniforms: {\n tDiffuse: { value: null },\n brightness: { value: 0 },\n contrast: { value: 0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n uniform float brightness;\n uniform float contrast;\n\n varying vec2 vUv;\n\n void main() {\n\n \tgl_FragColor = texture2D( tDiffuse, vUv );\n\n \tgl_FragColor.rgb += brightness;\n\n \tif (contrast > 0.0) {\n \t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;\n \t} else {\n \t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;\n \t}\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAOO,MAAM,2BAA2B;AAAA,EACtC,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,YAAY,EAAE,OAAO,EAAE;AAAA,IACvB,UAAU,EAAE,OAAO,EAAE;AAAA,EACvB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqB7B;;"}
+21
View File
@@ -0,0 +1,21 @@
/**
* Brightness and contrast adjustment
* https://github.com/evanw/glfx.js
* brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
* contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
*/
export declare const BrightnessContrastShader: {
uniforms: {
tDiffuse: {
value: null;
};
brightness: {
value: number;
};
contrast: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+49
View File
@@ -0,0 +1,49 @@
const BrightnessContrastShader = {
uniforms: {
tDiffuse: { value: null },
brightness: { value: 0 },
contrast: { value: 0 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
uniform float brightness;
uniform float contrast;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
gl_FragColor.rgb += brightness;
if (contrast > 0.0) {
gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;
} else {
gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;
}
}
`
)
};
export {
BrightnessContrastShader
};
//# sourceMappingURL=BrightnessContrastShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"BrightnessContrastShader.js","sources":["../../src/shaders/BrightnessContrastShader.ts"],"sourcesContent":["/**\n * Brightness and contrast adjustment\n * https://github.com/evanw/glfx.js\n * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)\n * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)\n */\n\nexport const BrightnessContrastShader = {\n uniforms: {\n tDiffuse: { value: null },\n brightness: { value: 0 },\n contrast: { value: 0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n uniform float brightness;\n uniform float contrast;\n\n varying vec2 vUv;\n\n void main() {\n\n \tgl_FragColor = texture2D( tDiffuse, vUv );\n\n \tgl_FragColor.rgb += brightness;\n\n \tif (contrast > 0.0) {\n \t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;\n \t} else {\n \t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;\n \t}\n\n }\n `,\n}\n"],"names":[],"mappings":"AAOO,MAAM,2BAA2B;AAAA,EACtC,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,YAAY,EAAE,OAAO,EAAE;AAAA,IACvB,UAAU,EAAE,OAAO,EAAE;AAAA,EACvB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqB7B;"}
+45
View File
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const ColorCorrectionShader = {
uniforms: {
tDiffuse: { value: null },
powRGB: { value: /* @__PURE__ */ new THREE.Vector3(2, 2, 2) },
mulRGB: { value: /* @__PURE__ */ new THREE.Vector3(1, 1, 1) },
addRGB: { value: /* @__PURE__ */ new THREE.Vector3(0, 0, 0) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
uniform vec3 powRGB;
uniform vec3 mulRGB;
uniform vec3 addRGB;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );
}
`
)
};
exports.ColorCorrectionShader = ColorCorrectionShader;
//# sourceMappingURL=ColorCorrectionShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ColorCorrectionShader.cjs","sources":["../../src/shaders/ColorCorrectionShader.ts"],"sourcesContent":["import { Vector3 } from 'three'\n\n/**\n * Color correction\n */\n\nexport const ColorCorrectionShader = {\n uniforms: {\n tDiffuse: { value: null },\n powRGB: { value: /* @__PURE__ */ new Vector3(2, 2, 2) },\n mulRGB: { value: /* @__PURE__ */ new Vector3(1, 1, 1) },\n addRGB: { value: /* @__PURE__ */ new Vector3(0, 0, 0) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n uniform vec3 powRGB;\n uniform vec3 mulRGB;\n uniform vec3 addRGB;\n\n varying vec2 vUv;\n\n void main() {\n\n \tgl_FragColor = texture2D( tDiffuse, vUv );\n \tgl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );\n\n }\n `,\n}\n"],"names":["Vector3"],"mappings":";;;AAMO,MAAM,wBAAwB;AAAA,EACnC,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,QAAQ,EAAE,OAAuB,oBAAIA,MAAAA,QAAQ,GAAG,GAAG,CAAC,EAAE;AAAA,IACtD,QAAQ,EAAE,OAAuB,oBAAIA,MAAAA,QAAQ,GAAG,GAAG,CAAC,EAAE;AAAA,IACtD,QAAQ,EAAE,OAAuB,oBAAIA,MAAAA,QAAQ,GAAG,GAAG,CAAC,EAAE;AAAA,EACxD;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAe7B;;"}
+22
View File
@@ -0,0 +1,22 @@
import { Vector3 } from 'three';
/**
* Color correction
*/
export declare const ColorCorrectionShader: {
uniforms: {
tDiffuse: {
value: null;
};
powRGB: {
value: Vector3;
};
mulRGB: {
value: Vector3;
};
addRGB: {
value: Vector3;
};
};
vertexShader: string;
fragmentShader: string;
};
+45
View File
@@ -0,0 +1,45 @@
import { Vector3 } from "three";
const ColorCorrectionShader = {
uniforms: {
tDiffuse: { value: null },
powRGB: { value: /* @__PURE__ */ new Vector3(2, 2, 2) },
mulRGB: { value: /* @__PURE__ */ new Vector3(1, 1, 1) },
addRGB: { value: /* @__PURE__ */ new Vector3(0, 0, 0) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
uniform vec3 powRGB;
uniform vec3 mulRGB;
uniform vec3 addRGB;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );
}
`
)
};
export {
ColorCorrectionShader
};
//# sourceMappingURL=ColorCorrectionShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ColorCorrectionShader.js","sources":["../../src/shaders/ColorCorrectionShader.ts"],"sourcesContent":["import { Vector3 } from 'three'\n\n/**\n * Color correction\n */\n\nexport const ColorCorrectionShader = {\n uniforms: {\n tDiffuse: { value: null },\n powRGB: { value: /* @__PURE__ */ new Vector3(2, 2, 2) },\n mulRGB: { value: /* @__PURE__ */ new Vector3(1, 1, 1) },\n addRGB: { value: /* @__PURE__ */ new Vector3(0, 0, 0) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n uniform vec3 powRGB;\n uniform vec3 mulRGB;\n uniform vec3 addRGB;\n\n varying vec2 vUv;\n\n void main() {\n\n \tgl_FragColor = texture2D( tDiffuse, vUv );\n \tgl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );\n\n }\n `,\n}\n"],"names":[],"mappings":";AAMO,MAAM,wBAAwB;AAAA,EACnC,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,QAAQ,EAAE,OAAuB,oBAAI,QAAQ,GAAG,GAAG,CAAC,EAAE;AAAA,IACtD,QAAQ,EAAE,OAAuB,oBAAI,QAAQ,GAAG,GAAG,CAAC,EAAE;AAAA,IACtD,QAAQ,EAAE,OAAuB,oBAAI,QAAQ,GAAG,GAAG,CAAC,EAAE;AAAA,EACxD;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAe7B;"}
+44
View File
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const ColorifyShader = {
uniforms: {
tDiffuse: { value: null },
color: { value: /* @__PURE__ */ new THREE.Color(16777215) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform vec3 color;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
vec3 luma = vec3( 0.299, 0.587, 0.114 );
float v = dot( texel.xyz, luma );
gl_FragColor = vec4( v * color, texel.w );
}
`
)
};
exports.ColorifyShader = ColorifyShader;
//# sourceMappingURL=ColorifyShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ColorifyShader.cjs","sources":["../../src/shaders/ColorifyShader.ts"],"sourcesContent":["import { Color } from 'three'\n\n/**\n * Colorify shader\n */\n\nexport const ColorifyShader = {\n uniforms: {\n tDiffuse: { value: null },\n color: { value: /* @__PURE__ */ new Color(0xffffff) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform vec3 color;\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n\n \tvec3 luma = vec3( 0.299, 0.587, 0.114 );\n \tfloat v = dot( texel.xyz, luma );\n\n \tgl_FragColor = vec4( v * color, texel.w );\n\n }\n `,\n}\n"],"names":["Color"],"mappings":";;;AAMO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,OAAO,EAAE,OAA2B,oBAAAA,MAAA,MAAM,QAAQ,EAAE;AAAA,EACtD;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB7B;;"}
+16
View File
@@ -0,0 +1,16 @@
import { Color } from 'three';
/**
* Colorify shader
*/
export declare const ColorifyShader: {
uniforms: {
tDiffuse: {
value: null;
};
color: {
value: Color;
};
};
vertexShader: string;
fragmentShader: string;
};
+44
View File
@@ -0,0 +1,44 @@
import { Color } from "three";
const ColorifyShader = {
uniforms: {
tDiffuse: { value: null },
color: { value: /* @__PURE__ */ new Color(16777215) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform vec3 color;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
vec3 luma = vec3( 0.299, 0.587, 0.114 );
float v = dot( texel.xyz, luma );
gl_FragColor = vec4( v * color, texel.w );
}
`
)
};
export {
ColorifyShader
};
//# sourceMappingURL=ColorifyShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ColorifyShader.js","sources":["../../src/shaders/ColorifyShader.ts"],"sourcesContent":["import { Color } from 'three'\n\n/**\n * Colorify shader\n */\n\nexport const ColorifyShader = {\n uniforms: {\n tDiffuse: { value: null },\n color: { value: /* @__PURE__ */ new Color(0xffffff) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform vec3 color;\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n\n \tvec3 luma = vec3( 0.299, 0.587, 0.114 );\n \tfloat v = dot( texel.xyz, luma );\n\n \tgl_FragColor = vec4( v * color, texel.w );\n\n }\n `,\n}\n"],"names":[],"mappings":";AAMO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,OAAO,EAAE,OAA2B,oBAAA,MAAM,QAAQ,EAAE;AAAA,EACtD;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiB7B;"}
+75
View File
@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const ConvolutionShader = {
defines: {
KERNEL_SIZE_FLOAT: "25.0",
KERNEL_SIZE_INT: "25"
},
uniforms: {
tDiffuse: { value: null },
uImageIncrement: { value: /* @__PURE__ */ new THREE.Vector2(1953125e-9, 0) },
cKernel: { value: [] }
},
vertexShader: (
/* glsl */
`
uniform vec2 uImageIncrement;
varying vec2 vUv;
void main() {
vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float cKernel[ KERNEL_SIZE_INT ];
uniform sampler2D tDiffuse;
uniform vec2 uImageIncrement;
varying vec2 vUv;
void main() {
vec2 imageCoord = vUv;
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {
sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];
imageCoord += uImageIncrement;
}
gl_FragColor = sum;
}
`
),
buildKernel: function(sigma) {
function gauss(x, sigma2) {
return Math.exp(-(x * x) / (2 * sigma2 * sigma2));
}
const kMaxKernelSize = 25;
const kernelSize = Math.min(2 * Math.ceil(sigma * 3) + 1, kMaxKernelSize);
const halfWidth = (kernelSize - 1) * 0.5;
const values = new Array(kernelSize);
let sum = 0;
for (let i = 0; i < kernelSize; ++i) {
values[i] = gauss(i - halfWidth, sigma);
sum += values[i];
}
for (let i = 0; i < kernelSize; ++i)
values[i] /= sum;
return values;
}
};
exports.ConvolutionShader = ConvolutionShader;
//# sourceMappingURL=ConvolutionShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ConvolutionShader.cjs","sources":["../../src/shaders/ConvolutionShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Convolution shader\n * ported from o3d sample to WebGL / GLSL\n * http://o3d.googlecode.com/svn/trunk/samples/convolution.html\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type ConvolutionShaderDefines = {\n KERNEL_SIZE_FLOAT: string\n KERNEL_SIZE_INT: string\n}\n\nexport type ConvolutionShaderUniforms = {\n cKernel: IUniform<number[]>\n tDiffuse: IUniform<Texture | null>\n uImageIncrement: IUniform<Vector2>\n}\n\nexport interface IConvolutionShader extends IShader<ConvolutionShaderUniforms, ConvolutionShaderDefines> {\n buildKernel: (sigma: number) => number[]\n}\n\nexport const ConvolutionShader: IConvolutionShader = {\n defines: {\n KERNEL_SIZE_FLOAT: '25.0',\n KERNEL_SIZE_INT: '25',\n },\n\n uniforms: {\n tDiffuse: { value: null },\n uImageIncrement: { value: /* @__PURE__ */ new Vector2(0.001953125, 0.0) },\n cKernel: { value: [] },\n },\n\n vertexShader: /* glsl */ `\n uniform vec2 uImageIncrement;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float cKernel[ KERNEL_SIZE_INT ];\n\n uniform sampler2D tDiffuse;\n uniform vec2 uImageIncrement;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec2 imageCoord = vUv;\n \tvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n \tfor( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {\n\n \t\tsum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];\n \t\timageCoord += uImageIncrement;\n\n \t}\n\n \tgl_FragColor = sum;\n\n }\n `,\n\n buildKernel: function (sigma) {\n // We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.\n\n function gauss(x: number, sigma: number): number {\n return Math.exp(-(x * x) / (2.0 * sigma * sigma))\n }\n\n const kMaxKernelSize = 25\n\n const kernelSize = Math.min(2 * Math.ceil(sigma * 3.0) + 1, kMaxKernelSize)\n\n const halfWidth = (kernelSize - 1) * 0.5\n\n const values: number[] = new Array(kernelSize)\n\n let sum = 0.0\n\n for (let i = 0; i < kernelSize; ++i) {\n values[i] = gauss(i - halfWidth, sigma)\n sum += values[i]\n }\n\n // normalize the kernel\n\n for (let i = 0; i < kernelSize; ++i) values[i] /= sum\n\n return values\n },\n}\n"],"names":["Vector2","sigma"],"mappings":";;;AA0BO,MAAM,oBAAwC;AAAA,EACnD,SAAS;AAAA,IACP,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,EACnB;AAAA,EAEA,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,iBAAiB,EAAE,2BAA2BA,MAAQ,QAAA,YAAa,CAAG,EAAE;AAAA,IACxE,SAAS,EAAE,OAAO,GAAG;AAAA,EACvB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAazB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB3B,aAAa,SAAU,OAAO;AAGnB,aAAA,MAAM,GAAWC,QAAuB;AAC/C,aAAO,KAAK,IAAI,EAAE,IAAI,MAAM,IAAMA,SAAQA,OAAM;AAAA,IAClD;AAEA,UAAM,iBAAiB;AAEjB,UAAA,aAAa,KAAK,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAG,IAAI,GAAG,cAAc;AAEpE,UAAA,aAAa,aAAa,KAAK;AAE/B,UAAA,SAAmB,IAAI,MAAM,UAAU;AAE7C,QAAI,MAAM;AAEV,aAAS,IAAI,GAAG,IAAI,YAAY,EAAE,GAAG;AACnC,aAAO,CAAC,IAAI,MAAM,IAAI,WAAW,KAAK;AACtC,aAAO,OAAO,CAAC;AAAA,IACjB;AAIA,aAAS,IAAI,GAAG,IAAI,YAAY,EAAE;AAAG,aAAO,CAAC,KAAK;AAE3C,WAAA;AAAA,EACT;AACF;;"}
+21
View File
@@ -0,0 +1,21 @@
import { Vector2 } from 'three';
/**
* Convolution shader
* ported from o3d sample to WebGL / GLSL
* http://o3d.googlecode.com/svn/trunk/samples/convolution.html
*/
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type ConvolutionShaderDefines = {
KERNEL_SIZE_FLOAT: string;
KERNEL_SIZE_INT: string;
};
export type ConvolutionShaderUniforms = {
cKernel: IUniform<number[]>;
tDiffuse: IUniform<Texture | null>;
uImageIncrement: IUniform<Vector2>;
};
export interface IConvolutionShader extends IShader<ConvolutionShaderUniforms, ConvolutionShaderDefines> {
buildKernel: (sigma: number) => number[];
}
export declare const ConvolutionShader: IConvolutionShader;
+75
View File
@@ -0,0 +1,75 @@
import { Vector2 } from "three";
const ConvolutionShader = {
defines: {
KERNEL_SIZE_FLOAT: "25.0",
KERNEL_SIZE_INT: "25"
},
uniforms: {
tDiffuse: { value: null },
uImageIncrement: { value: /* @__PURE__ */ new Vector2(1953125e-9, 0) },
cKernel: { value: [] }
},
vertexShader: (
/* glsl */
`
uniform vec2 uImageIncrement;
varying vec2 vUv;
void main() {
vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float cKernel[ KERNEL_SIZE_INT ];
uniform sampler2D tDiffuse;
uniform vec2 uImageIncrement;
varying vec2 vUv;
void main() {
vec2 imageCoord = vUv;
vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );
for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {
sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];
imageCoord += uImageIncrement;
}
gl_FragColor = sum;
}
`
),
buildKernel: function(sigma) {
function gauss(x, sigma2) {
return Math.exp(-(x * x) / (2 * sigma2 * sigma2));
}
const kMaxKernelSize = 25;
const kernelSize = Math.min(2 * Math.ceil(sigma * 3) + 1, kMaxKernelSize);
const halfWidth = (kernelSize - 1) * 0.5;
const values = new Array(kernelSize);
let sum = 0;
for (let i = 0; i < kernelSize; ++i) {
values[i] = gauss(i - halfWidth, sigma);
sum += values[i];
}
for (let i = 0; i < kernelSize; ++i)
values[i] /= sum;
return values;
}
};
export {
ConvolutionShader
};
//# sourceMappingURL=ConvolutionShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"ConvolutionShader.js","sources":["../../src/shaders/ConvolutionShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Convolution shader\n * ported from o3d sample to WebGL / GLSL\n * http://o3d.googlecode.com/svn/trunk/samples/convolution.html\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type ConvolutionShaderDefines = {\n KERNEL_SIZE_FLOAT: string\n KERNEL_SIZE_INT: string\n}\n\nexport type ConvolutionShaderUniforms = {\n cKernel: IUniform<number[]>\n tDiffuse: IUniform<Texture | null>\n uImageIncrement: IUniform<Vector2>\n}\n\nexport interface IConvolutionShader extends IShader<ConvolutionShaderUniforms, ConvolutionShaderDefines> {\n buildKernel: (sigma: number) => number[]\n}\n\nexport const ConvolutionShader: IConvolutionShader = {\n defines: {\n KERNEL_SIZE_FLOAT: '25.0',\n KERNEL_SIZE_INT: '25',\n },\n\n uniforms: {\n tDiffuse: { value: null },\n uImageIncrement: { value: /* @__PURE__ */ new Vector2(0.001953125, 0.0) },\n cKernel: { value: [] },\n },\n\n vertexShader: /* glsl */ `\n uniform vec2 uImageIncrement;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float cKernel[ KERNEL_SIZE_INT ];\n\n uniform sampler2D tDiffuse;\n uniform vec2 uImageIncrement;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec2 imageCoord = vUv;\n \tvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\n\n \tfor( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {\n\n \t\tsum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];\n \t\timageCoord += uImageIncrement;\n\n \t}\n\n \tgl_FragColor = sum;\n\n }\n `,\n\n buildKernel: function (sigma) {\n // We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.\n\n function gauss(x: number, sigma: number): number {\n return Math.exp(-(x * x) / (2.0 * sigma * sigma))\n }\n\n const kMaxKernelSize = 25\n\n const kernelSize = Math.min(2 * Math.ceil(sigma * 3.0) + 1, kMaxKernelSize)\n\n const halfWidth = (kernelSize - 1) * 0.5\n\n const values: number[] = new Array(kernelSize)\n\n let sum = 0.0\n\n for (let i = 0; i < kernelSize; ++i) {\n values[i] = gauss(i - halfWidth, sigma)\n sum += values[i]\n }\n\n // normalize the kernel\n\n for (let i = 0; i < kernelSize; ++i) values[i] /= sum\n\n return values\n },\n}\n"],"names":["sigma"],"mappings":";AA0BO,MAAM,oBAAwC;AAAA,EACnD,SAAS;AAAA,IACP,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,EACnB;AAAA,EAEA,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,iBAAiB,EAAE,2BAA2B,QAAQ,YAAa,CAAG,EAAE;AAAA,IACxE,SAAS,EAAE,OAAO,GAAG;AAAA,EACvB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAazB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB3B,aAAa,SAAU,OAAO;AAGnB,aAAA,MAAM,GAAWA,QAAuB;AAC/C,aAAO,KAAK,IAAI,EAAE,IAAI,MAAM,IAAMA,SAAQA,OAAM;AAAA,IAClD;AAEA,UAAM,iBAAiB;AAEjB,UAAA,aAAa,KAAK,IAAI,IAAI,KAAK,KAAK,QAAQ,CAAG,IAAI,GAAG,cAAc;AAEpE,UAAA,aAAa,aAAa,KAAK;AAE/B,UAAA,SAAmB,IAAI,MAAM,UAAU;AAE7C,QAAI,MAAM;AAEV,aAAS,IAAI,GAAG,IAAI,YAAY,EAAE,GAAG;AACnC,aAAO,CAAC,IAAI,MAAM,IAAI,WAAW,KAAK;AACtC,aAAO,OAAO,CAAC;AAAA,IACjB;AAIA,aAAS,IAAI,GAAG,IAAI,YAAY,EAAE;AAAG,aAAO,CAAC,KAAK;AAE3C,WAAA;AAAA,EACT;AACF;"}
+40
View File
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const CopyShader = {
uniforms: {
tDiffuse: { value: null },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}
`
)
};
exports.CopyShader = CopyShader;
//# sourceMappingURL=CopyShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"CopyShader.cjs","sources":["../../src/shaders/CopyShader.ts"],"sourcesContent":["/**\n * Full-screen textured quad shader\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type CopyShaderUniforms = {\n opacity: IUniform<number>\n tDiffuse: IUniform<Texture | null>\n}\n\nexport interface ICopyShader extends IShader<CopyShaderUniforms> {}\n\nexport const CopyShader: ICopyShader = {\n uniforms: {\n tDiffuse: { value: null },\n opacity: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n \tgl_FragColor = opacity * texel;\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAcO,MAAM,aAA0B;AAAA,EACrC,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAc7B;;"}
+12
View File
@@ -0,0 +1,12 @@
/**
* Full-screen textured quad shader
*/
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type CopyShaderUniforms = {
opacity: IUniform<number>;
tDiffuse: IUniform<Texture | null>;
};
export interface ICopyShader extends IShader<CopyShaderUniforms> {
}
export declare const CopyShader: ICopyShader;
+40
View File
@@ -0,0 +1,40 @@
const CopyShader = {
uniforms: {
tDiffuse: { value: null },
opacity: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}
`
)
};
export {
CopyShader
};
//# sourceMappingURL=CopyShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"CopyShader.js","sources":["../../src/shaders/CopyShader.ts"],"sourcesContent":["/**\n * Full-screen textured quad shader\n */\n\nimport type { IUniform, Texture } from 'three'\nimport type { IShader } from './types'\n\nexport type CopyShaderUniforms = {\n opacity: IUniform<number>\n tDiffuse: IUniform<Texture | null>\n}\n\nexport interface ICopyShader extends IShader<CopyShaderUniforms> {}\n\nexport const CopyShader: ICopyShader = {\n uniforms: {\n tDiffuse: { value: null },\n opacity: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n \tgl_FragColor = opacity * texel;\n\n }\n `,\n}\n"],"names":[],"mappings":"AAcO,MAAM,aAA0B;AAAA,EACrC,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAc7B;"}
+50
View File
@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const DOFMipMapShader = {
uniforms: {
tColor: { value: null },
tDepth: { value: null },
focus: { value: 1 },
maxblur: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float focus;
uniform float maxblur;
uniform sampler2D tColor;
uniform sampler2D tDepth;
varying vec2 vUv;
void main() {
vec4 depth = texture2D( tDepth, vUv );
float factor = depth.x - focus;
vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );
gl_FragColor = col;
gl_FragColor.a = 1.0;
}
`
)
};
exports.DOFMipMapShader = DOFMipMapShader;
//# sourceMappingURL=DOFMipMapShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DOFMipMapShader.cjs","sources":["../../src/shaders/DOFMipMapShader.ts"],"sourcesContent":["/**\n * Depth-of-field shader using mipmaps\n * - from Matt Handley @applmak\n * - requires power-of-2 sized render target with enabled mipmaps\n */\n\nexport const DOFMipMapShader = {\n uniforms: {\n tColor: { value: null },\n tDepth: { value: null },\n focus: { value: 1.0 },\n maxblur: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float focus;\n uniform float maxblur;\n\n uniform sampler2D tColor;\n uniform sampler2D tDepth;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 depth = texture2D( tDepth, vUv );\n\n \tfloat factor = depth.x - focus;\n\n \tvec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );\n\n \tgl_FragColor = col;\n \tgl_FragColor.a = 1.0;\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAMO,MAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,IACR,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,OAAO,EAAE,OAAO,EAAI;AAAA,IACpB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsB7B;;"}
+23
View File
@@ -0,0 +1,23 @@
/**
* Depth-of-field shader using mipmaps
* - from Matt Handley @applmak
* - requires power-of-2 sized render target with enabled mipmaps
*/
export declare const DOFMipMapShader: {
uniforms: {
tColor: {
value: null;
};
tDepth: {
value: null;
};
focus: {
value: number;
};
maxblur: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+50
View File
@@ -0,0 +1,50 @@
const DOFMipMapShader = {
uniforms: {
tColor: { value: null },
tDepth: { value: null },
focus: { value: 1 },
maxblur: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float focus;
uniform float maxblur;
uniform sampler2D tColor;
uniform sampler2D tDepth;
varying vec2 vUv;
void main() {
vec4 depth = texture2D( tDepth, vUv );
float factor = depth.x - focus;
vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );
gl_FragColor = col;
gl_FragColor.a = 1.0;
}
`
)
};
export {
DOFMipMapShader
};
//# sourceMappingURL=DOFMipMapShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DOFMipMapShader.js","sources":["../../src/shaders/DOFMipMapShader.ts"],"sourcesContent":["/**\n * Depth-of-field shader using mipmaps\n * - from Matt Handley @applmak\n * - requires power-of-2 sized render target with enabled mipmaps\n */\n\nexport const DOFMipMapShader = {\n uniforms: {\n tColor: { value: null },\n tDepth: { value: null },\n focus: { value: 1.0 },\n maxblur: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float focus;\n uniform float maxblur;\n\n uniform sampler2D tColor;\n uniform sampler2D tDepth;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 depth = texture2D( tDepth, vUv );\n\n \tfloat factor = depth.x - focus;\n\n \tvec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );\n\n \tgl_FragColor = col;\n \tgl_FragColor.a = 1.0;\n\n }\n `,\n}\n"],"names":[],"mappings":"AAMO,MAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,IACR,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,OAAO,EAAE,OAAO,EAAI;AAAA,IACpB,SAAS,EAAE,OAAO,EAAI;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsB7B;"}
+144
View File
@@ -0,0 +1,144 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const DepthLimitedBlurShader = {
defines: {
KERNEL_RADIUS: 4,
DEPTH_PACKING: 1,
PERSPECTIVE_CAMERA: 1
},
uniforms: {
tDiffuse: { value: null },
size: { value: /* @__PURE__ */ new THREE.Vector2(512, 512) },
sampleUvOffsets: { value: [/* @__PURE__ */ new THREE.Vector2(0, 0)] },
sampleWeights: { value: [1] },
tDepth: { value: null },
cameraNear: { value: 10 },
cameraFar: { value: 1e3 },
depthCutoff: { value: 10 }
},
vertexShader: (
/* glsl */
`
#include <common>
uniform vec2 size;
varying vec2 vUv;
varying vec2 vInvSize;
void main() {
vUv = uv;
vInvSize = 1.0 / size;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
#include <packing>
uniform sampler2D tDiffuse;
uniform sampler2D tDepth;
uniform float cameraNear;
uniform float cameraFar;
uniform float depthCutoff;
uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];
uniform float sampleWeights[ KERNEL_RADIUS + 1 ];
varying vec2 vUv;
varying vec2 vInvSize;
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, cameraNear, cameraFar );
#else
return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
#endif
}
void main() {
float depth = getDepth( vUv );
if( depth >= ( 1.0 - EPSILON ) ) {
discard;
}
float centerViewZ = -getViewZ( depth );
bool rBreak = false, lBreak = false;
float weightSum = sampleWeights[0];
vec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;
for( int i = 1; i <= KERNEL_RADIUS; i ++ ) {
float sampleWeight = sampleWeights[i];
vec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;
vec2 sampleUv = vUv + sampleUvOffset;
float viewZ = -getViewZ( getDepth( sampleUv ) );
if( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;
if( ! rBreak ) {
diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;
weightSum += sampleWeight;
}
sampleUv = vUv - sampleUvOffset;
viewZ = -getViewZ( getDepth( sampleUv ) );
if( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;
if( ! lBreak ) {
diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;
weightSum += sampleWeight;
}
}
gl_FragColor = diffuseSum / weightSum;
}
`
)
};
const BlurShaderUtils = {
createSampleWeights: (kernelRadius, stdDev) => {
const gaussian = (x, stdDev2) => {
return Math.exp(-(x * x) / (2 * (stdDev2 * stdDev2))) / (Math.sqrt(2 * Math.PI) * stdDev2);
};
const weights = [];
for (let i = 0; i <= kernelRadius; i++) {
weights.push(gaussian(i, stdDev));
}
return weights;
},
createSampleOffsets: (kernelRadius, uvIncrement) => {
const offsets = [];
for (let i = 0; i <= kernelRadius; i++) {
offsets.push(uvIncrement.clone().multiplyScalar(i));
}
return offsets;
},
configure: (shader, kernelRadius, stdDev, uvIncrement) => {
shader.defines["KERNEL_RADIUS"] = kernelRadius;
shader.uniforms["sampleUvOffsets"].value = BlurShaderUtils.createSampleOffsets(kernelRadius, uvIncrement);
shader.uniforms["sampleWeights"].value = BlurShaderUtils.createSampleWeights(kernelRadius, stdDev);
shader.needsUpdate = true;
}
};
exports.BlurShaderUtils = BlurShaderUtils;
exports.DepthLimitedBlurShader = DepthLimitedBlurShader;
//# sourceMappingURL=DepthLimitedBlurShader.cjs.map
File diff suppressed because one or more lines are too long
+28
View File
@@ -0,0 +1,28 @@
import { Vector2 } from 'three';
import type { IUniform, Texture } from 'three';
import type { IShader } from './types';
export type DepthLimitedBlurShaderDefines = {
DEPTH_PACKING: number;
KERNEL_RADIUS: number;
PERSPECTIVE_CAMERA: number;
};
export type DepthLimitedBlurShaderUniforms = {
cameraFar: IUniform<number>;
cameraNear: IUniform<number>;
depthCutoff: IUniform<number>;
sampleUvOffsets: IUniform<Vector2[]>;
sampleWeights: IUniform<number[]>;
size: IUniform<Vector2>;
tDepth: IUniform<Texture | null>;
tDiffuse: IUniform<Texture | null>;
};
export interface IDepthLimitedBlurShader extends IShader<DepthLimitedBlurShaderUniforms, DepthLimitedBlurShaderDefines> {
defines: DepthLimitedBlurShaderDefines;
needsUpdate?: boolean;
}
export declare const DepthLimitedBlurShader: IDepthLimitedBlurShader;
export declare const BlurShaderUtils: {
createSampleWeights: (kernelRadius: number, stdDev: number) => number[];
createSampleOffsets: (kernelRadius: number, uvIncrement: Vector2) => Vector2[];
configure: (shader: IDepthLimitedBlurShader, kernelRadius: number, stdDev: number, uvIncrement: Vector2) => void;
};
+144
View File
@@ -0,0 +1,144 @@
import { Vector2 } from "three";
const DepthLimitedBlurShader = {
defines: {
KERNEL_RADIUS: 4,
DEPTH_PACKING: 1,
PERSPECTIVE_CAMERA: 1
},
uniforms: {
tDiffuse: { value: null },
size: { value: /* @__PURE__ */ new Vector2(512, 512) },
sampleUvOffsets: { value: [/* @__PURE__ */ new Vector2(0, 0)] },
sampleWeights: { value: [1] },
tDepth: { value: null },
cameraNear: { value: 10 },
cameraFar: { value: 1e3 },
depthCutoff: { value: 10 }
},
vertexShader: (
/* glsl */
`
#include <common>
uniform vec2 size;
varying vec2 vUv;
varying vec2 vInvSize;
void main() {
vUv = uv;
vInvSize = 1.0 / size;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
#include <packing>
uniform sampler2D tDiffuse;
uniform sampler2D tDepth;
uniform float cameraNear;
uniform float cameraFar;
uniform float depthCutoff;
uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];
uniform float sampleWeights[ KERNEL_RADIUS + 1 ];
varying vec2 vUv;
varying vec2 vInvSize;
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, cameraNear, cameraFar );
#else
return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
#endif
}
void main() {
float depth = getDepth( vUv );
if( depth >= ( 1.0 - EPSILON ) ) {
discard;
}
float centerViewZ = -getViewZ( depth );
bool rBreak = false, lBreak = false;
float weightSum = sampleWeights[0];
vec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;
for( int i = 1; i <= KERNEL_RADIUS; i ++ ) {
float sampleWeight = sampleWeights[i];
vec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;
vec2 sampleUv = vUv + sampleUvOffset;
float viewZ = -getViewZ( getDepth( sampleUv ) );
if( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;
if( ! rBreak ) {
diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;
weightSum += sampleWeight;
}
sampleUv = vUv - sampleUvOffset;
viewZ = -getViewZ( getDepth( sampleUv ) );
if( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;
if( ! lBreak ) {
diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;
weightSum += sampleWeight;
}
}
gl_FragColor = diffuseSum / weightSum;
}
`
)
};
const BlurShaderUtils = {
createSampleWeights: (kernelRadius, stdDev) => {
const gaussian = (x, stdDev2) => {
return Math.exp(-(x * x) / (2 * (stdDev2 * stdDev2))) / (Math.sqrt(2 * Math.PI) * stdDev2);
};
const weights = [];
for (let i = 0; i <= kernelRadius; i++) {
weights.push(gaussian(i, stdDev));
}
return weights;
},
createSampleOffsets: (kernelRadius, uvIncrement) => {
const offsets = [];
for (let i = 0; i <= kernelRadius; i++) {
offsets.push(uvIncrement.clone().multiplyScalar(i));
}
return offsets;
},
configure: (shader, kernelRadius, stdDev, uvIncrement) => {
shader.defines["KERNEL_RADIUS"] = kernelRadius;
shader.uniforms["sampleUvOffsets"].value = BlurShaderUtils.createSampleOffsets(kernelRadius, uvIncrement);
shader.uniforms["sampleWeights"].value = BlurShaderUtils.createSampleWeights(kernelRadius, stdDev);
shader.needsUpdate = true;
}
};
export {
BlurShaderUtils,
DepthLimitedBlurShader
};
//# sourceMappingURL=DepthLimitedBlurShader.js.map
File diff suppressed because one or more lines are too long
+97
View File
@@ -0,0 +1,97 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const DigitalGlitch = {
uniforms: {
tDiffuse: { value: null },
//diffuse texture
tDisp: { value: null },
//displacement texture for digital glitch squares
byp: { value: 0 },
//apply the glitch ?
amount: { value: 0.08 },
angle: { value: 0.02 },
seed: { value: 0.02 },
seed_x: { value: 0.02 },
//-1,1
seed_y: { value: 0.02 },
//-1,1
distortion_x: { value: 0.5 },
distortion_y: { value: 0.6 },
col_s: { value: 0.05 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform int byp; //should we apply the glitch ?
uniform sampler2D tDiffuse;
uniform sampler2D tDisp;
uniform float amount;
uniform float angle;
uniform float seed;
uniform float seed_x;
uniform float seed_y;
uniform float distortion_x;
uniform float distortion_y;
uniform float col_s;
varying vec2 vUv;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main() {
if(byp<1) {
vec2 p = vUv;
float xs = floor(gl_FragCoord.x / 0.5);
float ys = floor(gl_FragCoord.y / 0.5);
//based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
vec4 normal = texture2D (tDisp, p*seed*seed);
if(p.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {
if(seed_x>0.){
p.y = 1. - (p.y + distortion_y);
}
else {
p.y = distortion_y;
}
}
if(p.x<distortion_y+col_s && p.x>distortion_y-col_s*seed) {
if(seed_y>0.){
p.x=distortion_x;
}
else {
p.x = 1. - (p.x + distortion_x);
}
}
p.x+=normal.x*seed_x*(seed/5.);
p.y+=normal.y*seed_y*(seed/5.);
//base from RGB shift shader
vec2 offset = amount * vec2( cos(angle), sin(angle));
vec4 cr = texture2D(tDiffuse, p + offset);
vec4 cga = texture2D(tDiffuse, p);
vec4 cb = texture2D(tDiffuse, p - offset);
gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);
//add noise
vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);
gl_FragColor = gl_FragColor+ snow;
}
else {
gl_FragColor=texture2D (tDiffuse, vUv);
}
}
`
)
};
exports.DigitalGlitch = DigitalGlitch;
//# sourceMappingURL=DigitalGlitch.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DigitalGlitch.cjs","sources":["../../src/shaders/DigitalGlitch.ts"],"sourcesContent":["export const DigitalGlitch = {\n uniforms: {\n tDiffuse: { value: null }, //diffuse texture\n tDisp: { value: null }, //displacement texture for digital glitch squares\n byp: { value: 0 }, //apply the glitch ?\n amount: { value: 0.08 },\n angle: { value: 0.02 },\n seed: { value: 0.02 },\n seed_x: { value: 0.02 }, //-1,1\n seed_y: { value: 0.02 }, //-1,1\n distortion_x: { value: 0.5 },\n distortion_y: { value: 0.6 },\n col_s: { value: 0.05 },\n },\n\n vertexShader: /* glsl */ `\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}\n\t`,\n\n fragmentShader: /* glsl */ `\n\t\tuniform int byp; //should we apply the glitch ?\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDisp;\n\t\tuniform float amount;\n\t\tuniform float angle;\n\t\tuniform float seed;\n\t\tuniform float seed_x;\n\t\tuniform float seed_y;\n\t\tuniform float distortion_x;\n\t\tuniform float distortion_y;\n\t\tuniform float col_s;\n\n\t\tvarying vec2 vUv;\n\n\t\tfloat rand(vec2 co){\n\t\t\treturn fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tif(byp<1) {\n\t\t\t\tvec2 p = vUv;\n\t\t\t\tfloat xs = floor(gl_FragCoord.x / 0.5);\n\t\t\t\tfloat ys = floor(gl_FragCoord.y / 0.5);\n\t\t//based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch\n\t\t\t\tvec4 normal = texture2D (tDisp, p*seed*seed);\n\t\t\t\tif(p.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {\n\t\t\t\t\tif(seed_x>0.){\n\t\t\t\t\t\tp.y = 1. - (p.y + distortion_y);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tp.y = distortion_y;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(p.x<distortion_y+col_s && p.x>distortion_y-col_s*seed) {\n\t\t\t\t\tif(seed_y>0.){\n\t\t\t\t\t\tp.x=distortion_x;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tp.x = 1. - (p.x + distortion_x);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tp.x+=normal.x*seed_x*(seed/5.);\n\t\t\t\tp.y+=normal.y*seed_y*(seed/5.);\n\t\t//base from RGB shift shader\n\t\t\t\tvec2 offset = amount * vec2( cos(angle), sin(angle));\n\t\t\t\tvec4 cr = texture2D(tDiffuse, p + offset);\n\t\t\t\tvec4 cga = texture2D(tDiffuse, p);\n\t\t\t\tvec4 cb = texture2D(tDiffuse, p - offset);\n\t\t\t\tgl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);\n\t\t//add noise\n\t\t\t\tvec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);\n\t\t\t\tgl_FragColor = gl_FragColor+ snow;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tgl_FragColor=texture2D (tDiffuse, vUv);\n\t\t\t}\n\t\t}\n`,\n}\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAgB;AAAA,EAC3B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA;AAAA,IACxB,OAAO,EAAE,OAAO,KAAK;AAAA;AAAA,IACrB,KAAK,EAAE,OAAO,EAAE;AAAA;AAAA,IAChB,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,OAAO,EAAE,OAAO,KAAK;AAAA,IACrB,MAAM,EAAE,OAAO,KAAK;AAAA,IACpB,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,IACtB,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,IACtB,cAAc,EAAE,OAAO,IAAI;AAAA,IAC3B,cAAc,EAAE,OAAO,IAAI;AAAA,IAC3B,OAAO,EAAE,OAAO,KAAK;AAAA,EACvB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2D7B;;"}
+39
View File
@@ -0,0 +1,39 @@
export declare const DigitalGlitch: {
uniforms: {
tDiffuse: {
value: null;
};
tDisp: {
value: null;
};
byp: {
value: number;
};
amount: {
value: number;
};
angle: {
value: number;
};
seed: {
value: number;
};
seed_x: {
value: number;
};
seed_y: {
value: number;
};
distortion_x: {
value: number;
};
distortion_y: {
value: number;
};
col_s: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+97
View File
@@ -0,0 +1,97 @@
const DigitalGlitch = {
uniforms: {
tDiffuse: { value: null },
//diffuse texture
tDisp: { value: null },
//displacement texture for digital glitch squares
byp: { value: 0 },
//apply the glitch ?
amount: { value: 0.08 },
angle: { value: 0.02 },
seed: { value: 0.02 },
seed_x: { value: 0.02 },
//-1,1
seed_y: { value: 0.02 },
//-1,1
distortion_x: { value: 0.5 },
distortion_y: { value: 0.6 },
col_s: { value: 0.05 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform int byp; //should we apply the glitch ?
uniform sampler2D tDiffuse;
uniform sampler2D tDisp;
uniform float amount;
uniform float angle;
uniform float seed;
uniform float seed_x;
uniform float seed_y;
uniform float distortion_x;
uniform float distortion_y;
uniform float col_s;
varying vec2 vUv;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main() {
if(byp<1) {
vec2 p = vUv;
float xs = floor(gl_FragCoord.x / 0.5);
float ys = floor(gl_FragCoord.y / 0.5);
//based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
vec4 normal = texture2D (tDisp, p*seed*seed);
if(p.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {
if(seed_x>0.){
p.y = 1. - (p.y + distortion_y);
}
else {
p.y = distortion_y;
}
}
if(p.x<distortion_y+col_s && p.x>distortion_y-col_s*seed) {
if(seed_y>0.){
p.x=distortion_x;
}
else {
p.x = 1. - (p.x + distortion_x);
}
}
p.x+=normal.x*seed_x*(seed/5.);
p.y+=normal.y*seed_y*(seed/5.);
//base from RGB shift shader
vec2 offset = amount * vec2( cos(angle), sin(angle));
vec4 cr = texture2D(tDiffuse, p + offset);
vec4 cga = texture2D(tDiffuse, p);
vec4 cb = texture2D(tDiffuse, p - offset);
gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);
//add noise
vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);
gl_FragColor = gl_FragColor+ snow;
}
else {
gl_FragColor=texture2D (tDiffuse, vUv);
}
}
`
)
};
export {
DigitalGlitch
};
//# sourceMappingURL=DigitalGlitch.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DigitalGlitch.js","sources":["../../src/shaders/DigitalGlitch.ts"],"sourcesContent":["export const DigitalGlitch = {\n uniforms: {\n tDiffuse: { value: null }, //diffuse texture\n tDisp: { value: null }, //displacement texture for digital glitch squares\n byp: { value: 0 }, //apply the glitch ?\n amount: { value: 0.08 },\n angle: { value: 0.02 },\n seed: { value: 0.02 },\n seed_x: { value: 0.02 }, //-1,1\n seed_y: { value: 0.02 }, //-1,1\n distortion_x: { value: 0.5 },\n distortion_y: { value: 0.6 },\n col_s: { value: 0.05 },\n },\n\n vertexShader: /* glsl */ `\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}\n\t`,\n\n fragmentShader: /* glsl */ `\n\t\tuniform int byp; //should we apply the glitch ?\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDisp;\n\t\tuniform float amount;\n\t\tuniform float angle;\n\t\tuniform float seed;\n\t\tuniform float seed_x;\n\t\tuniform float seed_y;\n\t\tuniform float distortion_x;\n\t\tuniform float distortion_y;\n\t\tuniform float col_s;\n\n\t\tvarying vec2 vUv;\n\n\t\tfloat rand(vec2 co){\n\t\t\treturn fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tif(byp<1) {\n\t\t\t\tvec2 p = vUv;\n\t\t\t\tfloat xs = floor(gl_FragCoord.x / 0.5);\n\t\t\t\tfloat ys = floor(gl_FragCoord.y / 0.5);\n\t\t//based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch\n\t\t\t\tvec4 normal = texture2D (tDisp, p*seed*seed);\n\t\t\t\tif(p.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {\n\t\t\t\t\tif(seed_x>0.){\n\t\t\t\t\t\tp.y = 1. - (p.y + distortion_y);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tp.y = distortion_y;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(p.x<distortion_y+col_s && p.x>distortion_y-col_s*seed) {\n\t\t\t\t\tif(seed_y>0.){\n\t\t\t\t\t\tp.x=distortion_x;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tp.x = 1. - (p.x + distortion_x);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tp.x+=normal.x*seed_x*(seed/5.);\n\t\t\t\tp.y+=normal.y*seed_y*(seed/5.);\n\t\t//base from RGB shift shader\n\t\t\t\tvec2 offset = amount * vec2( cos(angle), sin(angle));\n\t\t\t\tvec4 cr = texture2D(tDiffuse, p + offset);\n\t\t\t\tvec4 cga = texture2D(tDiffuse, p);\n\t\t\t\tvec4 cb = texture2D(tDiffuse, p - offset);\n\t\t\t\tgl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);\n\t\t//add noise\n\t\t\t\tvec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);\n\t\t\t\tgl_FragColor = gl_FragColor+ snow;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tgl_FragColor=texture2D (tDiffuse, vUv);\n\t\t\t}\n\t\t}\n`,\n}\n"],"names":[],"mappings":"AAAO,MAAM,gBAAgB;AAAA,EAC3B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA;AAAA,IACxB,OAAO,EAAE,OAAO,KAAK;AAAA;AAAA,IACrB,KAAK,EAAE,OAAO,EAAE;AAAA;AAAA,IAChB,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,OAAO,EAAE,OAAO,KAAK;AAAA,IACrB,MAAM,EAAE,OAAO,KAAK;AAAA,IACpB,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,IACtB,QAAQ,EAAE,OAAO,KAAK;AAAA;AAAA,IACtB,cAAc,EAAE,OAAO,IAAI;AAAA,IAC3B,cAAc,EAAE,OAAO,IAAI;AAAA,IAC3B,OAAO,EAAE,OAAO,KAAK;AAAA,EACvB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2D7B;"}
+61
View File
@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const DotScreenShader = {
uniforms: {
tDiffuse: { value: null },
tSize: { value: /* @__PURE__ */ new THREE.Vector2(256, 256) },
center: { value: /* @__PURE__ */ new THREE.Vector2(0.5, 0.5) },
angle: { value: 1.57 },
scale: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform vec2 center;
uniform float angle;
uniform float scale;
uniform vec2 tSize;
uniform sampler2D tDiffuse;
varying vec2 vUv;
float pattern() {
float s = sin( angle ), c = cos( angle );
vec2 tex = vUv * tSize - center;
vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;
return ( sin( point.x ) * sin( point.y ) ) * 4.0;
}
void main() {
vec4 color = texture2D( tDiffuse, vUv );
float average = ( color.r + color.g + color.b ) / 3.0;
gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );
}
`
)
};
exports.DotScreenShader = DotScreenShader;
//# sourceMappingURL=DotScreenShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DotScreenShader.cjs","sources":["../../src/shaders/DotScreenShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Dot screen shader\n * based on glfx.js sepia shader\n * https://github.com/evanw/glfx.js\n */\n\nexport const DotScreenShader = {\n uniforms: {\n tDiffuse: { value: null },\n tSize: { value: /* @__PURE__ */ new Vector2(256, 256) },\n center: { value: /* @__PURE__ */ new Vector2(0.5, 0.5) },\n angle: { value: 1.57 },\n scale: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform vec2 center;\n uniform float angle;\n uniform float scale;\n uniform vec2 tSize;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n float pattern() {\n\n \tfloat s = sin( angle ), c = cos( angle );\n\n \tvec2 tex = vUv * tSize - center;\n \tvec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;\n\n \treturn ( sin( point.x ) * sin( point.y ) ) * 4.0;\n\n }\n\n void main() {\n\n \tvec4 color = texture2D( tDiffuse, vUv );\n\n \tfloat average = ( color.r + color.g + color.b ) / 3.0;\n\n \tgl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );\n\n }\n `,\n}\n"],"names":["Vector2"],"mappings":";;;AAQO,MAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,OAAO,EAAE,2BAA2BA,MAAQ,QAAA,KAAK,GAAG,EAAE;AAAA,IACtD,QAAQ,EAAE,2BAA2BA,MAAQ,QAAA,KAAK,GAAG,EAAE;AAAA,IACvD,OAAO,EAAE,OAAO,KAAK;AAAA,IACrB,OAAO,EAAE,OAAO,EAAI;AAAA,EACtB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+B7B;;"}
+27
View File
@@ -0,0 +1,27 @@
import { Vector2 } from 'three';
/**
* Dot screen shader
* based on glfx.js sepia shader
* https://github.com/evanw/glfx.js
*/
export declare const DotScreenShader: {
uniforms: {
tDiffuse: {
value: null;
};
tSize: {
value: Vector2;
};
center: {
value: Vector2;
};
angle: {
value: number;
};
scale: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+61
View File
@@ -0,0 +1,61 @@
import { Vector2 } from "three";
const DotScreenShader = {
uniforms: {
tDiffuse: { value: null },
tSize: { value: /* @__PURE__ */ new Vector2(256, 256) },
center: { value: /* @__PURE__ */ new Vector2(0.5, 0.5) },
angle: { value: 1.57 },
scale: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform vec2 center;
uniform float angle;
uniform float scale;
uniform vec2 tSize;
uniform sampler2D tDiffuse;
varying vec2 vUv;
float pattern() {
float s = sin( angle ), c = cos( angle );
vec2 tex = vUv * tSize - center;
vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;
return ( sin( point.x ) * sin( point.y ) ) * 4.0;
}
void main() {
vec4 color = texture2D( tDiffuse, vUv );
float average = ( color.r + color.g + color.b ) / 3.0;
gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );
}
`
)
};
export {
DotScreenShader
};
//# sourceMappingURL=DotScreenShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DotScreenShader.js","sources":["../../src/shaders/DotScreenShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Dot screen shader\n * based on glfx.js sepia shader\n * https://github.com/evanw/glfx.js\n */\n\nexport const DotScreenShader = {\n uniforms: {\n tDiffuse: { value: null },\n tSize: { value: /* @__PURE__ */ new Vector2(256, 256) },\n center: { value: /* @__PURE__ */ new Vector2(0.5, 0.5) },\n angle: { value: 1.57 },\n scale: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform vec2 center;\n uniform float angle;\n uniform float scale;\n uniform vec2 tSize;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n float pattern() {\n\n \tfloat s = sin( angle ), c = cos( angle );\n\n \tvec2 tex = vUv * tSize - center;\n \tvec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;\n\n \treturn ( sin( point.x ) * sin( point.y ) ) * 4.0;\n\n }\n\n void main() {\n\n \tvec4 color = texture2D( tDiffuse, vUv );\n\n \tfloat average = ( color.r + color.g + color.b ) / 3.0;\n\n \tgl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );\n\n }\n `,\n}\n"],"names":[],"mappings":";AAQO,MAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,OAAO,EAAE,2BAA2B,QAAQ,KAAK,GAAG,EAAE;AAAA,IACtD,QAAQ,EAAE,2BAA2B,QAAQ,KAAK,GAAG,EAAE;AAAA,IACvD,OAAO,EAAE,OAAO,KAAK;AAAA,IACrB,OAAO,EAAE,OAAO,EAAI;AAAA,EACtB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+B7B;"}
+1108
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+19
View File
@@ -0,0 +1,19 @@
import { Vector2 } from 'three';
/**
* NVIDIA FXAA by Timothy Lottes
* http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html
* - WebGL port by @supereggbert
* http://www.glge.org/demos/fxaa/
*/
export declare const FXAAShader: {
uniforms: {
tDiffuse: {
value: null;
};
resolution: {
value: Vector2;
};
};
vertexShader: string;
fragmentShader: string;
};
+1108
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+82
View File
@@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const FilmShader = {
uniforms: {
tDiffuse: { value: null },
time: { value: 0 },
nIntensity: { value: 0.5 },
sIntensity: { value: 0.05 },
sCount: { value: 4096 },
grayscale: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
// control parameter
uniform float time;
uniform bool grayscale;
// noise effect intensity value (0 = no effect, 1 = full effect)
uniform float nIntensity;
// scanlines effect intensity value (0 = no effect, 1 = full effect)
uniform float sIntensity;
// scanlines effect count value (0 = no effect, 4096 = full effect)
uniform float sCount;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
// sample the source
vec4 cTextureScreen = texture2D( tDiffuse, vUv );
// make some noise
float dx = rand( vUv + time );
// add noise
vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );
// get us a sine and cosine
vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );
// add scanlines
cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;
// interpolate between source and result by intensity
cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );
// convert to grayscale if desired
if( grayscale ) {
cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );
}
gl_FragColor = vec4( cResult, cTextureScreen.a );
}
`
)
};
exports.FilmShader = FilmShader;
//# sourceMappingURL=FilmShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FilmShader.cjs","sources":["../../src/shaders/FilmShader.ts"],"sourcesContent":["/**\n * Film grain & scanlines shader\n *\n * - ported from HLSL to WebGL / GLSL\n * http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html\n *\n * Screen Space Static Postprocessor\n *\n * Produces an analogue noise overlay similar to a film grain / TV static\n *\n * Original implementation and noise algorithm\n * Pat 'Hawthorne' Shearon\n *\n * Optimized scanlines + noise version with intensity scaling\n * Georg 'Leviathan' Steinrohder\n *\n * This version is provided under a Creative Commons Attribution 3.0 License\n * http://creativecommons.org/licenses/by/3.0/\n */\n\nexport const FilmShader = {\n uniforms: {\n tDiffuse: { value: null },\n time: { value: 0.0 },\n nIntensity: { value: 0.5 },\n sIntensity: { value: 0.05 },\n sCount: { value: 4096 },\n grayscale: { value: 1 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #include <common>\n\n // control parameter\n uniform float time;\n\n uniform bool grayscale;\n\n // noise effect intensity value (0 = no effect, 1 = full effect)\n uniform float nIntensity;\n\n // scanlines effect intensity value (0 = no effect, 1 = full effect)\n uniform float sIntensity;\n\n // scanlines effect count value (0 = no effect, 4096 = full effect)\n uniform float sCount;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // sample the source\n \tvec4 cTextureScreen = texture2D( tDiffuse, vUv );\n\n // make some noise\n \tfloat dx = rand( vUv + time );\n\n // add noise\n \tvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );\n\n // get us a sine and cosine\n \tvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\n\n // add scanlines\n \tcResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\n\n // interpolate between source and result by intensity\n \tcResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\n\n // convert to grayscale if desired\n \tif( grayscale ) {\n\n \t\tcResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n\n \t}\n\n \tgl_FragColor = vec4( cResult, cTextureScreen.a );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAoBO,MAAM,aAAa;AAAA,EACxB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,MAAM,EAAE,OAAO,EAAI;AAAA,IACnB,YAAY,EAAE,OAAO,IAAI;AAAA,IACzB,YAAY,EAAE,OAAO,KAAK;AAAA,IAC1B,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,WAAW,EAAE,OAAO,EAAE;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoD7B;;"}
+43
View File
@@ -0,0 +1,43 @@
/**
* Film grain & scanlines shader
*
* - ported from HLSL to WebGL / GLSL
* http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
*
* Screen Space Static Postprocessor
*
* Produces an analogue noise overlay similar to a film grain / TV static
*
* Original implementation and noise algorithm
* Pat 'Hawthorne' Shearon
*
* Optimized scanlines + noise version with intensity scaling
* Georg 'Leviathan' Steinrohder
*
* This version is provided under a Creative Commons Attribution 3.0 License
* http://creativecommons.org/licenses/by/3.0/
*/
export declare const FilmShader: {
uniforms: {
tDiffuse: {
value: null;
};
time: {
value: number;
};
nIntensity: {
value: number;
};
sIntensity: {
value: number;
};
sCount: {
value: number;
};
grayscale: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+82
View File
@@ -0,0 +1,82 @@
const FilmShader = {
uniforms: {
tDiffuse: { value: null },
time: { value: 0 },
nIntensity: { value: 0.5 },
sIntensity: { value: 0.05 },
sCount: { value: 4096 },
grayscale: { value: 1 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
#include <common>
// control parameter
uniform float time;
uniform bool grayscale;
// noise effect intensity value (0 = no effect, 1 = full effect)
uniform float nIntensity;
// scanlines effect intensity value (0 = no effect, 1 = full effect)
uniform float sIntensity;
// scanlines effect count value (0 = no effect, 4096 = full effect)
uniform float sCount;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
// sample the source
vec4 cTextureScreen = texture2D( tDiffuse, vUv );
// make some noise
float dx = rand( vUv + time );
// add noise
vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );
// get us a sine and cosine
vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );
// add scanlines
cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;
// interpolate between source and result by intensity
cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );
// convert to grayscale if desired
if( grayscale ) {
cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );
}
gl_FragColor = vec4( cResult, cTextureScreen.a );
}
`
)
};
export {
FilmShader
};
//# sourceMappingURL=FilmShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FilmShader.js","sources":["../../src/shaders/FilmShader.ts"],"sourcesContent":["/**\n * Film grain & scanlines shader\n *\n * - ported from HLSL to WebGL / GLSL\n * http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html\n *\n * Screen Space Static Postprocessor\n *\n * Produces an analogue noise overlay similar to a film grain / TV static\n *\n * Original implementation and noise algorithm\n * Pat 'Hawthorne' Shearon\n *\n * Optimized scanlines + noise version with intensity scaling\n * Georg 'Leviathan' Steinrohder\n *\n * This version is provided under a Creative Commons Attribution 3.0 License\n * http://creativecommons.org/licenses/by/3.0/\n */\n\nexport const FilmShader = {\n uniforms: {\n tDiffuse: { value: null },\n time: { value: 0.0 },\n nIntensity: { value: 0.5 },\n sIntensity: { value: 0.05 },\n sCount: { value: 4096 },\n grayscale: { value: 1 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #include <common>\n\n // control parameter\n uniform float time;\n\n uniform bool grayscale;\n\n // noise effect intensity value (0 = no effect, 1 = full effect)\n uniform float nIntensity;\n\n // scanlines effect intensity value (0 = no effect, 1 = full effect)\n uniform float sIntensity;\n\n // scanlines effect count value (0 = no effect, 4096 = full effect)\n uniform float sCount;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // sample the source\n \tvec4 cTextureScreen = texture2D( tDiffuse, vUv );\n\n // make some noise\n \tfloat dx = rand( vUv + time );\n\n // add noise\n \tvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );\n\n // get us a sine and cosine\n \tvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\n\n // add scanlines\n \tcResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\n\n // interpolate between source and result by intensity\n \tcResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\n\n // convert to grayscale if desired\n \tif( grayscale ) {\n\n \t\tcResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n\n \t}\n\n \tgl_FragColor = vec4( cResult, cTextureScreen.a );\n\n }\n `,\n}\n"],"names":[],"mappings":"AAoBO,MAAM,aAAa;AAAA,EACxB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,MAAM,EAAE,OAAO,EAAI;AAAA,IACnB,YAAY,EAAE,OAAO,IAAI;AAAA,IACzB,YAAY,EAAE,OAAO,KAAK;AAAA,IAC1B,QAAQ,EAAE,OAAO,KAAK;AAAA,IACtB,WAAW,EAAE,OAAO,EAAE;AAAA,EACxB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoD7B;"}
+83
View File
@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const FocusShader = {
uniforms: {
tDiffuse: { value: null },
screenWidth: { value: 1024 },
screenHeight: { value: 1024 },
sampleDistance: { value: 0.94 },
waveFactor: { value: 125e-5 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float screenWidth;
uniform float screenHeight;
uniform float sampleDistance;
uniform float waveFactor;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 color, org, tmp, add;
float sample_dist, f;
vec2 vin;
vec2 uv = vUv;
add = color = org = texture2D( tDiffuse, uv );
vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );
sample_dist = dot( vin, vin ) * 2.0;
f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;
vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );
add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );
color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );
gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );
}
`
)
};
exports.FocusShader = FocusShader;
//# sourceMappingURL=FocusShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FocusShader.cjs","sources":["../../src/shaders/FocusShader.ts"],"sourcesContent":["/**\n * Focus shader\n * based on PaintEffect postprocess from ro.me\n * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js\n */\n\nexport const FocusShader = {\n uniforms: {\n tDiffuse: { value: null },\n screenWidth: { value: 1024 },\n screenHeight: { value: 1024 },\n sampleDistance: { value: 0.94 },\n waveFactor: { value: 0.00125 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float screenWidth;\n uniform float screenHeight;\n uniform float sampleDistance;\n uniform float waveFactor;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 color, org, tmp, add;\n \tfloat sample_dist, f;\n \tvec2 vin;\n \tvec2 uv = vUv;\n\n \tadd = color = org = texture2D( tDiffuse, uv );\n\n \tvin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );\n \tsample_dist = dot( vin, vin ) * 2.0;\n\n \tf = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;\n\n \tvec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tcolor = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );\n \tcolor = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );\n\n \tgl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAMO,MAAM,cAAc;AAAA,EACzB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,aAAa,EAAE,OAAO,KAAK;AAAA,IAC3B,cAAc,EAAE,OAAO,KAAK;AAAA,IAC5B,gBAAgB,EAAE,OAAO,KAAK;AAAA,IAC9B,YAAY,EAAE,OAAO,OAAQ;AAAA,EAC/B;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsD7B;;"}
+26
View File
@@ -0,0 +1,26 @@
/**
* Focus shader
* based on PaintEffect postprocess from ro.me
* http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
*/
export declare const FocusShader: {
uniforms: {
tDiffuse: {
value: null;
};
screenWidth: {
value: number;
};
screenHeight: {
value: number;
};
sampleDistance: {
value: number;
};
waveFactor: {
value: number;
};
};
vertexShader: string;
fragmentShader: string;
};
+83
View File
@@ -0,0 +1,83 @@
const FocusShader = {
uniforms: {
tDiffuse: { value: null },
screenWidth: { value: 1024 },
screenHeight: { value: 1024 },
sampleDistance: { value: 0.94 },
waveFactor: { value: 125e-5 }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform float screenWidth;
uniform float screenHeight;
uniform float sampleDistance;
uniform float waveFactor;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 color, org, tmp, add;
float sample_dist, f;
vec2 vin;
vec2 uv = vUv;
add = color = org = texture2D( tDiffuse, uv );
vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );
sample_dist = dot( vin, vin ) * 2.0;
f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;
vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );
add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );
if( tmp.b < color.b ) color = tmp;
color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );
color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );
gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );
}
`
)
};
export {
FocusShader
};
//# sourceMappingURL=FocusShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FocusShader.js","sources":["../../src/shaders/FocusShader.ts"],"sourcesContent":["/**\n * Focus shader\n * based on PaintEffect postprocess from ro.me\n * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js\n */\n\nexport const FocusShader = {\n uniforms: {\n tDiffuse: { value: null },\n screenWidth: { value: 1024 },\n screenHeight: { value: 1024 },\n sampleDistance: { value: 0.94 },\n waveFactor: { value: 0.00125 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float screenWidth;\n uniform float screenHeight;\n uniform float sampleDistance;\n uniform float waveFactor;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n \tvec4 color, org, tmp, add;\n \tfloat sample_dist, f;\n \tvec2 vin;\n \tvec2 uv = vUv;\n\n \tadd = color = org = texture2D( tDiffuse, uv );\n\n \tvin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );\n \tsample_dist = dot( vin, vin ) * 2.0;\n\n \tf = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;\n\n \tvec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tadd += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );\n \tif( tmp.b < color.b ) color = tmp;\n\n \tcolor = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );\n \tcolor = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );\n\n \tgl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );\n\n }\n `,\n}\n"],"names":[],"mappings":"AAMO,MAAM,cAAc;AAAA,EACzB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,aAAa,EAAE,OAAO,KAAK;AAAA,IAC3B,cAAc,EAAE,OAAO,KAAK;AAAA,IAC5B,gBAAgB,EAAE,OAAO,KAAK;AAAA,IAC9B,YAAY,EAAE,OAAO,OAAQ;AAAA,EAC/B;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsD7B;"}
+86
View File
@@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const THREE = require("three");
const FreiChenShader = {
uniforms: {
tDiffuse: { value: null },
aspect: { value: /* @__PURE__ */ new THREE.Vector2(512, 512) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
varying vec2 vUv;
uniform vec2 aspect;
vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);
mat3 G[9];
// hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45
const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );
const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );
const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );
const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );
const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );
const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );
const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );
const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );
const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );
void main(void)
{
G[0] = g0,
G[1] = g1,
G[2] = g2,
G[3] = g3,
G[4] = g4,
G[5] = g5,
G[6] = g6,
G[7] = g7,
G[8] = g8;
mat3 I;
float cnv[9];
vec3 sample;
/* fetch the 3x3 neighbourhood and use the RGB vectors length as intensity value */
for (float i=0.0; i<3.0; i++) {
for (float j=0.0; j<3.0; j++) {
sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;
I[int(i)][int(j)] = length(sample);
}
}
/* calculate the convolution values for all the masks */
for (int i=0; i<9; i++) {
float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);
cnv[i] = dp3 * dp3;
}
float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);
float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);
gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);
}
`
)
};
exports.FreiChenShader = FreiChenShader;
//# sourceMappingURL=FreiChenShader.cjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FreiChenShader.cjs","sources":["../../src/shaders/FreiChenShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Edge Detection Shader using Frei-Chen filter\n * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector\n *\n * aspect: vec2 of (1/width, 1/height)\n */\n\nexport const FreiChenShader = {\n uniforms: {\n tDiffuse: { value: null },\n aspect: { value: /* @__PURE__ */ new Vector2(512, 512) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n\n uniform vec2 aspect;\n\n vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);\n\n mat3 G[9];\n\n // hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45\n\n const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );\n const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );\n const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );\n const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );\n const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );\n const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );\n const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );\n const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );\n const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );\n\n void main(void)\n {\n\n \tG[0] = g0,\n \tG[1] = g1,\n \tG[2] = g2,\n \tG[3] = g3,\n \tG[4] = g4,\n \tG[5] = g5,\n \tG[6] = g6,\n \tG[7] = g7,\n \tG[8] = g8;\n\n \tmat3 I;\n \tfloat cnv[9];\n \tvec3 sample;\n\n /* fetch the 3x3 neighbourhood and use the RGB vectors length as intensity value */\n \tfor (float i=0.0; i<3.0; i++) {\n \t\tfor (float j=0.0; j<3.0; j++) {\n \t\t\tsample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;\n \t\t\tI[int(i)][int(j)] = length(sample);\n \t\t}\n \t}\n\n /* calculate the convolution values for all the masks */\n \tfor (int i=0; i<9; i++) {\n \t\tfloat dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);\n \t\tcnv[i] = dp3 * dp3;\n \t}\n\n \tfloat M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);\n \tfloat S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);\n\n \tgl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);\n }\n `,\n}\n"],"names":["Vector2"],"mappings":";;;AASO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,QAAQ,EAAE,2BAA2BA,MAAQ,QAAA,KAAK,GAAG,EAAE;AAAA,EACzD;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2D7B;;"}
+19
View File
@@ -0,0 +1,19 @@
import { Vector2 } from 'three';
/**
* Edge Detection Shader using Frei-Chen filter
* Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector
*
* aspect: vec2 of (1/width, 1/height)
*/
export declare const FreiChenShader: {
uniforms: {
tDiffuse: {
value: null;
};
aspect: {
value: Vector2;
};
};
vertexShader: string;
fragmentShader: string;
};
+86
View File
@@ -0,0 +1,86 @@
import { Vector2 } from "three";
const FreiChenShader = {
uniforms: {
tDiffuse: { value: null },
aspect: { value: /* @__PURE__ */ new Vector2(512, 512) }
},
vertexShader: (
/* glsl */
`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
`
),
fragmentShader: (
/* glsl */
`
uniform sampler2D tDiffuse;
varying vec2 vUv;
uniform vec2 aspect;
vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);
mat3 G[9];
// hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45
const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );
const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );
const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );
const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );
const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );
const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );
const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );
const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );
const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );
void main(void)
{
G[0] = g0,
G[1] = g1,
G[2] = g2,
G[3] = g3,
G[4] = g4,
G[5] = g5,
G[6] = g6,
G[7] = g7,
G[8] = g8;
mat3 I;
float cnv[9];
vec3 sample;
/* fetch the 3x3 neighbourhood and use the RGB vectors length as intensity value */
for (float i=0.0; i<3.0; i++) {
for (float j=0.0; j<3.0; j++) {
sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;
I[int(i)][int(j)] = length(sample);
}
}
/* calculate the convolution values for all the masks */
for (int i=0; i<9; i++) {
float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);
cnv[i] = dp3 * dp3;
}
float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);
float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);
gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);
}
`
)
};
export {
FreiChenShader
};
//# sourceMappingURL=FreiChenShader.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"FreiChenShader.js","sources":["../../src/shaders/FreiChenShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * Edge Detection Shader using Frei-Chen filter\n * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector\n *\n * aspect: vec2 of (1/width, 1/height)\n */\n\nexport const FreiChenShader = {\n uniforms: {\n tDiffuse: { value: null },\n aspect: { value: /* @__PURE__ */ new Vector2(512, 512) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n\n uniform vec2 aspect;\n\n vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);\n\n mat3 G[9];\n\n // hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45\n\n const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );\n const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );\n const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );\n const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );\n const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );\n const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );\n const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );\n const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );\n const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );\n\n void main(void)\n {\n\n \tG[0] = g0,\n \tG[1] = g1,\n \tG[2] = g2,\n \tG[3] = g3,\n \tG[4] = g4,\n \tG[5] = g5,\n \tG[6] = g6,\n \tG[7] = g7,\n \tG[8] = g8;\n\n \tmat3 I;\n \tfloat cnv[9];\n \tvec3 sample;\n\n /* fetch the 3x3 neighbourhood and use the RGB vectors length as intensity value */\n \tfor (float i=0.0; i<3.0; i++) {\n \t\tfor (float j=0.0; j<3.0; j++) {\n \t\t\tsample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;\n \t\t\tI[int(i)][int(j)] = length(sample);\n \t\t}\n \t}\n\n /* calculate the convolution values for all the masks */\n \tfor (int i=0; i<9; i++) {\n \t\tfloat dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);\n \t\tcnv[i] = dp3 * dp3;\n \t}\n\n \tfloat M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);\n \tfloat S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);\n\n \tgl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);\n }\n `,\n}\n"],"names":[],"mappings":";AASO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,QAAQ,EAAE,2BAA2B,QAAQ,KAAK,GAAG,EAAE;AAAA,EACzD;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2D7B;"}

Some files were not shown because too many files have changed in this diff Show More