Created
January 30, 2020 21:39
-
-
Save mauriciomassaia/aac84edbf895f73cd7a006506255ef6a to your computer and use it in GitHub Desktop.
PixiJS - Fragment to add a gap and also a mask in projection with 3 walls of 1920x1200 each.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 3 walls using each a 1920x1200 projector in a row but wall1 and wall2 collided as per projector physical placement | |
| // so need to have a gap, as wall2 only uses 1866px so from x: 1920 (end wall1) to x:1974 (beginning wall2) we need | |
| // to shift all pixels by 54px | |
| // Also discard all pixels that cover the pillar area where another projector will be used with a cone mapping to play | |
| // content on loop. | |
| precision mediump float; | |
| // supplied by pixijs | |
| varying vec2 vTextureCoord; | |
| varying vec2 vFilterCoord; | |
| uniform sampler2D uSampler; | |
| uniform vec4 inputPixel; | |
| uniform float gapx1; | |
| uniform float gapx2; | |
| uniform float pillarx1; | |
| uniform float pillarx2; | |
| float gapLen = gapx2 - gapx1; // in pixels | |
| void main () | |
| { | |
| vec2 coords = vTextureCoord.xy; | |
| vec4 color; | |
| float x = vTextureCoord.x * inputPixel.x; | |
| float normGap = gapLen / inputPixel.x; | |
| // Shift pixels based on the gap between wall1 and wall2 projections | |
| // to blend the image properly | |
| if (x <= gapx1) { | |
| color = texture2D(uSampler, coords); | |
| } else if (x > gapx1 && x <= gapx2) { | |
| color = vec4(0.0); | |
| } else { | |
| // deduct the gapLen | |
| coords.x -= normGap; | |
| color = texture2D(uSampler, coords); | |
| } | |
| // discar pixels between pillar area as there will be another | |
| // projection mapping with a looping video at the exhibition | |
| if (x >= pillarx1 && x <= pillarx2) { | |
| discard; | |
| } | |
| gl_FragColor = color; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment