diff --git a/blurs/blur11fast-horizontal-gamma-encode-every-fbo.slang b/blurs/blur11fast-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..d910887 --- /dev/null +++ b/blurs/blur11fast-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11fast-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur11fast-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..36997c4 --- /dev/null +++ b/blurs/blur11fast-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11fast-horizontal-last-pass.slang b/blurs/blur11fast-horizontal-last-pass.slang new file mode 100644 index 0000000..1220392 --- /dev/null +++ b/blurs/blur11fast-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11fast-horizontal.slang b/blurs/blur11fast-horizontal.slang new file mode 100644 index 0000000..72bdcf0 --- /dev/null +++ b/blurs/blur11fast-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11fast-vertical-gamma-encode-every-fbo.slang b/blurs/blur11fast-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..843c0b1 --- /dev/null +++ b/blurs/blur11fast-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11fast-vertical.slang b/blurs/blur11fast-vertical.slang new file mode 100644 index 0000000..1cb691e --- /dev/null +++ b/blurs/blur11fast-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11resize-horizontal-gamma-encode-every-fbo.slang b/blurs/blur11resize-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..c67e1f9 --- /dev/null +++ b/blurs/blur11resize-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11resize-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur11resize-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..e14b773 --- /dev/null +++ b/blurs/blur11resize-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11resize-horizontal-last-pass.slang b/blurs/blur11resize-horizontal-last-pass.slang new file mode 100644 index 0000000..3e105a1 --- /dev/null +++ b/blurs/blur11resize-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11resize-horizontal.slang b/blurs/blur11resize-horizontal.slang new file mode 100644 index 0000000..066df28 --- /dev/null +++ b/blurs/blur11resize-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11resize-vertical-gamma-encode-every-fbo.slang b/blurs/blur11resize-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..160729c --- /dev/null +++ b/blurs/blur11resize-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur11resize-vertical.slang b/blurs/blur11resize-vertical.slang new file mode 100644 index 0000000..90158c5 --- /dev/null +++ b/blurs/blur11resize-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur11resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3fast-horizontal-gamma-encode-every-fbo.slang b/blurs/blur3fast-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..212ab6f --- /dev/null +++ b/blurs/blur3fast-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3fast-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur3fast-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..188c6b4 --- /dev/null +++ b/blurs/blur3fast-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3fast-horizontal-last-pass.slang b/blurs/blur3fast-horizontal-last-pass.slang new file mode 100644 index 0000000..d508039 --- /dev/null +++ b/blurs/blur3fast-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3fast-horizontal.slang b/blurs/blur3fast-horizontal.slang new file mode 100644 index 0000000..4d9d5f4 --- /dev/null +++ b/blurs/blur3fast-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3fast-vertical-gamma-encode-every-fbo.slang b/blurs/blur3fast-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..15a9e6b --- /dev/null +++ b/blurs/blur3fast-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3fast-vertical.slang b/blurs/blur3fast-vertical.slang new file mode 100644 index 0000000..a42c2b8 --- /dev/null +++ b/blurs/blur3fast-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3resize-horizontal-gamma-encode-every-fbo.slang b/blurs/blur3resize-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..c497bf0 --- /dev/null +++ b/blurs/blur3resize-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3resize-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur3resize-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..4eadb90 --- /dev/null +++ b/blurs/blur3resize-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3resize-horizontal-last-pass.slang b/blurs/blur3resize-horizontal-last-pass.slang new file mode 100644 index 0000000..d339ce5 --- /dev/null +++ b/blurs/blur3resize-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3resize-horizontal.slang b/blurs/blur3resize-horizontal.slang new file mode 100644 index 0000000..5cc3f1c --- /dev/null +++ b/blurs/blur3resize-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3resize-vertical-gamma-encode-every-fbo.slang b/blurs/blur3resize-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..35ecc9b --- /dev/null +++ b/blurs/blur3resize-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3resize-vertical.slang b/blurs/blur3resize-vertical.slang new file mode 100644 index 0000000..e5b11ce --- /dev/null +++ b/blurs/blur3resize-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3-gamma-encode-every-fbo.slang b/blurs/blur3x3-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..6af8321 --- /dev/null +++ b/blurs/blur3x3-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3-last-pass-gamma-encode-every-fbo.slang b/blurs/blur3x3-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..2567a41 --- /dev/null +++ b/blurs/blur3x3-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass-resize.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3-last-pass.slang b/blurs/blur3x3-last-pass.slang new file mode 100644 index 0000000..4290a6c --- /dev/null +++ b/blurs/blur3x3-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3.slang b/blurs/blur3x3.slang new file mode 100644 index 0000000..caffdf8 --- /dev/null +++ b/blurs/blur3x3.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3resize-gamma-encode-every-fbo.slang b/blurs/blur3x3resize-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..abc4b1e --- /dev/null +++ b/blurs/blur3x3resize-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass-resize.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3resize-last-pass-gamma-encode-every-fbo.slang b/blurs/blur3x3resize-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..2567a41 --- /dev/null +++ b/blurs/blur3x3resize-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass-resize.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3resize-last-pass.slang b/blurs/blur3x3resize-last-pass.slang new file mode 100644 index 0000000..b430f00 --- /dev/null +++ b/blurs/blur3x3resize-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass-resize.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur3x3resize.slang b/blurs/blur3x3resize.slang new file mode 100644 index 0000000..c72d02f --- /dev/null +++ b/blurs/blur3x3resize.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass-resize.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur3x3resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5fast-horizontal-gamma-encode-every-fbo.slang b/blurs/blur5fast-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..1644912 --- /dev/null +++ b/blurs/blur5fast-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5fast-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur5fast-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..c074006 --- /dev/null +++ b/blurs/blur5fast-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5fast-horizontal-last-pass.slang b/blurs/blur5fast-horizontal-last-pass.slang new file mode 100644 index 0000000..240b90e --- /dev/null +++ b/blurs/blur5fast-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5fast-horizontal.slang b/blurs/blur5fast-horizontal.slang new file mode 100644 index 0000000..b638643 --- /dev/null +++ b/blurs/blur5fast-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5fast-vertical-gamma-encode-every-fbo.slang b/blurs/blur5fast-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..922c71c --- /dev/null +++ b/blurs/blur5fast-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5fast-vertical.slang b/blurs/blur5fast-vertical.slang new file mode 100644 index 0000000..0750af7 --- /dev/null +++ b/blurs/blur5fast-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5resize-horizontal-gamma-encode-every-fbo.slang b/blurs/blur5resize-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..0f4b9ff --- /dev/null +++ b/blurs/blur5resize-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5resize-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur5resize-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..09935ac --- /dev/null +++ b/blurs/blur5resize-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5resize-horizontal-last-pass.slang b/blurs/blur5resize-horizontal-last-pass.slang new file mode 100644 index 0000000..929d899 --- /dev/null +++ b/blurs/blur5resize-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5resize-horizontal.slang b/blurs/blur5resize-horizontal.slang new file mode 100644 index 0000000..baf3430 --- /dev/null +++ b/blurs/blur5resize-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5resize-vertical-gamma-encode-every-fbo.slang b/blurs/blur5resize-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..f59b54d --- /dev/null +++ b/blurs/blur5resize-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5resize-vertical.slang b/blurs/blur5resize-vertical.slang new file mode 100644 index 0000000..061ee15 --- /dev/null +++ b/blurs/blur5resize-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5x5-gamma-encode-every-fbo.slang b/blurs/blur5x5-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..6af815b --- /dev/null +++ b/blurs/blur5x5-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5x5(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5x5-last-pass-gamma-encode-every-fbo.slang b/blurs/blur5x5-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..4019848 --- /dev/null +++ b/blurs/blur5x5-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5x5(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5x5-last-pass.slang b/blurs/blur5x5-last-pass.slang new file mode 100644 index 0000000..80a958f --- /dev/null +++ b/blurs/blur5x5-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5x5(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur5x5.slang b/blurs/blur5x5.slang new file mode 100644 index 0000000..39b01a3 --- /dev/null +++ b/blurs/blur5x5.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur5x5(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7fast-horizontal-gamma-encode-every-fbo.slang b/blurs/blur7fast-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..5e973be --- /dev/null +++ b/blurs/blur7fast-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7fast-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur7fast-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..20b09ab --- /dev/null +++ b/blurs/blur7fast-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7fast-horizontal-last-pass.slang b/blurs/blur7fast-horizontal-last-pass.slang new file mode 100644 index 0000000..dc8029b --- /dev/null +++ b/blurs/blur7fast-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7fast-horizontal.slang b/blurs/blur7fast-horizontal.slang new file mode 100644 index 0000000..9f0bb91 --- /dev/null +++ b/blurs/blur7fast-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7fast-vertical-gamma-encode-every-fbo.slang b/blurs/blur7fast-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..6ead23e --- /dev/null +++ b/blurs/blur7fast-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7fast-vertical.slang b/blurs/blur7fast-vertical.slang new file mode 100644 index 0000000..bff459e --- /dev/null +++ b/blurs/blur7fast-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7resize-horizontal-gamma-encode-every-fbo.slang b/blurs/blur7resize-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..afcbb86 --- /dev/null +++ b/blurs/blur7resize-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7resize-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur7resize-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..f4f497b --- /dev/null +++ b/blurs/blur7resize-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7resize-horizontal-last-pass.slang b/blurs/blur7resize-horizontal-last-pass.slang new file mode 100644 index 0000000..2183817 --- /dev/null +++ b/blurs/blur7resize-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7resize-horizontal.slang b/blurs/blur7resize-horizontal.slang new file mode 100644 index 0000000..4726b55 --- /dev/null +++ b/blurs/blur7resize-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7resize-vertical-gamma-encode-every-fbo.slang b/blurs/blur7resize-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..18cb379 --- /dev/null +++ b/blurs/blur7resize-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7resize-vertical.slang b/blurs/blur7resize-vertical.slang new file mode 100644 index 0000000..250e84d --- /dev/null +++ b/blurs/blur7resize-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7x7-gamma-encode-every-fbo.slang b/blurs/blur7x7-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..82aa0cb --- /dev/null +++ b/blurs/blur7x7-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7x7(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7x7-last-pass-gamma-encode-every-fbo.slang b/blurs/blur7x7-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..1d2b266 --- /dev/null +++ b/blurs/blur7x7-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7x7(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7x7-last-pass.slang b/blurs/blur7x7-last-pass.slang new file mode 100644 index 0000000..5967195 --- /dev/null +++ b/blurs/blur7x7-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7x7(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur7x7.slang b/blurs/blur7x7.slang new file mode 100644 index 0000000..9e5fd8a --- /dev/null +++ b/blurs/blur7x7.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur7x7(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9fast-horizontal-gamma-encode-every-fbo.slang b/blurs/blur9fast-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..a84e349 --- /dev/null +++ b/blurs/blur9fast-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9fast-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur9fast-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..645bee6 --- /dev/null +++ b/blurs/blur9fast-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9fast-horizontal-last-pass.slang b/blurs/blur9fast-horizontal-last-pass.slang new file mode 100644 index 0000000..12c6207 --- /dev/null +++ b/blurs/blur9fast-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9fast-horizontal.slang b/blurs/blur9fast-horizontal.slang index 78f6a91..4a48784 100644 --- a/blurs/blur9fast-horizontal.slang +++ b/blurs/blur9fast-horizontal.slang @@ -58,30 +58,9 @@ layout(std140, set = 0, binding = 0) uniform UBO #include "../include/blur-functions.h" #pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 tex_uv; -layout(location = 1) out vec2 blur_dxdy; +#include "vertex-shader-blur-fast-horizontal.h" -void main() -{ - gl_Position = global.MVP * Position; - tex_uv = TexCoord; - - // Get the uv sample distance between output pixels. Blurs are not generic - // Gaussian resizers, and correct blurs require: - // 1.) params.OutputSize.xy == params.SourceSize.xy * 2^m, where m is an integer <= 0. - // 2.) mipmap_inputN = "true" for this pass in preset if m != 0 - // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs - // Gaussian resizers would upsize using the distance between input texels - // (not output pixels), but we avoid this and consistently blur at the - // destination size. Otherwise, combining statically calculated weights - // with bilinear sample exploitation would result in terrible artifacts. - const vec2 dxdy_scale = vec2(1.0);//params.SourceSize.xy * params.OutputSize.zw; - const vec2 dxdy = dxdy_scale * params.SourceSize.zw; - // This blur is horizontal-only, so zero out the vertical offset: - blur_dxdy = vec2(dxdy.x, 0.0); -} +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// #pragma stage fragment layout(location = 0) in vec2 tex_uv; diff --git a/blurs/blur9fast-vertical-gamma-encode-every-fbo.slang b/blurs/blur9fast-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..c351fbf --- /dev/null +++ b/blurs/blur9fast-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-fast-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9fast(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9fast-vertical.slang b/blurs/blur9fast-vertical.slang index 2cdfbd5..2e0e1f1 100644 --- a/blurs/blur9fast-vertical.slang +++ b/blurs/blur9fast-vertical.slang @@ -58,30 +58,9 @@ layout(std140, set = 0, binding = 0) uniform UBO #include "../include/blur-functions.h" #pragma stage vertex -layout(location = 0) in vec4 Position; -layout(location = 1) in vec2 TexCoord; -layout(location = 0) out vec2 tex_uv; -layout(location = 1) out vec2 blur_dxdy; +#include "vertex-shader-blur-fast-vertical.h" -void main() -{ - gl_Position = global.MVP * Position; - tex_uv = TexCoord; - - // Get the uv sample distance between output pixels. Blurs are not generic - // Gaussian resizers, and correct blurs require: - // 1.) params.OutputSize.xy == params.SourceSize.xy * 2^m, where m is an integer <= 0. - // 2.) mipmap_inputN = "true" for this pass in preset if m != 0 - // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs - // Gaussian resizers would upsize using the distance between input texels - // (not output pixels), but we avoid this and consistently blur at the - // destination size. Otherwise, combining statically calculated weights - // with bilinear sample exploitation would result in terrible artifacts. - const vec2 dxdy_scale = vec2(1.0);//params.SourceSize.xy * params.OutputSize.zw; - const vec2 dxdy = dxdy_scale * params.SourceSize.zw; - // This blur is vertical-only, so zero out the vertical offset: - blur_dxdy = vec2(0.0, dxdy.y); -} +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// #pragma stage fragment layout(location = 0) in vec2 tex_uv; diff --git a/blurs/blur9resize-horizontal-gamma-encode-every-fbo.slang b/blurs/blur9resize-horizontal-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..e50fb4b --- /dev/null +++ b/blurs/blur9resize-horizontal-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9resize-horizontal-last-pass-gamma-encode-every-fbo.slang b/blurs/blur9resize-horizontal-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..0a436c8 --- /dev/null +++ b/blurs/blur9resize-horizontal-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9resize-horizontal-last-pass.slang b/blurs/blur9resize-horizontal-last-pass.slang new file mode 100644 index 0000000..71a5b0c --- /dev/null +++ b/blurs/blur9resize-horizontal-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9resize-horizontal.slang b/blurs/blur9resize-horizontal.slang new file mode 100644 index 0000000..11248b9 --- /dev/null +++ b/blurs/blur9resize-horizontal.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-horizontal.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9resize-vertical-gamma-encode-every-fbo.slang b/blurs/blur9resize-vertical-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..cdf42d3 --- /dev/null +++ b/blurs/blur9resize-vertical-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9resize-vertical.slang b/blurs/blur9resize-vertical.slang new file mode 100644 index 0000000..20426cc --- /dev/null +++ b/blurs/blur9resize-vertical.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-resize-vertical.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9resize(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9x9-gamma-encode-every-fbo.slang b/blurs/blur9x9-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..e9c074b --- /dev/null +++ b/blurs/blur9x9-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9x9(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9x9-last-pass-gamma-encode-every-fbo.slang b/blurs/blur9x9-last-pass-gamma-encode-every-fbo.slang new file mode 100644 index 0000000..d3dedf2 --- /dev/null +++ b/blurs/blur9x9-last-pass-gamma-encode-every-fbo.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9x9(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9x9-last-pass.slang b/blurs/blur9x9-last-pass.slang new file mode 100644 index 0000000..cb6a5ce --- /dev/null +++ b/blurs/blur9x9-last-pass.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9x9(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/blur9x9.slang b/blurs/blur9x9.slang new file mode 100644 index 0000000..ed1c665 --- /dev/null +++ b/blurs/blur9x9.slang @@ -0,0 +1,76 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// gamma-management.h needs to know what kind of pipeline we're using and +// what pass this is in that pipeline. This will become obsolete if/when we +// can #define things like this in the .cgp preset file. +//#define GAMMA_ENCODE_EVERY_FBO +//#define FIRST_PASS +//#define LAST_PASS +//#define SIMULATE_CRT_ON_LCD +//#define SIMULATE_GBA_ON_LCD +//#define SIMULATE_LCD_ON_CRT +//#define SIMULATE_GBA_ON_CRT + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +// #included by vertex shader: +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +#include "vertex-shader-blur-one-pass.h" + +/////////////////////////////// FRAGMENT SHADER ////////////////////////////// + +#pragma stage fragment +layout(location = 0) in vec2 tex_uv; +layout(location = 1) in vec2 blur_dxdy; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +void main() +{ + vec3 color = tex2Dblur9x9(Source, tex_uv, blur_dxdy); + // Encode and output the blurred image: + FragColor = encode_output(vec4(color, 1.0)); +} \ No newline at end of file diff --git a/blurs/vertex-shader-blur-fast-horizontal.h b/blurs/vertex-shader-blur-fast-horizontal.h new file mode 100644 index 0000000..78390a6 --- /dev/null +++ b/blurs/vertex-shader-blur-fast-horizontal.h @@ -0,0 +1,62 @@ +#ifndef VERTEX_SHADER_BLUR_FAST_HORIZONTAL_H +#define VERTEX_SHADER_BLUR_FAST_HORIZONTAL_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in .cgp preset if m != 0 + // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs + // Gaussian resizers would upsize using the distance between input texels + // (not output pixels), but we avoid this and consistently blur at the + // destination size. Otherwise, combining statically calculated weights + // with bilinear sample exploitation would result in terrible artifacts. + const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw; + const vec2 dxdy = dxdy_scale * params.SourceSize.zw; + // This blur is horizontal-only, so zero out the vertical offset: + blur_dxdy = vec2(dxdy.x, 0.0); +} + +#endif // VERTEX_SHADER_BLUR_FAST_HORIZONTAL_H \ No newline at end of file diff --git a/blurs/vertex-shader-blur-fast-vertical.h b/blurs/vertex-shader-blur-fast-vertical.h new file mode 100644 index 0000000..cd324a0 --- /dev/null +++ b/blurs/vertex-shader-blur-fast-vertical.h @@ -0,0 +1,64 @@ +#ifndef VERTEX_SHADER_BLUR_FAST_VERTICAL_H +#define VERTEX_SHADER_BLUR_FAST_VERTICAL_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in .cgp preset if m != 0 + // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs + // Gaussian resizers would upsize using the distance between input texels + // (not output pixels), but we avoid this and consistently blur at the + // destination size. Otherwise, combining statically calculated weights + // with bilinear sample exploitation would result in terrible artifacts. + const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw; + const vec2 dxdy = dxdy_scale * params.SourceSize.zw; + // This blur is vertical-only, so zero out the horizontal offset: + blur_dxdy = vec2(0.0, dxdy.y); +} + +#endif // VERTEX_SHADER_BLUR_FAST_VERTICAL_H \ No newline at end of file diff --git a/blurs/vertex-shader-blur-one-pass-resize.h b/blurs/vertex-shader-blur-one-pass-resize.h new file mode 100644 index 0000000..3321625 --- /dev/null +++ b/blurs/vertex-shader-blur-one-pass-resize.h @@ -0,0 +1,62 @@ +#ifndef VERTEX_SHADER_BLUR_ONE_PASS_RESIZE_H +#define VERTEX_SHADER_BLUR_ONE_PASS_RESIZE_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in .cgp preset if m != 0 + // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs + // Arbitrary upsizing will be acceptable if filter_linearN = "true", and + // arbitrary downsizing will be acceptable if mipmap_inputN = "true" too. + // Only the "resize" blurs can manage this though, and they still aren't + // proper Gaussian resizers (because they sample between texels and always + // blur after resizing, not during). + const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw; + blur_dxdy = dxdy_scale * params.SourceSize.zw; +} + +#endif // VERTEX_SHADER_BLUR_ONE_PASS_H \ No newline at end of file diff --git a/blurs/vertex-shader-blur-one-pass-shared-sample.h b/blurs/vertex-shader-blur-one-pass-shared-sample.h new file mode 100644 index 0000000..fd960d4 --- /dev/null +++ b/blurs/vertex-shader-blur-one-pass-shared-sample.h @@ -0,0 +1,77 @@ +#ifndef VERTEX_SHADER_BLUR_ONE_PASS_SHARED_SAMPLE_H +#define VERTEX_SHADER_BLUR_ONE_PASS_SHARED_SAMPLE_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec4 output_pixel_num; +layout(location = 2) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in the preset if m < 0 + // 3.) filter_linearN = "true" for all one-pass blurs + // 4.) #define DRIVERS_ALLOW_TEX2DLOD for shared-sample blurs + // Gaussian resizers would upsize using the distance between input texels + // (not output pixels), but we avoid this and consistently blur at the + // destination size. Otherwise, combining statically calculated weights + // with bilinear sample exploitation would result in terrible artifacts. + const vec2 dxdy_scale params.SourceSize.xy * params.OutputSize.zw; + blur_dxdy = dxdy_scale * params.SourceSize.zw; + + // Get the output pixel number in ([0, xres), [0, yres)) with respect to + // the uv origin (.xy components) and the screen origin (.zw components). + // Both are useful. Don't round until the fragment shader. + const float2 video_uv = tex_uv; + output_pixel_num.xy = params.OutputSize.xy * vec2(video_uv.x, video_uv.y); + output_pixel_num.zw = params.OutputSize.xy * + (out_position.xy * 0.5 + vec2(0.5)); + + // Set the mip level correctly for shared-sample blurs (where the + // derivatives are unreliable): + const float mip_level = log2(params.SourceSize.xy * params.OutputSize.zw).y; + tex_uv = vec4(tex_uv, 0.0, mip_level); +} + +#endif // VERTEX_SHADER_BLUR_ONE_PASS_SHARED_SAMPLE_H \ No newline at end of file diff --git a/blurs/vertex-shader-blur-one-pass.h b/blurs/vertex-shader-blur-one-pass.h new file mode 100644 index 0000000..d94a6df --- /dev/null +++ b/blurs/vertex-shader-blur-one-pass.h @@ -0,0 +1,62 @@ +#ifndef VERTEX_SHADER_BLUR_ONE_PASS_H +#define VERTEX_SHADER_BLUR_ONE_PASS_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in the preset if m < 0 + // 3.) filter_linearN = "true" for all one-pass blurs + // Gaussian resizers would upsize using the distance between input texels + // (not output pixels), but we avoid this and consistently blur at the + // destination size. Otherwise, combining statically calculated weights + // with bilinear sample exploitation would result in terrible artifacts. + const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw; + blur_dxdy = dxdy_scale * params.SourceSize.zw; +} + +#endif // VERTEX_SHADER_BLUR_ONE_PASS_H \ No newline at end of file diff --git a/blurs/vertex-shader-blur-resize-horizontal.h b/blurs/vertex-shader-blur-resize-horizontal.h new file mode 100644 index 0000000..66b2179 --- /dev/null +++ b/blurs/vertex-shader-blur-resize-horizontal.h @@ -0,0 +1,65 @@ +#ifndef VERTEX_SHADER_BLUR_RESIZE_HORIZONTAL_H +#define VERTEX_SHADER_BLUR_RESIZE_HORIZONTAL_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in .cgp preset if m != 0 + // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs + // Arbitrary upsizing will be acceptable if filter_linearN = "true", and + // arbitrary downsizing will be acceptable if mipmap_inputN = "true" too. + // Only the "resize" blurs can manage this though, and they still aren't + // proper Gaussian resizers (because they sample between texels and always + // blur after resizing, not during). + const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw; + const vec2 dxdy = dxdy_scale * params.SourceSize.zw; + // This blur is horizontal-only, so zero out the vertical offset: + blur_dxdy = vec2(dxdy.x, 0.0); +} + +#endif // VERTEX_SHADER_BLUR_RESIZE_HORIZONTAL_H \ No newline at end of file diff --git a/blurs/vertex-shader-blur-resize-vertical.h b/blurs/vertex-shader-blur-resize-vertical.h new file mode 100644 index 0000000..41fbe2b --- /dev/null +++ b/blurs/vertex-shader-blur-resize-vertical.h @@ -0,0 +1,65 @@ +#ifndef VERTEX_SHADER_BLUR_RESIZE_VERTICAL_H +#define VERTEX_SHADER_BLUR_RESIZE_VERTICAL_H + +///////////////////////////////// MIT LICENSE //////////////////////////////// + +// Copyright (C) 2014 TroggleMonkey +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + + +///////////////////////////// SETTINGS MANAGEMENT //////////////////////////// + +// PASS SETTINGS: +// Pass settings should be set by the shader file that #includes this one. + + +////////////////////////////////// INCLUDES ////////////////////////////////// + +#include "../include/gamma-management.h" +#include "../include/blur-functions.h" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 tex_uv; +layout(location = 1) out vec2 blur_dxdy; + +void main() +{ + gl_Position = global.MVP * Position; + tex_uv = TexCoord; + + // Get the uv sample distance between output pixels. Blurs are not generic + // Gaussian resizers, and correct blurs require: + // 1.) OutputSize.xy == SourceSize.xy * 2^m, where m is an integer <= 0. + // 2.) mipmap_inputN = "true" for this pass in .cgp preset if m != 0 + // 3.) filter_linearN = "true" except for 1x scale nearest neighbor blurs + // Arbitrary upsizing will be acceptable if filter_linearN = "true", and + // arbitrary downsizing will be acceptable if mipmap_inputN = "true" too. + // Only the "resize" blurs can manage this though, and they still aren't + // proper Gaussian resizers (because they sample between texels and always + // blur after resizing, not during). + const vec2 dxdy_scale = params.SourceSize.xy * params.OutputSize.zw; + const vec2 dxdy = dxdy_scale * params.SourceSize.zw; + // This blur is vertical-only, so zero out the horizontal offset: + blur_dxdy = vec2(0.0, dxdy.y); +} + +#endif // VERTEX_SHADER_BLUR_RESIZE_VERTICAL_H \ No newline at end of file diff --git a/include/blur-functions.h b/include/blur-functions.h index 41dfd4c..bfef056 100644 --- a/include/blur-functions.h +++ b/include/blur-functions.h @@ -241,6 +241,176 @@ float get_fast_gaussian_weight_sum_inv(const float sigma) (sigma - 0.0860587260734721))), 0.399334576340352/sigma); } +//////////////////// ARBITRARILY RESIZABLE SEPARABLE BLURS /////////////////// + +vec3 tex2Dblur11resize(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Global requirements must be met (see file description). + // Returns: A 1D 11x Gaussian blurred texture lookup using a 11-tap blur. + // It may be mipmapped depending on settings and dxdy. + // Calculate Gaussian blur kernel weights and a normalization factor for + // distances of 0-4, ignoring constant factors (since we're normalizing). + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float w3 = exp(-9.0 * denom_inv); + const float w4 = exp(-16.0 * denom_inv); + const float w5 = exp(-25.0 * denom_inv); + const float weight_sum_inv = 1.0 / + (w0 + 2.0 * (w1 + w2 + w3 + w4 + w5)); + // Statically normalize weights, sum weighted samples, and return. Blurs are + // currently optimized for dynamic weights. + vec3 sum = vec3(0.0); + sum += w5 * tex2D_linearize(tex, tex_uv - 5.0 * dxdy).rgb; + sum += w4 * tex2D_linearize(tex, tex_uv - 4.0 * dxdy).rgb; + sum += w3 * tex2D_linearize(tex, tex_uv - 3.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv - 2.0 * dxdy).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv - 1.0 * dxdy).rgb; + sum += w0 * tex2D_linearize(tex, tex_uv).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv + 1.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv + 2.0 * dxdy).rgb; + sum += w3 * tex2D_linearize(tex, tex_uv + 3.0 * dxdy).rgb; + sum += w4 * tex2D_linearize(tex, tex_uv + 4.0 * dxdy).rgb; + sum += w5 * tex2D_linearize(tex, tex_uv + 5.0 * dxdy).rgb; + return sum * weight_sum_inv; +} + +vec3 tex2Dblur9resize(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Global requirements must be met (see file description). + // Returns: A 1D 9x Gaussian blurred texture lookup using a 9-tap blur. + // It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float w3 = exp(-9.0 * denom_inv); + const float w4 = exp(-16.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * (w1 + w2 + w3 + w4)); + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w4 * tex2D_linearize(tex, tex_uv - 4.0 * dxdy).rgb; + sum += w3 * tex2D_linearize(tex, tex_uv - 3.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv - 2.0 * dxdy).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv - 1.0 * dxdy).rgb; + sum += w0 * tex2D_linearize(tex, tex_uv).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv + 1.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv + 2.0 * dxdy).rgb; + sum += w3 * tex2D_linearize(tex, tex_uv + 3.0 * dxdy).rgb; + sum += w4 * tex2D_linearize(tex, tex_uv + 4.0 * dxdy).rgb; + return sum * weight_sum_inv; +} + +vec3 tex2Dblur7resize(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Global requirements must be met (see file description). + // Returns: A 1D 7x Gaussian blurred texture lookup using a 7-tap blur. + // It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float w3 = exp(-9.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * (w1 + w2 + w3)); + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w3 * tex2D_linearize(tex, tex_uv - 3.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv - 2.0 * dxdy).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv - 1.0 * dxdy).rgb; + sum += w0 * tex2D_linearize(tex, tex_uv).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv + 1.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv + 2.0 * dxdy).rgb; + sum += w3 * tex2D_linearize(tex, tex_uv + 3.0 * dxdy).rgb; + return sum * weight_sum_inv; +} + +vec3 tex2Dblur5resize(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Global requirements must be met (see file description). + // Returns: A 1D 5x Gaussian blurred texture lookup using a 5-tap blur. + // It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * (w1 + w2)); + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w2 * tex2D_linearize(tex, tex_uv - 2.0 * dxdy).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv - 1.0 * dxdy).rgb; + sum += w0 * tex2D_linearize(tex, tex_uv).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv + 1.0 * dxdy).rgb; + sum += w2 * tex2D_linearize(tex, tex_uv + 2.0 * dxdy).rgb; + return sum * weight_sum_inv; +} + +vec3 tex2Dblur3resize(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Global requirements must be met (see file description). + // Returns: A 1D 3x Gaussian blurred texture lookup using a 3-tap blur. + // It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * w1); + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w1 * tex2D_linearize(tex, tex_uv - 1.0 * dxdy).rgb; + sum += w0 * tex2D_linearize(tex, tex_uv).rgb; + sum += w1 * tex2D_linearize(tex, tex_uv + 1.0 * dxdy).rgb; + return sum * weight_sum_inv; +} + +/////////////////////////// FAST SEPARABLE BLURS /////////////////////////// + +vec3 tex2Dblur11fast(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: 1.) Global requirements must be met (see file description). + // 2.) filter_linearN must = "true" in your .cgp file. + // 3.) For gamma-correct bilinear filtering, global + // gamma_aware_bilinear == true (from gamma-management.h) + // Returns: A 1D 11x Gaussian blurred texture lookup using 6 linear + // taps. It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float w3 = exp(-9.0 * denom_inv); + const float w4 = exp(-16.0 * denom_inv); + const float w5 = exp(-25.0 * denom_inv); + const float weight_sum_inv = 1.0 / + (w0 + 2.0 * (w1 + w2 + w3 + w4 + w5)); + // Calculate combined weights and linear sample ratios between texel pairs. + // The center texel (with weight w0) is used twice, so halve its weight. + const float w01 = w0 * 0.5 + w1; + const float w23 = w2 + w3; + const float w45 = w4 + w5; + const float w01_ratio = w1/w01; + const float w23_ratio = w3/w23; + const float w45_ratio = w5/w45; + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w45 * tex2D_linearize(tex, tex_uv - (4.0 + w45_ratio) * dxdy).rgb; + sum += w23 * tex2D_linearize(tex, tex_uv - (2.0 + w23_ratio) * dxdy).rgb; + sum += w01 * tex2D_linearize(tex, tex_uv - w01_ratio * dxdy).rgb; + sum += w01 * tex2D_linearize(tex, tex_uv + w01_ratio * dxdy).rgb; + sum += w23 * tex2D_linearize(tex, tex_uv + (2.0 + w23_ratio) * dxdy).rgb; + sum += w45 * tex2D_linearize(tex, tex_uv + (4.0 + w45_ratio) * dxdy).rgb; + return sum * weight_sum_inv; +} + vec3 tex2Dblur17fast(const sampler2D tex, const vec2 tex_uv, const vec2 dxdy, const float sigma) { @@ -493,6 +663,79 @@ vec3 tex2Dblur43fast(const sampler2D tex, const vec2 tex_uv, return sum * weight_sum_inv; } +vec3 tex2Dblur3fast(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Same as tex2Dblur11() + // Returns: A 1D 3x Gaussian blurred texture lookup using 2 linear + // taps. It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * w1); + // Calculate combined weights and linear sample ratios between texel pairs. + // The center texel (with weight w0) is used twice, so halve its weight. + const float w01 = w0 * 0.5 + w1; + const float w01_ratio = w1/w01; + // Weights for all samples are the same, so just average them: + return 0.5 * ( + tex2D_linearize(tex, tex_uv - w01_ratio * dxdy).rgb + + tex2D_linearize(tex, tex_uv + w01_ratio * dxdy).rgb); +} + +vec3 tex2Dblur5fast(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Same as tex2Dblur11() + // Returns: A 1D 5x Gaussian blurred texture lookup using 1 nearest + // neighbor and 2 linear taps. It may be mipmapped depending + // on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * (w1 + w2)); + // Calculate combined weights and linear sample ratios between texel pairs. + const float w12 = w1 + w2; + const float w12_ratio = w2/w12; + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w12 * tex2D_linearize(tex, tex_uv - (1.0 + w12_ratio) * dxdy).rgb; + sum += w0 * tex2D_linearize(tex, tex_uv).rgb; + sum += w12 * tex2D_linearize(tex, tex_uv + (1.0 + w12_ratio) * dxdy).rgb; + return sum * weight_sum_inv; +} + +vec3 tex2Dblur7fast(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Requires: Same as tex2Dblur11() + // Returns: A 1D 7x Gaussian blurred texture lookup using 4 linear + // taps. It may be mipmapped depending on settings and dxdy. + // First get the texel weights and normalization factor as above. + const float denom_inv = 0.5/(sigma*sigma); + const float w0 = 1.0; + const float w1 = exp(-1.0 * denom_inv); + const float w2 = exp(-4.0 * denom_inv); + const float w3 = exp(-9.0 * denom_inv); + const float weight_sum_inv = 1.0 / (w0 + 2.0 * (w1 + w2 + w3)); + // Calculate combined weights and linear sample ratios between texel pairs. + // The center texel (with weight w0) is used twice, so halve its weight. + const float w01 = w0 * 0.5 + w1; + const float w23 = w2 + w3; + const float w01_ratio = w1/w01; + const float w23_ratio = w3/w23; + // Statically normalize weights, sum weighted samples, and return: + vec3 sum = vec3(0.0); + sum += w23 * tex2D_linearize(tex, tex_uv - (2.0 + w23_ratio) * dxdy).rgb; + sum += w01 * tex2D_linearize(tex, tex_uv - w01_ratio * dxdy).rgb; + sum += w01 * tex2D_linearize(tex, tex_uv + w01_ratio * dxdy).rgb; + sum += w23 * tex2D_linearize(tex, tex_uv + (2.0 + w23_ratio) * dxdy).rgb; + return sum * weight_sum_inv; +} + //////////////////// ARBITRARILY RESIZABLE ONE-PASS BLURS //////////////////// vec3 tex2Dblur3x3resize(const sampler2D tex, const vec2 tex_uv, @@ -571,6 +814,360 @@ vec3 tex2Dblur9fast(const sampler2D tex, const vec2 tex_uv, return sum * weight_sum_inv; } +vec3 tex2Dblur9x9(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Perform a 1-pass 9x9 blur with 5x5 bilinear samples. + // Requires: Same as tex2Dblur9() + // Returns: A 9x9 Gaussian blurred mipmapped texture lookup composed of + // 5x5 carefully selected bilinear samples. + // Description: + // Perform a 1-pass 9x9 blur with 5x5 bilinear samples. Adjust the + // bilinear sample location to reflect the true Gaussian weights for each + // underlying texel. The following diagram illustrates the relative + // locations of bilinear samples. Each sample with the same number has the + // same weight (notice the symmetry). The letters a, b, c, d distinguish + // quadrants, and the letters U, D, L, R, C (up, down, left, right, center) + // distinguish 1D directions along the line containing the pixel center: + // 6a 5a 2U 5b 6b + // 4a 3a 1U 3b 4b + // 2L 1L 0C 1R 2R + // 4c 3c 1D 3d 4d + // 6c 5c 2D 5d 6d + // The following diagram illustrates the underlying equally spaced texels, + // named after the sample that accesses them and subnamed by their location + // within their 2x2, 2x1, 1x2, or 1x1 texel block: + // 6a4 6a3 5a4 5a3 2U2 5b3 5b4 6b3 6b4 + // 6a2 6a1 5a2 5a1 2U1 5b1 5b2 6b1 6b2 + // 4a4 4a3 3a4 3a3 1U2 3b3 3b4 4b3 4b4 + // 4a2 4a1 3a2 3a1 1U1 3b1 3b2 4b1 4b2 + // 2L2 2L1 1L2 1L1 0C1 1R1 1R2 2R1 2R2 + // 4c2 4c1 3c2 3c1 1D1 3d1 3d2 4d1 4d2 + // 4c4 4c3 3c4 3c3 1D2 3d3 3d4 4d3 4d4 + // 6c2 6c1 5c2 5c1 2D1 5d1 5d2 6d1 6d2 + // 6c4 6c3 5c4 5c3 2D2 5d3 5d4 6d3 6d4 + // Note there is only one C texel and only two texels for each U, D, L, or + // R sample. The center sample is effectively a nearest neighbor sample, + // and the U/D/L/R samples use 1D linear filtering. All other texels are + // read with bilinear samples somewhere within their 2x2 texel blocks. + + // COMPUTE TEXTURE COORDS: + // Statically compute sampling offsets within each 2x2 texel block, based + // on 1D sampling ratios between texels [1, 2] and [3, 4] texels away from + // the center, and reuse them independently for both dimensions. Compute + // these offsets based on the relative 1D Gaussian weights of the texels + // in question. (w1off means "Gaussian weight for the texel 1.0 texels + // away from the pixel center," etc.). + const float denom_inv = 0.5/(sigma*sigma); + const float w1off = exp(-1.0 * denom_inv); + const float w2off = exp(-4.0 * denom_inv); + const float w3off = exp(-9.0 * denom_inv); + const float w4off = exp(-16.0 * denom_inv); + const float texel1to2ratio = w2off/(w1off + w2off); + const float texel3to4ratio = w4off/(w3off + w4off); + // Statically compute texel offsets from the fragment center to each + // bilinear sample in the bottom-right quadrant, including x-axis-aligned: + const vec2 sample1R_texel_offset = vec2(1.0, 0.0) + vec2(texel1to2ratio, 0.0); + const vec2 sample2R_texel_offset = vec2(3.0, 0.0) + vec2(texel3to4ratio, 0.0); + const vec2 sample3d_texel_offset = vec2(1.0, 1.0) + vec2(texel1to2ratio, texel1to2ratio); + const vec2 sample4d_texel_offset = vec2(3.0, 1.0) + vec2(texel3to4ratio, texel1to2ratio); + const vec2 sample5d_texel_offset = vec2(1.0, 3.0) + vec2(texel1to2ratio, texel3to4ratio); + const vec2 sample6d_texel_offset = vec2(3.0, 3.0) + vec2(texel3to4ratio, texel3to4ratio); + + // CALCULATE KERNEL WEIGHTS FOR ALL SAMPLES: + // Statically compute Gaussian texel weights for the bottom-right quadrant. + // Read underscores as "and." + const float w1R1 = w1off; + const float w1R2 = w2off; + const float w2R1 = w3off; + const float w2R2 = w4off; + const float w3d1 = exp(-LENGTH_SQ(vec2(1.0, 1.0)) * denom_inv); + const float w3d2_3d3 = exp(-LENGTH_SQ(vec2(2.0, 1.0)) * denom_inv); + const float w3d4 = exp(-LENGTH_SQ(vec2(2.0, 2.0)) * denom_inv); + const float w4d1_5d1 = exp(-LENGTH_SQ(vec2(3.0, 1.0)) * denom_inv); + const float w4d2_5d3 = exp(-LENGTH_SQ(vec2(4.0, 1.0)) * denom_inv); + const float w4d3_5d2 = exp(-LENGTH_SQ(vec2(3.0, 2.0)) * denom_inv); + const float w4d4_5d4 = exp(-LENGTH_SQ(vec2(4.0, 2.0)) * denom_inv); + const float w6d1 = exp(-LENGTH_SQ(vec2(3.0, 3.0)) * denom_inv); + const float w6d2_6d3 = exp(-LENGTH_SQ(vec2(4.0, 3.0)) * denom_inv); + const float w6d4 = exp(-LENGTH_SQ(vec2(4.0, 4.0)) * denom_inv); + // Statically add texel weights in each sample to get sample weights: + const float w0 = 1.0; + const float w1 = w1R1 + w1R2; + const float w2 = w2R1 + w2R2; + const float w3 = w3d1 + 2.0 * w3d2_3d3 + w3d4; + const float w4 = w4d1_5d1 + w4d2_5d3 + w4d3_5d2 + w4d4_5d4; + const float w5 = w4; + const float w6 = w6d1 + 2.0 * w6d2_6d3 + w6d4; + // Get the weight sum inverse (normalization factor): + const float weight_sum_inv = + 1.0/(w0 + 4.0 * (w1 + w2 + w3 + w4 + w5 + w6)); + + // LOAD TEXTURE SAMPLES: + // Load all 25 samples (1 nearest, 8 linear, 16 bilinear) using symmetry: + const vec2 mirror_x = vec2(-1.0, 1.0); + const vec2 mirror_y = vec2(1.0, -1.0); + const vec2 mirror_xy = vec2(-1.0, -1.0); + const vec2 dxdy_mirror_x = dxdy * mirror_x; + const vec2 dxdy_mirror_y = dxdy * mirror_y; + const vec2 dxdy_mirror_xy = dxdy * mirror_xy; + // Sampling order doesn't seem to affect performance, so just be clear: + const vec3 sample0C = tex2D_linearize(tex, tex_uv).rgb; + const vec3 sample1R = tex2D_linearize(tex, tex_uv + dxdy * sample1R_texel_offset).rgb; + const vec3 sample1D = tex2D_linearize(tex, tex_uv + dxdy * sample1R_texel_offset.yx).rgb; + const vec3 sample1L = tex2D_linearize(tex, tex_uv - dxdy * sample1R_texel_offset).rgb; + const vec3 sample1U = tex2D_linearize(tex, tex_uv - dxdy * sample1R_texel_offset.yx).rgb; + const vec3 sample2R = tex2D_linearize(tex, tex_uv + dxdy * sample2R_texel_offset).rgb; + const vec3 sample2D = tex2D_linearize(tex, tex_uv + dxdy * sample2R_texel_offset.yx).rgb; + const vec3 sample2L = tex2D_linearize(tex, tex_uv - dxdy * sample2R_texel_offset).rgb; + const vec3 sample2U = tex2D_linearize(tex, tex_uv - dxdy * sample2R_texel_offset.yx).rgb; + const vec3 sample3d = tex2D_linearize(tex, tex_uv + dxdy * sample3d_texel_offset).rgb; + const vec3 sample3c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample3d_texel_offset).rgb; + const vec3 sample3b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample3d_texel_offset).rgb; + const vec3 sample3a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample3d_texel_offset).rgb; + const vec3 sample4d = tex2D_linearize(tex, tex_uv + dxdy * sample4d_texel_offset).rgb; + const vec3 sample4c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample4d_texel_offset).rgb; + const vec3 sample4b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample4d_texel_offset).rgb; + const vec3 sample4a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample4d_texel_offset).rgb; + const vec3 sample5d = tex2D_linearize(tex, tex_uv + dxdy * sample5d_texel_offset).rgb; + const vec3 sample5c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample5d_texel_offset).rgb; + const vec3 sample5b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample5d_texel_offset).rgb; + const vec3 sample5a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample5d_texel_offset).rgb; + const vec3 sample6d = tex2D_linearize(tex, tex_uv + dxdy * sample6d_texel_offset).rgb; + const vec3 sample6c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample6d_texel_offset).rgb; + const vec3 sample6b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample6d_texel_offset).rgb; + const vec3 sample6a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample6d_texel_offset).rgb; + + // SUM WEIGHTED SAMPLES: + // Statically normalize weights (so total = 1.0), and sum weighted samples. + vec3 sum = w0 * sample0C; + sum += w1 * (sample1R + sample1D + sample1L + sample1U); + sum += w2 * (sample2R + sample2D + sample2L + sample2U); + sum += w3 * (sample3d + sample3c + sample3b + sample3a); + sum += w4 * (sample4d + sample4c + sample4b + sample4a); + sum += w5 * (sample5d + sample5c + sample5b + sample5a); + sum += w6 * (sample6d + sample6c + sample6b + sample6a); + return sum * weight_sum_inv; +} + +vec3 tex2Dblur7x7(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Perform a 1-pass 7x7 blur with 5x5 bilinear samples. + // Requires: Same as tex2Dblur9() + // Returns: A 7x7 Gaussian blurred mipmapped texture lookup composed of + // 4x4 carefully selected bilinear samples. + // Description: + // First see the descriptions for tex2Dblur9x9() and tex2Dblur7(). This + // blur mixes concepts from both. The sample layout is as follows: + // 4a 3a 3b 4b + // 2a 1a 1b 2b + // 2c 1c 1d 2d + // 4c 3c 3d 4d + // The texel layout is as follows. Note that samples 3a/3b, 1a/1b, 1c/1d, + // and 3c/3d share a vertical column of texels, and samples 2a/2c, 1a/1c, + // 1b/1d, and 2b/2d share a horizontal row of texels (all sample1's share + // the center texel): + // 4a4 4a3 3a4 3ab3 3b4 4b3 4b4 + // 4a2 4a1 3a2 3ab1 3b2 4b1 4b2 + // 2a4 2a3 1a4 1ab3 1b4 2b3 2b4 + // 2ac2 2ac1 1ac2 1* 1bd2 2bd1 2bd2 + // 2c4 2c3 1c4 1cd3 1d4 2d3 2d4 + // 4c2 4c1 3c2 3cd1 3d2 4d1 4d2 + // 4c4 4c3 3c4 3cd3 3d4 4d3 4d4 + + // COMPUTE TEXTURE COORDS: + // Statically compute bilinear sampling offsets (details in tex2Dblur9x9). + const float denom_inv = 0.5/(sigma*sigma); + const float w0off = 1.0; + const float w1off = exp(-1.0 * denom_inv); + const float w2off = exp(-4.0 * denom_inv); + const float w3off = exp(-9.0 * denom_inv); + const float texel0to1ratio = w1off/(w0off * 0.5 + w1off); + const float texel2to3ratio = w3off/(w2off + w3off); + // Statically compute texel offsets from the fragment center to each + // bilinear sample in the bottom-right quadrant, including axis-aligned: + const vec2 sample1d_texel_offset = vec2(texel0to1ratio, texel0to1ratio); + const vec2 sample2d_texel_offset = vec2(2.0, 0.0) + vec2(texel2to3ratio, texel0to1ratio); + const vec2 sample3d_texel_offset = vec2(0.0, 2.0) + vec2(texel0to1ratio, texel2to3ratio); + const vec2 sample4d_texel_offset = vec2(2.0, 2.0) + vec2(texel2to3ratio, texel2to3ratio); + + // CALCULATE KERNEL WEIGHTS FOR ALL SAMPLES: + // Statically compute Gaussian texel weights for the bottom-right quadrant. + // Read underscores as "and." + const float w1abcd = 1.0; + const float w1bd2_1cd3 = exp(-LENGTH_SQ(vec2(1.0, 0.0)) * denom_inv); + const float w2bd1_3cd1 = exp(-LENGTH_SQ(vec2(2.0, 0.0)) * denom_inv); + const float w2bd2_3cd2 = exp(-LENGTH_SQ(vec2(3.0, 0.0)) * denom_inv); + const float w1d4 = exp(-LENGTH_SQ(vec2(1.0, 1.0)) * denom_inv); + const float w2d3_3d2 = exp(-LENGTH_SQ(vec2(2.0, 1.0)) * denom_inv); + const float w2d4_3d4 = exp(-LENGTH_SQ(vec2(3.0, 1.0)) * denom_inv); + const float w4d1 = exp(-LENGTH_SQ(vec2(2.0, 2.0)) * denom_inv); + const float w4d2_4d3 = exp(-LENGTH_SQ(vec2(3.0, 2.0)) * denom_inv); + const float w4d4 = exp(-LENGTH_SQ(vec2(3.0, 3.0)) * denom_inv); + // Statically add texel weights in each sample to get sample weights. + // Split weights for shared texels between samples sharing them: + const float w1 = w1abcd * 0.25 + w1bd2_1cd3 + w1d4; + const float w2_3 = (w2bd1_3cd1 + w2bd2_3cd2) * 0.5 + w2d3_3d2 + w2d4_3d4; + const float w4 = w4d1 + 2.0 * w4d2_4d3 + w4d4; + // Get the weight sum inverse (normalization factor): + const float weight_sum_inv = + 1.0/(4.0 * (w1 + 2.0 * w2_3 + w4)); + + // LOAD TEXTURE SAMPLES: + // Load all 16 samples using symmetry: + const vec2 mirror_x = vec2(-1.0, 1.0); + const vec2 mirror_y = vec2(1.0, -1.0); + const vec2 mirror_xy = vec2(-1.0, -1.0); + const vec2 dxdy_mirror_x = dxdy * mirror_x; + const vec2 dxdy_mirror_y = dxdy * mirror_y; + const vec2 dxdy_mirror_xy = dxdy * mirror_xy; + const vec3 sample1a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample1d_texel_offset).rgb; + const vec3 sample2a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample2d_texel_offset).rgb; + const vec3 sample3a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample3d_texel_offset).rgb; + const vec3 sample4a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample4d_texel_offset).rgb; + const vec3 sample1b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample1d_texel_offset).rgb; + const vec3 sample2b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample2d_texel_offset).rgb; + const vec3 sample3b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample3d_texel_offset).rgb; + const vec3 sample4b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample4d_texel_offset).rgb; + const vec3 sample1c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample1d_texel_offset).rgb; + const vec3 sample2c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample2d_texel_offset).rgb; + const vec3 sample3c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample3d_texel_offset).rgb; + const vec3 sample4c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample4d_texel_offset).rgb; + const vec3 sample1d = tex2D_linearize(tex, tex_uv + dxdy * sample1d_texel_offset).rgb; + const vec3 sample2d = tex2D_linearize(tex, tex_uv + dxdy * sample2d_texel_offset).rgb; + const vec3 sample3d = tex2D_linearize(tex, tex_uv + dxdy * sample3d_texel_offset).rgb; + const vec3 sample4d = tex2D_linearize(tex, tex_uv + dxdy * sample4d_texel_offset).rgb; + + // SUM WEIGHTED SAMPLES: + // Statically normalize weights (so total = 1.0), and sum weighted samples. + vec3 sum = vec3(0.0); + sum += w1 * (sample1a + sample1b + sample1c + sample1d); + sum += w2_3 * (sample2a + sample2b + sample2c + sample2d); + sum += w2_3 * (sample3a + sample3b + sample3c + sample3d); + sum += w4 * (sample4a + sample4b + sample4c + sample4d); + return sum * weight_sum_inv; +} + +vec3 tex2Dblur5x5(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Perform a 1-pass 5x5 blur with 3x3 bilinear samples. + // Requires: Same as tex2Dblur9() + // Returns: A 5x5 Gaussian blurred mipmapped texture lookup composed of + // 3x3 carefully selected bilinear samples. + // Description: + // First see the description for tex2Dblur9x9(). This blur uses the same + // concept and sample/texel locations except on a smaller scale. Samples: + // 2a 1U 2b + // 1L 0C 1R + // 2c 1D 2d + // Texels: + // 2a4 2a3 1U2 2b3 2b4 + // 2a2 2a1 1U1 2b1 2b2 + // 1L2 1L1 0C1 1R1 1R2 + // 2c2 2c1 1D1 2d1 2d2 + // 2c4 2c3 1D2 2d3 2d4 + + // COMPUTE TEXTURE COORDS: + // Statically compute bilinear sampling offsets (details in tex2Dblur9x9). + const float denom_inv = 0.5/(sigma*sigma); + const float w1off = exp(-1.0 * denom_inv); + const float w2off = exp(-4.0 * denom_inv); + const float texel1to2ratio = w2off/(w1off + w2off); + // Statically compute texel offsets from the fragment center to each + // bilinear sample in the bottom-right quadrant, including x-axis-aligned: + const vec2 sample1R_texel_offset = vec2(1.0, 0.0) + vec2(texel1to2ratio, 0.0); + const vec2 sample2d_texel_offset = vec2(1.0, 1.0) + vec2(texel1to2ratio, texel1to2ratio); + + // CALCULATE KERNEL WEIGHTS FOR ALL SAMPLES: + // Statically compute Gaussian texel weights for the bottom-right quadrant. + // Read underscores as "and." + const float w1R1 = w1off; + const float w1R2 = w2off; + const float w2d1 = exp(-LENGTH_SQ(vec2(1.0, 1.0)) * denom_inv); + const float w2d2_3 = exp(-LENGTH_SQ(vec2(2.0, 1.0)) * denom_inv); + const float w2d4 = exp(-LENGTH_SQ(vec2(2.0, 2.0)) * denom_inv); + // Statically add texel weights in each sample to get sample weights: + const float w0 = 1.0; + const float w1 = w1R1 + w1R2; + const float w2 = w2d1 + 2.0 * w2d2_3 + w2d4; + // Get the weight sum inverse (normalization factor): + const float weight_sum_inv = 1.0/(w0 + 4.0 * (w1 + w2)); + + // LOAD TEXTURE SAMPLES: + // Load all 9 samples (1 nearest, 4 linear, 4 bilinear) using symmetry: + const vec2 mirror_x = vec2(-1.0, 1.0); + const vec2 mirror_y = vec2(1.0, -1.0); + const vec2 mirror_xy = vec2(-1.0, -1.0); + const vec2 dxdy_mirror_x = dxdy * mirror_x; + const vec2 dxdy_mirror_y = dxdy * mirror_y; + const vec2 dxdy_mirror_xy = dxdy * mirror_xy; + const vec3 sample0C = tex2D_linearize(tex, tex_uv).rgb; + const vec3 sample1R = tex2D_linearize(tex, tex_uv + dxdy * sample1R_texel_offset).rgb; + const vec3 sample1D = tex2D_linearize(tex, tex_uv + dxdy * sample1R_texel_offset.yx).rgb; + const vec3 sample1L = tex2D_linearize(tex, tex_uv - dxdy * sample1R_texel_offset).rgb; + const vec3 sample1U = tex2D_linearize(tex, tex_uv - dxdy * sample1R_texel_offset.yx).rgb; + const vec3 sample2d = tex2D_linearize(tex, tex_uv + dxdy * sample2d_texel_offset).rgb; + const vec3 sample2c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample2d_texel_offset).rgb; + const vec3 sample2b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample2d_texel_offset).rgb; + const vec3 sample2a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample2d_texel_offset).rgb; + + // SUM WEIGHTED SAMPLES: + // Statically normalize weights (so total = 1.0), and sum weighted samples. + vec3 sum = w0 * sample0C; + sum += w1 * (sample1R + sample1D + sample1L + sample1U); + sum += w2 * (sample2a + sample2b + sample2c + sample2d); + return sum * weight_sum_inv; +} + +vec3 tex2Dblur3x3(const sampler2D tex, const vec2 tex_uv, + const vec2 dxdy, const float sigma) +{ + // Perform a 1-pass 3x3 blur with 5x5 bilinear samples. + // Requires: Same as tex2Dblur9() + // Returns: A 3x3 Gaussian blurred mipmapped texture lookup composed of + // 2x2 carefully selected bilinear samples. + // Description: + // First see the descriptions for tex2Dblur9x9() and tex2Dblur7(). This + // blur mixes concepts from both. The sample layout is as follows: + // 0a 0b + // 0c 0d + // The texel layout is as follows. Note that samples 0a/0b and 0c/0d share + // a vertical column of texels, and samples 0a/0c and 0b/0d share a + // horizontal row of texels (all samples share the center texel): + // 0a3 0ab2 0b3 + // 0ac1 0*0 0bd1 + // 0c3 0cd2 0d3 + + // COMPUTE TEXTURE COORDS: + // Statically compute bilinear sampling offsets (details in tex2Dblur9x9). + const float denom_inv = 0.5/(sigma*sigma); + const float w0off = 1.0; + const float w1off = exp(-1.0 * denom_inv); + const float texel0to1ratio = w1off/(w0off * 0.5 + w1off); + // Statically compute texel offsets from the fragment center to each + // bilinear sample in the bottom-right quadrant, including axis-aligned: + const vec2 sample0d_texel_offset = vec2(texel0to1ratio, texel0to1ratio); + + // LOAD TEXTURE SAMPLES: + // Load all 4 samples using symmetry: + const vec2 mirror_x = vec2(-1.0, 1.0); + const vec2 mirror_y = vec2(1.0, -1.0); + const vec2 mirror_xy = vec2(-1.0, -1.0); + const vec2 dxdy_mirror_x = dxdy * mirror_x; + const vec2 dxdy_mirror_y = dxdy * mirror_y; + const vec2 dxdy_mirror_xy = dxdy * mirror_xy; + const vec3 sample0a = tex2D_linearize(tex, tex_uv + dxdy_mirror_xy * sample0d_texel_offset).rgb; + const vec3 sample0b = tex2D_linearize(tex, tex_uv + dxdy_mirror_y * sample0d_texel_offset).rgb; + const vec3 sample0c = tex2D_linearize(tex, tex_uv + dxdy_mirror_x * sample0d_texel_offset).rgb; + const vec3 sample0d = tex2D_linearize(tex, tex_uv + dxdy * sample0d_texel_offset).rgb; + + // SUM WEIGHTED SAMPLES: + // Weights for all samples are the same, so just average them: + return 0.25 * (sample0a + sample0b + sample0c + sample0d); +} + vec3 tex2Dblur9fast(const sampler2D tex, const vec2 tex_uv, const vec2 dxdy) { @@ -600,4 +1197,81 @@ vec3 tex2Dblur31fast(const sampler2D texture, const vec2 tex_uv, return tex2Dblur31fast(texture, tex_uv, dxdy, blur31_std_dev); } +vec3 tex2Dblur3fast(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur3fast(texture, tex_uv, dxdy, blur3_std_dev); +} + +vec3 tex2Dblur3x3(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur3x3(texture, tex_uv, dxdy, blur3_std_dev); +} + +vec3 tex2Dblur5fast(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur5fast(texture, tex_uv, dxdy, blur5_std_dev); +} + +vec3 tex2Dblur5resize(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur5resize(texture, tex_uv, dxdy, blur5_std_dev); +} +vec3 tex2Dblur3resize(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur3resize(texture, tex_uv, dxdy, blur3_std_dev); +} + +vec3 tex2Dblur5x5(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur5x5(texture, tex_uv, dxdy, blur5_std_dev); +} + +vec3 tex2Dblur7resize(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur7resize(texture, tex_uv, dxdy, blur7_std_dev); +} + +vec3 tex2Dblur7fast(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur7fast(texture, tex_uv, dxdy, blur7_std_dev); +} + +vec3 tex2Dblur7x7(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur7x7(texture, tex_uv, dxdy, blur7_std_dev); +} + +vec3 tex2Dblur9resize(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur9resize(texture, tex_uv, dxdy, blur9_std_dev); +} + +vec3 tex2Dblur9x9(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur9x9(texture, tex_uv, dxdy, blur9_std_dev); +} + +vec3 tex2Dblur11resize(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur11resize(texture, tex_uv, dxdy, blur11_std_dev); +} + +vec3 tex2Dblur11fast(const sampler2D texture, const vec2 tex_uv, + const vec2 dxdy) +{ + return tex2Dblur11fast(texture, tex_uv, dxdy, blur11_std_dev); +} + #endif // BLUR_FUNCTIONS_H \ No newline at end of file