mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-18 06:09:30 -07:00
Added noise to coloration passes, removed film grain pass. Added ImageOverlayPass option; effect can be specified in URL variables.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @author rezmason
|
||||
*/
|
||||
|
||||
THREE.HorizontalColorationPass = function (colors) {
|
||||
THREE.HorizontalColorationPass = function (colors, ditherMagnitude = 1) {
|
||||
const values = new Uint8Array([].concat(...colors.map(color => color.toArray().map(component => Math.floor(component * 255)))));
|
||||
|
||||
this.dataTexture = new THREE.DataTexture(
|
||||
@@ -19,6 +19,7 @@ THREE.HorizontalColorationPass = function (colors) {
|
||||
uniforms: {
|
||||
tDiffuse: { value: null },
|
||||
tColorData: { value: this.dataTexture },
|
||||
ditherMagnitude: { value: ditherMagnitude },
|
||||
},
|
||||
|
||||
vertexShader: `
|
||||
@@ -30,13 +31,22 @@ THREE.HorizontalColorationPass = function (colors) {
|
||||
`,
|
||||
|
||||
fragmentShader: `
|
||||
#define PI 3.14159265359
|
||||
|
||||
uniform sampler2D tDiffuse;
|
||||
uniform sampler2D tColorData;
|
||||
uniform float ditherMagnitude;
|
||||
varying vec2 vUv;
|
||||
|
||||
highp float rand( const in vec2 uv ) {
|
||||
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
||||
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
||||
return fract(sin(sn) * c);
|
||||
}
|
||||
|
||||
void main() {
|
||||
float value = texture2D(tDiffuse, vUv).r;
|
||||
vec3 value2 = texture2D(tColorData, vUv).rgb;
|
||||
vec3 value2 = texture2D(tColorData, vUv).rgb - rand( gl_FragCoord.xy ) * ditherMagnitude;
|
||||
gl_FragColor = vec4(value2 * value, 1.0);
|
||||
}
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user