-Added HQ2x, HQ3x and HQ4x shaders. [MooglyGuy,Jules Blok,Cameron Zemek,Maxim Stepin]

This commit is contained in:
therealmogminer@gmail.com 2016-04-18 19:39:46 +02:00
parent 82188dee99
commit c64b88bc78
88 changed files with 1075 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

60
bgfx/chains/hq2x.json Normal file
View File

@ -0,0 +1,60 @@
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
/*
* Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
*
* Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net )
*
* Copyright (C) 2014 Jules Blok ( jules@aerix.nl )
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
{
"name": "HQ2x",
"author": "libretro",
"targets": [
{
"name": "scaled_out",
"mode": "guest",
"scale": 2,
"doublebuffer": true
},
{
"name": "internal",
"mode": "native",
"doublebuffer": true
}
],
"passes": [
{
"effect": "hq2x/hq2x",
"name": "HQ2x pass",
"input": [
{ "sampler": "decal", "texture": "screen" },
{ "sampler": "LUT", "texture": "bgfx/chains/hq2x.png", "bilinear": true }
],
"output": "scaled_out"
},
{ "effect": "hq2x/blit",
"name": "Final Blit",
"input": [
{ "sampler": "s_tex", "target": "scaled_out" }
],
"output": "output"
}
]
}

60
bgfx/chains/hq3x.json Normal file
View File

@ -0,0 +1,60 @@
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
/*
* Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
*
* Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net )
*
* Copyright (C) 2014 Jules Blok ( jules@aerix.nl )
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
{
"name": "HQ3x",
"author": "libretro",
"targets": [
{
"name": "scaled_out",
"mode": "guest",
"scale": 2,
"doublebuffer": true
},
{
"name": "internal",
"mode": "native",
"doublebuffer": true
}
],
"passes": [
{
"effect": "hq3x/hq3x",
"name": "HQ3x pass",
"input": [
{ "sampler": "decal", "texture": "screen" },
{ "sampler": "LUT", "texture": "bgfx/chains/hq3x.png", "bilinear": false }
],
"output": "scaled_out"
},
{ "effect": "hq3x/blit",
"name": "Final Blit",
"input": [
{ "sampler": "s_tex", "target": "scaled_out" }
],
"output": "output"
}
]
}

60
bgfx/chains/hq4x.json Normal file
View File

@ -0,0 +1,60 @@
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
/*
* Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com )
*
* Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net )
*
* Copyright (C) 2014 Jules Blok ( jules@aerix.nl )
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
{
"name": "HQ4x",
"author": "libretro",
"targets": [
{
"name": "scaled_out",
"mode": "guest",
"scale": 2,
"doublebuffer": true
},
{
"name": "internal",
"mode": "native",
"doublebuffer": true
}
],
"passes": [
{
"effect": "hq4x/hq4x",
"name": "HQ4x pass",
"input": [
{ "sampler": "decal", "texture": "screen" },
{ "sampler": "LUT", "texture": "bgfx/chains/hq4x.png", "bilinear": false }
],
"output": "scaled_out"
},
{ "effect": "hq4x/blit",
"name": "Final Blit",
"input": [
{ "sampler": "s_tex", "target": "scaled_out" }
],
"output": "output"
}
]
}

121
bgfx/effects/hq2x/blit.json Normal file
View File

@ -0,0 +1,121 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// blit.json: A simple texture-to-target copy.
//
//============================================================
{
// blend (required): The blend state for this effect.
"blend": {
// equation (optional): What equation to perform on the source and destination blend values.
// values: "add", "sub", "revSub", "min", "max"
// default: "add"
//
// "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub"
"equation": "add",
// blend function parameters (optional): What factors to use in the blend function when calculating the final pixel.
// values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha"
// defaults (srcColor, srcAlpha): "1"
// defaults (dstColor, dstAlpha): "0"
//
// "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha"
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
// depth (required): The depth state for this effect.
"depth": {
// function (optional): The depth function to use when drawing.
// values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always"
// default: "always"
"function": "always",
// writeenable (optional): Whether to store Z-buffer data.
// values: true, false
// default: false
"writeenable": false
},
// cull (required): The cull mode for this effect.
"cull": {
// mode (optional): What winding, if any, to cull.
// values: "none", "cw", "ccw"
// default: "ccw"
//
// "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw"
"mode": "none"
},
// write (required): Write enable for color and alpha channels.
"write": {
// rgb (optional): Whether to store color data when drawing.
// values: true, false
// default: false
"rgb": true,
// alpha (optional): Whether to store alpha data when drawing.
// values: true, false
// default: false
"alpha": true
},
// vertex (required): The vertex shader to use when drawing.
// value: A string containing the path and name of a shader file to use, minus the extension.
"vertex": "chains/hq2x/vs_blit",
// pixel/fragment (required): The pixel or fragment shader to use when drawing.
// value: A string containing the path and name of a shader file to use, minus the extension.
"fragment": "chains/hq2x/fs_blit",
// uniforms (required): The list of uniforms for this effect. Can be empty, but must exist.
"uniforms": [
{
// name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader.
// value: A string containing the name of the uniform as described above.
//
// NOTE: Some names correspond to special values that will be automatically filled by the BGFX
// code if they are used by the shader. These names are:
// "u_screen_dims"
// The dimensions of the first texture input if present, otherwise the dimensions of the output window.
// Valid values: xy
// "u_inv_screen_dims"
// The reciprocal of u_screen_dims.
// Valid values: xy
// "u_source_dims"
// The size, in pixels, of the screen texture incoming to the chain.
// Valid values: xy
// "u_rotation_type"
// This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270.
// Valid values: x
// "u_swap_xy"
// Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false.
// Valid values: x
// "u_quad_dims"
// The dimensions, in pixels, occupied by this one screen primitive itself in the output window.
// Valid values: xy
// "u_tex_sizeN"
// The dimensions, in pixels, of the texture in input pair N. Starts at 0.
// valid values: xy
"name": "s_tex",
// type (required): The type of the uniform.
// values: "int", "vec4", "mat3", "mat4"
//
// Note: "int" should only be used for samplers.
"type": "int",
// values (required): The array of numbers with which to initialize the uniform.
// value: A JSON array containin the correct amount of numbers to initialize a uniform of the
// above-specified type. The following size rules should be followed:
// "int": 1 float
// "vec4": 4 floats
// "mat3": 9 floats
// "mat4": 16 floats
"values": [ 1.0 ]
}
]
}

View File

@ -0,0 +1,29 @@
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/hq2x/vs_hq2x",
"fragment": "chains/hq2x/fs_hq2x",
"uniforms": [
{ "name": "decal", "type": "int", "values": [ 1.0 ] },
{ "name": "LUT", "type": "int", "values": [ 1.0 ] },
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }
]
}

121
bgfx/effects/hq3x/blit.json Normal file
View File

@ -0,0 +1,121 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// blit.json: A simple texture-to-target copy.
//
//============================================================
{
// blend (required): The blend state for this effect.
"blend": {
// equation (optional): What equation to perform on the source and destination blend values.
// values: "add", "sub", "revSub", "min", "max"
// default: "add"
//
// "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub"
"equation": "add",
// blend function parameters (optional): What factors to use in the blend function when calculating the final pixel.
// values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha"
// defaults (srcColor, srcAlpha): "1"
// defaults (dstColor, dstAlpha): "0"
//
// "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha"
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
// depth (required): The depth state for this effect.
"depth": {
// function (optional): The depth function to use when drawing.
// values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always"
// default: "always"
"function": "always",
// writeenable (optional): Whether to store Z-buffer data.
// values: true, false
// default: false
"writeenable": false
},
// cull (required): The cull mode for this effect.
"cull": {
// mode (optional): What winding, if any, to cull.
// values: "none", "cw", "ccw"
// default: "ccw"
//
// "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw"
"mode": "none"
},
// write (required): Write enable for color and alpha channels.
"write": {
// rgb (optional): Whether to store color data when drawing.
// values: true, false
// default: false
"rgb": true,
// alpha (optional): Whether to store alpha data when drawing.
// values: true, false
// default: false
"alpha": true
},
// vertex (required): The vertex shader to use when drawing.
// value: A string containing the path and name of a shader file to use, minus the extension.
"vertex": "chains/hq3x/vs_blit",
// pixel/fragment (required): The pixel or fragment shader to use when drawing.
// value: A string containing the path and name of a shader file to use, minus the extension.
"fragment": "chains/hq3x/fs_blit",
// uniforms (required): The list of uniforms for this effect. Can be empty, but must exist.
"uniforms": [
{
// name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader.
// value: A string containing the name of the uniform as described above.
//
// NOTE: Some names correspond to special values that will be automatically filled by the BGFX
// code if they are used by the shader. These names are:
// "u_screen_dims"
// The dimensions of the first texture input if present, otherwise the dimensions of the output window.
// Valid values: xy
// "u_inv_screen_dims"
// The reciprocal of u_screen_dims.
// Valid values: xy
// "u_source_dims"
// The size, in pixels, of the screen texture incoming to the chain.
// Valid values: xy
// "u_rotation_type"
// This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270.
// Valid values: x
// "u_swap_xy"
// Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false.
// Valid values: x
// "u_quad_dims"
// The dimensions, in pixels, occupied by this one screen primitive itself in the output window.
// Valid values: xy
// "u_tex_sizeN"
// The dimensions, in pixels, of the texture in input pair N. Starts at 0.
// valid values: xy
"name": "s_tex",
// type (required): The type of the uniform.
// values: "int", "vec4", "mat3", "mat4"
//
// Note: "int" should only be used for samplers.
"type": "int",
// values (required): The array of numbers with which to initialize the uniform.
// value: A JSON array containin the correct amount of numbers to initialize a uniform of the
// above-specified type. The following size rules should be followed:
// "int": 1 float
// "vec4": 4 floats
// "mat3": 9 floats
// "mat4": 16 floats
"values": [ 1.0 ]
}
]
}

View File

@ -0,0 +1,29 @@
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/hq3x/vs_hq3x",
"fragment": "chains/hq3x/fs_hq3x",
"uniforms": [
{ "name": "decal", "type": "int", "values": [ 1.0 ] },
{ "name": "LUT", "type": "int", "values": [ 1.0 ] },
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }
]
}

121
bgfx/effects/hq4x/blit.json Normal file
View File

@ -0,0 +1,121 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// blit.json: A simple texture-to-target copy.
//
//============================================================
{
// blend (required): The blend state for this effect.
"blend": {
// equation (optional): What equation to perform on the source and destination blend values.
// values: "add", "sub", "revSub", "min", "max"
// default: "add"
//
// "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub"
"equation": "add",
// blend function parameters (optional): What factors to use in the blend function when calculating the final pixel.
// values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha"
// defaults (srcColor, srcAlpha): "1"
// defaults (dstColor, dstAlpha): "0"
//
// "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha"
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
// depth (required): The depth state for this effect.
"depth": {
// function (optional): The depth function to use when drawing.
// values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always"
// default: "always"
"function": "always",
// writeenable (optional): Whether to store Z-buffer data.
// values: true, false
// default: false
"writeenable": false
},
// cull (required): The cull mode for this effect.
"cull": {
// mode (optional): What winding, if any, to cull.
// values: "none", "cw", "ccw"
// default: "ccw"
//
// "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw"
"mode": "none"
},
// write (required): Write enable for color and alpha channels.
"write": {
// rgb (optional): Whether to store color data when drawing.
// values: true, false
// default: false
"rgb": true,
// alpha (optional): Whether to store alpha data when drawing.
// values: true, false
// default: false
"alpha": true
},
// vertex (required): The vertex shader to use when drawing.
// value: A string containing the path and name of a shader file to use, minus the extension.
"vertex": "chains/hq4x/vs_blit",
// pixel/fragment (required): The pixel or fragment shader to use when drawing.
// value: A string containing the path and name of a shader file to use, minus the extension.
"fragment": "chains/hq4x/fs_blit",
// uniforms (required): The list of uniforms for this effect. Can be empty, but must exist.
"uniforms": [
{
// name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader.
// value: A string containing the name of the uniform as described above.
//
// NOTE: Some names correspond to special values that will be automatically filled by the BGFX
// code if they are used by the shader. These names are:
// "u_screen_dims"
// The dimensions of the first texture input if present, otherwise the dimensions of the output window.
// Valid values: xy
// "u_inv_screen_dims"
// The reciprocal of u_screen_dims.
// Valid values: xy
// "u_source_dims"
// The size, in pixels, of the screen texture incoming to the chain.
// Valid values: xy
// "u_rotation_type"
// This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270.
// Valid values: x
// "u_swap_xy"
// Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false.
// Valid values: x
// "u_quad_dims"
// The dimensions, in pixels, occupied by this one screen primitive itself in the output window.
// Valid values: xy
// "u_tex_sizeN"
// The dimensions, in pixels, of the texture in input pair N. Starts at 0.
// valid values: xy
"name": "s_tex",
// type (required): The type of the uniform.
// values: "int", "vec4", "mat3", "mat4"
//
// Note: "int" should only be used for samplers.
"type": "int",
// values (required): The array of numbers with which to initialize the uniform.
// value: A JSON array containin the correct amount of numbers to initialize a uniform of the
// above-specified type. The following size rules should be followed:
// "int": 1 float
// "vec4": 4 floats
// "mat3": 9 floats
// "mat4": 16 floats
"values": [ 1.0 ]
}
]
}

View File

@ -0,0 +1,29 @@
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
{
"blend": {
"equation": "add",
"srcColor": "1",
"dstColor": "0",
"srcAlpha": "1",
"dstAlpha": "0"
},
"depth": {
"function": "always",
"writeenable": false
},
"cull": {
"mode": "none"
},
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/hq4x/vs_hq4x",
"fragment": "chains/hq4x/fs_hq4x",
"uniforms": [
{ "name": "decal", "type": "int", "values": [ 1.0 ] },
{ "name": "LUT", "type": "int", "values": [ 1.0 ] },
{ "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -245,7 +245,7 @@ void chain_manager::process_screen_quad(uint32_t view, uint32_t screen, render_p
tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base);
std::string full_name = "screen" + std::to_string(screen);
bgfx_texture *texture = new bgfx_texture(full_name, bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem);
bgfx_texture *texture = new bgfx_texture(full_name, bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem, BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT);
m_textures.add_provider(full_name, texture);
m_targets.update_target_sizes(screen, tex_width, tex_height, TARGET_STYLE_GUEST);

View File

@ -0,0 +1,14 @@
$input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "common.sh"
// Samplers
SAMPLER2D(s_tex, 0);
void main()
{
gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0;
}

View File

@ -0,0 +1,75 @@
$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
#include "common.sh"
// Autos
uniform vec4 u_tex_size0;
// Samplers
SAMPLER2D(decal, 0);
SAMPLER2D(LUT, 1);
#define trY 48.0
#define trU 7.0
#define trV 6.0
#define SCALE 2.0
float diff(vec3 yuv1, vec3 yuv2)
{
vec3 yuv_threshold = vec3(trY / 255.0, trU / 255.0, trV / 255.0);
vec3 yuv_offset = vec3(0, 0.5, 0.5);
float res_x = (abs((yuv1.x + 0.0) - (yuv2.x + 0.0)) > (trY / 255.0)) ? 1.0 : 0.0;
float res_y = (abs((yuv1.y + 0.5) - (yuv2.y + 0.5)) > (trU / 255.0)) ? 1.0 : 0.0;
float res_z = (abs((yuv1.z + 0.5) - (yuv2.z + 0.5)) > (trV / 255.0)) ? 1.0 : 0.0;
return (res_x > 0.0) ? 1.0 : ((res_y > 0.0) ? 1.0 : ((res_z > 0.0) ? 1.0 : 0.0));
}
void main()
{
mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081);
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
vec2 quad = sign(-0.5 + fp);
vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy;
float dx = ps.x;
float dy = ps.y;
vec4 p1 = texture2D(decal, v_texcoord0);
vec4 p2 = texture2D(decal, v_texcoord0 + ps * quad);
vec4 p3 = texture2D(decal, v_texcoord0 + vec2(dx, 0) * quad);
vec4 p4 = texture2D(decal, v_texcoord0 + vec2(0, dy) * quad);
vec3 w1 = mul(yuv, texture2D(decal, v_texcoord1.xw).rgb);
vec3 w2 = mul(yuv, texture2D(decal, v_texcoord1.yw).rgb);
vec3 w3 = mul(yuv, texture2D(decal, v_texcoord1.zw).rgb);
vec3 w4 = mul(yuv, texture2D(decal, v_texcoord2.xw).rgb);
vec3 w5 = mul(yuv, p1.rgb);
vec3 w6 = mul(yuv, texture2D(decal, v_texcoord2.zw).rgb);
vec3 w7 = mul(yuv, texture2D(decal, v_texcoord3.xw).rgb);
vec3 w8 = mul(yuv, texture2D(decal, v_texcoord3.yw).rgb);
vec3 w9 = mul(yuv, texture2D(decal, v_texcoord3.zw).rgb);
mat3 pattern = mat3(diff(w5, w1), diff(w5, w2), diff(w5, w3), diff(w5, w4), 0.0, diff(w5, w6), diff(w5, w7), diff(w5, w8), diff(w5, w9));
vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8));
vec2 index;
index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) +
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
dot(pattern[2], vec3(32.0, 64.0, 128.0));
index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE));
vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE));
vec2 offset = step / vec2(2.0, 2.0);
vec4 weights = texture2D(LUT, index * step + offset);
float sum = dot(weights, vec4(1.0, 1.0, 1.0, 1.0));
mat4 transposed = mat4(vec4(p1.x, p2.x, p3.x, p4.x), vec4(p1.y, p2.y, p3.y, p4.y), vec4(p1.z, p2.z, p3.z, p4.z), vec4(p1.w, p2.w, p3.w, p4.w));
vec4 res = mul(transposed, weights / vec4(sum, sum, sum, sum));
gl_FragColor = vec4(res.rgb, 1.0);
}

View File

@ -0,0 +1,9 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;

View File

@ -0,0 +1,14 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_color0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "common.sh"
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}

View File

@ -0,0 +1,36 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
#include "common.sh"
// Autos
uniform vec4 u_tex_size0;
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_color0 = a_color0;
vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy;
float dx = ps.x;
float dy = ps.y;
// +----+----+----+
// | | | |
// | w1 | w2 | w3 |
// +----+----+----+
// | | | |
// | w4 | w5 | w6 |
// +----+----+----+
// | | | |
// | w7 | w8 | w9 |
// +----+----+----+
v_texcoord0 = a_texcoord0;
v_texcoord1 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, -dy); // w1 | w2 | w3
v_texcoord2 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); // w4 | w5 | w6
v_texcoord3 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, dy); // w7 | w8 | w9
}

View File

@ -0,0 +1,14 @@
$input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "common.sh"
// Samplers
SAMPLER2D(s_tex, 0);
void main()
{
gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0;
}

View File

@ -0,0 +1,75 @@
$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
#include "common.sh"
// Autos
uniform vec4 u_tex_size0;
// Samplers
SAMPLER2D(decal, 0);
SAMPLER2D(LUT, 1);
#define trY 48.0
#define trU 7.0
#define trV 6.0
#define SCALE 3.0
float diff(vec3 yuv1, vec3 yuv2)
{
vec3 yuv_threshold = vec3(trY / 255.0, trU / 255.0, trV / 255.0);
vec3 yuv_offset = vec3(0, 0.5, 0.5);
float res_x = (abs((yuv1.x + 0.0) - (yuv2.x + 0.0)) > (trY / 255.0)) ? 1.0 : 0.0;
float res_y = (abs((yuv1.y + 0.5) - (yuv2.y + 0.5)) > (trU / 255.0)) ? 1.0 : 0.0;
float res_z = (abs((yuv1.z + 0.5) - (yuv2.z + 0.5)) > (trV / 255.0)) ? 1.0 : 0.0;
return (res_x > 0.0) ? 1.0 : ((res_y > 0.0) ? 1.0 : ((res_z > 0.0) ? 1.0 : 0.0));
}
void main()
{
mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081);
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
vec2 quad = sign(-0.5 + fp);
vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy;
float dx = ps.x;
float dy = ps.y;
vec4 p1 = texture2D(decal, v_texcoord0);
vec4 p2 = texture2D(decal, v_texcoord0 + ps * quad);
vec4 p3 = texture2D(decal, v_texcoord0 + vec2(dx, 0) * quad);
vec4 p4 = texture2D(decal, v_texcoord0 + vec2(0, dy) * quad);
vec3 w1 = mul(yuv, texture2D(decal, v_texcoord1.xw).rgb);
vec3 w2 = mul(yuv, texture2D(decal, v_texcoord1.yw).rgb);
vec3 w3 = mul(yuv, texture2D(decal, v_texcoord1.zw).rgb);
vec3 w4 = mul(yuv, texture2D(decal, v_texcoord2.xw).rgb);
vec3 w5 = mul(yuv, p1.rgb);
vec3 w6 = mul(yuv, texture2D(decal, v_texcoord2.zw).rgb);
vec3 w7 = mul(yuv, texture2D(decal, v_texcoord3.xw).rgb);
vec3 w8 = mul(yuv, texture2D(decal, v_texcoord3.yw).rgb);
vec3 w9 = mul(yuv, texture2D(decal, v_texcoord3.zw).rgb);
mat3 pattern = mat3(diff(w5, w1), diff(w5, w2), diff(w5, w3), diff(w5, w4), 0.0, diff(w5, w6), diff(w5, w7), diff(w5, w8), diff(w5, w9));
vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8));
vec2 index;
index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) +
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
dot(pattern[2], vec3(32.0, 64.0, 128.0));
index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE));
vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE));
vec2 offset = step / vec2(2.0, 2.0);
vec4 weights = texture2D(LUT, index * step + offset);
float sum = dot(weights, vec4(1.0, 1.0, 1.0, 1.0));
mat4 transposed = mat4(vec4(p1.x, p2.x, p3.x, p4.x), vec4(p1.y, p2.y, p3.y, p4.y), vec4(p1.z, p2.z, p3.z, p4.z), vec4(p1.w, p2.w, p3.w, p4.w));
vec4 res = mul(transposed, weights / vec4(sum, sum, sum, sum));
gl_FragColor = vec4(res.rgb, 1.0);
}

View File

@ -0,0 +1,9 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;

View File

@ -0,0 +1,14 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_color0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "common.sh"
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}

View File

@ -0,0 +1,36 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
#include "common.sh"
// Autos
uniform vec4 u_tex_size0;
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_color0 = a_color0;
vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy;
float dx = ps.x;
float dy = ps.y;
// +----+----+----+
// | | | |
// | w1 | w2 | w3 |
// +----+----+----+
// | | | |
// | w4 | w5 | w6 |
// +----+----+----+
// | | | |
// | w7 | w8 | w9 |
// +----+----+----+
v_texcoord0 = a_texcoord0;
v_texcoord1 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, -dy); // w1 | w2 | w3
v_texcoord2 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); // w4 | w5 | w6
v_texcoord3 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, dy); // w7 | w8 | w9
}

View File

@ -0,0 +1,14 @@
$input v_color0, v_texcoord0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "common.sh"
// Samplers
SAMPLER2D(s_tex, 0);
void main()
{
gl_FragColor = texture2D(s_tex, v_texcoord0) * v_color0;
}

View File

@ -0,0 +1,75 @@
$input v_color0, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
#include "common.sh"
// Autos
uniform vec4 u_tex_size0;
// Samplers
SAMPLER2D(decal, 0);
SAMPLER2D(LUT, 1);
#define trY 48.0
#define trU 7.0
#define trV 6.0
#define SCALE 4.0
float diff(vec3 yuv1, vec3 yuv2)
{
vec3 yuv_threshold = vec3(trY / 255.0, trU / 255.0, trV / 255.0);
vec3 yuv_offset = vec3(0, 0.5, 0.5);
float res_x = (abs((yuv1.x + 0.0) - (yuv2.x + 0.0)) > (trY / 255.0)) ? 1.0 : 0.0;
float res_y = (abs((yuv1.y + 0.5) - (yuv2.y + 0.5)) > (trU / 255.0)) ? 1.0 : 0.0;
float res_z = (abs((yuv1.z + 0.5) - (yuv2.z + 0.5)) > (trV / 255.0)) ? 1.0 : 0.0;
return (res_x > 0.0) ? 1.0 : ((res_y > 0.0) ? 1.0 : ((res_z > 0.0) ? 1.0 : 0.0));
}
void main()
{
mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.5, 0.5, -0.419, -0.081);
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
vec2 quad = sign(-0.5 + fp);
vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy;
float dx = ps.x;
float dy = ps.y;
vec4 p1 = texture2D(decal, v_texcoord0);
vec4 p2 = texture2D(decal, v_texcoord0 + ps * quad);
vec4 p3 = texture2D(decal, v_texcoord0 + vec2(dx, 0) * quad);
vec4 p4 = texture2D(decal, v_texcoord0 + vec2(0, dy) * quad);
vec3 w1 = mul(yuv, texture2D(decal, v_texcoord1.xw).rgb);
vec3 w2 = mul(yuv, texture2D(decal, v_texcoord1.yw).rgb);
vec3 w3 = mul(yuv, texture2D(decal, v_texcoord1.zw).rgb);
vec3 w4 = mul(yuv, texture2D(decal, v_texcoord2.xw).rgb);
vec3 w5 = mul(yuv, p1.rgb);
vec3 w6 = mul(yuv, texture2D(decal, v_texcoord2.zw).rgb);
vec3 w7 = mul(yuv, texture2D(decal, v_texcoord3.xw).rgb);
vec3 w8 = mul(yuv, texture2D(decal, v_texcoord3.yw).rgb);
vec3 w9 = mul(yuv, texture2D(decal, v_texcoord3.zw).rgb);
mat3 pattern = mat3(diff(w5, w1), diff(w5, w2), diff(w5, w3), diff(w5, w4), 0.0, diff(w5, w6), diff(w5, w7), diff(w5, w8), diff(w5, w9));
vec4 cross = vec4(diff(w4, w2), diff(w2, w6), diff(w8, w4), diff(w6, w8));
vec2 index;
index.x = dot(pattern[0], vec3( 1.0, 2.0, 4.0)) +
dot(pattern[1], vec3( 8.0, 0.0, 16.0)) +
dot(pattern[2], vec3(32.0, 64.0, 128.0));
index.y = dot(cross, vec4(1.0, 2.0, 4.0, 8.0)) * SCALE * SCALE + dot(floor(fp * vec2(SCALE, SCALE)), vec2(1.0, SCALE));
vec2 step = vec2(1.0, 1.0) / vec2(256.0, 16.0 * (SCALE * SCALE));
vec2 offset = step / vec2(2.0, 2.0);
vec4 weights = texture2D(LUT, index * step + offset);
float sum = dot(weights, vec4(1.0, 1.0, 1.0, 1.0));
mat4 transposed = mat4(vec4(p1.x, p2.x, p3.x, p4.x), vec4(p1.y, p2.y, p3.y, p4.y), vec4(p1.z, p2.z, p3.z, p4.z), vec4(p1.w, p2.w, p3.w, p4.w));
vec4 res = mul(transposed, weights / vec4(sum, sum, sum, sum));
gl_FragColor = vec4(res.rgb, 1.0);
}

View File

@ -0,0 +1,9 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0);
vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;

View File

@ -0,0 +1,14 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_color0
// license:BSD-3-Clause
// copyright-holders:Dario Manesku
#include "common.sh"
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}

View File

@ -0,0 +1,36 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_color0
// license:LGPL-2.1+
// copyright-holders:Jules Blok,Cameron Zemek,Maxim Stepin
#include "common.sh"
// Autos
uniform vec4 u_tex_size0;
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
v_color0 = a_color0;
vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy;
float dx = ps.x;
float dy = ps.y;
// +----+----+----+
// | | | |
// | w1 | w2 | w3 |
// +----+----+----+
// | | | |
// | w4 | w5 | w6 |
// +----+----+----+
// | | | |
// | w7 | w8 | w9 |
// +----+----+----+
v_texcoord0 = a_texcoord0;
v_texcoord1 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, -dy); // w1 | w2 | w3
v_texcoord2 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, 0.0); // w4 | w5 | w6
v_texcoord3 = a_texcoord0.xxxy + vec4(-dx, 0.0, dx, dy); // w7 | w8 | w9
}