├── .classpath
├── .gitignore
├── .project
├── DesignPattern.png
├── DesignPattern.ucls
├── P5LibrarySetup.md
├── README.md
├── data
├── README
├── oldSketches
│ └── OLD_GPU3DPhysicsSimulation
│ │ ├── GPU3DPhysicsSimulation.pde
│ │ ├── data
│ │ ├── pfrag.glsl
│ │ └── pvert.glsl
│ │ └── test.png
├── shaders
│ ├── _based.glsl
│ ├── _basedDecoding.glsl
│ ├── _basedDecoding2D.glsl
│ ├── _basedDecodingInt.glsl
│ ├── _basedtest.glsl
│ ├── bilateral.glsl
│ ├── blendadd.glsl
│ ├── blendaverage.glsl
│ ├── blendcolor.glsl
│ ├── blendcolorburn.glsl
│ ├── blendcolordodge.glsl
│ ├── blenddarken.glsl
│ ├── blenddifference.glsl
│ ├── blendexclusion.glsl
│ ├── blendglow.glsl
│ ├── blendhardlight.glsl
│ ├── blendhardmix.glsl
│ ├── blendhue.glsl
│ ├── blendlighten.glsl
│ ├── blendlinearburn.glsl
│ ├── blendlineardodge.glsl
│ ├── blendlinearlight.glsl
│ ├── blendluminosity.glsl
│ ├── blendmultiply.glsl
│ ├── blendnegation.glsl
│ ├── blendoverlay.glsl
│ ├── blendphoenix.glsl
│ ├── blendpinlight.glsl
│ ├── blendreflect.glsl
│ ├── blendsaturation.glsl
│ ├── blendscreen.glsl
│ ├── blendsoftlight.glsl
│ ├── blendsubstract.glsl
│ ├── blendvividlight.glsl
│ ├── cannyedge1.glsl
│ ├── cannyedge2.glsl
│ ├── chromakey.glsl
│ ├── chromakey2.glsl
│ ├── chromawarp.glsl
│ ├── chromawarphigh.glsl
│ ├── chromawarplow.glsl
│ ├── chromawarpmedium.glsl
│ ├── colorthreshold.glsl
│ ├── constrastsaturationbrightness.glsl
│ ├── datamoshing.glsl
│ ├── datamoshing3x3.glsl
│ ├── datamoshing5x5.glsl
│ ├── denoise.glsl
│ ├── desaturate.glsl
│ ├── dilation.glsl
│ ├── dilationrgb.glsl
│ ├── dithering.glsl
│ ├── ditheringNonRectangular5x5.glsl
│ ├── ditheringNonRectangular8x8.glsl
│ ├── ditheringbayer2x2.glsl
│ ├── ditheringbayer2x2rgb.glsl
│ ├── ditheringbayer3x3.glsl
│ ├── ditheringbayer3x3rgb.glsl
│ ├── ditheringbayer4x4.glsl
│ ├── ditheringbayer4x4rgb.glsl
│ ├── ditheringbayer8x8.glsl
│ ├── ditheringbayer8x8rgb.glsl
│ ├── ditheringclusterdot4x4.glsl
│ ├── ditheringclusterdot4x4rgb.glsl
│ ├── ditheringclusterdot5x3.glsl
│ ├── ditheringclusterdot5x3rgb.glsl
│ ├── ditheringclusterdot8x8.glsl
│ ├── ditheringclusterdot8x8rgb.glsl
│ ├── ditheringrandom3x3.glsl
│ ├── ditheringrandom3x3rgb.glsl
│ ├── erosion.glsl
│ ├── erosionrgb.glsl
│ ├── gamma.glsl
│ ├── gaussianblur.glsl
│ ├── gaussianblur13x13.glsl
│ ├── gaussianblur5x5.glsl
│ ├── gaussianblur7x7.glsl
│ ├── gaussianblur9x9.glsl
│ ├── glitchdisplaceluma.glsl
│ ├── glitchdisplacergb.glsl
│ ├── glitchinvert.glsl
│ ├── glitchpixelate.glsl
│ ├── glitchshiftrgb.glsl
│ ├── glitchshufflergb.glsl
│ ├── glitchstitch.glsl
│ ├── grain.glsl
│ ├── grainrgb.glsl
│ ├── highpass.glsl
│ ├── huesegmentation.glsl
│ ├── invert.glsl
│ ├── level.glsl
│ ├── lut1d.glsl
│ ├── lut1dgen.glsl
│ ├── mask.glsl
│ ├── mask2.glsl
│ ├── median3x3.glsl
│ ├── median5x5.glsl
│ ├── pixelate.glsl
│ ├── radialblur.glsl
│ ├── radialblurhigh.glsl
│ ├── radialblurlow.glsl
│ ├── radialblurmedium.glsl
│ ├── ramp1d.glsl
│ ├── rotatedDitheringBayer2x2.glsl
│ ├── rotatedDitheringBayer3x3.glsl
│ ├── rotatedDitheringBayer4x4.glsl
│ ├── rotatedDitheringBayer8x8.glsl
│ ├── rotatedDitheringClusterDot4x4.glsl
│ ├── rotatedDitheringClusterDot5x3.glsl
│ ├── rotatedDitheringClusterDot8x8.glsl
│ ├── signeddistancefield.glsl
│ ├── sobel.glsl
│ ├── sobeledge.glsl
│ ├── threshold.glsl
│ ├── uv.glsl
│ └── vert.glsl
└── textures
│ ├── img.jpeg
│ ├── minicactus.png
│ └── minicactus_noised.png
├── examples
├── README
├── compositions
│ ├── Blending
│ │ ├── Blending.pde
│ │ └── data
│ │ │ ├── base.png
│ │ │ └── src.png
│ ├── ChromaKey
│ │ ├── ChromaKey.pde
│ │ └── data
│ │ │ ├── base.png
│ │ │ └── src.png
│ └── Masks
│ │ ├── Masks.pde
│ │ └── data
│ │ ├── base.png
│ │ ├── mask.png
│ │ └── src.png
├── core
│ └── LibraryInfos
│ │ └── LibraryInfos.pde
├── filters
│ ├── ChromaWarping
│ │ ├── ChromaWarping.pde
│ │ └── data
│ │ │ └── src.png
│ ├── ContrastSaturationBrightness
│ │ ├── ContrastSaturationBrightness.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Datamoshing
│ │ ├── Datamoshing.pde
│ │ └── data
│ │ │ ├── BW.png
│ │ │ ├── coverrsources.mp4
│ │ │ └── src.png
│ ├── Denoise
│ │ ├── Denoise.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Desaturation
│ │ ├── Desaturation.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Dilation
│ │ ├── Dilation.pde
│ │ └── data
│ │ │ ├── BW.png
│ │ │ └── src.png
│ ├── Ditherings
│ │ ├── Ditherings.pde
│ │ ├── data
│ │ │ └── src.png
│ │ ├── filteredImg1.png
│ │ ├── filteredImg2.png
│ │ ├── filteredImg3.png
│ │ ├── filteredImg4.png
│ │ ├── filteredImg5.png
│ │ ├── filteredImg6.png
│ │ ├── filteredImg7.png
│ │ └── filteredImg8.png
│ ├── DitheringsRGB
│ │ ├── DitheringsRGB.pde
│ │ ├── data
│ │ │ └── src.png
│ │ ├── filteredImg1.png
│ │ ├── filteredImg2.png
│ │ ├── filteredImg3.png
│ │ ├── filteredImg4.png
│ │ ├── filteredImg5.png
│ │ ├── filteredImg6.png
│ │ ├── filteredImg7.png
│ │ └── filteredImg8.png
│ ├── Erosion
│ │ ├── Erosion.pde
│ │ └── data
│ │ │ ├── BW.png
│ │ │ └── src.png
│ ├── GammaCorrection
│ │ ├── GammaCorrection.pde
│ │ └── data
│ │ │ └── src.png
│ ├── GaussianBlur
│ │ ├── GaussianBlur.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Glitches
│ │ ├── Glitches.pde
│ │ ├── data
│ │ │ └── src.png
│ │ ├── filteredImg1.png
│ │ ├── filteredImg2.png
│ │ ├── filteredImg3.png
│ │ ├── filteredImg4.png
│ │ ├── filteredImg5.png
│ │ ├── filteredImg6.png
│ │ ├── filteredImg7.png
│ │ └── filteredImg8.png
│ ├── HighPass
│ │ ├── HighPass.pde
│ │ └── data
│ │ │ └── src.png
│ ├── HueSegmentation
│ │ ├── HueSegmentation.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Invert
│ │ ├── Invert.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Level
│ │ ├── Level.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Lut1D
│ │ ├── Lut1D.pde
│ │ └── data
│ │ │ ├── LUT_cool.jpg
│ │ │ ├── LUT_old.jpg
│ │ │ ├── LUT_old_2.jpg
│ │ │ └── src.png
│ ├── Pixelate
│ │ ├── Pixelate.pde
│ │ └── data
│ │ │ └── src.png
│ ├── RGBGrain
│ │ ├── RGBGrain.pde
│ │ └── data
│ │ │ └── src.png
│ ├── RadialBlur
│ │ ├── RadialBlur.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Ramp1D
│ │ ├── Ramp1D.pde
│ │ └── data
│ │ │ ├── ramp_0.png
│ │ │ ├── ramp_1.png
│ │ │ ├── ramp_10.png
│ │ │ ├── ramp_2.png
│ │ │ ├── ramp_3.png
│ │ │ ├── ramp_4.png
│ │ │ ├── ramp_5.png
│ │ │ ├── ramp_6.png
│ │ │ ├── ramp_7.png
│ │ │ ├── ramp_8.png
│ │ │ ├── ramp_9.png
│ │ │ └── src.png
│ ├── SequentialFilter
│ │ ├── SequentialFilter.pde
│ │ └── data
│ │ │ └── src.png
│ ├── SignedDistanceField
│ │ ├── SignedDistanceField.pde
│ │ └── data
│ │ │ └── src.png
│ ├── SobelAndCannyEdges
│ │ ├── SobelAndCannyEdges.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Thresholds
│ │ ├── Thresholds.pde
│ │ └── data
│ │ │ └── src.png
│ └── WhiteGrain
│ │ ├── WhiteGrain.pde
│ │ └── data
│ │ └── src.png
├── others
│ ├── AccentuationProcess
│ │ ├── AccentuationProcess.pde
│ │ └── data
│ │ │ └── src.png
│ ├── GPU2DPhysicsSimulation
│ │ ├── GPU2DPhysicsSimulation.pde
│ │ └── data
│ │ │ ├── pfrag.glsl
│ │ │ ├── posFrag.glsl
│ │ │ ├── pvert.glsl
│ │ │ └── velFrag.glsl
│ ├── GPU3DPhysicsSimulation
│ │ ├── GPU3DPhysicsSimulation.pde
│ │ └── data
│ │ │ ├── pfrag.glsl
│ │ │ ├── posFrag.glsl
│ │ │ ├── pvert.glsl
│ │ │ └── velFrag.glsl
│ ├── OSX_KinectRawDepthIntoRGBAMod
│ │ ├── OSX_KinectRawDepthIntoRGBAMod.pde
│ │ └── data
│ │ │ └── frag.glsl
│ ├── OSX_KinectRawDepthIntoRGBAMod_PointCloud
│ │ ├── OSX_KinectRawDepthIntoRGBAMod_PointCloud.pde
│ │ └── data
│ │ │ ├── frag.glsl
│ │ │ └── vert.glsl
│ ├── ProcessHueSegmentation
│ │ ├── ProcessHueSegmentation.pde
│ │ └── data
│ │ │ └── src.png
│ ├── Win_KinectRawDepthIntoRGBAMod
│ │ ├── Win_KinectRawDepthIntoRGBAMod.pde
│ │ └── data
│ │ │ └── frag.glsl
│ └── Win_KinectRawDepthIntoRGBAMod_PointCloud
│ │ ├── Win_KinectRawDepthIntoRGBAMod_PointCloud.pde
│ │ └── data
│ │ ├── frag.glsl
│ │ └── vert.glsl
└── utils
│ ├── DoubleToRGBAEncoding
│ ├── DoubleToRGBAEncoding.pde
│ └── data
│ │ └── src.png
│ ├── FloatToRGBAEncoding
│ ├── FloatToRGBAEncoding.pde
│ └── data
│ │ └── src.png
│ ├── Generate1DLUT
│ ├── Generate1DLUT.pde
│ └── lut1d.png
│ ├── IntToRGBAEncoding
│ ├── IntToRGBAEncoding.pde
│ └── data
│ │ └── src.png
│ ├── PingPongBuffering
│ └── PingPongBuffering.pde
│ └── Vec2ToRGBAEncoding
│ ├── Vec2ToRGBAEncoding.pde
│ └── data
│ └── src.png
├── floatToRGBAEncoding.md
├── lib
└── README
├── license.txt
├── releases
└── GPUImage-0-0-2.zip
├── resources
├── README.md
├── build.properties
├── build.xml
├── code
│ ├── ExampleTaglet.class
│ ├── ExampleTaglet.java
│ ├── ant-contrib-1.0b3.jar
│ └── doc.sh
├── library.properties
└── stylesheet.css
├── src
└── gpuimage
│ ├── core
│ ├── Compositor.java
│ ├── Filter.java
│ ├── GPUImage.java
│ ├── GPUImageBaseEffects.java
│ ├── GPUImageInterface.java
│ ├── LUTGenerator.java
│ └── ProceduralTexture.java
│ └── utils
│ ├── FloatPacking.java
│ ├── GPUImageBaseFloatPacking.java
│ ├── GPUImageMathsPixels.java
│ ├── IntPacking.java
│ ├── PingPongBuffer.java
│ ├── PingPongGraphics.java
│ └── Vec2Packing.java
└── web
├── index.html
└── stylesheet.css
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | tmp
3 | distribution
4 | resources/build.properties
5 | resources/build.xml
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | processing-library-template
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/DesignPattern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/DesignPattern.png
--------------------------------------------------------------------------------
/data/README:
--------------------------------------------------------------------------------
1 | the data folder:
2 | If your Library is using files like images, sound files,
3 | any data file, etc., put them into the data folder.
4 | When coding your Library you can use processing's internal loading
5 | functions like loadImage(), loadStrings(), etc. to load files
6 | located inside the data folder into your Library.
7 |
8 |
--------------------------------------------------------------------------------
/data/oldSketches/OLD_GPU3DPhysicsSimulation/data/pfrag.glsl:
--------------------------------------------------------------------------------
1 | #version 150
2 | #ifdef GL_ES
3 | precision mediump float;
4 | precision mediump int;
5 | #endif
6 |
7 | in vec4 vertColor;
8 | in vec4 vertTexCoord;
9 |
10 | out vec4 fragColor;
11 |
12 |
13 | void main() {
14 | fragColor = vertColor;
15 | }
--------------------------------------------------------------------------------
/data/oldSketches/OLD_GPU3DPhysicsSimulation/data/pvert.glsl:
--------------------------------------------------------------------------------
1 |
2 | #version 150
3 | #ifdef GL_ES
4 | precision highp float;
5 | precision highp vec2;
6 | precision highp vec3;
7 | precision highp vec4;
8 | precision highp int;
9 | #endif
10 |
11 | const vec4 efactor = vec4(1.0, 255.0, 65025.0, 16581375.0);
12 | const vec4 dfactor = vec4(1.0/1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0);
13 | const float mask = 1.0/256.0;
14 |
15 | uniform mat4 transform;
16 | uniform mat4 projection;
17 | uniform mat4 modelview;
18 |
19 | uniform sampler2D posBuffer;
20 | uniform vec2 bufferResolution;
21 | uniform vec2 gridResolution;
22 | uniform vec3 worldResolution;
23 |
24 |
25 | in vec4 position;
26 | in vec3 normal;
27 | in vec4 color;
28 | in vec2 offset;
29 |
30 | out vec4 vertColor;
31 | out vec4 vertTexCoord;
32 |
33 |
34 | float decodeRGBA32(vec4 rgba){
35 | return dot(rgba, dfactor);
36 | }
37 |
38 |
39 |
40 | void main(){
41 |
42 | //vec3 pos = getVector(position.xy, bufferResolution, vec3(1000.0), posBuffer);
43 | vec2 bufferRes = bufferResolution / vec2(1.0, 3.0);
44 | vertTexCoord.xy = position.xy / (bufferResolution.xy - vec2(1.0)) ;
45 | vec2 inc = vec2(0.0, 1.0/3.0);
46 |
47 | vec4 ex = texture2D(posBuffer, vertTexCoord.xy + inc * 0.0);
48 | vec4 ey = texture2D(posBuffer, vertTexCoord.xy + inc * 1.0);
49 | vec4 ez = texture2D(posBuffer, vertTexCoord.xy + inc * 2.0);
50 |
51 | float x = decodeRGBA32(ex);// * 2.0 - 1.0;
52 | float y = decodeRGBA32(ey);// * 2.0 - 1.0;
53 | float z = decodeRGBA32(ez);// * 2.0 - 1.0;
54 |
55 | vec3 pos = vec3(x, y, z) * 2.0 - 1.0;
56 |
57 | vec4 clip = projection * modelview * vec4(pos * worldResolution, 1.0);
58 | gl_Position = clip + projection * vec4(offset.xy * 0.25, 0, 0);
59 |
60 | vertColor = color;//vec4(x, y, z, 1.0);
61 |
62 | }
--------------------------------------------------------------------------------
/data/oldSketches/OLD_GPU3DPhysicsSimulation/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/data/oldSketches/OLD_GPU3DPhysicsSimulation/test.png
--------------------------------------------------------------------------------
/data/shaders/_based.glsl:
--------------------------------------------------------------------------------
1 | //blend sources : http://wiki.polycount.com/wiki/Blending_functions
2 |
3 | #ifdef GL_ES
4 | precision mediump float;
5 | precision mediump int;
6 | #endif
7 |
8 | uniform sampler2D texture;
9 |
10 | in vec4 vertTexCoord;
11 | out vec4 fragColor;
12 |
13 |
14 | void main(){
15 | vec2 uv = vertTexCoord.xy;
16 | vec4 tex = texture(texture, uv);
17 |
18 | fragColor = tex;
19 | }
--------------------------------------------------------------------------------
/data/shaders/_basedDecoding.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision highp float;
3 | precision highp vec4;
4 | precision highp vec3;
5 | precision highp vec2;
6 | precision highp int;
7 | #endif
8 |
9 | //constants elements
10 | const vec4 efactor = vec4(1.0, 255.0, 65025.0, 16581375.0);
11 | const vec4 dfactor = vec4(1.0/1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0);
12 | const float mask = 1.0/256.0;
13 |
14 |
15 | uniform sampler2D texture;
16 |
17 | in vec4 vertTexCoord;
18 | out vec4 fragColor;
19 |
20 | vec4 encodeRGBA32(float v){
21 | vec4 rgba = v * efactor.rgba;
22 | rgba.gba = fract(rgba.gba);
23 | rgba.rgb -= rgba.gba * mask;
24 | rgba.a = 1.0;
25 | return rgba;
26 | }
27 |
28 | vec4 encodeRGBA24(float v){
29 | vec3 rgb = v * efactor.rgb;
30 | rgb.gb = fract(rgb.gb);
31 | rgb.rg -= rgb.gb * mask;
32 | return vec4(rgb, 1.0);
33 | }
34 |
35 | vec4 encodeRGBA16(float v){
36 | vec2 rg = v * efactor.rg;
37 | rg.g = fract(rg.g);
38 | rg.r -= rg.g * mask;
39 | return vec4(rg, 0.0, 1.0);
40 | }
41 |
42 | float decodeRGBA32(vec4 rgba){
43 | return dot(rgba, dfactor.rgba);
44 | }
45 |
46 | float decodeRGBA24(vec3 rgb){
47 | return dot(rgb, dfactor.rgb);
48 | }
49 |
50 | float decodeRGBA16(vec2 rg){
51 | return dot(rg, dfactor.rg);
52 | }
53 |
54 |
55 | void main(){
56 | vec2 uv = vertTexCoord.xy;
57 | vec4 tex = texture(texture, uv);
58 |
59 | float data = decodeRGBA32(tex);
60 | vec4 encodedData = encodeRGBA32(data);
61 |
62 | fragColor = encodedData;
63 | }
--------------------------------------------------------------------------------
/data/shaders/_basedDecoding2D.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision highp float;
3 | precision highp vec4;
4 | precision highp vec3;
5 | precision highp vec2;
6 | precision highp int;
7 | #endif
8 |
9 | //constants elements
10 | const vec2 efactor = vec2(1.0, 255.0);
11 | const vec2 dfactor = vec2(1.0/1.0, 1.0/255.0);
12 | const float mask = 1.0/256.0;
13 |
14 |
15 | uniform sampler2D texture;
16 |
17 | in vec4 vertTexCoord;
18 | out vec4 fragColor;
19 |
20 |
21 | vec2 encodeRGBA16(float v){
22 | vec2 rg = v * efactor;
23 | rg.g = fract(rg.g);
24 | rg.r -= rg.g * mask;
25 | return vec2(rg);
26 | }
27 |
28 | vec4 encodeRGBA1616(vec2 xy){
29 | vec4 encodedData = vec4(encodeRGBA16(xy.x), encodeRGBA16(xy.y));
30 | encodedData.a = 1.0;
31 | return encodedData;
32 | }
33 |
34 | vec2 decodeRGBA16(vec4 rgba){
35 | return vec2(dot(rgba.rg, dfactor), dot(rgba.ba, dfactor));
36 | }
37 |
38 |
39 | void main(){
40 | vec2 uv = vertTexCoord.xy;
41 | vec4 tex = texture(texture, uv);
42 |
43 | vec2 data = decodeRGBA16(tex);
44 | vec4 encodedData = encodeRGBA1616(data);
45 |
46 | fragColor = encodedData;
47 | }
--------------------------------------------------------------------------------
/data/shaders/_basedDecodingInt.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision highp float;
3 | precision highp vec4;
4 | precision highp vec3;
5 | precision highp vec2;
6 | precision highp int;
7 | #endif
8 |
9 | uniform sampler2D texture;
10 | uniform int dataMax;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 |
16 | vec4 encodeRGBAMod(float value, float edge){
17 | float divider = float(edge) / 256.0;
18 |
19 | float modValue = mod(value, 255.0);
20 | float modIndex = value / 255.0;
21 |
22 | float index = modIndex / divider;
23 | float luma = fract(modValue);
24 |
25 | return vec4(luma, luma, index, 1.0);
26 | }
27 |
28 | float decodeRGBAMod(vec4 rgba, float edge){
29 | float divider = float(edge) / 256.0;
30 | float index = round(rgba.b * divider);
31 |
32 | return rgba.r + 255 * index;
33 | }
34 |
35 | void main(){
36 | vec2 uv = vertTexCoord.xy;
37 | vec4 tex = texture(texture, uv);
38 |
39 | float data = decodeRGBAMod(tex, dataMax);
40 | vec4 encodedData = encodeRGBAMod(data, float(dataMax));
41 |
42 | fragColor = encodedData;
43 | }
--------------------------------------------------------------------------------
/data/shaders/bilateral.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | // Original shader by mrharicot
7 | // https://www.shadertoy.com/view/4dfGDH
8 | // Ported to Processing by Raphaël de Courville
9 | // Update in order to use vertTexCoord attribute by BonjourLab
10 |
11 | #define SIGMA 5.0
12 | #define BSIGMA 0.1
13 | #define MSIZE 5 //define the kerner size
14 |
15 | uniform sampler2D texture;
16 | uniform vec2 resolution;
17 | in vec4 vertTexCoord;
18 |
19 | out vec4 fragColor;
20 |
21 | float normpdf(in float x, in float sigma)
22 | {
23 | return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;
24 | }
25 |
26 | float normpdf3(in vec3 v, in float sigma)
27 | {
28 | return 0.39894*exp(-0.5*dot(v,v)/(sigma*sigma))/sigma;
29 | }
30 |
31 | void main(void)
32 | {
33 | vec2 uv = vertTexCoord.xy;
34 | vec2 screenuv = vertTexCoord.xy * resolution.xy;
35 | vec3 c = texture(texture, vertTexCoord.xy).rgb;
36 |
37 | //declare stuff
38 | const int kSize = (MSIZE-1)/2;
39 | float kernel[MSIZE];
40 | vec3 final_colour = vec3(0.0);
41 |
42 | //create the 1-D kernel
43 | float Z = 0.0;
44 | for (int j = 0; j <= kSize; ++j)
45 | {
46 | kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), SIGMA);
47 | }
48 |
49 |
50 | vec3 cc;
51 | float factor;
52 | float bZ = 1.0/normpdf(0.0, BSIGMA);
53 | //read out the texels
54 | for (int i=-kSize; i <= kSize; ++i)
55 | {
56 | for (int j=-kSize; j <= kSize; ++j)
57 | {
58 | vec2 iuv = (screenuv + vec2(float(i),float(j)) ) / resolution.xy ;
59 | cc = texture(texture, vec2(0.0, 0.0) + iuv).rgb;
60 | factor = normpdf3(cc-c, BSIGMA)*bZ*kernel[kSize+j]*kernel[kSize+i];
61 | Z += factor;
62 | final_colour += factor*cc;
63 |
64 | }
65 | }
66 |
67 | fragColor = vec4(final_colour/Z, 1.0);
68 | }
--------------------------------------------------------------------------------
/data/shaders/blendadd.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 | #ifdef GL_ES
28 | precision mediump float;
29 | precision mediump int;
30 | #endif
31 |
32 | uniform sampler2D texture;
33 | uniform sampler2D base;
34 | uniform float opacity;
35 | uniform int srci = 0;
36 | uniform int basei = 0;
37 |
38 | in vec4 vertTexCoord;
39 | out vec4 fragColor;
40 |
41 | #define BlendAdd(base, blend) min(base + blend, vec3(1.0))
42 |
43 | void main(){
44 | vec2 uv = vertTexCoord.xy;
45 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
46 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
47 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
48 | vec3 blended = BlendAdd(based, blend);
49 |
50 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
51 | }
--------------------------------------------------------------------------------
/data/shaders/blendaverage.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 | #ifdef GL_ES
28 | precision mediump float;
29 | precision mediump int;
30 | #endif
31 |
32 | uniform sampler2D texture;
33 | uniform sampler2D base;
34 | uniform float opacity;
35 | uniform int srci = 0;
36 | uniform int basei = 0;
37 |
38 | in vec4 vertTexCoord;
39 | out vec4 fragColor;
40 |
41 | #define BlendAverage(base, blend) ((base + blend) / 2.0)
42 |
43 | void main(){
44 | vec2 uv = vertTexCoord.xy;
45 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
46 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
47 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
48 | vec3 blended = BlendAverage(based, blend);
49 |
50 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
51 | }
--------------------------------------------------------------------------------
/data/shaders/blendcolorburn.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 |
40 | in vec4 vertTexCoord;
41 | out vec4 fragColor;
42 |
43 | #define BlendColorBurnf(base, blend) ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0))
44 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
45 | #define BlendColorBurn(base, blend) Blend(base, blend, BlendColorBurnf)
46 |
47 | void main(){
48 | vec2 uv = vertTexCoord.xy;
49 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
50 |
51 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
52 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
53 | vec3 blended = BlendColorBurn(based, blend);
54 |
55 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
56 | }
--------------------------------------------------------------------------------
/data/shaders/blendcolordodge.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 |
40 | in vec4 vertTexCoord;
41 | out vec4 fragColor;
42 |
43 | #define BlendColorDodgef(base, blend) ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0))
44 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
45 | #define BlendColorDodge(base, blend) Blend(base, blend, BlendColorDodgef)
46 |
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
51 |
52 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
53 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
54 | vec3 blended = BlendColorDodge(based, blend);
55 |
56 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
57 | }
--------------------------------------------------------------------------------
/data/shaders/blenddarken.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 | #ifdef GL_ES
28 | precision mediump float;
29 | precision mediump int;
30 | #endif
31 |
32 | uniform sampler2D texture;
33 | uniform sampler2D base;
34 | uniform float opacity;
35 | uniform int srci = 0;
36 | uniform int basei = 0;
37 |
38 | in vec4 vertTexCoord;
39 | out vec4 fragColor;
40 |
41 |
42 | #define BlendDarkenf(base, blend) min(blend, base)
43 | #define BlendDarken BlendDarkenf
44 |
45 | void main(){
46 | vec2 uv = vertTexCoord.xy;
47 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
48 |
49 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
50 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
51 | vec3 blended = BlendDarken(based, blend);
52 |
53 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
54 | }
--------------------------------------------------------------------------------
/data/shaders/blenddifference.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendDifference(base, blend) abs(base - blend)
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
47 |
48 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
49 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
50 | vec3 blended = BlendDifference(based, blend);
51 |
52 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
53 | }
--------------------------------------------------------------------------------
/data/shaders/blendexclusion.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendExclusion(base, blend) (base + blend - 2.0 * base * blend)
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
47 |
48 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
49 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
50 | vec3 blended = BlendExclusion(based, blend);
51 |
52 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
53 | }
--------------------------------------------------------------------------------
/data/shaders/blendglow.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendReflectf(base, blend) ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0))
43 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
44 | #define BlendReflect(base, blend) Blend(base, blend, BlendReflectf)
45 | #define BlendGlow(base, blend) BlendReflect(blend, base)
46 |
47 | void main(){
48 | vec2 uv = vertTexCoord.xy;
49 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
50 |
51 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
52 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
53 | vec3 blended = BlendGlow(based, blend);
54 |
55 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
56 | }
--------------------------------------------------------------------------------
/data/shaders/blendhardlight.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendOverlayf(base, blend) (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
43 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
44 | #define BlendOverlay(base, blend) Blend(base, blend, BlendOverlayf)
45 | #define BlendHardLight(base, blend) BlendOverlay(blend, base)
46 |
47 | void main(){
48 | vec2 uv = vertTexCoord.xy;
49 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
50 |
51 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
52 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
53 | vec3 blended = BlendHardLight(based, blend);
54 |
55 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
56 | }
--------------------------------------------------------------------------------
/data/shaders/blendlighten.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 |
43 | #define BlendLightenf(base, blend) max(blend, base)
44 | #define BlendLighten BlendLightenf
45 |
46 | void main(){
47 | vec2 uv = vertTexCoord.xy;
48 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
49 |
50 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
51 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
52 | vec3 blended = BlendLighten(based, blend);
53 |
54 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
55 | }
--------------------------------------------------------------------------------
/data/shaders/blendlinearburn.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendSubstract(base, blend) max(base + blend - vec3(1.0), vec3(0.0))
43 | #define BlendLinearBurn BlendSubstract
44 |
45 | void main(){
46 | vec2 uv = vertTexCoord.xy;
47 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
48 |
49 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
50 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
51 | vec3 blended = BlendLinearBurn(based, blend);
52 |
53 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
54 | }
--------------------------------------------------------------------------------
/data/shaders/blendlineardodge.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendAdd(base, blend) min(base + blend, vec3(1.0))
43 | #define BlendLinearDodge BlendAdd
44 |
45 | void main(){
46 | vec2 uv = vertTexCoord.xy;
47 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
48 |
49 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
50 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
51 | vec3 blended = BlendLinearDodge(based, blend);
52 |
53 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
54 | }
--------------------------------------------------------------------------------
/data/shaders/blendmultiply.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendMultiply(base, blend) (base * blend)
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
47 |
48 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
49 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
50 | vec3 blended = BlendMultiply(based, blend);
51 |
52 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
53 | }
--------------------------------------------------------------------------------
/data/shaders/blendnegation.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendNegation(base, blend) (vec3(1.0) - abs(vec3(1.0) - base - blend))
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
47 |
48 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
49 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
50 | vec3 blended = BlendNegation(based, blend);
51 |
52 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
53 | }
--------------------------------------------------------------------------------
/data/shaders/blendoverlay.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendOverlayf(base, blend) (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend)))
43 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
44 | #define BlendOverlay(base, blend) Blend(base, blend, BlendOverlayf)
45 |
46 | void main(){
47 | vec2 uv = vertTexCoord.xy;
48 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
49 |
50 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
51 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
52 | vec3 blended = BlendOverlay(based, blend);
53 |
54 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
55 | }
--------------------------------------------------------------------------------
/data/shaders/blendphoenix.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 |
43 | #define BlendPhoenix(base, blend) (min(base, blend) - max(base, blend) + vec3(1.0))
44 |
45 | void main(){
46 | vec2 uv = vertTexCoord.xy;
47 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
48 |
49 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
50 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
51 | vec3 blended = BlendPhoenix(based, blend);
52 |
53 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
54 | }
--------------------------------------------------------------------------------
/data/shaders/blendreflect.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendReflectf(base, blend) ((blend == 1.0) ? blend : min(base * base / (1.0 - blend), 1.0))
43 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
44 | #define BlendReflect(base, blend) Blend(base, blend, BlendReflectf)
45 |
46 | void main(){
47 | vec2 uv = vertTexCoord.xy;
48 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
49 |
50 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
51 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
52 | vec3 blended = BlendReflect(based, blend);
53 |
54 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
55 | }
--------------------------------------------------------------------------------
/data/shaders/blendscreen.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendScreenf(base, blend) (1.0 - ((1.0 - base) * (1.0 - blend)))
43 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
44 | #define BlendScreen(base, blend) Blend(base, blend, BlendScreenf)
45 |
46 |
47 | void main(){
48 | vec2 uv = vertTexCoord.xy;
49 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
50 |
51 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
52 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
53 | vec3 blended = BlendScreen(based, blend);
54 |
55 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
56 | }
--------------------------------------------------------------------------------
/data/shaders/blendsoftlight.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendSoftLightf(base, blend) ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend)))
43 | #define Blend(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b))
44 | #define BlendSoftLight(base, blend) Blend(base, blend, BlendSoftLightf)
45 |
46 | void main(){
47 | vec2 uv = vertTexCoord.xy;
48 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
49 |
50 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
51 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
52 | vec3 blended = BlendSoftLight(based, blend);
53 |
54 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
55 | }
--------------------------------------------------------------------------------
/data/shaders/blendsubstract.glsl:
--------------------------------------------------------------------------------
1 | /*
2 | ** Copyright (c) 2012, Romain Dura romain@shazbits.com
3 | **
4 | ** Permission to use, copy, modify, and/or distribute this software for any
5 | ** purpose with or without fee is hereby granted, provided that the above
6 | ** copyright notice and this permission notice appear in all copies.
7 | **
8 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 | ** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 | ** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 | ** SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 | ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 | ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14 | ** IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 | */
16 |
17 | /*
18 | ** Photoshop & misc math
19 | ** Blending modes, RGB/HSL/Contrast/Desaturate, levels control
20 | **
21 | ** Romain Dura | Romz
22 | ** Blog: http://mouaif.wordpress.com
23 | ** Post: http://mouaif.wordpress.com/?p=94
24 | ** Update : Bonjour Lab
25 | */
26 |
27 |
28 | #ifdef GL_ES
29 | precision mediump float;
30 | precision mediump int;
31 | #endif
32 |
33 | uniform sampler2D texture;
34 | uniform sampler2D base;
35 | uniform float opacity;
36 | uniform int srci = 0;
37 | uniform int basei = 0;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | #define BlendSubstract(base, blend) max(base + blend - vec3(1.0), vec3(0.0))
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
47 |
48 | vec3 based = texture(base , uv * (1 - srci) + iuv * srci ).rgb;
49 | vec3 blend = texture(texture , uv * (1 - basei) + iuv * basei).rgb;
50 | vec3 blended = BlendSubstract(based, blend);
51 |
52 | fragColor = mix(vec4(based, 1.0), vec4(blended, 1.0), opacity);
53 | }
--------------------------------------------------------------------------------
/data/shaders/cannyedge2.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | //based on https://www.objc.io/issues/21-camera-and-photos/gpu-accelerated-machine-vision/
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform float lowerThreshold = 0.8;
10 |
11 | in vec4 vertTexCoord;
12 | out vec4 fragColor;
13 |
14 |
15 | void main(){
16 | vec2 uv = vertTexCoord.xy;
17 | vec4 tex = texture(texture, uv);
18 | vec2 uvinc = vec2(1.0) / resolution.xy;
19 |
20 | vec3 curGradientDir = texture(texture, uv).rgb;
21 | vec2 gradientDirection = ((curGradientDir.gb * 2.0) - 1.0) * uvinc;
22 |
23 | float firstSampledGradientMagnitude = texture(texture, uv + gradientDirection).r;
24 | float secondSampledGradientMagnitude = texture(texture, uv - gradientDirection).r;
25 |
26 | float multiplier = step(firstSampledGradientMagnitude, curGradientDir.r);
27 | multiplier = multiplier * step(secondSampledGradientMagnitude, curGradientDir.r);
28 |
29 | float thresholdCompliance = smoothstep(lowerThreshold, lowerThreshold + 0.01, curGradientDir.r);
30 | multiplier = multiplier * thresholdCompliance;
31 |
32 | fragColor = vec4(vec3(multiplier), 1.0);
33 | }
--------------------------------------------------------------------------------
/data/shaders/chromakey.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 | #define PI 3.14159265359
6 | uniform sampler2D texture;
7 | uniform float threshold = 0.5;
8 | uniform float curveThreshold = 0.5;
9 | uniform vec3 keyColor;
10 |
11 | in vec4 vertTexCoord;
12 | out vec4 fragColor;
13 |
14 | vec3 rgb2hsv(vec3 rgb)
15 | {
16 | float Cmax = max(rgb.r, max(rgb.g, rgb.b));
17 | float Cmin = min(rgb.r, min(rgb.g, rgb.b));
18 | float delta = Cmax - Cmin;
19 |
20 | vec3 hsv = vec3(0., 0., Cmax);
21 |
22 | if (Cmax > Cmin)
23 | {
24 | hsv.y = delta / Cmax;
25 |
26 | if (rgb.r == Cmax)
27 | hsv.x = (rgb.g - rgb.b) / delta;
28 | else
29 | {
30 | if (rgb.g == Cmax)
31 | hsv.x = 2. + (rgb.b - rgb.r) / delta;
32 | else
33 | hsv.x = 4. + (rgb.r - rgb.g) / delta;
34 | }
35 | hsv.x = fract(hsv.x / 6.);
36 | }
37 | return hsv;
38 | }
39 |
40 | float chromaKey(vec3 color, vec3 keycolor)
41 | {
42 | vec3 weights = vec3(4.f, 1.f, 2.f);
43 |
44 | vec3 src = rgb2hsv(color);
45 | vec3 key = rgb2hsv(keycolor);
46 |
47 | return length(weights * (key - src));
48 | }
49 |
50 | vec3 changeSaturation(vec3 color, float saturation)
51 | {
52 | float luma = dot(vec3(0.213, 0.715, 0.072) * color, vec3(1.));
53 | return mix(vec3(luma), color, saturation);
54 | }
55 |
56 | void main(){
57 | vec2 uv = vertTexCoord.xy;
58 |
59 | vec3 tex = texture(texture, uv).rgb;
60 | float ckey = smoothstep(0.0, 1.0, chromaKey(tex, keyColor));
61 | float inc = smoothstep(threshold, 1.0, ckey);
62 | /*
63 | float curveinc1 = 1.0 - pow(cos(PI * inc / 2.0), curveThreshold);
64 | float curveinc2 = pow(abs(inc), curveThreshold);
65 | float curveinc3 = pow(abs(sin(PI * inc / 2.0)), curveThreshold);
66 | float curveinc4 = 1.0 - pow(min(cos(PI * inc / 2.0), 1.0 - abs(inc)), curveThreshold);
67 | */
68 | vec4 finalColor= mix(vec4(0.0), vec4(tex, 1.0), inc);
69 |
70 | fragColor = finalColor;
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/data/shaders/chromakey2.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 | #define PI 3.14159265359
6 | uniform sampler2D texture;
7 | uniform sampler2D base;
8 | uniform float threshold = 0.5;
9 | uniform float curveThreshold = 0.5;
10 | uniform vec3 keyColor;
11 | uniform int srci = 0;
12 | uniform int basei = 0;
13 |
14 | in vec4 vertTexCoord;
15 | out vec4 fragColor;
16 |
17 | vec3 rgb2hsv(vec3 rgb)
18 | {
19 | float Cmax = max(rgb.r, max(rgb.g, rgb.b));
20 | float Cmin = min(rgb.r, min(rgb.g, rgb.b));
21 | float delta = Cmax - Cmin;
22 |
23 | vec3 hsv = vec3(0., 0., Cmax);
24 |
25 | if (Cmax > Cmin)
26 | {
27 | hsv.y = delta / Cmax;
28 |
29 | if (rgb.r == Cmax)
30 | hsv.x = (rgb.g - rgb.b) / delta;
31 | else
32 | {
33 | if (rgb.g == Cmax)
34 | hsv.x = 2. + (rgb.b - rgb.r) / delta;
35 | else
36 | hsv.x = 4. + (rgb.r - rgb.g) / delta;
37 | }
38 | hsv.x = fract(hsv.x / 6.);
39 | }
40 | return hsv;
41 | }
42 |
43 | float chromaKey(vec3 color, vec3 keycolor)
44 | {
45 | vec3 weights = vec3(4.f, 1.f, 2.f);
46 |
47 | vec3 src = rgb2hsv(color);
48 | vec3 key = rgb2hsv(keycolor);
49 |
50 | return length(weights * (key - src));
51 | }
52 |
53 | vec3 changeSaturation(vec3 color, float saturation)
54 | {
55 | float luma = dot(vec3(0.213, 0.715, 0.072) * color, vec3(1.));
56 | return mix(vec3(luma), color, saturation);
57 | }
58 |
59 | void main(){
60 | vec2 uv = vertTexCoord.xy;
61 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
62 |
63 | vec3 tex = texture(texture, uv * (1 - basei) + iuv * basei).rgb;
64 | vec3 texBase = texture(base, uv * (1 - srci) + iuv * srci).rgb;
65 | float ckey = smoothstep(0.0, 1.0, chromaKey(tex, keyColor));
66 | float inc = smoothstep(threshold, 1.0, ckey);
67 | /*
68 | float curveinc1 = 1.0 - pow(cos(PI * inc / 2.0), curveThreshold);
69 | float curveinc2 = pow(abs(inc), curveThreshold);
70 | float curveinc3 = pow(abs(sin(PI * inc / 2.0)), curveThreshold);
71 | float curveinc4 = 1.0 - pow(min(cos(PI * inc / 2.0), 1.0 - abs(inc)), curveThreshold);
72 | */
73 | vec4 finalColor= mix(vec4(texBase, 1.0), vec4(tex, 1.0), inc);
74 |
75 | fragColor = finalColor;
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/data/shaders/chromawarp.glsl:
--------------------------------------------------------------------------------
1 |
2 | #ifdef GL_ES
3 | precision mediump float;
4 | precision mediump int;
5 | #endif
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 | uniform int octave = 4;
12 | uniform float angle = 3.14159265359 / 200.0;
13 |
14 | in vec4 vertTexCoord;
15 | out vec4 fragColor;
16 |
17 |
18 | mat2 rotate2d(float _angle){
19 | return mat2(cos(_angle),-sin(_angle),
20 | sin(_angle),cos(_angle));
21 | }
22 |
23 | vec4 radialBlur(int octave, vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin, float angle)
24 | {
25 | vec4 focus = texture2D(texture, blurOrigin);
26 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
27 |
28 | float distToCenter = length(uv - blurOrigin);
29 |
30 | uv += texelSize * 0.5 - blurOrigin;
31 |
32 | for (int i = 0; i < octave; i++)
33 | {
34 | float scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1));
35 | vec2 uvRed = rotate2d( angle * distToCenter) * uv;
36 | vec2 uvGreen = uv;
37 | vec2 uvRBlue = rotate2d(-angle * distToCenter) * uv;
38 | blur += vec4( texture(texture, uvRed * scale + blurOrigin).r,
39 | texture(texture, uvGreen * scale + blurOrigin).g,
40 | texture(texture, uvRBlue * scale + blurOrigin).b,
41 | 1.0);
42 | }
43 |
44 | return blur / float(octave);
45 | }
46 |
47 | void main(){
48 | vec2 texelSize = vec2(1.0)/resolution;
49 | vec4 rd = radialBlur(octave, vertTexCoord.xy, texelSize, blurSize, blurOrigin, angle);
50 | fragColor = rd;
51 | }
--------------------------------------------------------------------------------
/data/shaders/chromawarphigh.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 | uniform float angle = 3.14159265359 / 200.0;
12 |
13 | in vec4 vertTexCoord;
14 | out vec4 fragColor;
15 |
16 | #define scale(i) scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1))
17 | #define uvr() uvred = rotate2d( angle * distToCenter) * uv
18 | #define uvg() uvgreen = uv
19 | #define uvb() uvblue = rotate2d(-angle * distToCenter) * uv
20 | #define blur(i) scale(i); uvr(); uvg(); uvb(); blur += vec4(texture(texture, uvred * scale + blurOrigin).r, texture(texture, uvgreen * scale + blurOrigin).g, texture(texture, uvblue * scale + blurOrigin).b, 1.0)
21 |
22 | mat2 rotate2d(float _angle){
23 | return mat2(cos(_angle),-sin(_angle),
24 | sin(_angle),cos(_angle));
25 | }
26 |
27 | vec4 radialBlur(vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin, float angle)
28 | {
29 | vec4 focus = texture(texture, blurOrigin);
30 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
31 | float scale;
32 | vec2 uvred;
33 | vec2 uvgreen;
34 | vec2 uvblue;
35 | int octave = 20;
36 |
37 | float distToCenter = length(uv - blurOrigin);
38 |
39 | uv += texelSize * 0.5 - blurOrigin;
40 |
41 | blur(1);
42 | blur(2);
43 | blur(3);
44 | blur(4);
45 | blur(5);
46 | blur(6);
47 | blur(7);
48 | blur(8);
49 | blur(9);
50 | blur(10);
51 | blur(11);
52 | blur(12);
53 | blur(13);
54 | blur(14);
55 | blur(15);
56 | blur(16);
57 | blur(17);
58 | blur(18);
59 | blur(19);
60 | blur(20);
61 |
62 | return blur / 20;
63 | }
64 |
65 | void main(){
66 | vec2 texelSize = vec2(1.0)/resolution;
67 | vec4 rd = radialBlur(vertTexCoord.xy, texelSize, blurSize, blurOrigin, angle);
68 | fragColor = rd;
69 | }
--------------------------------------------------------------------------------
/data/shaders/chromawarplow.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 | uniform float angle = 3.14159265359 / 200.0;
12 |
13 | in vec4 vertTexCoord;
14 | out vec4 fragColor;
15 |
16 | #define scale(i) scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1))
17 | #define uvr() uvred = rotate2d( angle * distToCenter) * uv
18 | #define uvg() uvgreen = uv
19 | #define uvb() uvblue = rotate2d(-angle * distToCenter) * uv
20 | #define blur(i) scale(i); uvr(); uvg(); uvb(); blur += vec4(texture(texture, uvred * scale + blurOrigin).r, texture(texture, uvgreen * scale + blurOrigin).g, texture(texture, uvblue * scale + blurOrigin).b, 1.0)
21 |
22 | mat2 rotate2d(float _angle){
23 | return mat2(cos(_angle),-sin(_angle),
24 | sin(_angle),cos(_angle));
25 | }
26 |
27 | vec4 radialBlur(vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin, float angle)
28 | {
29 | vec4 focus = texture(texture, blurOrigin);
30 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
31 | float scale;
32 | vec2 uvred;
33 | vec2 uvgreen;
34 | vec2 uvblue;
35 | int octave = 4;
36 |
37 | float distToCenter = length(uv - blurOrigin);
38 |
39 | uv += texelSize * 0.5 - blurOrigin;
40 |
41 | blur(1);
42 | blur(2);
43 | blur(3);
44 | blur(4);
45 |
46 | return blur / octave;
47 | }
48 |
49 | void main(){
50 | vec2 texelSize = vec2(1.0)/resolution;
51 | vec4 rd = radialBlur(vertTexCoord.xy, texelSize, blurSize, blurOrigin, angle);
52 | fragColor = rd;
53 | }
--------------------------------------------------------------------------------
/data/shaders/chromawarpmedium.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 | uniform float angle = 3.14159265359 / 200.0;
12 |
13 | in vec4 vertTexCoord;
14 | out vec4 fragColor;
15 |
16 | #define scale(i) scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1))
17 | #define uvr() uvred = rotate2d( angle * distToCenter) * uv
18 | #define uvg() uvgreen = uv
19 | #define uvb() uvblue = rotate2d(-angle * distToCenter) * uv
20 | #define blur(i) scale(i); uvr(); uvg(); uvb(); blur += vec4(texture(texture, uvred * scale + blurOrigin).r, texture(texture, uvgreen * scale + blurOrigin).g, texture(texture, uvblue * scale + blurOrigin).b, 1.0)
21 |
22 | mat2 rotate2d(float _angle){
23 | return mat2(cos(_angle),-sin(_angle),
24 | sin(_angle),cos(_angle));
25 | }
26 |
27 | vec4 radialBlur(vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin, float angle)
28 | {
29 | vec4 focus = texture(texture, blurOrigin);
30 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
31 | float scale;
32 | vec2 uvred;
33 | vec2 uvgreen;
34 | vec2 uvblue;
35 | int octave = 10;
36 |
37 | float distToCenter = length(uv - blurOrigin);
38 |
39 | uv += texelSize * 0.5 - blurOrigin;
40 |
41 | blur(1);
42 | blur(2);
43 | blur(3);
44 | blur(4);
45 | blur(5);
46 | blur(6);
47 | blur(7);
48 | blur(8);
49 | blur(9);
50 | blur(10);
51 |
52 | return blur / octave;
53 | }
54 |
55 | void main(){
56 | vec2 texelSize = vec2(1.0)/resolution;
57 | vec4 rd = radialBlur(vertTexCoord.xy, texelSize, blurSize, blurOrigin, angle);
58 | fragColor = rd;
59 | }
--------------------------------------------------------------------------------
/data/shaders/colorthreshold.glsl:
--------------------------------------------------------------------------------
1 |
2 | #ifdef GL_ES
3 | precision mediump float;
4 | precision mediump int;
5 | #endif
6 |
7 | uniform sampler2D texture;
8 | uniform float levelRed = 0.0;
9 | uniform float levelGreen = 0.0;
10 | uniform float levelBlue = 0.0;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 | //based on the tutorial : https://learnopengl.com/#!Advanced-Lighting/Bloom
16 | vec4 getBright(vec3 color_, vec3 threshold_){
17 | vec3 inc = step(threshold_, color_);
18 | return vec4(color_ * inc, 1.0);
19 | }
20 |
21 | void main(){
22 | vec2 uv = vertTexCoord.xy;
23 | vec4 tex = texture(texture, uv);
24 | vec4 threshold = getBright(tex.rgb, vec3(levelRed, levelGreen, levelBlue));
25 |
26 | fragColor = threshold;
27 | }
--------------------------------------------------------------------------------
/data/shaders/constrastsaturationbrightness.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform float brightness = 1.0;
8 | uniform float contrast = 1.0;
9 | uniform float saturation = 1.0;
10 |
11 | in vec4 vertTexCoord;
12 | out vec4 fragColor;
13 |
14 | /*
15 | ** Contrast, saturation, brightness
16 | ** Code of this function is from TGM's shader pack
17 | ** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
18 | */
19 |
20 | // For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
21 | vec3 contrastSaturationBrightness(vec3 color, float brt, float sat, float con)
22 | {
23 | // Increase or decrease theese values to adjust r, g and b color channels seperately
24 | const float AvgLumR = 0.5;
25 | const float AvgLumG = 0.5;
26 | const float AvgLumB = 0.5;
27 |
28 | const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
29 |
30 | vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
31 | vec3 brtColor = color * brt;
32 | vec3 intensity = vec3(dot(brtColor, LumCoeff));
33 | vec3 satColor = mix(intensity, brtColor, sat);
34 | vec3 conColor = mix(AvgLumin, satColor, con);
35 | return conColor;
36 | }
37 |
38 |
39 | void main()
40 | {
41 | vec2 uv = vertTexCoord.xy;
42 | vec4 tex = texture(texture, uv);
43 |
44 | tex.rgb = contrastSaturationBrightness(tex.rgb, brightness, saturation, contrast);
45 |
46 | fragColor = tex;
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/data/shaders/denoise.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | /**
8 | * Simple denoise algorithm based average neigbors and weight.
9 | */
10 | #define EXP 0.5
11 |
12 | uniform sampler2D texture;
13 | uniform vec2 resolution;
14 |
15 | in vec4 vertTexCoord;
16 |
17 | out vec4 fragColor;
18 |
19 | vec4 addAverageNeighbors(sampler2D texture, vec2 uv, vec2 ij, vec2 resolution, vec4 center){
20 | vec4 samplePix = texture(texture, uv + ij / resolution);
21 | //float weight = abs(1.0 - (ij.x + ij.y) * 0.25);
22 | float weight = 1.0 - abs(dot(samplePix.rgb - center.rgb, vec3(0.25)));
23 | weight = pow(weight, EXP);
24 | return vec4(samplePix.rgb * weight, weight);
25 | }
26 |
27 | void main() {
28 | vec2 uv = vertTexCoord.xy;
29 | vec4 center = texture(texture, uv);
30 | vec4 color = vec4(0.0);
31 |
32 | color += addAverageNeighbors(texture, uv, vec2(-1, -1), resolution, center);
33 | color += addAverageNeighbors(texture, uv, vec2( 0, -1), resolution, center);
34 | color += addAverageNeighbors(texture, uv, vec2( 1, -1), resolution, center);
35 |
36 | color += addAverageNeighbors(texture, uv, vec2(-1, 0), resolution, center);
37 | color += addAverageNeighbors(texture, uv, vec2( 0, 0), resolution, center);
38 | color += addAverageNeighbors(texture, uv, vec2( 1, 0), resolution, center);
39 |
40 | color += addAverageNeighbors(texture, uv, vec2(-1, 1), resolution, center);
41 | color += addAverageNeighbors(texture, uv, vec2( 0, 1), resolution, center);
42 | color += addAverageNeighbors(texture, uv, vec2( 1, 1), resolution, center);
43 |
44 | fragColor = vec4(color.rgb / color.a, 1.0);
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/data/shaders/desaturate.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform float desaturation = 1.0;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 | vec4 Desaturate(vec3 color, float value)
13 | {
14 | vec3 grayXfer = vec3(0.3, 0.59, 0.11);
15 | vec3 gray = vec3(dot(grayXfer, color));
16 | return vec4(mix(color, gray, value), 1.0);
17 | }
18 |
19 | void main(){
20 | vec2 uv = vertTexCoord.xy;
21 | vec3 tex = texture(texture, uv).rgb;
22 |
23 | fragColor = Desaturate(tex, desaturation);
24 | }
--------------------------------------------------------------------------------
/data/shaders/dilation.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 |
13 | void main(){
14 | vec2 uv = vertTexCoord.xy;
15 | vec2 texelSize = vec2(1.0) / resolution;
16 |
17 | //define neighbors
18 | float CC = texture(texture, uv).r;
19 | float CT = texture(texture, uv + vec2( 0.0, -1.0) * texelSize).r;
20 | float RT = texture(texture, uv + vec2( 1.0, -1.0) * texelSize).r;
21 | float RC = texture(texture, uv + vec2( 1.0, 0.0) * texelSize).r;
22 | float RB = texture(texture, uv + vec2( 1.0, 1.0) * texelSize).r;
23 | float CB = texture(texture, uv + vec2( 0.0, 1.0) * texelSize).r;
24 | float LB = texture(texture, uv + vec2(-1.0, 1.0) * texelSize).r;
25 | float LC = texture(texture, uv + vec2(-1.0, 0.0) * texelSize).r;
26 | float LT = texture(texture, uv + vec2(-1.0, -1.0) * texelSize).r;
27 |
28 | //compare value
29 | float val = max(CC, CT);
30 | val = max(val, RT);
31 | val = max(val, RC);
32 | val = max(val, RB);
33 | val = max(val, CB);
34 | val = max(val, LB);
35 | val = max(val, LC);
36 | val = max(val, LT);
37 |
38 | fragColor = vec4(vec3(val), 1.0);
39 | }
--------------------------------------------------------------------------------
/data/shaders/dilationrgb.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 |
13 | void main(){
14 | vec2 uv = vertTexCoord.xy;
15 | vec2 texelSize = vec2(1.0) / resolution;
16 |
17 | //define neighbors
18 | vec3 CC = texture(texture, uv).rgb;
19 | vec3 CT = texture(texture, uv + vec2( 0.0, -1.0) * texelSize).rgb;
20 | vec3 RT = texture(texture, uv + vec2( 1.0, -1.0) * texelSize).rgb;
21 | vec3 RC = texture(texture, uv + vec2( 1.0, 0.0) * texelSize).rgb;
22 | vec3 RB = texture(texture, uv + vec2( 1.0, 1.0) * texelSize).rgb;
23 | vec3 CB = texture(texture, uv + vec2( 0.0, 1.0) * texelSize).rgb;
24 | vec3 LB = texture(texture, uv + vec2(-1.0, 1.0) * texelSize).rgb;
25 | vec3 LC = texture(texture, uv + vec2(-1.0, 0.0) * texelSize).rgb;
26 | vec3 LT = texture(texture, uv + vec2(-1.0, -1.0) * texelSize).rgb;
27 |
28 | //compare value
29 | vec3 val = max(CC, CT);
30 | val = max(val, RT);
31 | val = max(val, RC);
32 | val = max(val, RB);
33 | val = max(val, CB);
34 | val = max(val, LB);
35 | val = max(val, LC);
36 | val = max(val, LT);
37 |
38 | fragColor = vec4(val, 1.0);
39 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringNonRectangular5x5.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 |
16 |
17 | const int nonRectangular5x5[25] = int[]( 3, 0, 1, 2, 4,
18 | 1, 2, 4, 3, 0,
19 | 4, 3, 0, 1, 2,
20 | 0, 1, 2, 4, 3,
21 | 2, 4, 3, 0, 1);
22 |
23 |
24 | uniform sampler2D texture;
25 | uniform vec2 resolution;
26 | uniform float theta;
27 |
28 | in vec4 vertTexCoord;
29 | out vec4 fragColor;
30 |
31 | mat2 rotate2D(float angle){
32 | return mat2( cos(angle), -sin(angle),
33 | sin(angle), cos(angle));
34 | }
35 |
36 | float getLuma(vec3 color_){
37 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
38 | }
39 |
40 | float index(vec2 screenpos){
41 | int x = int(mod(screenpos.x, 5));
42 | int y = int(mod(screenpos.y, 5));
43 | return (1.0 + nonRectangular5x5[(x + y * 5)]) / (4.0 + 1.0);
44 | }
45 |
46 | float dither(vec2 screenpos, float lum){
47 | float d = index(screenpos);
48 | return step(d, lum);
49 | }
50 |
51 |
52 | void main(){
53 | vec2 uv = vertTexCoord.xy;
54 |
55 | vec4 tex = texture(texture, uv);
56 |
57 | //rotate uv
58 | uv -= vec2(0.5, 0.5);
59 | uv = rotate2D(theta) * uv;
60 | uv += vec2(0.5, 0.5);
61 | float luma = getLuma(tex.rgb);
62 | float value = dither(uv * resolution, luma);
63 |
64 | fragColor = vec4(vec3(value), 1.0);
65 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringNonRectangular8x8.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 |
16 | #define PI 3.14159265359
17 |
18 | const int nonRectangular8x7[56] = int[](1, 6, 0, 5, 3, 4, 2, 7,
19 | 4, 2, 7, 1, 6, 0, 5, 3,
20 | 0, 5, 3, 4, 2, 7, 1, 6,
21 | 7, 1, 6, 0, 5, 3, 4, 2,
22 | 3, 4, 2, 7, 1, 6, 0, 5,
23 | 6, 0, 5, 3, 4, 2, 7, 1,
24 | 2, 7, 1, 6, 0, 5, 3, 4);
25 |
26 |
27 | uniform sampler2D texture;
28 | uniform vec2 resolution;
29 | uniform float theta;
30 |
31 | in vec4 vertTexCoord;
32 | out vec4 fragColor;
33 |
34 | mat2 rotate2D(float angle){
35 | return mat2( cos(angle), -sin(angle),
36 | sin(angle), cos(angle));
37 | }
38 |
39 | float getLuma(vec3 color_){
40 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
41 | }
42 |
43 | float index(vec2 screenpos){
44 | int x = int(mod(screenpos.x, 8));
45 | int y = int(mod(screenpos.y, 7));
46 | return (1.0 + nonRectangular8x7[(x + y * 8)]) / (8.0);
47 | }
48 |
49 | float dither(vec2 screenpos, float lum){
50 | float d = index(screenpos);
51 | return step(d, lum);
52 | }
53 |
54 |
55 | void main(){
56 | vec2 uv = vertTexCoord.xy;
57 |
58 | vec4 tex = texture(texture, uv);
59 |
60 | //rotate uv
61 | uv -= vec2(0.5, 0.5);
62 | uv = rotate2D(theta) * uv;
63 | uv += vec2(0.5, 0.5);
64 |
65 | float luma = getLuma(tex.rgb);
66 | float value = dither(uv * resolution * 1.0, luma);
67 |
68 | fragColor = vec4(vec3(value), 1.0);
69 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer2x2.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer2x2[4] = int[](0, 2,
16 | 3, 1);
17 |
18 |
19 | uniform sampler2D texture;
20 | uniform vec2 resolution;
21 | uniform float theta;
22 |
23 | in vec4 vertTexCoord;
24 | out vec4 fragColor;
25 |
26 | mat2 rotate2D(float angle){
27 | return mat2( cos(angle), -sin(angle),
28 | sin(angle), cos(angle));
29 | }
30 |
31 | float getLuma(vec3 color_){
32 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
33 | }
34 |
35 | float index(vec2 screenpos){
36 | int x = int(mod(screenpos.x, 2));
37 | int y = int(mod(screenpos.y, 2));
38 | return (1.0 + bayer2x2[(x + y * 2)]) / (4.0 + 1.0);
39 | }
40 |
41 | float dither(vec2 screenpos, float lum){
42 | float d = index(screenpos);
43 | return step(d, lum);
44 | }
45 |
46 | void main(){
47 | vec2 uv = vertTexCoord.xy;
48 | vec4 tex = texture(texture, uv);
49 |
50 | //rotate uv
51 | uv -= vec2(0.5, 0.5);
52 | uv = rotate2D(theta) * uv;
53 | uv += vec2(0.5, 0.5);
54 |
55 | float luma = getLuma(tex.rgb);
56 | float value = dither(uv * resolution, luma);
57 |
58 | fragColor = vec4(vec3(value), 1.0);
59 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer2x2rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer2x2[4] = int[](0, 2,
16 | 3, 1);
17 |
18 |
19 | uniform sampler2D texture;
20 | uniform vec2 resolution;
21 | uniform float theta;
22 |
23 | in vec4 vertTexCoord;
24 | out vec4 fragColor;
25 |
26 | mat2 rotate2D(float angle){
27 | return mat2( cos(angle), -sin(angle),
28 | sin(angle), cos(angle));
29 | }
30 |
31 | float index(vec2 screenpos){
32 | int x = int(mod(screenpos.x, 2));
33 | int y = int(mod(screenpos.y, 2));
34 | return (1.0 + bayer2x2[(x + y * 2)]) / (4.0 + 1.0);
35 | }
36 |
37 | float dither(vec2 screenpos, float lum){
38 | float d = index(screenpos);
39 | return step(d, lum);
40 | }
41 |
42 | void main(){
43 | vec2 uv = vertTexCoord.xy;
44 | vec4 tex = texture(texture, uv);
45 |
46 | //rotate uv
47 | uv -= vec2(0.5, 0.5);
48 | uv = rotate2D(theta) * uv;
49 | uv += vec2(0.5, 0.5);
50 |
51 | float r = dither(uv * resolution, tex.r);
52 | float g = dither(uv * resolution, tex.g);
53 | float b = dither(uv * resolution, tex.b);
54 |
55 | fragColor = vec4(r, g, b, 1.0);
56 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer3x3.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer3x3[9] = int[](0, 7, 3,
16 | 6, 5, 2,
17 | 4, 1, 8);
18 |
19 |
20 | uniform sampler2D texture;
21 | uniform vec2 resolution;
22 | uniform float theta;
23 |
24 | in vec4 vertTexCoord;
25 | out vec4 fragColor;
26 |
27 | mat2 rotate2D(float angle){
28 | return mat2( cos(angle), -sin(angle),
29 | sin(angle), cos(angle));
30 | }
31 |
32 | float getLuma(vec3 color_){
33 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
34 | }
35 |
36 | float index(vec2 screenpos){
37 | int x = int(mod(screenpos.x, 3));
38 | int y = int(mod(screenpos.y, 3));
39 | return (1.0 + bayer3x3[(x + y * 3)]) / (9.0 + 1.0);
40 | }
41 |
42 | float dither(vec2 screenpos, float lum){
43 | float d = index(screenpos);
44 | return step(d, lum);
45 | }
46 |
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 | vec4 tex = texture(texture, uv);
51 |
52 |
53 | //rotate uv
54 | uv -= vec2(0.5, 0.5);
55 | uv = rotate2D(theta) * uv;
56 | uv += vec2(0.5, 0.5);
57 |
58 |
59 | float luma = getLuma(tex.rgb);
60 | float value = dither(uv * resolution, luma);
61 |
62 | fragColor = vec4(vec3(value), 1.0);
63 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer3x3rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer3x3[9] = int[](0, 7, 3,
16 | 6, 5, 2,
17 | 4, 1, 8);
18 |
19 |
20 | uniform sampler2D texture;
21 | uniform vec2 resolution;
22 | uniform float theta;
23 |
24 | in vec4 vertTexCoord;
25 | out vec4 fragColor;
26 |
27 | mat2 rotate2D(float angle){
28 | return mat2( cos(angle), -sin(angle),
29 | sin(angle), cos(angle));
30 | }
31 |
32 |
33 | float index(vec2 screenpos){
34 | int x = int(mod(screenpos.x, 3));
35 | int y = int(mod(screenpos.y, 3));
36 | return (1.0 + bayer3x3[(x + y * 3)]) / (9.0 + 1.0);
37 | }
38 |
39 | float dither(vec2 screenpos, float lum){
40 | float d = index(screenpos);
41 | return step(d, lum);
42 | }
43 |
44 |
45 | void main(){
46 | vec2 uv = vertTexCoord.xy;
47 | vec4 tex = texture(texture, uv);
48 |
49 | //rotate uv
50 | uv -= vec2(0.5, 0.5);
51 | uv = rotate2D(theta) * uv;
52 | uv += vec2(0.5, 0.5);
53 |
54 | float r = dither(uv * resolution, tex.r);
55 | float g = dither(uv * resolution, tex.g);
56 | float b = dither(uv * resolution, tex.b);
57 |
58 | fragColor = vec4(r, g, b, 1.0);
59 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer4x4.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer4x4[16] = int[](0, 8, 2, 10,
16 | 12, 4, 14, 6,
17 | 3, 11, 1, 9,
18 | 15, 7, 13, 5);
19 |
20 |
21 | uniform sampler2D texture;
22 | uniform vec2 resolution;
23 | uniform float theta;
24 |
25 | in vec4 vertTexCoord;
26 | out vec4 fragColor;
27 |
28 | mat2 rotate2D(float angle){
29 | return mat2( cos(angle), -sin(angle),
30 | sin(angle), cos(angle));
31 | }
32 |
33 | float getLuma(vec3 color_){
34 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
35 | }
36 |
37 | float index(vec2 screenpos){
38 | int x = int(mod(screenpos.x, 4));
39 | int y = int(mod(screenpos.y, 4));
40 | return (1.0 + bayer4x4[(x + y * 4)]) / (16.0 + 1.0);
41 | }
42 |
43 | float dither(vec2 screenpos, float lum){
44 | float d = index(screenpos);
45 | return step(d, lum);
46 | }
47 |
48 |
49 | void main(){
50 | vec2 uv = vertTexCoord.xy;
51 | vec4 tex = texture(texture, uv);
52 |
53 | //rotate uv
54 | uv -= vec2(0.5, 0.5);
55 | uv = rotate2D(theta) * uv;
56 | uv += vec2(0.5, 0.5);
57 |
58 | float luma = getLuma(tex.rgb);
59 | float value = dither(uv * resolution, luma);
60 |
61 | fragColor = vec4(vec3(value), 1.0);
62 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer4x4rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer4x4[16] = int[](0, 8, 2, 10,
16 | 12, 4, 14, 6,
17 | 3, 11, 1, 9,
18 | 15, 7, 13, 5);
19 |
20 |
21 | uniform sampler2D texture;
22 | uniform vec2 resolution;
23 | uniform float theta;
24 |
25 | in vec4 vertTexCoord;
26 | out vec4 fragColor;
27 |
28 | mat2 rotate2D(float angle){
29 | return mat2( cos(angle), -sin(angle),
30 | sin(angle), cos(angle));
31 | }
32 |
33 | float index(vec2 screenpos){
34 | int x = int(mod(screenpos.x, 4));
35 | int y = int(mod(screenpos.y, 4));
36 | return (1.0 + bayer4x4[(x + y * 4)]) / (16.0 + 1.0);
37 | }
38 |
39 | float dither(vec2 screenpos, float lum){
40 | float d = index(screenpos);
41 | return step(d, lum);
42 | }
43 |
44 |
45 | void main(){
46 | vec2 uv = vertTexCoord.xy;
47 | vec4 tex = texture(texture, uv);
48 |
49 | //rotate uv
50 | uv -= vec2(0.5, 0.5);
51 | uv = rotate2D(theta) * uv;
52 | uv += vec2(0.5, 0.5);
53 |
54 | float r = dither(uv * resolution, tex.r);
55 | float g = dither(uv * resolution, tex.g);
56 | float b = dither(uv * resolution, tex.b);
57 |
58 | fragColor = vec4(r, g, b, 1.0);
59 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer8x8.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer8x8[64] = int[](0, 32, 8, 40, 2, 34, 10, 42,
16 | 48, 16, 56, 24, 50, 18, 58, 26,
17 | 12, 44, 4, 36, 14, 46, 6, 38,
18 | 60, 28, 52, 20, 62, 30, 54, 22,
19 | 3, 35, 11, 43, 1, 33, 9, 41,
20 | 51, 19, 59, 27, 49, 17, 57, 25,
21 | 15, 47, 7, 39, 13, 45, 5, 37,
22 | 63, 31, 55, 23, 61, 29, 53, 21);
23 |
24 |
25 | uniform sampler2D texture;
26 | uniform vec2 resolution;
27 | uniform float theta;
28 |
29 | in vec4 vertTexCoord;
30 | out vec4 fragColor;
31 |
32 | mat2 rotate2D(float angle){
33 | return mat2( cos(angle), -sin(angle),
34 | sin(angle), cos(angle));
35 | }
36 |
37 | float getLuma(vec3 color_){
38 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
39 | }
40 |
41 | float index(vec2 screenpos){
42 | int x = int(mod(screenpos.x, 8));
43 | int y = int(mod(screenpos.y, 8));
44 | return (1.0 + bayer8x8[(x + y * 8)]) / (64.0 + 1.0);
45 | }
46 |
47 | float dither(vec2 screenpos, float lum){
48 | float d = index(screenpos);
49 | return step(d, lum);
50 | }
51 |
52 |
53 | void main(){
54 | vec2 uv = vertTexCoord.xy;
55 | vec4 tex = texture(texture, uv);
56 |
57 | //rotate uv
58 | uv -= vec2(0.5, 0.5);
59 | uv = rotate2D(theta) * uv;
60 | uv += vec2(0.5, 0.5);
61 |
62 | float luma = getLuma(tex.rgb);
63 | float value = dither(uv * resolution, luma);
64 |
65 | fragColor = vec4(vec3(value), 1.0);
66 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringbayer8x8rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer8x8[64] = int[](0, 32, 8, 40, 2, 34, 10, 42,
16 | 48, 16, 56, 24, 50, 18, 58, 26,
17 | 12, 44, 4, 36, 14, 46, 6, 38,
18 | 60, 28, 52, 20, 62, 30, 54, 22,
19 | 3, 35, 11, 43, 1, 33, 9, 41,
20 | 51, 19, 59, 27, 49, 17, 57, 25,
21 | 15, 47, 7, 39, 13, 45, 5, 37,
22 | 63, 31, 55, 23, 61, 29, 53, 21);
23 |
24 |
25 | uniform sampler2D texture;
26 | uniform vec2 resolution;
27 | uniform float theta;
28 |
29 | in vec4 vertTexCoord;
30 | out vec4 fragColor;
31 |
32 | mat2 rotate2D(float angle){
33 | return mat2( cos(angle), -sin(angle),
34 | sin(angle), cos(angle));
35 | }
36 |
37 | float index(vec2 screenpos){
38 | int x = int(mod(screenpos.x, 8));
39 | int y = int(mod(screenpos.y, 8));
40 | return (1.0 + bayer8x8[(x + y * 8)]) / (64.0 + 1.0);
41 | }
42 |
43 | float dither(vec2 screenpos, float lum){
44 | float d = index(screenpos);
45 | return step(d, lum);
46 | }
47 |
48 |
49 | void main(){
50 | vec2 uv = vertTexCoord.xy;
51 | vec4 tex = texture(texture, uv);
52 |
53 | //rotate uv
54 | uv -= vec2(0.5, 0.5);
55 | uv = rotate2D(theta) * uv;
56 | uv += vec2(0.5, 0.5);
57 |
58 | float r = dither(uv * resolution, tex.r);
59 | float g = dither(uv * resolution, tex.g);
60 | float b = dither(uv * resolution, tex.b);
61 |
62 | fragColor = vec4(r, g, b, 1.0);
63 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringclusterdot4x4.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot4x4[16] = int[](12, 5, 6, 13,
16 | 4, 0, 1, 7,
17 | 11, 3, 2, 8,
18 | 15, 10, 9, 14);
19 |
20 |
21 | uniform sampler2D texture;
22 | uniform vec2 resolution;
23 | uniform float theta;
24 |
25 | in vec4 vertTexCoord;
26 | out vec4 fragColor;
27 |
28 | mat2 rotate2D(float angle){
29 | return mat2( cos(angle), -sin(angle),
30 | sin(angle), cos(angle));
31 | }
32 |
33 | float getLuma(vec3 color_){
34 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
35 | }
36 |
37 | float index(vec2 screenpos){
38 | int x = int(mod(screenpos.x, 4));
39 | int y = int(mod(screenpos.y, 4));
40 | return (1.0 + clusterDot4x4[(x + y * 4)]) / (16.0 + 1.0);
41 | }
42 |
43 | float dither(vec2 screenpos, float lum){
44 | float d = index(screenpos);
45 | return step(d, lum);
46 | }
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 | vec4 tex = texture(texture, uv);
51 | //rotate uv
52 | uv -= vec2(0.5, 0.5);
53 | uv = rotate2D(theta) * uv;
54 | uv += vec2(0.5, 0.5);
55 |
56 | float luma = getLuma(tex.rgb);
57 | float value = dither(uv * resolution, luma);
58 |
59 | fragColor = vec4(vec3(value), 1.0);
60 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringclusterdot4x4rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot4x4[16] = int[](12, 5, 6, 13,
16 | 4, 0, 1, 7,
17 | 11, 3, 2, 8,
18 | 15, 10, 9, 14);
19 |
20 |
21 | uniform sampler2D texture;
22 | uniform vec2 resolution;
23 | uniform float theta;
24 |
25 | in vec4 vertTexCoord;
26 | out vec4 fragColor;
27 |
28 | mat2 rotate2D(float angle){
29 | return mat2( cos(angle), -sin(angle),
30 | sin(angle), cos(angle));
31 | }
32 |
33 | float index(vec2 screenpos){
34 | int x = int(mod(screenpos.x, 4));
35 | int y = int(mod(screenpos.y, 4));
36 | return (1.0 + clusterDot4x4[(x + y * 4)]) / (16.0 + 1.0);
37 | }
38 |
39 | float dither(vec2 screenpos, float lum){
40 | float d = index(screenpos);
41 | return step(d, lum);
42 | }
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec4 tex = texture(texture, uv);
47 | //rotate uv
48 | uv -= vec2(0.5, 0.5);
49 | uv = rotate2D(theta) * uv;
50 | uv += vec2(0.5, 0.5);
51 |
52 | float r = dither(uv * resolution, tex.r);
53 | float g = dither(uv * resolution, tex.g);
54 | float b = dither(uv * resolution, tex.b);
55 |
56 | fragColor = vec4(r, g, b, 1.0);
57 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringclusterdot5x3.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot5x3[15] = int[]( 9, 3, 0, 6, 12,
16 | 10, 4, 1, 7, 13,
17 | 11, 5, 2, 8, 14);
18 |
19 |
20 | uniform sampler2D texture;
21 | uniform vec2 resolution;
22 | uniform float theta;
23 |
24 | in vec4 vertTexCoord;
25 | out vec4 fragColor;
26 |
27 | mat2 rotate2D(float angle){
28 | return mat2( cos(angle), -sin(angle),
29 | sin(angle), cos(angle));
30 | }
31 |
32 | float getLuma(vec3 color_){
33 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
34 | }
35 |
36 | float index(vec2 screenpos){
37 | int x = int(mod(screenpos.x, 5));
38 | int y = int(mod(screenpos.y, 3));
39 | return (1.0 + clusterDot5x3[(x + y * 5)]) / (15.0 + 1.0);
40 | }
41 |
42 | float dither(vec2 screenpos, float lum){
43 | float d = index(screenpos);
44 | return step(d, lum);
45 | }
46 |
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 | vec4 tex = texture(texture, uv);
51 |
52 | //rotate uv
53 | uv -= vec2(0.5, 0.5);
54 | uv = rotate2D(theta) * uv;
55 | uv += vec2(0.5, 0.5);
56 |
57 | float luma = getLuma(tex.rgb);
58 | float value = dither(uv * resolution, luma);
59 |
60 | fragColor = vec4(vec3(value), 1.0);
61 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringclusterdot5x3rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot5x3[15] = int[]( 9, 3, 0, 6, 12,
16 | 10, 4, 1, 7, 13,
17 | 11, 5, 2, 8, 14);
18 |
19 |
20 | uniform sampler2D texture;
21 | uniform vec2 resolution;
22 | uniform float theta;
23 |
24 | in vec4 vertTexCoord;
25 | out vec4 fragColor;
26 |
27 | mat2 rotate2D(float angle){
28 | return mat2( cos(angle), -sin(angle),
29 | sin(angle), cos(angle));
30 | }
31 |
32 | float index(vec2 screenpos){
33 | int x = int(mod(screenpos.x, 5));
34 | int y = int(mod(screenpos.y, 3));
35 | return (1.0 + clusterDot5x3[(x + y * 5)]) / (15.0 + 1.0);
36 | }
37 |
38 |
39 | float dither(vec2 screenpos, float lum){
40 | float d = index(screenpos);
41 | return step(d, lum);
42 | }
43 |
44 | void main(){
45 | vec2 uv = vertTexCoord.xy;
46 | vec4 tex = texture(texture, uv);
47 |
48 | //rotate uv
49 | uv -= vec2(0.5, 0.5);
50 | uv = rotate2D(theta) * uv;
51 | uv += vec2(0.5, 0.5);
52 |
53 | float r = dither(uv * resolution, tex.r);
54 | float g = dither(uv * resolution, tex.g);
55 | float b = dither(uv * resolution, tex.b);
56 |
57 | fragColor = vec4(r, g, b, 1.0);
58 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringclusterdot8x8.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot8x8[64] = int[](24, 10, 12, 26, 35, 47, 49, 37,
16 | 8, 0, 2, 14, 45, 59, 61, 51,
17 | 22, 6, 4, 16, 43, 57, 63, 53,
18 | 30, 20, 18, 28, 33, 41, 55, 39,
19 | 34, 46, 48, 36, 25, 11, 13, 27,
20 | 44, 58, 60, 50, 9, 1, 3, 15,
21 | 42, 56, 62, 52, 23, 7, 5, 17,
22 | 32, 42, 54, 38, 31, 21, 19, 29);
23 |
24 |
25 | uniform sampler2D texture;
26 | uniform vec2 resolution;
27 | uniform float theta;
28 |
29 | in vec4 vertTexCoord;
30 | out vec4 fragColor;
31 |
32 | mat2 rotate2D(float angle){
33 | return mat2( cos(angle), -sin(angle),
34 | sin(angle), cos(angle));
35 | }
36 |
37 | float getLuma(vec3 color_){
38 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
39 | }
40 |
41 | float index(vec2 screenpos){
42 | int x = int(mod(screenpos.x, 8));
43 | int y = int(mod(screenpos.y, 8));
44 | return (1.0 + clusterDot8x8[(x + y * 8)]) / (64.0 + 1.0);
45 | }
46 |
47 | float dither(vec2 screenpos, float lum){
48 | float d = index(screenpos);
49 | return step(d, lum);
50 | }
51 |
52 |
53 | void main(){
54 | vec2 uv = vertTexCoord.xy;
55 | vec4 tex = texture(texture, uv);
56 |
57 | //rotate uv
58 | uv -= vec2(0.5, 0.5);
59 | uv = rotate2D(theta) * uv;
60 | uv += vec2(0.5, 0.5);
61 |
62 | float luma = getLuma(tex.rgb);
63 | float value = dither(uv * resolution, luma);
64 |
65 | fragColor = vec4(vec3(value), 1.0);
66 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringclusterdot8x8rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot8x8[64] = int[](24, 10, 12, 26, 35, 47, 49, 37,
16 | 8, 0, 2, 14, 45, 59, 61, 51,
17 | 22, 6, 4, 16, 43, 57, 63, 53,
18 | 30, 20, 18, 28, 33, 41, 55, 39,
19 | 34, 46, 48, 36, 25, 11, 13, 27,
20 | 44, 58, 60, 50, 9, 1, 3, 15,
21 | 42, 56, 62, 52, 23, 7, 5, 17,
22 | 32, 42, 54, 38, 31, 21, 19, 29);
23 |
24 |
25 | uniform sampler2D texture;
26 | uniform vec2 resolution;
27 | uniform float theta;
28 |
29 | in vec4 vertTexCoord;
30 | out vec4 fragColor;
31 |
32 | mat2 rotate2D(float angle){
33 | return mat2( cos(angle), -sin(angle),
34 | sin(angle), cos(angle));
35 | }
36 |
37 |
38 | float index(vec2 screenpos){
39 | int x = int(mod(screenpos.x, 8));
40 | int y = int(mod(screenpos.y, 8));
41 | return (1.0 + clusterDot8x8[(x + y * 8)]) / (64.0 + 1.0);
42 | }
43 |
44 |
45 | float dither(vec2 screenpos, float lum){
46 | float d = index(screenpos);
47 | return step(d, lum);
48 | }
49 |
50 |
51 | void main(){
52 | vec2 uv = vertTexCoord.xy;
53 | vec4 tex = texture(texture, uv);
54 | //rotate uv
55 | uv -= vec2(0.5, 0.5);
56 | uv = rotate2D(theta) * uv;
57 | uv += vec2(0.5, 0.5);
58 |
59 | float r = dither(uv * resolution, tex.r);
60 | float g = dither(uv * resolution, tex.g);
61 | float b = dither(uv * resolution, tex.b);
62 |
63 | fragColor = vec4(r, g, b, 1.0);
64 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringrandom3x3.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int random3x3[54] = int[](1, 4, 7,
16 | 6, 0, 2,
17 | 3, 8, 5,
18 | 4, 6, 3,
19 | 8, 1, 5,
20 | 0, 3, 7,
21 | 5, 0, 3,
22 | 2, 8, 6,
23 | 7, 4, 1,
24 | 8, 2, 5,
25 | 6, 4, 0,
26 | 1, 7, 3,
27 | 2, 5, 8,
28 | 0, 7, 3,
29 | 4, 1, 6,
30 | 7, 4, 1,
31 | 3, 6, 8,
32 | 2, 0, 5);
33 |
34 |
35 | uniform sampler2D texture;
36 | uniform vec2 resolution;
37 | uniform float theta;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | mat2 rotate2D(float angle){
43 | return mat2( cos(angle), -sin(angle),
44 | sin(angle), cos(angle));
45 | }
46 | float random(vec2 tex){
47 | //return fract(sin(x) * offset);
48 | return fract(sin(dot(tex.xy, vec2(12.9898, 78.233))) * 43758.5453123);
49 | }
50 |
51 | float getLuma(vec3 color_){
52 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
53 | }
54 |
55 | float index(vec2 screenpos){
56 | int x = int(mod(screenpos.x, 3));
57 | int y = int(mod(screenpos.y, 3));
58 | int rand = (9 * int(floor(random(vertTexCoord.xy) * 6))) / 4;
59 | return (1.0 + random3x3[rand + (x + y * 3)]) / (9.0 + 1.0);
60 | }
61 |
62 | float dither(vec2 screenpos, float lum){
63 | float d = index(screenpos);
64 | return step(d, lum);
65 | }
66 |
67 |
68 | void main(){
69 | vec2 uv = vertTexCoord.xy;
70 | vec4 tex = texture(texture, uv);
71 | //rotate uv
72 | uv -= vec2(0.5, 0.5);
73 | uv = rotate2D(theta) * uv;
74 | uv += vec2(0.5, 0.5);
75 | float luma = getLuma(tex.rgb);
76 | float value = dither(uv * resolution, luma);
77 |
78 | fragColor = vec4(vec3(value), 1.0);
79 | }
--------------------------------------------------------------------------------
/data/shaders/ditheringrandom3x3rgb.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int random3x3[54] = int[](1, 4, 7,
16 | 6, 0, 2,
17 | 3, 8, 5,
18 | 4, 6, 3,
19 | 8, 1, 5,
20 | 0, 3, 7,
21 | 5, 0, 3,
22 | 2, 8, 6,
23 | 7, 4, 1,
24 | 8, 2, 5,
25 | 6, 4, 0,
26 | 1, 7, 3,
27 | 2, 5, 8,
28 | 0, 7, 3,
29 | 4, 1, 6,
30 | 7, 4, 1,
31 | 3, 6, 8,
32 | 2, 0, 5);
33 |
34 |
35 | uniform sampler2D texture;
36 | uniform vec2 resolution;
37 | uniform float theta;
38 |
39 | in vec4 vertTexCoord;
40 | out vec4 fragColor;
41 |
42 | float random(vec2 tex){
43 | //return fract(sin(x) * offset);
44 | return fract(sin(dot(tex.xy, vec2(12.9898, 78.233))) * 43758.5453123);
45 | }
46 |
47 |
48 | mat2 rotate2D(float angle){
49 | return mat2( cos(angle), -sin(angle),
50 | sin(angle), cos(angle));
51 | }
52 |
53 | float index(vec2 screenpos){
54 | int x = int(mod(screenpos.x, 3));
55 | int y = int(mod(screenpos.y, 3));
56 | int rand = (9 * int(floor(random(vertTexCoord.xy) * 6))) / 4;
57 | return (1.0 + random3x3[rand + (x + y * 3)]) / (9.0 + 1.0);
58 | }
59 |
60 |
61 | float dither(vec2 screenpos, float lum){
62 | float d = index(screenpos);
63 | return step(d, lum);
64 | }
65 |
66 |
67 | void main(){
68 | vec2 uv = vertTexCoord.xy;
69 | vec4 tex = texture(texture, uv);
70 |
71 | //rotate uv
72 | uv -= vec2(0.5, 0.5);
73 | uv = rotate2D(theta) * uv;
74 | uv += vec2(0.5, 0.5);
75 |
76 | float r = dither(uv * resolution, tex.r);
77 | float g = dither(uv * resolution, tex.g);
78 | float b = dither(uv * resolution, tex.b);
79 |
80 | fragColor = vec4(r, g, b, 1.0);
81 | }
--------------------------------------------------------------------------------
/data/shaders/erosion.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 |
13 | void main(){
14 | vec2 uv = vertTexCoord.xy;
15 | vec2 texelSize = vec2(1.0) / resolution;
16 |
17 | //define neighbors
18 | float CC = texture(texture, uv).r;
19 | float CT = texture(texture, uv + vec2( 0.0, -1.0) * texelSize).r;
20 | float RT = texture(texture, uv + vec2( 1.0, -1.0) * texelSize).r;
21 | float RC = texture(texture, uv + vec2( 1.0, 0.0) * texelSize).r;
22 | float RB = texture(texture, uv + vec2( 1.0, 1.0) * texelSize).r;
23 | float CB = texture(texture, uv + vec2( 0.0, 1.0) * texelSize).r;
24 | float LB = texture(texture, uv + vec2(-1.0, 1.0) * texelSize).r;
25 | float LC = texture(texture, uv + vec2(-1.0, 0.0) * texelSize).r;
26 | float LT = texture(texture, uv + vec2(-1.0, -1.0) * texelSize).r;
27 |
28 | //compare value
29 | float val = min(CC, CT);
30 | val = min(val, RT);
31 | val = min(val, RC);
32 | val = min(val, RB);
33 | val = min(val, CB);
34 | val = min(val, LB);
35 | val = min(val, LC);
36 | val = min(val, LT);
37 |
38 | fragColor = vec4(vec3(val), 1.0);
39 | }
--------------------------------------------------------------------------------
/data/shaders/erosionrgb.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 |
13 | void main(){
14 | vec2 uv = vertTexCoord.xy;
15 | vec2 texelSize = vec2(1.0) / resolution;
16 |
17 | //define neighbors
18 | vec3 CC = texture(texture, uv).rgb;
19 | vec3 CT = texture(texture, uv + vec2( 0.0, -1.0) * texelSize).rgb;
20 | vec3 RT = texture(texture, uv + vec2( 1.0, -1.0) * texelSize).rgb;
21 | vec3 RC = texture(texture, uv + vec2( 1.0, 0.0) * texelSize).rgb;
22 | vec3 RB = texture(texture, uv + vec2( 1.0, 1.0) * texelSize).rgb;
23 | vec3 CB = texture(texture, uv + vec2( 0.0, 1.0) * texelSize).rgb;
24 | vec3 LB = texture(texture, uv + vec2(-1.0, 1.0) * texelSize).rgb;
25 | vec3 LC = texture(texture, uv + vec2(-1.0, 0.0) * texelSize).rgb;
26 | vec3 LT = texture(texture, uv + vec2(-1.0, -1.0) * texelSize).rgb;
27 |
28 | //compare value
29 | vec3 val = min(CC, CT);
30 | val = min(val, RT);
31 | val = min(val, RC);
32 | val = min(val, RB);
33 | val = min(val, CB);
34 | val = min(val, LB);
35 | val = min(val, LC);
36 | val = min(val, LT);
37 |
38 | fragColor = vec4(val, 1.0);
39 | }
--------------------------------------------------------------------------------
/data/shaders/gamma.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform float gamma = 2.2;
7 | uniform sampler2D texture;
8 | in vec4 vertTexCoord;
9 | out vec4 fragColor;
10 |
11 | /*-------------------- GAMMA CORRECTION ---------------------------*/
12 | vec3 toLinear(vec3 rgb){
13 | return pow(rgb, vec3(gamma));
14 | }
15 |
16 | vec4 toLinear(vec4 rgba){
17 | return vec4(toLinear(rgba.rgb), rgba.a);
18 | }
19 |
20 | vec3 toGamma(vec3 rgb){
21 | return pow(rgb, vec3(1.0/gamma));
22 | }
23 |
24 | vec4 toGamma(vec4 rgba){
25 | return vec4(toGamma(rgba.rgb), rgba.a);
26 | }
27 |
28 | void main(){
29 | vec2 uv = vertTexCoord.xy;
30 | vec4 tex = texture(texture, uv);
31 | vec4 color = toGamma(tex);
32 |
33 |
34 | fragColor = color;
35 | }
--------------------------------------------------------------------------------
/data/shaders/gaussianblur13x13.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | #define PI 3.14159265359
7 | uniform sampler2D texture;
8 | uniform vec2 dir = vec2(0.0, 1.0);
9 | //uniform float radius = 2.0;
10 | //uniform vec2 resolution;
11 |
12 |
13 | uniform float blurSize = 1.0; // This should usually be equal to
14 | // 1.0f / texture_pixel_width for a horizontal blur, and
15 | // 1.0f / texture_pixel_height for a vertical blur.
16 | uniform float sigma = 4.0; //The sigma value for the gaussian function: higher value means more blur
17 |
18 | in vec4 vertTexCoord;
19 | out vec4 fragColor;
20 |
21 | #define avgPos(i) avgValue += texture(texture, uv - i * blurSize * dir) * incrementalGaussian.x;
22 | #define avgNeg(i) avgValue += texture(texture, uv + i * blurSize * dir) * incrementalGaussian.x;
23 | #define coeff() coefficientSum += 2.0 * incrementalGaussian.x;
24 | #define incGauss() incrementalGaussian.xy *= incrementalGaussian.yz;
25 | #define blur(i) avgPos(i); avgNeg(i); coeff(); incGauss();
26 | #define blur5x5() blur(1); blur(2);
27 | #define blur7x7() blur5x5(); blur(3);
28 | #define blur9x9() blur7x7(); blur(4);
29 | #define blur13x13() blur9x9(); blur(5); blur(6); blur(7);
30 |
31 | void main(){
32 |
33 | vec2 uv = vertTexCoord.xy;
34 | // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
35 |
36 | vec3 incrementalGaussian;
37 | incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
38 | incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
39 | incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
40 |
41 | vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0);
42 | float coefficientSum = 0.0;
43 |
44 | // Take the central sample first...
45 | avgValue += texture(texture, uv) * incrementalGaussian.x;
46 | coefficientSum += incrementalGaussian.x;
47 | incrementalGaussian.xy *= incrementalGaussian.yz;
48 |
49 | blur13x13();
50 |
51 | fragColor = avgValue / coefficientSum;
52 | }
--------------------------------------------------------------------------------
/data/shaders/gaussianblur5x5.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | #define PI 3.14159265359
7 | uniform sampler2D texture;
8 | uniform vec2 dir = vec2(0.0, 1.0);
9 | //uniform float radius = 2.0;
10 | //uniform vec2 resolution;
11 |
12 |
13 | uniform float blurSize = 1.0; // This should usually be equal to
14 | // 1.0f / texture_pixel_width for a horizontal blur, and
15 | // 1.0f / texture_pixel_height for a vertical blur.
16 | uniform float sigma = 4.0; //The sigma value for the gaussian function: higher value means more blur
17 |
18 | in vec4 vertTexCoord;
19 | out vec4 fragColor;
20 |
21 | #define avgPos(i) avgValue += texture(texture, uv - i * blurSize * dir) * incrementalGaussian.x;
22 | #define avgNeg(i) avgValue += texture(texture, uv + i * blurSize * dir) * incrementalGaussian.x;
23 | #define coeff() coefficientSum += 2.0 * incrementalGaussian.x;
24 | #define incGauss() incrementalGaussian.xy *= incrementalGaussian.yz;
25 | #define blur(i) avgPos(i); avgNeg(i); coeff(); incGauss();
26 | #define blur5x5() blur(1); blur(2);
27 | #define blur7x7() blur5x5(); blur(3);
28 | #define blur9x9() blur7x7(); blur(4);
29 | #define blur13x13() blur9x9(); blur(5); blur(6); blur(7);
30 |
31 | void main(){
32 |
33 | vec2 uv = vertTexCoord.xy;
34 | // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
35 |
36 | vec3 incrementalGaussian;
37 | incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
38 | incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
39 | incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
40 |
41 | vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0);
42 | float coefficientSum = 0.0;
43 |
44 | // Take the central sample first...
45 | avgValue += texture(texture, uv) * incrementalGaussian.x;
46 | coefficientSum += incrementalGaussian.x;
47 | incrementalGaussian.xy *= incrementalGaussian.yz;
48 |
49 | blur5x5();
50 |
51 | fragColor = avgValue / coefficientSum;
52 | }
--------------------------------------------------------------------------------
/data/shaders/gaussianblur7x7.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | #define PI 3.14159265359
7 | uniform sampler2D texture;
8 | uniform vec2 dir = vec2(0.0, 1.0);
9 | //uniform float radius = 2.0;
10 | //uniform vec2 resolution;
11 |
12 |
13 | uniform float blurSize = 1.0; // This should usually be equal to
14 | // 1.0f / texture_pixel_width for a horizontal blur, and
15 | // 1.0f / texture_pixel_height for a vertical blur.
16 | uniform float sigma = 4.0; //The sigma value for the gaussian function: higher value means more blur
17 |
18 | in vec4 vertTexCoord;
19 | out vec4 fragColor;
20 |
21 | #define avgPos(i) avgValue += texture(texture, uv - i * blurSize * dir) * incrementalGaussian.x;
22 | #define avgNeg(i) avgValue += texture(texture, uv + i * blurSize * dir) * incrementalGaussian.x;
23 | #define coeff() coefficientSum += 2.0 * incrementalGaussian.x;
24 | #define incGauss() incrementalGaussian.xy *= incrementalGaussian.yz;
25 | #define blur(i) avgPos(i); avgNeg(i); coeff(); incGauss();
26 | #define blur5x5() blur(1); blur(2);
27 | #define blur7x7() blur5x5(); blur(3);
28 | #define blur9x9() blur7x7(); blur(4);
29 | #define blur13x13() blur9x9(); blur(5); blur(6); blur(7);
30 |
31 | void main(){
32 |
33 | vec2 uv = vertTexCoord.xy;
34 | // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
35 |
36 | vec3 incrementalGaussian;
37 | incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
38 | incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
39 | incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
40 |
41 | vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0);
42 | float coefficientSum = 0.0;
43 |
44 | // Take the central sample first...
45 | avgValue += texture(texture, uv) * incrementalGaussian.x;
46 | coefficientSum += incrementalGaussian.x;
47 | incrementalGaussian.xy *= incrementalGaussian.yz;
48 |
49 | blur7x7();
50 |
51 | fragColor = avgValue / coefficientSum;
52 | }
--------------------------------------------------------------------------------
/data/shaders/gaussianblur9x9.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | #define PI 3.14159265359
7 | uniform sampler2D texture;
8 | uniform vec2 dir = vec2(0.0, 1.0);
9 | //uniform float radius = 2.0;
10 | //uniform vec2 resolution;
11 |
12 |
13 | uniform float blurSize = 1.0; // This should usually be equal to
14 | // 1.0f / texture_pixel_width for a horizontal blur, and
15 | // 1.0f / texture_pixel_height for a vertical blur.
16 | uniform float sigma = 4.0; //The sigma value for the gaussian function: higher value means more blur
17 |
18 | in vec4 vertTexCoord;
19 | out vec4 fragColor;
20 |
21 | #define avgPos(i) avgValue += texture(texture, uv - i * blurSize * dir) * incrementalGaussian.x;
22 | #define avgNeg(i) avgValue += texture(texture, uv + i * blurSize * dir) * incrementalGaussian.x;
23 | #define coeff() coefficientSum += 2.0 * incrementalGaussian.x;
24 | #define incGauss() incrementalGaussian.xy *= incrementalGaussian.yz;
25 | #define blur(i) avgPos(i); avgNeg(i); coeff(); incGauss();
26 | #define blur5x5() blur(1); blur(2);
27 | #define blur7x7() blur5x5(); blur(3);
28 | #define blur9x9() blur7x7(); blur(4);
29 | #define blur13x13() blur9x9(); blur(5); blur(6); blur(7);
30 |
31 | void main(){
32 |
33 | vec2 uv = vertTexCoord.xy;
34 | // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
35 |
36 | vec3 incrementalGaussian;
37 | incrementalGaussian.x = 1.0 / (sqrt(2.0 * PI) * sigma);
38 | incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
39 | incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
40 |
41 | vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0);
42 | float coefficientSum = 0.0;
43 |
44 | // Take the central sample first...
45 | avgValue += texture(texture, uv) * incrementalGaussian.x;
46 | coefficientSum += incrementalGaussian.x;
47 | incrementalGaussian.xy *= incrementalGaussian.yz;
48 |
49 | blur9x9();
50 |
51 | fragColor = avgValue / coefficientSum;
52 | }
--------------------------------------------------------------------------------
/data/shaders/grain.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | #define offset 43758.5453123
7 | uniform sampler2D texture;
8 | uniform float time;
9 | uniform float intensity;
10 |
11 | in vec4 vertTexCoord;
12 | out vec4 fragColor;
13 |
14 | //RANDOM
15 | float random(vec2 tex){
16 | //return fract(sin(x) * offset);
17 | return fract(sin(dot(tex.xy, vec2(12.9898, 78.233))) * offset);
18 | }
19 |
20 | float random(vec3 tex){
21 | //return fract(sin(x) * offset);
22 | return fract(sin(dot(tex.xyz, vec3(12.9898, 78.233, 12.9898))) * offset);
23 | }
24 |
25 | //GRAIN
26 | vec4 addGrain(vec2 uv, float time, float grainIntensity){
27 | float grain = random(fract(uv * time)) * grainIntensity;
28 | return vec4(vec3(grain), 1.0);
29 | }
30 |
31 | void main(){
32 | vec2 uv = vertTexCoord.xy;
33 | vec4 rgbaTex = texture(texture, vertTexCoord.xy);
34 | vec4 grain = addGrain(uv, time, intensity);
35 |
36 | fragColor = rgbaTex + grain;
37 | }
--------------------------------------------------------------------------------
/data/shaders/grainrgb.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | #define offset 43758.5453123
7 | uniform sampler2D texture;
8 | uniform float time = 1.0;
9 | uniform float intensity = 0.1;
10 |
11 | in vec4 vertTexCoord;
12 | out vec4 fragColor;
13 |
14 | //RANDOM
15 | float random(vec2 tex){
16 | //return fract(sin(x) * offset);
17 | return fract(sin(dot(tex.xy, vec2(12.9898, 78.233))) * offset);
18 | }
19 |
20 | float random(vec3 tex){
21 | //return fract(sin(x) * offset);
22 | return fract(sin(dot(tex.xyz, vec3(12.9898, 78.233, 12.9898))) * offset);
23 | }
24 |
25 | //GRAIN
26 | vec4 addGrain(vec2 uv, float time, float grainIntensity){
27 | float grainred = (random(fract(uv * time)) * 2.0 - 1.0) * grainIntensity;
28 | float graingreen = (random(fract(uv.yx * time)) * 2.0 - 1.0) * grainIntensity;
29 | float grainblue = (random(fract(vec2(grainred, graingreen) * time)) * 2.0 - 1.0) * grainIntensity;
30 | return vec4(grainred, graingreen, grainblue, 1.0);
31 | }
32 |
33 | void main(){
34 | vec2 uv = vertTexCoord.xy;
35 | vec4 rgbaTex = texture(texture, vertTexCoord.xy);
36 | vec4 grain = addGrain(uv, time, intensity);
37 |
38 | fragColor = rgbaTex + grain;
39 | }
--------------------------------------------------------------------------------
/data/shaders/highpass.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 | uniform float sharpFactor = 1.0;
9 |
10 | in vec4 vertTexCoord;
11 | out vec4 fragColor;
12 |
13 | #define highpass(i) tmp = texture(texture, uv + offsetTable[i]); sum += tmp * kernel[i]; sum.a = 1.0;
14 |
15 | vec4 highPass(sampler2D texture, vec2 uv, float stepInc){
16 | //highPass
17 | float step_w = 1.0/ (resolution.x * stepInc);
18 | float step_h = 1.0/ (resolution.y * stepInc);
19 |
20 | vec2 offsetTable[9];
21 | float kernel[9];
22 |
23 | offsetTable[0] = vec2(-step_w, -step_h);
24 | offsetTable[1] = vec2(0.0, -step_h);
25 | offsetTable[2] = vec2(step_w, -step_h);
26 |
27 | offsetTable[3] = vec2(-step_w, 0.0);
28 | offsetTable[4] = vec2(0.0, 0.0);
29 | offsetTable[5] = vec2(step_w, 0.0);
30 |
31 | offsetTable[6] = vec2(-step_w, step_h);
32 | offsetTable[7] = vec2(0.0, step_h);
33 | offsetTable[8] = vec2(step_w, step_h);
34 |
35 | kernel[0] = -1.;
36 | kernel[1] = -1.;
37 | kernel[2] = -1.;
38 |
39 | kernel[3] = -1.;
40 | kernel[4] = 8.;
41 | kernel[5] = -1.;
42 |
43 | kernel[6] = -1.;
44 | kernel[7] = -1.;
45 | kernel[8] = -1.;
46 |
47 | //int i = 0;
48 | vec4 sum = vec4(0.0);
49 | vec4 tmp= vec4(0.0);
50 |
51 | highpass(0);
52 | highpass(1);
53 | highpass(2);
54 | highpass(3);
55 | highpass(4);
56 | highpass(5);
57 | highpass(6);
58 | highpass(7);
59 | highpass(8);
60 |
61 | //map from 0 to 1 to 0.5 to 1
62 | return sum * 0.5 + 0.5;
63 | }
64 |
65 | void main(){
66 | vec2 uv = vertTexCoord.xy;
67 | vec4 tex = highPass(texture, uv, sharpFactor);
68 |
69 | fragColor = tex;
70 | }
--------------------------------------------------------------------------------
/data/shaders/invert.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 |
8 | in vec4 vertTexCoord;
9 | out vec4 fragColor;
10 |
11 |
12 | void main(){
13 | vec2 uv = vertTexCoord.xy;
14 | vec4 tex = texture(texture, uv);
15 |
16 | fragColor = vec4(vec3(1.0 - tex.rgb), 1.0);
17 | }
--------------------------------------------------------------------------------
/data/shaders/level.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec3 minInput = vec3(0.0);
8 | uniform vec3 maxInput = vec3(1.0);
9 | uniform vec3 minOutput = vec3(0.0);
10 | uniform vec3 maxOutput = vec3(1.0);
11 | uniform vec3 gamma = vec3(1.0);
12 |
13 | in vec4 vertTexCoord;
14 | out vec4 fragColor;
15 |
16 | #define gammaCorrection(color, gamma) pow(color, vec3(1.0) / gamma)
17 | #define levelsControlInputRange(color, minInput, maxInput) min(max(color - minInput, vec3(0.0)) / (maxInput - minInput), vec3(1.0))
18 | #define levelsControlInput(color, minInput, gamma, maxInput) gammaCorrection(levelsControlInputRange(color, minInput, maxInput), gamma)
19 | #define levelsControlOutputRange(color, minOutput, maxOutput) mix(minOutput, maxOutput, color)
20 | #define levelsControl(color, minInput, gamma, maxInput, minOutput, maxOutput) levelsControlOutputRange(levelsControlInput(color, minInput, gamma, maxInput), minOutput, maxOutput)
21 |
22 | void main()
23 | {
24 | vec2 uv = vertTexCoord.xy;
25 | vec4 tex = texture(texture, uv);
26 |
27 | tex.rgb = levelsControl(tex.rgb, minInput, gamma, maxInput, minOutput, maxOutput);
28 |
29 |
30 | fragColor = tex;
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/data/shaders/lut1d.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform sampler2D lut;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 | vec4 lookUp(vec4 color, sampler2D lut1d){
13 | vec3 colorLookedUp = vec3(texture(lut1d, vec2(color.r, 0.5)).r,
14 | texture(lut1d, vec2(color.g, 0.5)).g,
15 | texture(lut1d, vec2(color.b, 0.5)).b);
16 | return vec4(colorLookedUp, color.a);
17 | }
18 |
19 | void main(){
20 | vec2 uv = vertTexCoord.xy;
21 | vec4 tex = texture(texture, uv);
22 | vec4 lookedUpColor = lookUp(tex, lut);
23 |
24 | fragColor = lookedUpColor;
25 | }
--------------------------------------------------------------------------------
/data/shaders/lut1dgen.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 |
8 | in vec4 vertTexCoord;
9 | out vec4 fragColor;
10 |
11 | void main(){
12 | vec2 uv = vertTexCoord.xy;
13 |
14 | fragColor = vec4(uv.x, uv.x, uv.x, 1.0);
15 | }
--------------------------------------------------------------------------------
/data/shaders/mask.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform sampler2D mask;
8 | uniform int srci = 0;
9 | uniform int basei = 0;
10 |
11 | in vec4 vertTexCoord;
12 | out vec4 fragColor;
13 |
14 | void main(){
15 | vec2 uv = vertTexCoord.xy;
16 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
17 | vec4 tex = texture(texture, uv * (1 - basei) + iuv * basei);
18 | vec4 rgbaBack = vec4(tex.bgr, 0.0);
19 | float alpha = texture(mask, uv * (1 - srci) + iuv * srci).r;
20 | vec4 finalColor = mix(rgbaBack, tex, alpha);
21 |
22 | fragColor = finalColor;
23 | }
--------------------------------------------------------------------------------
/data/shaders/mask2.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform sampler2D base;
8 | uniform sampler2D mask;
9 | uniform int srci = 0;
10 | uniform int basei = 0;
11 | uniform int base2i = 0;
12 |
13 | in vec4 vertTexCoord;
14 | out vec4 fragColor;
15 |
16 | void main(){
17 | vec2 uv = vertTexCoord.xy;
18 | vec2 iuv = vec2(uv.x, 1.0 - uv.y);
19 | vec4 tex = texture(texture, uv * (1 - basei) + iuv * basei);
20 | vec4 texBase = texture(base, uv * (1 - base2i) + iuv * base2i);
21 | float alpha = texture(mask, uv * (1 - srci) + iuv * srci).r;
22 | vec4 finalColor = mix(texBase, tex, alpha);
23 |
24 | fragColor = finalColor;
25 | }
--------------------------------------------------------------------------------
/data/shaders/median3x3.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | /*
8 | Based on Morgan McGuire implementation of a 3*3 median filter
9 | http://casual-effects.com/research/McGuire2008Median/index.html
10 | RGB filtering. Optimized with no loop iteration by Bonjour Lab
11 | */
12 | uniform sampler2D texture;
13 | uniform vec2 resolution;
14 | in vec4 vertTexCoord;
15 |
16 | out vec4 fragColor;
17 |
18 | //median functions
19 | #define order(a, b) temp = a; a = min(a, b); b = max(temp, b);
20 | #define order2(a, b) order(pix[a], pix[b]);
21 | #define orderMin3(a, b, c) order2(a, b); order2(a, c);
22 | #define orderMax3(a, b, c) order2(b, c); order2(a, c);
23 | #define order3(a, b, c) orderMax3(a, b, c); order2(a, b);
24 | #define order4(a, b, c, d) order2(a, b); order2(c, d); order2(a, c); order2(b, d);
25 | #define order5(a, b, c, d, e) order2(a, b); order2(c, d); orderMin3(a, c, e); orderMax3(b, d, e);
26 | #define order6(a, b, c, d, e, f) order2(a, d); order2(b, e); order2(c, f); orderMin3(a, b, c); orderMax3(d, e, f);
27 |
28 |
29 | void main(){
30 | vec2 uv = vertTexCoord.xy;
31 | vec2 uvinc = vec2(1.0) / resolution.xy;
32 |
33 | vec3 pix[9];
34 | vec3 temp;
35 |
36 | pix[0] = texture(texture, uv + vec2(-1.0, -1.0) * uvinc).rgb;
37 | pix[1] = texture(texture, uv + vec2(0.0, -1.0) * uvinc).rgb;
38 | pix[2] = texture(texture, uv + vec2(1.0, -1.0) * uvinc).rgb;
39 | pix[3] = texture(texture, uv + vec2(-1.0, 0.0) * uvinc).rgb;
40 | pix[4] = texture(texture, uv + vec2(.0, .0) * uvinc).rgb;
41 | pix[5] = texture(texture, uv + vec2(1.0, .0) * uvinc).rgb;
42 | pix[6] = texture(texture, uv + vec2(-1.0, 1.0) * uvinc).rgb;
43 | pix[7] = texture(texture, uv + vec2(.0, 1.0) * uvinc).rgb;
44 | pix[8] = texture(texture, uv + vec2(1.0, 1.0) * uvinc).rgb;
45 |
46 | order6(0, 1, 2, 3, 4, 5);
47 | order5(1, 2, 3, 4, 6);
48 | order4(2, 3, 4, 7);
49 | order3(3, 4, 8);
50 |
51 | vec4 color = vec4(pix[4], 1.0);
52 |
53 | fragColor = color;
54 | }
--------------------------------------------------------------------------------
/data/shaders/pixelate.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 | uniform float pixelRes = 100;
9 |
10 | in vec4 vertTexCoord;
11 | out vec4 fragColor;
12 |
13 |
14 | void main(){
15 | float dx = 1.0 / pixelRes;
16 | float ratio = resolution.x / resolution.y;
17 | float dy = ratio / pixelRes;
18 |
19 | float u = floor(vertTexCoord.x / dx) * dx;
20 | float v = floor(vertTexCoord.y / dy) * dy;
21 |
22 | vec2 uv = vec2(u, v);
23 | vec4 tex = texture(texture, uv);
24 |
25 | fragColor = tex;
26 | }
--------------------------------------------------------------------------------
/data/shaders/radialblur.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform vec2 resolution;
8 | uniform vec2 blurOrigin = vec2(0.5);
9 | uniform float blurSize = 0.1;
10 | uniform int octave = 4;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 |
16 | vec4 radialBlur(int octave, vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin)
17 | {
18 | vec4 focus = texture(texture, blurOrigin);
19 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
20 |
21 | float distToCenter = length(uv - blurOrigin);
22 |
23 | uv += texelSize * 0.5 - blurOrigin;
24 |
25 | for (int i = 0; i < octave; i++)
26 | {
27 | float scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1));
28 | blur += vec4( texture(texture, uv * scale + blurOrigin).rgb, 1.0);
29 | }
30 |
31 | return blur / float(octave);
32 | }
33 |
34 | void main(){
35 | vec2 texelSize = vec2(1.0)/resolution;
36 | vec4 rd = radialBlur(octave, vertTexCoord.xy, texelSize, blurSize, blurOrigin);
37 | fragColor = rd;
38 | }
--------------------------------------------------------------------------------
/data/shaders/radialblurhigh.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 | #define scale(i) scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1))
16 | #define blur(i) scale(i); blur += vec4(texture(texture, uv * scale + blurOrigin).rgb, 1.0)
17 |
18 | vec4 radialBlur(vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin)
19 | {
20 | vec4 focus = texture(texture, blurOrigin);
21 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
22 | float scale;
23 | int octave = 20;
24 |
25 | float distToCenter = length(uv - blurOrigin);
26 |
27 | uv += texelSize * 0.5 - blurOrigin;
28 |
29 | blur(1);
30 | blur(2);
31 | blur(3);
32 | blur(4);
33 | blur(5);
34 | blur(6);
35 | blur(7);
36 | blur(8);
37 | blur(9);
38 | blur(10);
39 | blur(11);
40 | blur(12);
41 | blur(13);
42 | blur(14);
43 | blur(15);
44 | blur(16);
45 | blur(17);
46 | blur(18);
47 | blur(19);
48 | blur(20);
49 |
50 | return blur / 20;
51 | }
52 |
53 | void main(){
54 | vec2 texelSize = vec2(1.0)/resolution;
55 | vec4 rd = radialBlur(vertTexCoord.xy, texelSize, blurSize, blurOrigin);
56 | fragColor = rd;
57 | }
--------------------------------------------------------------------------------
/data/shaders/radialblurlow.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 | #define scale(i) scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1))
16 | #define blur(i) scale(i); blur += vec4(texture(texture, uv * scale + blurOrigin).rgb, 1.0)
17 |
18 | vec4 radialBlur(vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin)
19 | {
20 | vec4 focus = texture(texture, blurOrigin);
21 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
22 | float scale;
23 | int octave = 4;
24 |
25 | float distToCenter = length(uv - blurOrigin);
26 |
27 | uv += texelSize * 0.5 - blurOrigin;
28 |
29 | blur(1);
30 | blur(2);
31 | blur(3);
32 | blur(4);
33 |
34 | return blur / octave;
35 | }
36 |
37 | void main(){
38 | vec2 texelSize = vec2(1.0)/resolution;
39 | vec4 rd = radialBlur(vertTexCoord.xy, texelSize, blurSize, blurOrigin);
40 | fragColor = rd;
41 | }
--------------------------------------------------------------------------------
/data/shaders/radialblurmedium.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 |
7 | uniform sampler2D texture;
8 | uniform vec2 resolution;
9 | uniform vec2 blurOrigin = vec2(0.5);
10 | uniform float blurSize = 0.1;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 | #define scale(i) scale = 1.0 - (blurSize * distToCenter) * (float(i) / float(octave - 1))
16 | #define blur(i) scale(i); blur += vec4(texture(texture, uv * scale + blurOrigin).rgb, 1.0)
17 |
18 | vec4 radialBlur(vec2 uv, vec2 texelSize, float blurSize, vec2 blurOrigin)
19 | {
20 | vec4 focus = texture(texture, blurOrigin);
21 | vec4 blur = vec4(0.0, 0.0, 0.0, 0.0);
22 | float scale;
23 | int octave = 10;
24 |
25 | float distToCenter = length(uv - blurOrigin);
26 |
27 | uv += texelSize * 0.5 - blurOrigin;
28 |
29 | blur(1);
30 | blur(2);
31 | blur(3);
32 | blur(4);
33 | blur(5);
34 | blur(6);
35 | blur(7);
36 | blur(8);
37 | blur(9);
38 | blur(10);
39 |
40 | return blur / octave;
41 | }
42 |
43 | void main(){
44 | vec2 texelSize = vec2(1.0)/resolution;
45 | vec4 rd = radialBlur(vertTexCoord.xy, texelSize, blurSize, blurOrigin);
46 | fragColor = rd;
47 | }
--------------------------------------------------------------------------------
/data/shaders/ramp1d.glsl:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | precision mediump int;
4 | #endif
5 |
6 | uniform sampler2D texture;
7 | uniform sampler2D ramp;
8 |
9 | in vec4 vertTexCoord;
10 | out vec4 fragColor;
11 |
12 | float getLuma(vec3 color_){
13 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
14 | }
15 |
16 | vec4 getRamp(float luma, sampler2D ramp1d){
17 | vec3 colorRamped = texture(ramp1d, vec2(luma, 0.5)).rgb;
18 | return vec4(colorRamped, 1.0);
19 | }
20 |
21 | void main(){
22 | vec2 uv = vertTexCoord.xy;
23 | vec4 tex = texture(texture, uv);
24 | float luma = getLuma(tex.rgb);
25 | vec4 colorRamped = getRamp(luma, ramp);
26 |
27 | fragColor = colorRamped;
28 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringBayer2x2.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer2x2[4] = int[](0, 2,
16 | 3, 1);
17 |
18 |
19 | uniform sampler2D texture;
20 | uniform vec2 resolution;
21 | uniform float mouse;
22 |
23 | in vec4 vertTexCoord;
24 | out vec4 fragColor;
25 |
26 | mat2 rotate2d(float _angle){
27 | return mat2(cos(_angle),-sin(_angle),
28 | sin(_angle),cos(_angle));
29 | }
30 |
31 |
32 | float getLuma(vec3 color_){
33 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
34 | }
35 |
36 | float index(vec2 screenpos){
37 | int x = int(mod(screenpos.x, 2));
38 | int y = int(mod(screenpos.y, 2));
39 | return (1.0 + bayer2x2[(x + y * 2)]) / (4.0 + 1.0);
40 | }
41 |
42 | float dither(vec2 screenpos, float lum){
43 | float d = index(screenpos);
44 | return step(d, lum);
45 | }
46 |
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 | vec4 tex = texture(texture, uv);
51 | float luma = getLuma(tex.rgb);
52 |
53 |
54 | uv -= vec2(0.5);
55 | // rotate the space
56 | uv = rotate2d( mouse ) * uv;
57 | // move it back to the original place
58 | uv += vec2(0.5);
59 |
60 |
61 | float value = dither(uv * resolution, luma);
62 |
63 | fragColor = vec4(vec3(value), 1.0);
64 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringBayer3x3.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer3x3[9] = int[](0, 7, 3,
16 | 6, 5, 2,
17 | 4, 1, 8);
18 |
19 | uniform sampler2D texture;
20 | uniform vec2 resolution;
21 | uniform float mouse;
22 |
23 | in vec4 vertTexCoord;
24 | out vec4 fragColor;
25 |
26 | mat2 rotate2d(float _angle){
27 | return mat2(cos(_angle),-sin(_angle),
28 | sin(_angle),cos(_angle));
29 | }
30 |
31 |
32 | float getLuma(vec3 color_){
33 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
34 | }
35 |
36 | float index(vec2 screenpos){
37 | int x = int(mod(screenpos.x, 3));
38 | int y = int(mod(screenpos.y, 3));
39 | return (1.0 + bayer3x3[(x + y * 3)]) / (9.0 + 1.0);
40 | }
41 |
42 |
43 | float dither(vec2 screenpos, float lum){
44 | float d = index(screenpos);
45 | return step(d, lum);
46 | }
47 |
48 |
49 | void main(){
50 | vec2 uv = vertTexCoord.xy;
51 | vec4 tex = texture(texture, uv);
52 | float luma = getLuma(tex.rgb);
53 |
54 |
55 | uv -= vec2(0.5);
56 | // rotate the space
57 | uv = rotate2d( mouse ) * uv;
58 | // move it back to the original place
59 | uv += vec2(0.5);
60 |
61 |
62 | float value = dither(uv * resolution, luma);
63 |
64 | fragColor = vec4(vec3(value), 1.0);
65 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringBayer4x4.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer4x4[16] = int[](0, 8, 2, 10,
16 | 12, 4, 14, 6,
17 | 3, 11, 1, 9,
18 | 15, 7, 13, 5);
19 |
20 | uniform sampler2D texture;
21 | uniform vec2 resolution;
22 | uniform float mouse;
23 |
24 | in vec4 vertTexCoord;
25 | out vec4 fragColor;
26 |
27 | mat2 rotate2d(float _angle){
28 | return mat2(cos(_angle),-sin(_angle),
29 | sin(_angle),cos(_angle));
30 | }
31 |
32 | float getLuma(vec3 color_){
33 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
34 | }
35 |
36 | float index(vec2 screenpos){
37 | int x = int(mod(screenpos.x, 4));
38 | int y = int(mod(screenpos.y, 4));
39 | return (1.0 + bayer4x4[(x + y * 4)]) / (16.0);
40 | }
41 |
42 | float dither(vec2 screenpos, float lum){
43 | float d = index(screenpos);
44 | return step(d, lum);
45 | }
46 |
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 |
51 | vec4 tex = texture(texture, uv);
52 | float luma = getLuma(tex.rgb);
53 |
54 | uv -= vec2(0.5);
55 | // rotate the space
56 | uv = rotate2d( mouse ) * uv;
57 | // move it back to the original place
58 | uv += vec2(0.5);
59 |
60 | float value = dither(uv * resolution * 01.0, luma);
61 |
62 | fragColor = vec4(vec3(value), 1.0);
63 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringBayer8x8.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int bayer8x8[64] = int[](0, 32, 8, 40, 2, 34, 10, 42,
16 | 48, 16, 56, 24, 50, 18, 58, 26,
17 | 12, 44, 4, 36, 14, 46, 6, 38,
18 | 60, 28, 52, 20, 62, 30, 54, 22,
19 | 3, 35, 11, 43, 1, 33, 9, 41,
20 | 51, 19, 59, 27, 49, 17, 57, 25,
21 | 15, 47, 7, 39, 13, 45, 5, 37,
22 | 63, 31, 55, 23, 61, 29, 53, 21);
23 |
24 |
25 |
26 | uniform sampler2D texture;
27 | uniform vec2 resolution;
28 | uniform float mouse;
29 |
30 | in vec4 vertTexCoord;
31 | out vec4 fragColor;
32 |
33 | mat2 rotate2d(float _angle){
34 | return mat2(cos(_angle),-sin(_angle),
35 | sin(_angle),cos(_angle));
36 | }
37 |
38 |
39 | float getLuma(vec3 color_){
40 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
41 | }
42 |
43 | float index(vec2 screenpos){
44 | int x = int(mod(screenpos.x, 8));
45 | int y = int(mod(screenpos.y, 8));
46 | return (1.0 + bayer8x8[(x + y * 8)]) / (64.0 + 1.0);
47 | }
48 |
49 | float dither(vec2 screenpos, float lum){
50 | float d = index(screenpos);
51 | return step(d, lum);
52 | }
53 |
54 |
55 | void main(){
56 | vec2 uv = vertTexCoord.xy;
57 | vec4 tex = texture(texture, uv);
58 | float luma = getLuma(tex.rgb);
59 |
60 |
61 | uv -= vec2(0.5);
62 | // rotate the space
63 | uv = rotate2d( mouse ) * uv;
64 | // move it back to the original place
65 | uv += vec2(0.5);
66 |
67 |
68 | float value = dither(uv * resolution, luma);
69 |
70 | fragColor = vec4(vec3(value), 1.0);
71 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringClusterDot4x4.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 |
16 | const int clusterDot4x4[16] = int[](12, 5, 6, 13,
17 | 4, 0, 1, 7,
18 | 11, 3, 2, 8,
19 | 15, 10, 9, 14);
20 |
21 | uniform sampler2D texture;
22 | uniform vec2 resolution;
23 | uniform float mouse;
24 |
25 | in vec4 vertTexCoord;
26 | out vec4 fragColor;
27 |
28 | mat2 rotate2d(float _angle){
29 | return mat2(cos(_angle),-sin(_angle),
30 | sin(_angle),cos(_angle));
31 | }
32 |
33 |
34 | float getLuma(vec3 color_){
35 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
36 | }
37 |
38 | float index(vec2 screenpos){
39 | int x = int(mod(screenpos.x, 4));
40 | int y = int(mod(screenpos.y, 4));
41 | return (1.0 + clusterDot4x4[(x + y * 4)]) / (16.0 + 1.0);
42 | }
43 |
44 | float dither(vec2 screenpos, float lum){
45 | float d = index(screenpos);
46 | return step(d, lum);
47 | }
48 |
49 |
50 | void main(){
51 | vec2 uv = vertTexCoord.xy;
52 | vec4 tex = texture(texture, uv);
53 | float luma = getLuma(tex.rgb);
54 |
55 |
56 | uv -= vec2(0.5);
57 | // rotate the space
58 | uv = rotate2d( mouse ) * uv;
59 | // move it back to the original place
60 | uv += vec2(0.5);
61 |
62 |
63 | float value = dither(uv * resolution, luma);
64 |
65 | fragColor = vec4(vec3(value), 1.0);
66 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringClusterDot5x3.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 | const int clusterDot5x3[15] = int[]( 9, 3, 0, 6, 12,
16 | 10, 4, 1, 7, 13,
17 | 11, 5, 2, 8, 14);
18 |
19 | uniform sampler2D texture;
20 | uniform vec2 resolution;
21 | uniform float mouse;
22 |
23 | in vec4 vertTexCoord;
24 | out vec4 fragColor;
25 |
26 | mat2 rotate2d(float _angle){
27 | return mat2(cos(_angle),-sin(_angle),
28 | sin(_angle),cos(_angle));
29 | }
30 |
31 |
32 | float getLuma(vec3 color_){
33 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
34 | }
35 |
36 | float index(vec2 screenpos){
37 | int x = int(mod(screenpos.x, 5));
38 | int y = int(mod(screenpos.y, 3));
39 | return (1.0 + clusterDot5x3[(x + y * 5)]) / (15.0 + 1.0);
40 | }
41 |
42 | float dither(vec2 screenpos, float lum){
43 | float d = index(screenpos);
44 | return step(d, lum);
45 | }
46 |
47 |
48 | void main(){
49 | vec2 uv = vertTexCoord.xy;
50 | vec4 tex = texture(texture, uv);
51 | float luma = getLuma(tex.rgb);
52 |
53 |
54 | uv -= vec2(0.5);
55 | // rotate the space
56 | uv = rotate2d( mouse ) * uv;
57 | // move it back to the original place
58 | uv += vec2(0.5);
59 |
60 |
61 | float value = dither(uv * resolution, luma);
62 |
63 | fragColor = vec4(vec3(value), 1.0);
64 | }
--------------------------------------------------------------------------------
/data/shaders/rotatedDitheringClusterDot8x8.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * Based on :
3 | * * Alex Charlton implementation : http://alex-charlton.com/posts/Dithering_on_the_GPU/#fn1
4 | * * Bayer Matrix : https://en.wikipedia.org/wiki/Ordered_dithering
5 | * * http://caca.zoy.org/study/part2.html
6 | *
7 | * Update by Bonjour Lab
8 | */
9 |
10 | #ifdef GL_ES
11 | precision mediump float;
12 | precision mediump int;
13 | #endif
14 |
15 |
16 | const int clusterDot8x8[64] = int[](24, 10, 12, 26, 35, 47, 49, 37,
17 | 8, 0, 2, 14, 45, 59, 61, 51,
18 | 22, 6, 4, 16, 43, 57, 63, 53,
19 | 30, 20, 18, 28, 33, 41, 55, 39,
20 | 34, 46, 48, 36, 25, 11, 13, 27,
21 | 44, 58, 60, 50, 9, 1, 3, 15,
22 | 42, 56, 62, 52, 23, 7, 5, 17,
23 | 32, 42, 54, 38, 31, 21, 19, 29);
24 |
25 | uniform sampler2D texture;
26 | uniform vec2 resolution;
27 | uniform float mouse;
28 |
29 | in vec4 vertTexCoord;
30 | out vec4 fragColor;
31 |
32 | mat2 rotate2d(float _angle){
33 | return mat2(cos(_angle),-sin(_angle),
34 | sin(_angle),cos(_angle));
35 | }
36 |
37 |
38 | float getLuma(vec3 color_){
39 | return dot(color_.rgb, vec3(0.299, 0.587, 0.114));
40 | }
41 |
42 | float index(vec2 screenpos){
43 | int x = int(mod(screenpos.x, 8));
44 | int y = int(mod(screenpos.y, 8));
45 | return (1.0 + clusterDot8x8[(x + y * 8)]) / (64.0 + 1.0);
46 | }
47 |
48 | float dither(vec2 screenpos, float lum){
49 | float d = index(screenpos);
50 | return step(d, lum);
51 | }
52 |
53 |
54 | void main(){
55 | vec2 uv = vertTexCoord.xy;
56 | vec4 tex = texture(texture, uv);
57 | float luma = getLuma(tex.rgb);
58 |
59 |
60 | uv -= vec2(0.5);
61 | // rotate the space
62 | uv = rotate2d( mouse ) * uv;
63 | // move it back to the original place
64 | uv += vec2(0.5);
65 |
66 |
67 | float value = dither(uv * resolution, luma);
68 |
69 | fragColor = vec4(vec3(value), 1.0);
70 | }
--------------------------------------------------------------------------------
/data/shaders/signeddistancefield.glsl:
--------------------------------------------------------------------------------
1 | //blend sources : http://wiki.polycount.com/wiki/Blending_functions
2 |
3 | #ifdef GL_ES
4 | precision mediump float;
5 | precision mediump int;
6 | #endif
7 |
8 | uniform sampler2D texture;
9 | uniform vec2 resolution;
10 | uniform int searchDistance;
11 |
12 | in vec4 vertTexCoord;
13 | out vec4 fragColor;
14 |
15 |
16 | void main(){
17 | vec2 uv = vertTexCoord.xy;
18 | vec4 tex = texture(texture, uv);
19 |
20 | vec2 texel = vec2(1.0) / resolution;
21 |
22 | float hypothenuse = sqrt(resolution.x * resolution.x + resolution.y * resolution.y);
23 | float distance = hypothenuse;
24 |
25 | //the main idea is to take the neighbors of a pixel
26 | //If this neighbors is whit we compute the distance between the pixel and the neighbors
27 |
28 | for (int i = -searchDistance; i
7 | * Each available shaders are define in the GPUImageInterface.
8 | *
9 | * @see #GPUImageInterface
10 | * @author bonjour
11 | */
12 | public class ProceduralTexture extends GPUImageBaseEffects{
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/gpuimage/utils/FloatPacking.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/src/gpuimage/utils/FloatPacking.java
--------------------------------------------------------------------------------
/src/gpuimage/utils/GPUImageBaseFloatPacking.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/src/gpuimage/utils/GPUImageBaseFloatPacking.java
--------------------------------------------------------------------------------
/src/gpuimage/utils/GPUImageMathsPixels.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/src/gpuimage/utils/GPUImageMathsPixels.java
--------------------------------------------------------------------------------
/src/gpuimage/utils/IntPacking.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/src/gpuimage/utils/IntPacking.java
--------------------------------------------------------------------------------
/src/gpuimage/utils/Vec2Packing.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bonjour-Interactive-Lab/Processing-GPUImage/5e92a907edb4482510aeeb99b20cd17d2fdc90d7/src/gpuimage/utils/Vec2Packing.java
--------------------------------------------------------------------------------