// Generated by ShaderCompiler (--emit-cg). Do not edit manually.
#pragma once

#if defined(WITH_RHI_GXM)

#include <cstddef>
#include <cstring>

namespace nCine::RHI::GXM
{
	namespace
	{
		/** @brief Cg stage sources of one program variant, compiled on the console by SceShaccCg */
		struct GeneratedCgShader
		{
			const char* ProgramName;
			const char* VariantName;
			const char* VertexSource;
			const char* FragmentSource;
		};

		constexpr GeneratedCgShader GeneratedCgShaders[] = {
			{ "Antialiasing", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vPixelCoords;
static float2 vTexSizeInv;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vPixelCoords : TEXCOORD0;
	float2 vTexSizeInv : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vPixelCoords = aPosition * texRect.xy + 0.5;
	vTexSizeInv = 1.0 / texRect.xy;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vPixelCoords = vPixelCoords;
	_output.vTexSizeInv = vTexSizeInv;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vPixelCoords;
static float2 vTexSizeInv;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vPixelCoords : TEXCOORD0;
	float2 vTexSizeInv : TEXCOORD1;
};

float3 cubicHermite(float3 A, float3 B, float3 C, float3 D, float t)
{
	float t2 = t * t;
	float t3 = t * t * t;
	float3 a = -A / 2.0 + 3.0 * B / 2.0 - 3.0 * C / 2.0 + D / 2.0;
	float3 b = A - 5.0 * B / 2.0 + 2.0 * C - D / 2.0;
	float3 c = -A / 2.0 + C / 2.0;
	float3 d = B;
	return a * t3 + b * t2 + c * t + d;
}

float4 main(PsInput _input) : COLOR
{
	vPixelCoords = _input.vPixelCoords;
	vTexSizeInv = _input.vTexSizeInv;
	float2 frac_ = frac(vPixelCoords);
	float2 pixel_ = floor(vPixelCoords) * vTexSizeInv - ((float2)(vTexSizeInv * 0.5));
	float2 vTexSizeInv2 = 2.0 * vTexSizeInv;
	float3 C00 = tex2D(uTexture, pixel_ + float2(-vTexSizeInv.x, -vTexSizeInv.y)).xyz;
	float3 C10 = tex2D(uTexture, pixel_ + float2(0.0, -vTexSizeInv.y)).xyz;
	float3 C20 = tex2D(uTexture, pixel_ + float2(vTexSizeInv.x, -vTexSizeInv.y)).xyz;
	float3 C30 = tex2D(uTexture, pixel_ + float2(vTexSizeInv2.x, -vTexSizeInv.y)).xyz;
	float3 C01 = tex2D(uTexture, pixel_ + float2(-vTexSizeInv.x, 0.0)).xyz;
	float3 C11 = tex2D(uTexture, pixel_ + float2(0.0, 0.0)).xyz;
	float3 C21 = tex2D(uTexture, pixel_ + float2(vTexSizeInv.x, 0.0)).xyz;
	float3 C31 = tex2D(uTexture, pixel_ + float2(vTexSizeInv2.x, 0.0)).xyz;
	float3 C02 = tex2D(uTexture, pixel_ + float2(-vTexSizeInv.x, vTexSizeInv.y)).xyz;
	float3 C12 = tex2D(uTexture, pixel_ + float2(0.0, vTexSizeInv.y)).xyz;
	float3 C22 = tex2D(uTexture, pixel_ + float2(vTexSizeInv.x, vTexSizeInv.y)).xyz;
	float3 C32 = tex2D(uTexture, pixel_ + float2(vTexSizeInv2.x, vTexSizeInv.y)).xyz;
	float3 C03 = tex2D(uTexture, pixel_ + float2(-vTexSizeInv.x, vTexSizeInv2.y)).xyz;
	float3 C13 = tex2D(uTexture, pixel_ + float2(0.0, vTexSizeInv2.y)).xyz;
	float3 C23 = tex2D(uTexture, pixel_ + float2(vTexSizeInv.x, vTexSizeInv2.y)).xyz;
	float3 C33 = tex2D(uTexture, pixel_ + float2(vTexSizeInv2.x, vTexSizeInv2.y)).xyz;
	float3 CP0X = cubicHermite(C00, C10, C20, C30, frac_.x);
	float3 CP1X = cubicHermite(C01, C11, C21, C31, frac_.x);
	float3 CP2X = cubicHermite(C02, C12, C22, C32, frac_.x);
	float3 CP3X = cubicHermite(C03, C13, C23, C33, frac_.x);
	COLOR = float4(cubicHermite(CP0X, CP1X, CP2X, CP3X, frac_.y), 1.0);
	return COLOR;
}
)" },
			{ "BatchedShieldFire", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float4 vTexCoords;
static float4 vColor;
static float2 vPos;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = instances[int(aInstanceIndex)].texRect;
	vColor = instances[int(aInstanceIndex)].color;
	vPos = aPosition * ((float2)2.0) - ((float2)1.0);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPos = vPos;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float4 vTexCoords;
static float4 vColor;
static float2 vPos;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float triangleWave(float x, float period)
{
	float p = x / period;
	float f = frac(p);
	return abs(f - 0.5) * 2.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPos = _input.vPos;
	float2 scale = vColor.xy;
	float2 shift1 = vTexCoords.xy;
	float2 shift2 = vTexCoords.zw;
	float darkness = vColor.z;
	float alpha = vColor.w;
	float dist = length(vPos);
	if (dist > 1.0) {
		COLOR = float4(0.0, 0.0, 0.0, 0.0);
	} else {
		float3 v = float3(vPos.x, vPos.y, sqrt(1.0 - vPos.x * vPos.x - vPos.y * vPos.y));
		float3 n = normalize(v);
		float b = dot(n, float3(0.0, 0.0, 1.0));
		float2 q = float2(0.5 - 0.5 * atan2(n.z, n.x) / 3.1415926, -acos(vPos.y) / 3.1415926);
		float isNearBorder = 1.0 - aastep(0.96, dist);
		float mask1 = tex2D(uTexture, (shift1 + q * scale - (1.0) * floor((shift1 + q * scale) / (1.0)))).x;
		float maskNormalized1 = max(1.0 - abs(triangleWave(shift2.y + 0.5, 2.0) - mask1) * 6.0, 0.0);
		float mask2 = tex2D(uTexture, (shift2 + q * scale - (1.0) * floor((shift2 + q * scale) / (1.0)))).x;
		float maskNormalized2 = max(1.0 - abs(triangleWave(shift1.x, 1.333) - mask2) * 6.0, 0.0);
		float maskSum = min(maskNormalized1 + maskNormalized2, 1.0);
		COLOR = float4(lerp(float3(1.0, 0.3, 0.0), float3(1.0, 1.0, 1.0), max(maskSum * 2.0 - 1.0, 0.0)) * darkness, min(maskSum * b * isNearBorder * 1.3 + 0.1, 1.0) * alpha);
	}
	return COLOR;
}
)" },
			{ "BatchedShieldLightning", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float4 vTexCoords;
static float4 vColor;
static float2 vPos;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = instances[int(aInstanceIndex)].texRect;
	vColor = instances[int(aInstanceIndex)].color;
	vPos = aPosition * ((float2)2.0) - ((float2)1.0);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPos = vPos;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float4 vTexCoords;
static float4 vColor;
static float2 vPos;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float triangleWave(float x, float period)
{
	float p = x / period;
	float f = frac(p);
	return abs(f - 0.5) * 2.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPos = _input.vPos;
	float2 scale = vColor.xy;
	float2 shift1 = vTexCoords.xy;
	float2 shift2 = vTexCoords.zw;
	float darkness = vColor.z;
	float alpha = vColor.w;
	float dist = length(vPos);
	if (dist > 1.0) {
		COLOR = float4(0.0, 0.0, 0.0, 0.0);
	} else {
		float3 v = float3(vPos.x, vPos.y, sqrt(1.0 - vPos.x * vPos.x - vPos.y * vPos.y));
		float3 n = normalize(v);
		float b = dot(n, float3(0.0, 0.0, 1.0));
		float2 q = float2(0.5 - 0.5 * atan2(n.z, n.x) / 3.1415926, -acos(vPos.y) / 3.1415926);
		float isNearBorder = 1.0 - aastep(0.96, dist);
		float mask = tex2D(uTexture, (shift1 + q * scale - (1.0) * floor((shift1 + q * scale) / (1.0)))).x;
		float maskNormalized = max(1.0 - abs(triangleWave(shift2.y + 0.5, 2.0) - mask) * 8.0, 0.0);
		float isVeryNearBorder = 1.0 - aastep(0.024, abs(dist - 0.94));
		float maskSum = max(maskNormalized, isVeryNearBorder);
		COLOR = float4(lerp(float3(0.1, 1.0, 0.0), float3(1.0, 1.0, 1.0), max(maskSum * 2.0 - 1.0, 0.0)) * darkness, min(maskSum * b * isNearBorder * 1.3 + 0.1, 1.0) * alpha);
	}
	return COLOR;
}
)" },
			{ "Blur", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float2 uPixelOffset;
uniform float2 uDirection;

uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	float4 color = ((float4)0.0);
	float2 off1 = ((float2)1.3846153846) * uPixelOffset * uDirection;
	float2 off2 = ((float2)3.2307692308) * uPixelOffset * uDirection;
	color += tex2D(uTexture, vTexCoords) * 0.2270270270;
	color += tex2D(uTexture, vTexCoords + off1) * 0.3162162162;
	color += tex2D(uTexture, vTexCoords - off1) * 0.3162162162;
	color += tex2D(uTexture, vTexCoords + off2) * 0.0702702703;
	color += tex2D(uTexture, vTexCoords - off2) * 0.0702702703;
	COLOR = color;
	return COLOR;
}
)" },
			{ "Colorized", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor;
	float4 dye = ((float4)1.0) + (COLOR - ((float4)0.5)) * ((float4)4.0);
	float4 original = tex2D(uTexture, vTexCoords);
	float average = (original.x + original.y + original.z) * 0.5;
	float4 gray = float4(average, average, average, original.w);
	COLOR = gray * dye;
	return COLOR;
}
)" },
			{ "BatchedColorized", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor;
	float4 dye = ((float4)1.0) + (COLOR - ((float4)0.5)) * ((float4)4.0);
	float4 original = tex2D(uTexture, vTexCoords);
	float average = (original.x + original.y + original.z) * 0.5;
	float4 gray = float4(average, average, average, original.w);
	COLOR = gray * dye;
	return COLOR;
}
)" },
			{ "Combine", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float2 vViewSizeInv;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float2 vViewSizeInv : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vViewSizeInv = ((float2)1.0) / spriteSize;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vViewSizeInv = vViewSizeInv;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4 uAmbientColor;
uniform float uTime;

uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTextureLighting : TEXUNIT1;
uniform sampler2D uTextureBlurHalf : TEXUNIT2;
uniform sampler2D uTextureBlurQuarter : TEXUNIT3;

static float2 vTexCoords;
static float2 vViewSizeInv;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float2 vViewSizeInv : TEXCOORD1;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float2 noiseTexCoords(float2 position)
{
	float2 seed = position + frac(uTime * 0.01);
	return clamp(position + hash2D(seed) * vViewSizeInv * 1.4, ((float2)0.0), ((float2)1.0));
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vViewSizeInv = _input.vViewSizeInv;
	float4 blur1 = tex2D(uTextureBlurHalf, vTexCoords);
	float4 blur2 = tex2D(uTextureBlurQuarter, vTexCoords);
	float4 main = tex2D(uTexture, vTexCoords);
	float4 light = tex2D(uTextureLighting, noiseTexCoords(vTexCoords));
	float4 blur = (blur1 + blur2) * ((float4)0.5);
	float gray = dot(blur.xyz, float3(0.299, 0.587, 0.114));
	blur = float4(gray, gray, gray, blur.w);
	COLOR = lerp(lerp(main * (1.0 + light.y) + max(light.y - 0.7, 0.0) * ((float4)1.0), blur, ((float4)clamp((1.0 - light.x) / sqrt(max(uAmbientColor.w, 0.35)), 0.0, 1.0))), uAmbientColor, ((float4)(1.0 - light.x)));
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "CombineWithWater", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float2 vViewSizeInv;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float2 vViewSizeInv : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vViewSizeInv = ((float2)1.0) / spriteSize;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vViewSizeInv = vViewSizeInv;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4 uAmbientColor;
uniform float uTime;
uniform float2 uCameraPos;
uniform float uWaterLevel;

uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTextureLighting : TEXUNIT1;
uniform sampler2D uTextureBlurHalf : TEXUNIT2;
uniform sampler2D uTextureBlurQuarter : TEXUNIT3;
uniform sampler2D uTextureNoise : TEXUNIT4;

static float2 vTexCoords;
static float2 vViewSizeInv;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float2 vViewSizeInv : TEXCOORD1;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float2 noiseTexCoords(float2 position)
{
	float2 seed = position + frac(uTime * 0.01);
	return clamp(position + hash2D(seed) * vViewSizeInv * 1.4, ((float2)0.0), ((float2)1.0));
}

float wave(float x, float time)
{
	float waveOffset = cos((x - time) * 60.0) * 0.004 + cos((x - 2.0 * time) * 20.0) * 0.008 + sin((x + 2.0 * time) * 35.0) * 0.01 + cos((x + 4.0 * time) * 70.0) * 0.001;
	return waveOffset * 0.4;
}

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float3 permute(float3 x)
{
	return ((x * 34.0 + 1.0) * x - (289.0) * floor(((x * 34.0 + 1.0) * x) / (289.0)));
}

float snoise(float2 v)
{
	const float4 C = float4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);
	float2 i = floor(v + dot(v, C.yy));
	float2 x0 = v - i + dot(i, C.xx);
	float2 i1 = x0.x > x0.y ? float2(1.0, 0.0) : float2(0.0, 1.0);
	float4 x12 = x0.xyxy + C.xxzz;
	x12.xy -= i1;
	i = (i - (289.0) * floor((i) / (289.0)));
	float3 p = permute(permute(i.y + float3(0.0, i1.y, 1.0)) + i.x + float3(0.0, i1.x, 1.0));
	float3 m = max(0.5 - float3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
	m = m * m;
	m = m * m;
	float3 x = 2.0 * frac(p * C.www) - 1.0;
	float3 h = abs(x) - 0.5;
	float3 ox = floor(x + 0.5);
	float3 a0 = x - ox;
	m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
	float3 g;
	g.x = a0.x * x0.x + h.x * x0.y;
	g.yz = a0.yz * x12.xz + h.yz * x12.yw;
	return 130.0 * dot(m, g);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vViewSizeInv = _input.vViewSizeInv;
	float3 waterColor = float3(0.4, 0.6, 0.8);
	float2 uvLocal = vTexCoords;
	float2 uvWorldCenter = uCameraPos.xy * vViewSizeInv.xy;
	float2 uvWorld = uvLocal + uvWorldCenter;
	float waveHeight = wave(uvWorld.x, uTime);
	float isTexelBelow = aastep(waveHeight, uvLocal.y - uWaterLevel);
	float isTexelAbove = 1.0 - isTexelBelow;
	float2 disPos = uvWorld * ((float2)0.1) + ((float2)(uTime * 0.4 - (2.0) * floor((uTime * 0.4) / (2.0))));
	float2 dis = (tex2D(uTextureNoise, disPos).xy - ((float2)0.5)) * ((float2)0.01);
	float2 uv = clamp(uvLocal + (float2(0.004 * sin(uTime * 16.0 + uvWorld.y * 20.0), 0.0) + dis) * ((float2)isTexelBelow), ((float2)0.0), ((float2)1.0));
	float4 main = tex2D(uTexture, uv);
	float aberration = abs(uvLocal.x - 0.5) * 0.012;
	float red = tex2D(uTexture, float2(uv.x - aberration, uv.y)).x;
	float blue = tex2D(uTexture, float2(uv.x + aberration, uv.y)).z;
	main.xyz = lerp(main.xyz, waterColor * (0.4 + 1.2 * float3(red, main.y, blue)), ((float3)(isTexelBelow * 0.5)));
	float2 uvNormalized = (uvLocal / vViewSizeInv - (720.0) * floor((uvLocal / vViewSizeInv) / (720.0))) / 720.0;
	float noisePos = uvWorldCenter.x * 6.0 + uvLocal.x * 1.4 + uvWorldCenter.y * 0.5 + (1.0 - uvNormalized.x * 1.2 - uvNormalized.y) * -5.0;
	float rays = snoise(float2(noisePos, uTime * 5.0 + uvWorldCenter.y)) * 0.55 + 0.3;
	main.xyz += ((float3)(rays * isTexelBelow * max(1.0 - uvLocal.y * 1.4, 0.0) * 0.6));
	float topDist = abs(uvLocal.y - uWaterLevel - waveHeight);
	float isNearTop = 1.0 - aastep(vViewSizeInv.y * 2.8, topDist);
	float isVeryNearTop = 1.0 - aastep(vViewSizeInv.y * (0.8 - 100.0 * waveHeight), topDist);
	float topColorBlendFac = isNearTop * isTexelBelow * 0.6;
	main.xyz = lerp(main.xyz, tex2D(uTexture, float2(uvLocal.x, (uWaterLevel - uvLocal.y + uWaterLevel) * 0.97 - waveHeight + vViewSizeInv.y)).xyz, ((float3)topColorBlendFac));
	main.xyz += ((float3)(0.2 * isVeryNearTop));
	float4 blur1 = tex2D(uTextureBlurHalf, uv);
	float4 blur2 = tex2D(uTextureBlurQuarter, uv);
	float4 light = tex2D(uTextureLighting, noiseTexCoords(uv));
	float4 blur = (blur1 + blur2) * ((float4)0.5);
	float gray = dot(blur.xyz, float3(0.299, 0.587, 0.114));
	blur = float4(gray, gray, gray, blur.w);
	float darknessStrength = 1.0 - light.x;
	if (uWaterLevel < 0.4) {
		float aboveWaterDarkness = isTexelAbove * (0.4 - uWaterLevel);
		darknessStrength = min(1.0, darknessStrength + aboveWaterDarkness);
	}
	COLOR = lerp(lerp(main * (1.0 + light.y) + max(light.y - 0.7, 0.0) * ((float4)1.0), blur, ((float4)clamp((1.0 - light.x) / sqrt(max(uAmbientColor.w, 0.35)), 0.0, 1.0))), uAmbientColor, ((float4)darknessStrength));
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "CombineWithWaterLow", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float2 vViewSizeInv;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float2 vViewSizeInv : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vViewSizeInv = ((float2)1.0) / spriteSize;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vViewSizeInv = vViewSizeInv;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4 uAmbientColor;
uniform float uTime;
uniform float2 uCameraPos;
uniform float uWaterLevel;

uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTextureLighting : TEXUNIT1;
uniform sampler2D uTextureBlurHalf : TEXUNIT2;
uniform sampler2D uTextureBlurQuarter : TEXUNIT3;

static float2 vTexCoords;
static float2 vViewSizeInv;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float2 vViewSizeInv : TEXCOORD1;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float2 noiseTexCoords(float2 position)
{
	float2 seed = position + frac(uTime * 0.01);
	return clamp(position + hash2D(seed) * vViewSizeInv * 1.4, ((float2)0.0), ((float2)1.0));
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vViewSizeInv = _input.vViewSizeInv;
	float3 waterColor = float3(0.4, 0.6, 0.8);
	float2 uvLocal = vTexCoords;
	float2 uvWorldCenter = uCameraPos.xy * vViewSizeInv.xy;
	float2 uvWorld = uvLocal + uvWorldCenter;
	float isTexelBelow = 1.0 - step(uvLocal.y, uWaterLevel);
	float isTexelAbove = 1.0 - isTexelBelow;
	float2 uv = clamp(uvLocal + float2(0.008 * sin(uTime * 16.0 + uvWorld.y * 20.0) * isTexelBelow, 0.0), ((float2)0.0), ((float2)1.0));
	float4 main = tex2D(uTexture, uv);
	float topDist = abs(uvLocal.y - uWaterLevel);
	float topGradient = max(1.0 - topDist, 0.0);
	float isNearTop = 0.2 * topGradient * topGradient;
	float isVeryNearTop = 1.0 - step(vViewSizeInv.y, topDist);
	main.xyz = lerp(main.xyz, waterColor, ((float3)(isTexelBelow * 0.4))) + ((float3)((isNearTop + 0.2 * isVeryNearTop) * isTexelBelow));
	float4 blur1 = tex2D(uTextureBlurHalf, uv);
	float4 blur2 = tex2D(uTextureBlurQuarter, uv);
	float4 light = tex2D(uTextureLighting, noiseTexCoords(uv));
	float4 blur = (blur1 + blur2) * ((float4)0.5);
	float gray = dot(blur.xyz, float3(0.299, 0.587, 0.114));
	blur = float4(gray, gray, gray, blur.w);
	float darknessStrength = 1.0 - light.x;
	if (uWaterLevel < 0.4) {
		float aboveWaterDarkness = isTexelAbove * (0.4 - uWaterLevel);
		darknessStrength = min(1.0, darknessStrength + aboveWaterDarkness);
	}
	COLOR = lerp(lerp(main * (1.0 + light.y) + max(light.y - 0.7, 0.0) * ((float4)1.0), blur, ((float4)clamp((1.0 - light.x) / sqrt(max(uAmbientColor.w, 0.35)), 0.0, 1.0))), uAmbientColor, ((float4)darknessStrength));
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "DefaultBatchedMeshSprites", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aPosition;
static float2 aTexCoords;
static float aMeshIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float2 aTexCoords : TEXCOORD1;
	float aMeshIndex : TEXCOORD2;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aTexCoords = _input.aTexCoords;
	aMeshIndex = _input.aMeshIndex;
	float4 position = float4(aPosition.x * instances[int(aMeshIndex)].spriteSize.x, aPosition.y * instances[int(aMeshIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aMeshIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aTexCoords.x * instances[int(aMeshIndex)].texRect.x + instances[int(aMeshIndex)].texRect.y, aTexCoords.y * instances[int(aMeshIndex)].texRect.z + instances[int(aMeshIndex)].texRect.w);
	vColor = instances[int(aMeshIndex)].color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = tex2D(uTexture, vTexCoords) * vColor;
	return COLOR;
}
)" },
			{ "DefaultBatchedMeshSpritesNoTexture", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 682

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float2 spriteSize;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aPosition;
static float aMeshIndex;
static float4 gl_Position;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float aMeshIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vColor : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aMeshIndex = _input.aMeshIndex;
	float4 position = float4(aPosition.x * instances[int(aMeshIndex)].spriteSize.x, aPosition.y * instances[int(aMeshIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aMeshIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vColor = instances[int(aMeshIndex)].color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vColor : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vColor = _input.vColor;
	COLOR = vColor;
	return COLOR;
}
)" },
			{ "DefaultBatchedSpritesNoTexture", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 682

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float2 spriteSize;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vColor : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vColor = instances[int(aInstanceIndex)].color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vColor : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vColor = _input.vColor;
	COLOR = vColor;
	return COLOR;
}
)" },
			{ "DefaultImGui", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uGuiProjection;
uniform float uDepth;

static float2 aPosition;
static float2 aTexCoords;
static float4 aColor;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float2 aTexCoords : TEXCOORD1;
	float4 aColor : TEXCOORD2;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aTexCoords = _input.aTexCoords;
	aColor = _input.aColor;
	gl_Position = mul(float4(aPosition, uDepth, 1.0), uGuiProjection);
	vTexCoords = aTexCoords;
	vColor = aColor;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor * tex2D(uTexture, vTexCoords);
	return COLOR;
}
)" },
			{ "DefaultMeshSprite", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aPosition;
static float2 aTexCoords;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float2 aTexCoords : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aTexCoords = _input.aTexCoords;
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aTexCoords.x * texRect.x + texRect.y, aTexCoords.y * texRect.z + texRect.w);
	vColor = color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = tex2D(uTexture, vTexCoords) * vColor;
	return COLOR;
}
)" },
			{ "DefaultMeshSpriteNoTexture", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float2 spriteSize;

static float2 aPosition;
static float4 gl_Position;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vColor : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vColor = color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vColor : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vColor = _input.vColor;
	COLOR = vColor;
	return COLOR;
}
)" },
			{ "DefaultSprite", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor;
	COLOR = tex2D(uTexture, vTexCoords) * COLOR;
	return COLOR;
}
)" },
			{ "DefaultBatchedSprites", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor;
	COLOR = tex2D(uTexture, vTexCoords) * COLOR;
	return COLOR;
}
)" },
			{ "DefaultSpriteNoTexture", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vColor : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vColor = color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vColor : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vColor = _input.vColor;
	COLOR = vColor;
	return COLOR;
}
)" },
			{ "Downsample", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float2 uPixelOffset;

uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	float4 color = tex2D(uTexture, vTexCoords);
	color += tex2D(uTexture, vTexCoords + float2(0.0, uPixelOffset.y));
	color += tex2D(uTexture, vTexCoords + float2(uPixelOffset.x, 0.0));
	color += tex2D(uTexture, vTexCoords + uPixelOffset);
	COLOR = ((float4)0.25) * color;
	return COLOR;
}
)" },
			{ "FrozenMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	return src;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float2 size = COLOR.xy * COLOR.w * 2.0;
	float4 tex = maskSample(vTexCoords);
	float4 tex1 = maskSample(vTexCoords + float2(-size.x, 0));
	float4 tex2 = maskSample(vTexCoords + float2(0, size.y));
	float4 tex3 = maskSample(vTexCoords + float2(size.x, 0));
	float4 tex4 = maskSample(vTexCoords + float2(0, -size.y));
	float outline = tex1.w;
	outline += tex2.w;
	outline += tex3.w;
	outline += tex4.w;
	outline += maskSample(vTexCoords + float2(-size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(-size.x, -size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, -size.y)).w;
	outline = aastep(1.0, outline);
	float4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0;
	float grey = min((0.299 * color.x + 0.587 * color.y + 0.114 * color.z) * 2.6, 1.0);
	COLOR = lerp(tex, float4(0.2 * grey, 0.2 + grey * 0.62, 0.6 + 0.2 * grey, outline * 0.95), COLOR.w);
	return COLOR;
}
)" },
			{ "FrozenMask", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float2 size = COLOR.xy * COLOR.w * 2.0;
	float4 tex = maskSample(vTexCoords);
	float4 tex1 = maskSample(vTexCoords + float2(-size.x, 0));
	float4 tex2 = maskSample(vTexCoords + float2(0, size.y));
	float4 tex3 = maskSample(vTexCoords + float2(size.x, 0));
	float4 tex4 = maskSample(vTexCoords + float2(0, -size.y));
	float outline = tex1.w;
	outline += tex2.w;
	outline += tex3.w;
	outline += tex4.w;
	outline += maskSample(vTexCoords + float2(-size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(-size.x, -size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, -size.y)).w;
	outline = aastep(1.0, outline);
	float4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0;
	float grey = min((0.299 * color.x + 0.587 * color.y + 0.114 * color.z) * 2.6, 1.0);
	COLOR = lerp(tex, float4(0.2 * grey, 0.2 + grey * 0.62, 0.6 + 0.2 * grey, outline * 0.95), COLOR.w);
	return COLOR;
}
)" },
			{ "BatchedFrozenMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	return src;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float2 size = COLOR.xy * COLOR.w * 2.0;
	float4 tex = maskSample(vTexCoords);
	float4 tex1 = maskSample(vTexCoords + float2(-size.x, 0));
	float4 tex2 = maskSample(vTexCoords + float2(0, size.y));
	float4 tex3 = maskSample(vTexCoords + float2(size.x, 0));
	float4 tex4 = maskSample(vTexCoords + float2(0, -size.y));
	float outline = tex1.w;
	outline += tex2.w;
	outline += tex3.w;
	outline += tex4.w;
	outline += maskSample(vTexCoords + float2(-size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(-size.x, -size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, -size.y)).w;
	outline = aastep(1.0, outline);
	float4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0;
	float grey = min((0.299 * color.x + 0.587 * color.y + 0.114 * color.z) * 2.6, 1.0);
	COLOR = lerp(tex, float4(0.2 * grey, 0.2 + grey * 0.62, 0.6 + 0.2 * grey, outline * 0.95), COLOR.w);
	return COLOR;
}
)" },
			{ "BatchedFrozenMask", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float2 size = COLOR.xy * COLOR.w * 2.0;
	float4 tex = maskSample(vTexCoords);
	float4 tex1 = maskSample(vTexCoords + float2(-size.x, 0));
	float4 tex2 = maskSample(vTexCoords + float2(0, size.y));
	float4 tex3 = maskSample(vTexCoords + float2(size.x, 0));
	float4 tex4 = maskSample(vTexCoords + float2(0, -size.y));
	float outline = tex1.w;
	outline += tex2.w;
	outline += tex3.w;
	outline += tex4.w;
	outline += maskSample(vTexCoords + float2(-size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, size.y)).w;
	outline += maskSample(vTexCoords + float2(-size.x, -size.y)).w;
	outline += maskSample(vTexCoords + float2(size.x, -size.y)).w;
	outline = aastep(1.0, outline);
	float4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0;
	float grey = min((0.299 * color.x + 0.587 * color.y + 0.114 * color.z) * 2.6, 1.0);
	COLOR = lerp(tex, float4(0.2 * grey, 0.2 + grey * 0.62, 0.6 + 0.2 * grey, outline * 0.95), COLOR.w);
	return COLOR;
}
)" },
			{ "LightingMesh", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

uniform sampler2D uTexture : TEXUNIT0;

static float2 aPosition;
static float2 aTexCoords;
static float4 aColor;
static float4 gl_Position;
static float4 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float2 aTexCoords : TEXCOORD1;
	float4 aColor : TEXCOORD2;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aTexCoords = _input.aTexCoords;
	aColor = _input.aColor;
	gl_Position = mul(float4(aPosition.x, aPosition.y, 0.0, 1.0), mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float4(0.0, 0.0, aTexCoords.x, 0.0);
	vColor = aColor;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float4 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float lightBlend(float t)
{
	return t * t * t;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	float2 center = vTexCoords.xy;
	float radiusNear = vTexCoords.z;
	float intensity = vColor.x;
	float brightness = vColor.y;
	float dist = length(vColor.zw);
	if (dist > 1.0) {
		COLOR = float4(0.0, 0.0, 0.0, 1.0);
	} else {
		float diffuseFactor = 1.0;
		float strength = diffuseFactor * lightBlend(clamp(1.0 - (dist - radiusNear) / (1.0 - radiusNear), 0.0, 1.0));
		COLOR = float4(strength * intensity, strength * brightness, 0.0, 1.0);
	}
	return COLOR;
}
)" },
			{ "Outline", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor;
	float2 size = COLOR.xy;
	float outline = tex2D(uTexture, vTexCoords + float2(-size.x, 0)).w;
	outline += tex2D(uTexture, vTexCoords + float2(0, size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(size.x, 0)).w;
	outline += tex2D(uTexture, vTexCoords + float2(0, -size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(-size.x, size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(size.x, size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(-size.x, -size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(size.x, -size.y)).w;
	outline = aastep(1.0, outline);
	float outline2 = tex2D(uTexture, vTexCoords + float2(-2.0 * size.x, 0)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(0, 2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(2.0 * size.x, 0)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(0, -2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(-2.0 * size.x, 2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(2.0 * size.x, 2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(-2.0 * size.x, -2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(2.0 * size.x, -2.0 * size.y)).w;
	outline2 = aastep(1.0, outline2);
	float4 color = tex2D(uTexture, vTexCoords);
	COLOR = lerp(color, lerp(float4(0.0, 0.0, 0.0, COLOR.w * 0.5), float4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.w);
	return COLOR;
}
)" },
			{ "BatchedOutline", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = vColor;
	float2 size = COLOR.xy;
	float outline = tex2D(uTexture, vTexCoords + float2(-size.x, 0)).w;
	outline += tex2D(uTexture, vTexCoords + float2(0, size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(size.x, 0)).w;
	outline += tex2D(uTexture, vTexCoords + float2(0, -size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(-size.x, size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(size.x, size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(-size.x, -size.y)).w;
	outline += tex2D(uTexture, vTexCoords + float2(size.x, -size.y)).w;
	outline = aastep(1.0, outline);
	float outline2 = tex2D(uTexture, vTexCoords + float2(-2.0 * size.x, 0)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(0, 2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(2.0 * size.x, 0)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(0, -2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(-2.0 * size.x, 2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(2.0 * size.x, 2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(-2.0 * size.x, -2.0 * size.y)).w;
	outline2 += tex2D(uTexture, vTexCoords + float2(2.0 * size.x, -2.0 * size.y)).w;
	outline2 = aastep(1.0, outline2);
	float4 color = tex2D(uTexture, vTexCoords);
	COLOR = lerp(color, lerp(float4(0.0, 0.0, 0.0, COLOR.w * 0.5), float4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.w);
	return COLOR;
}
)" },
			{ "OutlinePalette", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 palette(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float alphaAt(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	return tex2D(uTexturePalette, float2(palX, palY)).w * src.w;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float2 size = COLOR.xy;
	float outline = alphaAt(vTexCoords + float2(-size.x, 0));
	outline += alphaAt(vTexCoords + float2(0, size.y));
	outline += alphaAt(vTexCoords + float2(size.x, 0));
	outline += alphaAt(vTexCoords + float2(0, -size.y));
	outline += alphaAt(vTexCoords + float2(-size.x, size.y));
	outline += alphaAt(vTexCoords + float2(size.x, size.y));
	outline += alphaAt(vTexCoords + float2(-size.x, -size.y));
	outline += alphaAt(vTexCoords + float2(size.x, -size.y));
	outline = aastep(1.0, outline);
	float outline2 = alphaAt(vTexCoords + float2(-2.0 * size.x, 0));
	outline2 += alphaAt(vTexCoords + float2(0, 2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(2.0 * size.x, 0));
	outline2 += alphaAt(vTexCoords + float2(0, -2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(-2.0 * size.x, 2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(2.0 * size.x, 2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(-2.0 * size.x, -2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(2.0 * size.x, -2.0 * size.y));
	outline2 = aastep(1.0, outline2);
	float4 color = palette(vTexCoords);
	COLOR = lerp(color, lerp(float4(0.0, 0.0, 0.0, COLOR.w * 0.5), float4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.w);
	return COLOR;
}
)" },
			{ "BatchedOutlinePalette", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float4 palette(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float alphaAt(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	return tex2D(uTexturePalette, float2(palX, palY)).w * src.w;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float2 size = COLOR.xy;
	float outline = alphaAt(vTexCoords + float2(-size.x, 0));
	outline += alphaAt(vTexCoords + float2(0, size.y));
	outline += alphaAt(vTexCoords + float2(size.x, 0));
	outline += alphaAt(vTexCoords + float2(0, -size.y));
	outline += alphaAt(vTexCoords + float2(-size.x, size.y));
	outline += alphaAt(vTexCoords + float2(size.x, size.y));
	outline += alphaAt(vTexCoords + float2(-size.x, -size.y));
	outline += alphaAt(vTexCoords + float2(size.x, -size.y));
	outline = aastep(1.0, outline);
	float outline2 = alphaAt(vTexCoords + float2(-2.0 * size.x, 0));
	outline2 += alphaAt(vTexCoords + float2(0, 2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(2.0 * size.x, 0));
	outline2 += alphaAt(vTexCoords + float2(0, -2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(-2.0 * size.x, 2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(2.0 * size.x, 2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(-2.0 * size.x, -2.0 * size.y));
	outline2 += alphaAt(vTexCoords + float2(2.0 * size.x, -2.0 * size.y));
	outline2 = aastep(1.0, outline2);
	float4 color = palette(vTexCoords);
	COLOR = lerp(color, lerp(float4(0.0, 0.0, 0.0, COLOR.w * 0.5), float4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.w);
	return COLOR;
}
)" },
			{ "PaletteRemap", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 src = tex2D(uTexture, vTexCoords);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 color = tex2D(uTexturePalette, float2(palX, palY));
	COLOR = float4(color.xyz, color.w * src.w) * COLOR;
	return COLOR;
}
)" },
			{ "BatchedPaletteRemap", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 src = tex2D(uTexture, vTexCoords);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 color = tex2D(uTexturePalette, float2(palX, palY));
	COLOR = float4(color.xyz, color.w * src.w) * COLOR;
	return COLOR;
}
)" },
			{ "PartialWhiteMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	return src;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 2.5, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "PartialWhiteMask", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 2.5, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "BatchedPartialWhiteMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	return src;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 2.5, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "BatchedPartialWhiteMask", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 2.5, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "Resize3xBrz", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static const float one_third = 1.0 / 3.0;
static const float two_third = 2.0 / 3.0;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vPixelCoords;
static float4 vTexCoords1;
static float4 vTexCoords2;
static float4 vTexCoords3;
static float4 vTexCoords4;
static float4 vTexCoords5;
static float4 vTexCoords6;
static float4 vTexCoords7;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vPixelCoords : TEXCOORD0;
	float4 vTexCoords1 : TEXCOORD1;
	float4 vTexCoords2 : TEXCOORD2;
	float4 vTexCoords3 : TEXCOORD3;
	float4 vTexCoords4 : TEXCOORD4;
	float4 vTexCoords5 : TEXCOORD5;
	float4 vTexCoords6 : TEXCOORD6;
	float4 vTexCoords7 : TEXCOORD7;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	float dx = 1.0 / texRect.x;
	float dy = 1.0 / texRect.y;
	float2 texCoord = aPosition + float2(0.0000001, 0.0000001);
	vPixelCoords = texCoord * texRect.xy;
	vTexCoords1 = texCoord.xxxy + float4(-dx, 0, dx, -2.0 * dy);
	vTexCoords2 = texCoord.xxxy + float4(-dx, 0, dx, -dy);
	vTexCoords3 = texCoord.xxxy + float4(-dx, 0, dx, 0);
	vTexCoords4 = texCoord.xxxy + float4(-dx, 0, dx, dy);
	vTexCoords5 = texCoord.xxxy + float4(-dx, 0, dx, 2.0 * dy);
	vTexCoords6 = texCoord.xyyy + float4(-2.0 * dx, -dy, 0, dy);
	vTexCoords7 = texCoord.xyyy + float4(2.0 * dx, -dy, 0, dy);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vPixelCoords = vPixelCoords;
	_output.vTexCoords1 = vTexCoords1;
	_output.vTexCoords2 = vTexCoords2;
	_output.vTexCoords3 = vTexCoords3;
	_output.vTexCoords4 = vTexCoords4;
	_output.vTexCoords5 = vTexCoords5;
	_output.vTexCoords6 = vTexCoords6;
	_output.vTexCoords7 = vTexCoords7;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

uniform sampler2D uTexture : TEXUNIT0;

static const float one_third = 1.0 / 3.0;
static const float two_third = 2.0 / 3.0;

static float2 vPixelCoords;
static float4 vTexCoords1;
static float4 vTexCoords2;
static float4 vTexCoords3;
static float4 vTexCoords4;
static float4 vTexCoords5;
static float4 vTexCoords6;
static float4 vTexCoords7;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vPixelCoords : TEXCOORD0;
	float4 vTexCoords1 : TEXCOORD1;
	float4 vTexCoords2 : TEXCOORD2;
	float4 vTexCoords3 : TEXCOORD3;
	float4 vTexCoords4 : TEXCOORD4;
	float4 vTexCoords5 : TEXCOORD5;
	float4 vTexCoords6 : TEXCOORD6;
	float4 vTexCoords7 : TEXCOORD7;
};

float Reduce(float3 color)
{
	return dot(color, float3(65536.0, 256.0, 1.0));
}

float DistYCbCr(float3 pixA, float3 pixB)
{
	const float3 w = float3(0.2627, 0.6780, 0.0593);
	const float scaleB = 0.5 / (1.0 - w.z);
	const float scaleR = 0.5 / (1.0 - w.x);
	float3 diff = pixA - pixB;
	float Y = dot(diff, w);
	float Cb = scaleB * (diff.z - Y);
	float Cr = scaleR * (diff.x - Y);
	return sqrt(1.0 * Y * (1.0 * Y) + Cb * Cb + Cr * Cr);
}

bool IsPixEqual(float3 pixA, float3 pixB)
{
	return DistYCbCr(pixA, pixB) < 30.0 / 255.0;
}

bool IsBlendingNeeded(int4 blend)
{
	return any((blend != ((int4)0)));
}

void ScalePixel(int4 blend, float3 k[9], inout float3 dst[9])
{
	float v0 = Reduce(k[0]);
	float v4 = Reduce(k[4]);
	float v5 = Reduce(k[5]);
	float v7 = Reduce(k[7]);
	float v8 = Reduce(k[8]);
	float dist_01_04 = DistYCbCr(k[1], k[4]);
	float dist_03_08 = DistYCbCr(k[3], k[8]);
	bool haveShallowLine = 2.2 * dist_01_04 <= dist_03_08 && v0 != v4 && v5 != v4;
	bool haveSteepLine = 2.2 * dist_03_08 <= dist_01_04 && v0 != v8 && v7 != v8;
	bool needBlend = blend[2] != 0;
	bool doLineBlend = blend[2] >= 2 || !(blend[1] != 0 && !IsPixEqual(k[0], k[4]) || blend[3] != 0 && !IsPixEqual(k[0], k[8]) || IsPixEqual(k[4], k[3]) && IsPixEqual(k[3], k[2]) && IsPixEqual(k[2], k[1]) && IsPixEqual(k[1], k[8]) && !IsPixEqual(k[0], k[2]));
	float3 blendPix = DistYCbCr(k[0], k[1]) <= DistYCbCr(k[0], k[3]) ? k[1] : k[3];
	dst[1] = lerp(dst[1], blendPix, needBlend && doLineBlend ? (haveSteepLine ? 0.750 : haveShallowLine ? 0.250 : 0.125) : 0.000);
	dst[2] = lerp(dst[2], blendPix, needBlend ? (doLineBlend ? (!haveShallowLine && !haveSteepLine ? 0.875 : 1.000) : 0.4545939598) : 0.000);
	dst[3] = lerp(dst[3], blendPix, needBlend && doLineBlend ? (haveShallowLine ? 0.750 : haveSteepLine ? 0.250 : 0.125) : 0.000);
	dst[4] = lerp(dst[4], blendPix, needBlend && doLineBlend && haveShallowLine ? 0.250 : 0.000);
	dst[8] = lerp(dst[8], blendPix, needBlend && doLineBlend && haveSteepLine ? 0.250 : 0.000);
}

float4 main(PsInput _input) : COLOR
{
	vPixelCoords = _input.vPixelCoords;
	vTexCoords1 = _input.vTexCoords1;
	vTexCoords2 = _input.vTexCoords2;
	vTexCoords3 = _input.vTexCoords3;
	vTexCoords4 = _input.vTexCoords4;
	vTexCoords5 = _input.vTexCoords5;
	vTexCoords6 = _input.vTexCoords6;
	vTexCoords7 = _input.vTexCoords7;
	float2 f = frac(vPixelCoords);
	float3 src[25];
	src[21] = tex2D(uTexture, vTexCoords1.xw).xyz;
	src[22] = tex2D(uTexture, vTexCoords1.yw).xyz;
	src[23] = tex2D(uTexture, vTexCoords1.zw).xyz;
	src[6] = tex2D(uTexture, vTexCoords2.xw).xyz;
	src[7] = tex2D(uTexture, vTexCoords2.yw).xyz;
	src[8] = tex2D(uTexture, vTexCoords2.zw).xyz;
	src[5] = tex2D(uTexture, vTexCoords3.xw).xyz;
	src[0] = tex2D(uTexture, vTexCoords3.yw).xyz;
	src[1] = tex2D(uTexture, vTexCoords3.zw).xyz;
	src[4] = tex2D(uTexture, vTexCoords4.xw).xyz;
	src[3] = tex2D(uTexture, vTexCoords4.yw).xyz;
	src[2] = tex2D(uTexture, vTexCoords4.zw).xyz;
	src[15] = tex2D(uTexture, vTexCoords5.xw).xyz;
	src[14] = tex2D(uTexture, vTexCoords5.yw).xyz;
	src[13] = tex2D(uTexture, vTexCoords5.zw).xyz;
	src[19] = tex2D(uTexture, vTexCoords6.xy).xyz;
	src[18] = tex2D(uTexture, vTexCoords6.xz).xyz;
	src[17] = tex2D(uTexture, vTexCoords6.xw).xyz;
	src[9] = tex2D(uTexture, vTexCoords7.xy).xyz;
	src[10] = tex2D(uTexture, vTexCoords7.xz).xyz;
	src[11] = tex2D(uTexture, vTexCoords7.xw).xyz;
	float v[9];
	v[0] = Reduce(src[0]);
	v[1] = Reduce(src[1]);
	v[2] = Reduce(src[2]);
	v[3] = Reduce(src[3]);
	v[4] = Reduce(src[4]);
	v[5] = Reduce(src[5]);
	v[6] = Reduce(src[6]);
	v[7] = Reduce(src[7]);
	v[8] = Reduce(src[8]);
	int4 blendResult = ((int4)0);
	if (!(v[0] == v[1] && v[3] == v[2] || v[0] == v[3] && v[1] == v[2])) {
		float dist_03_01 = DistYCbCr(src[4], src[0]) + DistYCbCr(src[0], src[8]) + DistYCbCr(src[14], src[2]) + DistYCbCr(src[2], src[10]) + 4.0 * DistYCbCr(src[3], src[1]);
		float dist_00_02 = DistYCbCr(src[5], src[3]) + DistYCbCr(src[3], src[13]) + DistYCbCr(src[7], src[1]) + DistYCbCr(src[1], src[11]) + 4.0 * DistYCbCr(src[0], src[2]);
		bool dominantGradient = 3.6 * dist_03_01 < dist_00_02;
		blendResult[2] = dist_03_01 < dist_00_02 && v[0] != v[1] && v[0] != v[3] ? (dominantGradient ? 2 : 1) : 0;
	}
	if (!(v[5] == v[0] && v[4] == v[3] || v[5] == v[4] && v[0] == v[3])) {
		float dist_04_00 = DistYCbCr(src[17], src[5]) + DistYCbCr(src[5], src[7]) + DistYCbCr(src[15], src[3]) + DistYCbCr(src[3], src[1]) + 4.0 * DistYCbCr(src[4], src[0]);
		float dist_05_03 = DistYCbCr(src[18], src[4]) + DistYCbCr(src[4], src[14]) + DistYCbCr(src[6], src[0]) + DistYCbCr(src[0], src[2]) + 4.0 * DistYCbCr(src[5], src[3]);
		bool dominantGradient = 3.6 * dist_05_03 < dist_04_00;
		blendResult[3] = dist_04_00 > dist_05_03 && v[0] != v[5] && v[0] != v[3] ? (dominantGradient ? 2 : 1) : 0;
	}
	if (!(v[7] == v[8] && v[0] == v[1] || v[7] == v[0] && v[8] == v[1])) {
		float dist_00_08 = DistYCbCr(src[5], src[7]) + DistYCbCr(src[7], src[23]) + DistYCbCr(src[3], src[1]) + DistYCbCr(src[1], src[9]) + 4.0 * DistYCbCr(src[0], src[8]);
		float dist_07_01 = DistYCbCr(src[6], src[0]) + DistYCbCr(src[0], src[2]) + DistYCbCr(src[22], src[8]) + DistYCbCr(src[8], src[10]) + 4.0 * DistYCbCr(src[7], src[1]);
		bool dominantGradient = 3.6 * dist_07_01 < dist_00_08;
		blendResult[1] = dist_00_08 > dist_07_01 && v[0] != v[7] && v[0] != v[1] ? (dominantGradient ? 2 : 1) : 0;
	}
	if (!(v[6] == v[7] && v[5] == v[0] || v[6] == v[5] && v[7] == v[0])) {
		float dist_05_07 = DistYCbCr(src[18], src[6]) + DistYCbCr(src[6], src[22]) + DistYCbCr(src[4], src[0]) + DistYCbCr(src[0], src[8]) + 4.0 * DistYCbCr(src[5], src[7]);
		float dist_06_00 = DistYCbCr(src[19], src[5]) + DistYCbCr(src[5], src[3]) + DistYCbCr(src[21], src[7]) + DistYCbCr(src[7], src[1]) + 4.0 * DistYCbCr(src[6], src[0]);
		bool dominantGradient = 3.6 * dist_05_07 < dist_06_00;
		blendResult[0] = dist_05_07 < dist_06_00 && v[0] != v[5] && v[0] != v[7] ? (dominantGradient ? 2 : 1) : 0;
	}
	float3 dst[9];
	dst[0] = src[0];
	dst[1] = src[0];
	dst[2] = src[0];
	dst[3] = src[0];
	dst[4] = src[0];
	dst[5] = src[0];
	dst[6] = src[0];
	dst[7] = src[0];
	dst[8] = src[0];
	if (IsBlendingNeeded(blendResult)) {
		float3 k[9];
		float3 tempDst8;
		float3 tempDst7;
		k[8] = src[8];
		k[7] = src[7];
		k[6] = src[6];
		k[5] = src[5];
		k[4] = src[4];
		k[3] = src[3];
		k[2] = src[2];
		k[1] = src[1];
		k[0] = src[0];
		ScalePixel(blendResult.xyzw, k, dst);
		k[8] = src[6];
		k[7] = src[5];
		k[6] = src[4];
		k[5] = src[3];
		k[4] = src[2];
		k[3] = src[1];
		k[2] = src[8];
		k[1] = src[7];
		tempDst8 = dst[8];
		tempDst7 = dst[7];
		dst[8] = dst[6];
		dst[7] = dst[5];
		dst[6] = dst[4];
		dst[5] = dst[3];
		dst[4] = dst[2];
		dst[3] = dst[1];
		dst[2] = tempDst8;
		dst[1] = tempDst7;
		ScalePixel(blendResult.wxyz, k, dst);
		k[8] = src[4];
		k[7] = src[3];
		k[6] = src[2];
		k[5] = src[1];
		k[4] = src[8];
		k[3] = src[7];
		k[2] = src[6];
		k[1] = src[5];
		tempDst8 = dst[8];
		tempDst7 = dst[7];
		dst[8] = dst[6];
		dst[7] = dst[5];
		dst[6] = dst[4];
		dst[5] = dst[3];
		dst[4] = dst[2];
		dst[3] = dst[1];
		dst[2] = tempDst8;
		dst[1] = tempDst7;
		ScalePixel(blendResult.zwxy, k, dst);
		k[8] = src[2];
		k[7] = src[1];
		k[6] = src[8];
		k[5] = src[7];
		k[4] = src[6];
		k[3] = src[5];
		k[2] = src[4];
		k[1] = src[3];
		tempDst8 = dst[8];
		tempDst7 = dst[7];
		dst[8] = dst[6];
		dst[7] = dst[5];
		dst[6] = dst[4];
		dst[5] = dst[3];
		dst[4] = dst[2];
		dst[3] = dst[1];
		dst[2] = tempDst8;
		dst[1] = tempDst7;
		ScalePixel(blendResult.yzwx, k, dst);
		tempDst8 = dst[8];
		tempDst7 = dst[7];
		dst[8] = dst[6];
		dst[7] = dst[5];
		dst[6] = dst[4];
		dst[5] = dst[3];
		dst[4] = dst[2];
		dst[3] = dst[1];
		dst[2] = tempDst8;
		dst[1] = tempDst7;
	}
	float3 res = lerp(lerp(dst[6], lerp(dst[7], dst[8], step(two_third, f.x)), step(one_third, f.x)), lerp(lerp(dst[5], lerp(dst[0], dst[1], step(two_third, f.x)), step(one_third, f.x)), lerp(dst[4], lerp(dst[3], dst[2], step(two_third, f.x)), step(one_third, f.x)), step(two_third, f.y)), step(one_third, f.y));
	COLOR = float4(res, 1.0);
	return COLOR;
}
)" },
			{ "ResizeCleanEdge", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float3 highestColor = float3(1., 1., 1.);
static float similarThreshold = 0.0;
static float lineWidth = 1.0;
static const float scale = 4.0;
static const float3x3 yuv_matrix = float3x3(float3(0.299, 0.587, 0.114), float3(-0.169, -0.331, 0.5), float3(0.5, -0.419, -0.081));

static float2 aQuadCorner;
static float4 gl_Position;
static float2 v_px;
static float2 size;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 v_px : TEXCOORD0;
	float2 size : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	size = texRect.xy + 0.0001;
	v_px = aPosition.xy * size;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.v_px = v_px;
	_output.size = size;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float3 highestColor = float3(1., 1., 1.);
static float similarThreshold = 0.0;
static float lineWidth = 1.0;
static const float scale = 4.0;
static const float3x3 yuv_matrix = float3x3(float3(0.299, 0.587, 0.114), float3(-0.169, -0.331, 0.5), float3(0.5, -0.419, -0.081));

static float2 v_px;
static float2 size;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 v_px : TEXCOORD0;
	float2 size : TEXCOORD1;
};

bool similar(float4 col1, float4 col2)
{
	return col1.w == 0. && col2.w == 0. || distance(col1, col2) <= similarThreshold;
}

bool similar3(float4 col1, float4 col2, float4 col3)
{
	return similar(col1, col2) && similar(col2, col3);
}

bool similar4(float4 col1, float4 col2, float4 col3, float4 col4)
{
	return similar(col1, col2) && similar(col2, col3) && similar(col3, col4);
}

bool higher(float4 thisCol, float4 otherCol)
{
	if (similar(thisCol, otherCol)) {
		return false;
	}
	if (thisCol.w == otherCol.w) {
		return distance(thisCol.xyz, highestColor) < distance(otherCol.xyz, highestColor);
	} else {
		return thisCol.w > otherCol.w;
	}
}

float cd(float4 col1, float4 col2)
{
	return distance(col1.xyzw, col2.xyzw);
}

float distToLine(float2 testPt, float2 pt1, float2 pt2, float2 dir)
{
	float2 lineDir = pt2 - pt1;
	float2 perpDir = float2(lineDir.y, -lineDir.x);
	float2 dirToPt1 = pt1 - testPt;
	return (dot(perpDir, dir) > 0.0 ? 1.0 : -1.0) * dot(normalize(perpDir), dirToPt1);
}

float4 sliceDist(float2 point_, float2 mainDir, float2 pointDir, float4 ub, float4 u, float4 uf, float4 uff, float4 b, float4 c, float4 f, float4 ff, float4 db, float4 d, float4 df, float4 dff, float4 ddb, float4 dd, float4 ddf)
{
	float minWidth = 0.45;
	float maxWidth = 1.142;
	float _lineWidth = max(minWidth, min(maxWidth, lineWidth));
	point_ = mainDir * (point_ - 0.5) + 0.5;
	float distAgainst = 4.0 * cd(f, d) + cd(uf, c) + cd(c, db) + cd(ff, df) + cd(df, dd);
	float distTowards = 4.0 * cd(c, df) + cd(u, f) + cd(f, dff) + cd(b, d) + cd(d, ddf);
	bool shouldSlice = distAgainst < distTowards || distAgainst < distTowards + 0.001 && !higher(c, f);
	if (similar4(f, d, b, u) && similar4(uf, df, db, ub) && !similar(c, f)) {
		shouldSlice = false;
	}
	if (!shouldSlice) {
		return ((float4)-1.0);
	}
	float dist = 1.0;
	bool flip = false;
	float2 center = float2(0.5, 0.5);
	if (similar3(f, d, db) && !similar3(f, d, b) && !similar(uf, db)) {
		if (similar(c, df) && higher(c, f)) {
		} else {
			if (higher(c, f)) {
				flip = true;
			}
			if (similar(u, f) && !similar(c, df) && !higher(c, u)) {
				flip = true;
			}
		}
		if (flip) {
			dist = _lineWidth - distToLine(point_, center + float2(1.5, -1.0) * pointDir, center + float2(-0.5, 0.0) * pointDir, -pointDir);
		} else {
			dist = distToLine(point_, center + float2(1.5, 0.0) * pointDir, center + float2(-0.5, 1.0) * pointDir, pointDir);
		}
		if (!flip && similar(c, uf) && !(similar3(c, uf, uff) && !similar3(c, uf, ff) && !similar(d, uff))) {
			float dist2 = distToLine(point_, center + float2(2.0, -1.0) * pointDir, center + float2(-0.0, 1.0) * pointDir, pointDir);
			dist = min(dist, dist2);
		}
		dist -= _lineWidth / 2.0;
		return dist <= 0.0 ? (cd(c, f) <= cd(c, d) ? f : d) : ((float4)-1.0);
	} else {
		if (similar3(uf, f, d) && !similar3(u, f, d) && !similar(uf, db)) {
			if (similar(c, df) && higher(c, d)) {
			} else {
				if (higher(c, d)) {
					flip = true;
				}
				if (similar(b, d) && !similar(c, df) && !higher(c, d)) {
					flip = true;
				}
			}
			if (flip) {
				dist = _lineWidth - distToLine(point_, center + float2(0.0, -0.5) * pointDir, center + float2(-1.0, 1.5) * pointDir, -pointDir);
			} else {
				dist = distToLine(point_, center + float2(1.0, -0.5) * pointDir, center + float2(0.0, 1.5) * pointDir, pointDir);
			}
			if (!flip && similar(c, db) && !(similar3(c, db, ddb) && !similar3(c, db, dd) && !similar(f, ddb))) {
				float dist2 = distToLine(point_, center + float2(1.0, 0.0) * pointDir, center + float2(-1.0, 2.0) * pointDir, pointDir);
				dist = min(dist, dist2);
			}
			dist -= _lineWidth / 2.0;
			return dist <= 0.0 ? (cd(c, f) <= cd(c, d) ? f : d) : ((float4)-1.0);
		} else {
			if (similar(f, d)) {
				if (similar(c, df) && higher(c, f)) {
					if (!similar(c, dd) && !similar(c, ff)) {
						flip = true;
					}
				} else {
					if (higher(c, f)) {
						flip = true;
					}
					if (!similar(c, b) && similar4(b, f, d, u)) {
						flip = true;
					}
				}
				if ((similar(f, db) && similar3(u, f, df) || similar(uf, d) && similar3(b, d, df)) && !similar(c, df)) {
					flip = true;
				}
				if (flip) {
					dist = _lineWidth - distToLine(point_, center + float2(1.0, -1.0) * pointDir, center + float2(-1.0, 1.0) * pointDir, -pointDir);
				} else {
					dist = distToLine(point_, center + float2(1.0, 0.0) * pointDir, center + float2(0.0, 1.0) * pointDir, pointDir);
				}
				if (!flip && similar3(c, uf, uff) && !similar3(c, uf, ff) && !similar(d, uff)) {
					float dist2 = distToLine(point_, center + float2(1.5, 0.0) * pointDir, center + float2(-0.5, 1.0) * pointDir, pointDir);
					dist = max(dist, dist2);
				}
				if (!flip && similar3(ddb, db, c) && !similar3(dd, db, c) && !similar(ddb, f)) {
					float dist2 = distToLine(point_, center + float2(1.0, -0.5) * pointDir, center + float2(0.0, 1.5) * pointDir, pointDir);
					dist = max(dist, dist2);
				}
				dist -= _lineWidth / 2.0;
				return dist <= 0.0 ? (cd(c, f) <= cd(c, d) ? f : d) : ((float4)-1.0);
			} else {
				if (similar3(ff, df, d) && !similar3(ff, df, c) && !similar(uff, d)) {
					if (similar(f, dff) && higher(f, ff)) {
					} else {
						if (higher(f, ff)) {
							flip = true;
						}
						if (similar(uf, ff) && !similar(f, dff) && !higher(f, uf)) {
							flip = true;
						}
					}
					if (flip) {
						dist = _lineWidth - distToLine(point_, center + float2(2.5, -1.0) * pointDir, center + float2(0.5, 0.0) * pointDir, -pointDir);
					} else {
						dist = distToLine(point_, center + float2(2.5, 0.0) * pointDir, center + float2(0.5, 1.0) * pointDir, pointDir);
					}
					dist -= _lineWidth / 2.0;
					return dist <= 0.0 ? (cd(f, ff) <= cd(f, df) ? ff : df) : ((float4)-1.0);
				} else {
					if (similar3(f, df, dd) && !similar3(c, df, dd) && !similar(f, ddb)) {
						if (similar(d, ddf) && higher(d, dd)) {
						} else {
							if (higher(d, dd)) {
								flip = true;
							}
							if (similar(db, dd) && !similar(d, ddf) && !higher(d, dd)) {
								flip = true;
							}
						}
						if (flip) {
							dist = _lineWidth - distToLine(point_, center + float2(0.0, 0.5) * pointDir, center + float2(-1.0, 2.5) * pointDir, -pointDir);
						} else {
							dist = distToLine(point_, center + float2(1.0, 0.5) * pointDir, center + float2(0.0, 2.5) * pointDir, pointDir);
						}
						dist -= _lineWidth / 2.0;
						return dist <= 0.0 ? (cd(d, df) <= cd(d, dd) ? df : dd) : ((float4)-1.0);
					}
				}
			}
		}
	}
	return ((float4)-1.0);
}

float4 main(PsInput _input) : COLOR
{
	v_px = _input.v_px;
	size = _input.size;
	float2 local = frac(v_px);
	float2 px = ceil(v_px);
	float2 pointDir = floor(local + 0.5) * 2.0 - 1.0;
	float4 uub = tex2D(uTexture, (px + float2(-1.0, -2.0) * pointDir) / size);
	float4 uu = tex2D(uTexture, (px + float2(0.0, -2.0) * pointDir) / size);
	float4 uuf = tex2D(uTexture, (px + float2(1.0, -2.0) * pointDir) / size);
	float4 ubb = tex2D(uTexture, (px + float2(-2.0, -2.0) * pointDir) / size);
	float4 ub = tex2D(uTexture, (px + float2(-1.0, -1.0) * pointDir) / size);
	float4 u = tex2D(uTexture, (px + float2(0.0, -1.0) * pointDir) / size);
	float4 uf = tex2D(uTexture, (px + float2(1.0, -1.0) * pointDir) / size);
	float4 uff = tex2D(uTexture, (px + float2(2.0, -1.0) * pointDir) / size);
	float4 bb = tex2D(uTexture, (px + float2(-2.0, 0.0) * pointDir) / size);
	float4 b = tex2D(uTexture, (px + float2(-1.0, 0.0) * pointDir) / size);
	float4 c = tex2D(uTexture, (px + float2(0.0, 0.0) * pointDir) / size);
	float4 f = tex2D(uTexture, (px + float2(1.0, 0.0) * pointDir) / size);
	float4 ff = tex2D(uTexture, (px + float2(2.0, 0.0) * pointDir) / size);
	float4 dbb = tex2D(uTexture, (px + float2(-2.0, 1.0) * pointDir) / size);
	float4 db = tex2D(uTexture, (px + float2(-1.0, 1.0) * pointDir) / size);
	float4 d = tex2D(uTexture, (px + float2(0.0, 1.0) * pointDir) / size);
	float4 df = tex2D(uTexture, (px + float2(1.0, 1.0) * pointDir) / size);
	float4 dff = tex2D(uTexture, (px + float2(2.0, 1.0) * pointDir) / size);
	float4 ddb = tex2D(uTexture, (px + float2(-1.0, 2.0) * pointDir) / size);
	float4 dd = tex2D(uTexture, (px + float2(0.0, 2.0) * pointDir) / size);
	float4 ddf = tex2D(uTexture, (px + float2(1.0, 2.0) * pointDir) / size);
	float4 col = c;
	float4 c_col = sliceDist(local, float2(1.0, 1.0), pointDir, ub, u, uf, uff, b, c, f, ff, db, d, df, dff, ddb, dd, ddf);
	float4 b_col = sliceDist(local, float2(-1.0, 1.0), pointDir, uf, u, ub, ubb, f, c, b, bb, df, d, db, dbb, ddf, dd, ddb);
	float4 u_col = sliceDist(local, float2(1.0, -1.0), pointDir, db, d, df, dff, b, c, f, ff, ub, u, uf, uff, uub, uu, uuf);
	if (c_col.x >= 0.0) {
		col = c_col;
	}
	if (b_col.x >= 0.0) {
		col = b_col;
	}
	if (u_col.x >= 0.0) {
		col = u_col;
	}
	COLOR = col;
	return COLOR;
}
)" },
			{ "ResizeCrtApertureGrille", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float2 vTexSize;
static float2 vViewSize;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float2 vTexSize : TEXCOORD1;
	float2 vViewSize : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = aPosition;
	vTexSize = texRect.xy;
	vViewSize = spriteSize;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vTexSize = vTexSize;
	_output.vViewSize = vViewSize;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float2 vTexSize;
static float2 vViewSize;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float2 vTexSize : TEXCOORD1;
	float2 vViewSize : TEXCOORD2;
};

float ToLinear1(float c)
{
	if (1 == 0) {
		return c;
	}
	return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4);
}

float3 ToLinear(float3 c)
{
	if (1 == 0) {
		return c;
	}
	return float3(ToLinear1(c.x), ToLinear1(c.y), ToLinear1(c.z));
}

float ToSrgb1(float c)
{
	if (1 == 0) {
		return c;
	}
	return c < 0.0031308 ? c * 12.92 : 1.055 * pow(c, 0.41666) - 0.055;
}

float3 ToSrgb(float3 c)
{
	if (1 == 0) {
		return c;
	}
	return float3(ToSrgb1(c.x), ToSrgb1(c.y), ToSrgb1(c.z));
}

float3 Fetch(float2 pos, float2 off, float2 texture_size)
{
	pos = (floor(pos * texture_size.xy + off) + float2(0.5, 0.5)) / texture_size.xy;
	return ToLinear(((float3)1.1) * tex2D(uTexture, pos.xy).xyz);
}

float2 Dist(float2 pos, float2 texture_size)
{
	pos = pos * texture_size.xy;
	return -(pos - floor(pos) - float2(0.5, 0.5));
}

float Gaus(float pos, float scale)
{
	return exp2(scale * pow(abs(pos), 2.0));
}

float3 Horz3(float2 pos, float off, float2 texture_size)
{
	float3 b = Fetch(pos, float2(-1.0, off), texture_size);
	float3 c = Fetch(pos, float2(0.0, off), texture_size);
	float3 d = Fetch(pos, float2(1.0, off), texture_size);
	float dst = Dist(pos, texture_size).x;
	float scale = -3.0;
	float wb = Gaus(dst - 1.0, scale);
	float wc = Gaus(dst + 0.0, scale);
	float wd = Gaus(dst + 1.0, scale);
	return (b * wb + c * wc + d * wd) / (wb + wc + wd);
}

float3 Horz5(float2 pos, float off, float2 texture_size)
{
	float3 a = Fetch(pos, float2(-2.0, off), texture_size);
	float3 b = Fetch(pos, float2(-1.0, off), texture_size);
	float3 c = Fetch(pos, float2(0.0, off), texture_size);
	float3 d = Fetch(pos, float2(1.0, off), texture_size);
	float3 e = Fetch(pos, float2(2.0, off), texture_size);
	float dst = Dist(pos, texture_size).x;
	float scale = -3.0;
	float wa = Gaus(dst - 2.0, scale);
	float wb = Gaus(dst - 1.0, scale);
	float wc = Gaus(dst + 0.0, scale);
	float wd = Gaus(dst + 1.0, scale);
	float we = Gaus(dst + 2.0, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we) / (wa + wb + wc + wd + we);
}

float3 Horz7(float2 pos, float off, float2 texture_size)
{
	float3 a = Fetch(pos, float2(-3.0, off), texture_size);
	float3 b = Fetch(pos, float2(-2.0, off), texture_size);
	float3 c = Fetch(pos, float2(-1.0, off), texture_size);
	float3 d = Fetch(pos, float2(0.0, off), texture_size);
	float3 e = Fetch(pos, float2(1.0, off), texture_size);
	float3 f = Fetch(pos, float2(2.0, off), texture_size);
	float3 g = Fetch(pos, float2(3.0, off), texture_size);
	float dst = Dist(pos, texture_size).x;
	float scale = -1.5;
	float wa = Gaus(dst - 3.0, scale);
	float wb = Gaus(dst - 2.0, scale);
	float wc = Gaus(dst - 1.0, scale);
	float wd = Gaus(dst + 0.0, scale);
	float we = Gaus(dst + 1.0, scale);
	float wf = Gaus(dst + 2.0, scale);
	float wg = Gaus(dst + 3.0, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we + f * wf + g * wg) / (wa + wb + wc + wd + we + wf + wg);
}

float Scan(float2 pos, float off, float2 texture_size)
{
	float dst = Dist(pos, texture_size).y;
	return Gaus(dst + off, -8.0);
}

float BloomScan(float2 pos, float off, float2 texture_size)
{
	float dst = Dist(pos, texture_size).y;
	return Gaus(dst + off, -2.0);
}

float3 Tri(float2 pos, float2 texture_size)
{
	float3 a = Horz3(pos, -1.0, texture_size);
	float3 b = Horz5(pos, 0.0, texture_size);
	float3 c = Horz3(pos, 1.0, texture_size);
	float wa = Scan(pos, -1.0, texture_size);
	float wb = Scan(pos, 0.0, texture_size);
	float wc = Scan(pos, 1.0, texture_size);
	return a * wa + b * wb + c * wc;
}

float3 Bloom(float2 pos, float2 texture_size)
{
	float3 a = Horz5(pos, -2.0, texture_size);
	float3 b = Horz7(pos, -1.0, texture_size);
	float3 c = Horz7(pos, 0.0, texture_size);
	float3 d = Horz7(pos, 1.0, texture_size);
	float3 e = Horz5(pos, 2.0, texture_size);
	float wa = BloomScan(pos, -2.0, texture_size);
	float wb = BloomScan(pos, -1.0, texture_size);
	float wc = BloomScan(pos, 0.0, texture_size);
	float wd = BloomScan(pos, 1.0, texture_size);
	float we = BloomScan(pos, 2.0, texture_size);
	return a * wa + b * wb + c * wc + d * wd + e * we;
}

float2 Warp(float2 pos)
{
	pos = pos * 2.0 - 1.0;
	pos *= float2(1.0 + pos.y * pos.y * 0.0155, 1.0 + pos.x * pos.x * 0.0205);
	return pos * 0.5 + 0.5;
}

float3 Mask(float2 pos)
{
	float3 mask = float3(0.7, 0.7, 0.7);
	pos.x = frac(pos.x / 3.0);
	if (pos.x < 0.333) {
		mask.x = 1.5;
	} else {
		if (pos.x < 0.666) {
			mask.y = 1.5;
		} else {
			mask.z = 1.5;
		}
	}
	return mask;
}

float4 crt_lottes(float2 texture_size, float2 video_size, float2 output_size, float2 tex)
{
	float2 pos = Warp(tex.xy * (texture_size.xy / video_size.xy)) * (video_size.xy / texture_size.xy);
	float3 outColor = Tri(pos, texture_size);
	outColor.xyz += Bloom(pos, texture_size) * 1.0 / 16.0;
	outColor.xyz *= Mask(floor(tex.xy * (texture_size.xy / video_size.xy) * output_size.xy) + float2(0.5, 0.5));
	return float4(ToSrgb(outColor.xyz), 1.0);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vTexSize = _input.vTexSize;
	vViewSize = _input.vViewSize;
	COLOR = crt_lottes(vTexSize, vTexSize, vViewSize, vTexCoords);
	return COLOR;
}
)" },
			{ "ResizeCrtScanlines", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vPixelCoords;
static float2 vTexCoords;
static float2 vOutputSize;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vPixelCoords : TEXCOORD0;
	float2 vTexCoords : TEXCOORD1;
	float2 vOutputSize : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vPixelCoords = aPosition * spriteSize.xy;
	vTexCoords = aPosition;
	vOutputSize = spriteSize.xy;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vPixelCoords = vPixelCoords;
	_output.vTexCoords = vTexCoords;
	_output.vOutputSize = vOutputSize;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vPixelCoords;
static float2 vTexCoords;
static float2 vOutputSize;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vPixelCoords : TEXCOORD0;
	float2 vTexCoords : TEXCOORD1;
	float2 vOutputSize : TEXCOORD2;
};

float3 toYiq(float3 value)
{
	const float3x3 yiqmat = float3x3(0.2989, 0.5870, 0.1140, 0.5959, -0.2744, -0.3216, 0.2115, -0.5229, 0.3114);
	return mul(yiqmat, value);
}

float3 fromYiq(float3 value)
{
	const float3x3 rgbmat = float3x3(1.0, 0.956, 0.6210, 1.0, -0.272, -0.6474, 1.0, -1.106, 1.7046);
	return mul(rgbmat, value);
}

float4 main(PsInput _input) : COLOR
{
	vPixelCoords = _input.vPixelCoords;
	vTexCoords = _input.vTexCoords;
	vOutputSize = _input.vOutputSize;
	float y = vPixelCoords.y;
	float2 uv0 = float2(vTexCoords.x, y / vOutputSize.y);
	float3 t0 = tex2D(uTexture, uv0).xyz;
	float ymod = (vPixelCoords.y - (3.0) * floor((vPixelCoords.y) / (3.0)));
	if (ymod > 2.0) {
		float2 uv1 = float2(vTexCoords.x, (y + 1.0) / vOutputSize.y);
		float3 t1 = tex2D(uTexture, uv1).xyz;
		COLOR.xyz = (t0 + t1) * 0.25;
	} else {
		t0 = toYiq(t0);
		t0.x *= 1.1;
		t0 = fromYiq(t0);
		COLOR.xyz = t0;
	}
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "ResizeCrtShadowMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float2 vTexSize;
static float2 vViewSize;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float2 vTexSize : TEXCOORD1;
	float2 vViewSize : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = aPosition;
	vTexSize = texRect.xy;
	vViewSize = spriteSize;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vTexSize = vTexSize;
	_output.vViewSize = vViewSize;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float2 vTexSize;
static float2 vViewSize;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float2 vTexSize : TEXCOORD1;
	float2 vViewSize : TEXCOORD2;
};

float ToLinear1(float c)
{
	if (1 == 0) {
		return c;
	}
	return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4);
}

float3 ToLinear(float3 c)
{
	if (1 == 0) {
		return c;
	}
	return float3(ToLinear1(c.x), ToLinear1(c.y), ToLinear1(c.z));
}

float ToSrgb1(float c)
{
	if (1 == 0) {
		return c;
	}
	return c < 0.0031308 ? c * 12.92 : 1.055 * pow(c, 0.41666) - 0.055;
}

float3 ToSrgb(float3 c)
{
	if (1 == 0) {
		return c;
	}
	return float3(ToSrgb1(c.x), ToSrgb1(c.y), ToSrgb1(c.z));
}

float3 Fetch(float2 pos, float2 off, float2 texture_size)
{
	pos = (floor(pos * texture_size.xy + off) + float2(0.5, 0.5)) / texture_size.xy;
	return ToLinear(((float3)1.0) * tex2D(uTexture, pos.xy).xyz);
}

float2 Dist(float2 pos, float2 texture_size)
{
	pos = pos * texture_size.xy;
	return -(pos - floor(pos) - float2(0.5, 0.5));
}

float Gaus(float pos, float scale)
{
	return exp2(scale * pow(abs(pos), 2.0));
}

float3 Horz3(float2 pos, float off, float2 texture_size)
{
	float3 b = Fetch(pos, float2(-1.0, off), texture_size);
	float3 c = Fetch(pos, float2(0.0, off), texture_size);
	float3 d = Fetch(pos, float2(1.0, off), texture_size);
	float dst = Dist(pos, texture_size).x;
	float scale = -3.0;
	float wb = Gaus(dst - 1.0, scale);
	float wc = Gaus(dst + 0.0, scale);
	float wd = Gaus(dst + 1.0, scale);
	return (b * wb + c * wc + d * wd) / (wb + wc + wd);
}

float3 Horz5(float2 pos, float off, float2 texture_size)
{
	float3 a = Fetch(pos, float2(-2.0, off), texture_size);
	float3 b = Fetch(pos, float2(-1.0, off), texture_size);
	float3 c = Fetch(pos, float2(0.0, off), texture_size);
	float3 d = Fetch(pos, float2(1.0, off), texture_size);
	float3 e = Fetch(pos, float2(2.0, off), texture_size);
	float dst = Dist(pos, texture_size).x;
	float scale = -3.0;
	float wa = Gaus(dst - 2.0, scale);
	float wb = Gaus(dst - 1.0, scale);
	float wc = Gaus(dst + 0.0, scale);
	float wd = Gaus(dst + 1.0, scale);
	float we = Gaus(dst + 2.0, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we) / (wa + wb + wc + wd + we);
}

float3 Horz7(float2 pos, float off, float2 texture_size)
{
	float3 a = Fetch(pos, float2(-3.0, off), texture_size);
	float3 b = Fetch(pos, float2(-2.0, off), texture_size);
	float3 c = Fetch(pos, float2(-1.0, off), texture_size);
	float3 d = Fetch(pos, float2(0.0, off), texture_size);
	float3 e = Fetch(pos, float2(1.0, off), texture_size);
	float3 f = Fetch(pos, float2(2.0, off), texture_size);
	float3 g = Fetch(pos, float2(3.0, off), texture_size);
	float dst = Dist(pos, texture_size).x;
	float scale = -1.5;
	float wa = Gaus(dst - 3.0, scale);
	float wb = Gaus(dst - 2.0, scale);
	float wc = Gaus(dst - 1.0, scale);
	float wd = Gaus(dst + 0.0, scale);
	float we = Gaus(dst + 1.0, scale);
	float wf = Gaus(dst + 2.0, scale);
	float wg = Gaus(dst + 3.0, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we + f * wf + g * wg) / (wa + wb + wc + wd + we + wf + wg);
}

float Scan(float2 pos, float off, float2 texture_size)
{
	float dst = Dist(pos, texture_size).y;
	return Gaus(dst + off, -6.0);
}

float BloomScan(float2 pos, float off, float2 texture_size)
{
	float dst = Dist(pos, texture_size).y;
	return Gaus(dst + off, -2.0);
}

float3 Tri(float2 pos, float2 texture_size)
{
	float3 a = Horz3(pos, -1.0, texture_size);
	float3 b = Horz5(pos, 0.0, texture_size);
	float3 c = Horz3(pos, 1.0, texture_size);
	float wa = Scan(pos, -1.0, texture_size);
	float wb = Scan(pos, 0.0, texture_size);
	float wc = Scan(pos, 1.0, texture_size);
	return a * wa + b * wb + c * wc;
}

float3 Bloom(float2 pos, float2 texture_size)
{
	float3 a = Horz5(pos, -2.0, texture_size);
	float3 b = Horz7(pos, -1.0, texture_size);
	float3 c = Horz7(pos, 0.0, texture_size);
	float3 d = Horz7(pos, 1.0, texture_size);
	float3 e = Horz5(pos, 2.0, texture_size);
	float wa = BloomScan(pos, -2.0, texture_size);
	float wb = BloomScan(pos, -1.0, texture_size);
	float wc = BloomScan(pos, 0.0, texture_size);
	float wd = BloomScan(pos, 1.0, texture_size);
	float we = BloomScan(pos, 2.0, texture_size);
	return a * wa + b * wb + c * wc + d * wd + e * we;
}

float2 Warp(float2 pos)
{
	pos = pos * 2.0 - 1.0;
	pos *= float2(1.0 + pos.y * pos.y * 0.031, 1.0 + pos.x * pos.x * 0.041);
	return pos * 0.5 + 0.5;
}

float3 Mask(float2 pos)
{
	float3 mask = float3(0.55, 0.55, 0.55);
	pos.xy = floor(pos.xy * float2(1.0, 0.5));
	pos.x += pos.y * 3.0;
	pos.x = frac(pos.x / 6.0);
	if (pos.x < 0.333) {
		mask.x = 1.5;
	} else {
		if (pos.x < 0.666) {
			mask.y = 1.5;
		} else {
			mask.z = 1.5;
		}
	}
	return mask;
}

float4 crt_lottes(float2 texture_size, float2 video_size, float2 output_size, float2 tex)
{
	float2 pos = Warp(tex.xy * (texture_size.xy / video_size.xy)) * (video_size.xy / texture_size.xy);
	float3 outColor = Tri(pos, texture_size);
	outColor.xyz += Bloom(pos, texture_size) * 1.0 / 12.0;
	outColor.xyz *= Mask(floor(tex.xy * (texture_size.xy / video_size.xy) * output_size.xy) + float2(0.5, 0.5));
	return float4(ToSrgb(outColor.xyz), 1.0);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vTexSize = _input.vTexSize;
	vViewSize = _input.vViewSize;
	COLOR = crt_lottes(vTexSize, vTexSize, vViewSize, vTexCoords);
	return COLOR;
}
)" },
			{ "ResizeHQ2x", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static const float mx = 0.325;
static const float k = -0.250;
static const float max_w = 0.25;
static const float min_w = -0.05;
static const float lum_add = 0.25;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords0;
static float4 vTexCoords1;
static float4 vTexCoords2;
static float4 vTexCoords3;
static float4 vTexCoords4;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords0 : TEXCOORD0;
	float4 vTexCoords1 : TEXCOORD1;
	float4 vTexCoords2 : TEXCOORD2;
	float4 vTexCoords3 : TEXCOORD3;
	float4 vTexCoords4 : TEXCOORD4;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	float x = 0.5 / texRect.x;
	float y = 0.5 / texRect.y;
	float2 dg1 = float2(x, y);
	float2 dg2 = float2(-x, y);
	float2 dx = float2(x, 0.0);
	float2 dy = float2(0.0, y);
	vTexCoords0.xy = aPosition;
	vTexCoords1.xy = aPosition - dg1;
	vTexCoords1.zw = aPosition - dy;
	vTexCoords2.xy = aPosition - dg2;
	vTexCoords2.zw = aPosition + dx;
	vTexCoords3.xy = aPosition + dg1;
	vTexCoords3.zw = aPosition + dy;
	vTexCoords4.xy = aPosition + dg2;
	vTexCoords4.zw = aPosition - dx;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords0 = vTexCoords0;
	_output.vTexCoords1 = vTexCoords1;
	_output.vTexCoords2 = vTexCoords2;
	_output.vTexCoords3 = vTexCoords3;
	_output.vTexCoords4 = vTexCoords4;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static const float mx = 0.325;
static const float k = -0.250;
static const float max_w = 0.25;
static const float min_w = -0.05;
static const float lum_add = 0.25;

static float2 vTexCoords0;
static float4 vTexCoords1;
static float4 vTexCoords2;
static float4 vTexCoords3;
static float4 vTexCoords4;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords0 : TEXCOORD0;
	float4 vTexCoords1 : TEXCOORD1;
	float4 vTexCoords2 : TEXCOORD2;
	float4 vTexCoords3 : TEXCOORD3;
	float4 vTexCoords4 : TEXCOORD4;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords0 = _input.vTexCoords0;
	vTexCoords1 = _input.vTexCoords1;
	vTexCoords2 = _input.vTexCoords2;
	vTexCoords3 = _input.vTexCoords3;
	vTexCoords4 = _input.vTexCoords4;
	float3 c00 = tex2D(uTexture, vTexCoords1.xy).xyz;
	float3 c10 = tex2D(uTexture, vTexCoords1.zw).xyz;
	float3 c20 = tex2D(uTexture, vTexCoords2.xy).xyz;
	float3 c01 = tex2D(uTexture, vTexCoords4.zw).xyz;
	float3 c11 = tex2D(uTexture, vTexCoords0.xy).xyz;
	float3 c21 = tex2D(uTexture, vTexCoords2.zw).xyz;
	float3 c02 = tex2D(uTexture, vTexCoords4.xy).xyz;
	float3 c12 = tex2D(uTexture, vTexCoords3.zw).xyz;
	float3 c22 = tex2D(uTexture, vTexCoords3.xy).xyz;
	float3 dt = float3(1.0, 1.0, 1.0);
	float md1 = dot(abs(c00 - c22), dt);
	float md2 = dot(abs(c02 - c20), dt);
	float w1 = dot(abs(c22 - c11), dt) * md2;
	float w2 = dot(abs(c02 - c11), dt) * md1;
	float w3 = dot(abs(c00 - c11), dt) * md2;
	float w4 = dot(abs(c20 - c11), dt) * md1;
	float t1 = w1 + w3;
	float t2 = w2 + w4;
	float ww = max(t1, t2) + 0.0001;
	float3 cx = (w1 * c00 + w2 * c20 + w3 * c22 + w4 * c02 + ww * c11) / (t1 + t2 + ww);
	float lc1 = k / (0.12 * dot(c10 + c12 + cx, dt) + lum_add);
	float lc2 = k / (0.12 * dot(c01 + c21 + cx, dt) + lum_add);
	w1 = clamp(lc1 * dot(abs(cx - c10), dt) + mx, min_w, max_w);
	w2 = clamp(lc2 * dot(abs(cx - c21), dt) + mx, min_w, max_w);
	w3 = clamp(lc1 * dot(abs(cx - c12), dt) + mx, min_w, max_w);
	w4 = clamp(lc2 * dot(abs(cx - c01), dt) + mx, min_w, max_w);
	COLOR.xyz = w1 * c10 + w2 * c21 + w3 * c12 + w4 * c01 + (1.0 - w1 - w2 - w3 - w4) * cx;
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "ResizeMonochrome", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float4x4 bayerIndex = float4x4(float4(0.0625, 0.5625, 0.1875, 0.6875), float4(0.8125, 0.3125, 0.9375, 0.4375), float4(0.25, 0.75, 0.125, 0.625), float4(1.0, 0.5, 0.875, 0.375));

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vPixelCoords;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vPixelCoords : TEXCOORD0;
	float2 vTexCoords : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vPixelCoords = aPosition * texRect.xy;
	vTexCoords = aPosition;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vPixelCoords = vPixelCoords;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

uniform sampler2D uTexture : TEXUNIT0;

static float4x4 bayerIndex = float4x4(float4(0.0625, 0.5625, 0.1875, 0.6875), float4(0.8125, 0.3125, 0.9375, 0.4375), float4(0.25, 0.75, 0.125, 0.625), float4(1.0, 0.5, 0.875, 0.375));

static float2 vPixelCoords;
static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vPixelCoords : TEXCOORD0;
	float2 vTexCoords : TEXCOORD1;
};

float dither4x4(float2 position, float brightness)
{
	float bayerValue = bayerIndex[int((position.x - (4.0) * floor((position.x) / (4.0))))][int((position.y - (4.0) * floor((position.y) / (4.0))))];
	return brightness + (brightness < bayerValue ? -0.05 : 0.1);
}

float4 main(PsInput _input) : COLOR
{
	vPixelCoords = _input.vPixelCoords;
	vTexCoords = _input.vTexCoords;
	float3 color = tex2D(uTexture, vTexCoords).xyz;
	float gray = dot((color - ((float3)0.5)) * float3(1.4, 1.2, 1.0) + ((float3)0.5), float3(0.3, 0.7, 0.1));
	gray = dither4x4(vPixelCoords, gray);
	float palette = abs(1.0 - gray) * 0.75 + 0.125;
	if (palette < 0.25) {
		color = float3(0.675, 0.710, 0.420);
	} else {
		if (palette < 0.5) {
			color = float3(0.463, 0.518, 0.283);
		} else {
			if (palette < 0.75) {
				color = float3(0.247, 0.314, 0.247);
			} else {
				color = float3(0.1, 0.134, 0.151);
			}
		}
	}
	COLOR = float4(color, 1.0);
	return COLOR;
}
)" },
			{ "ResizeSabr", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static const float4 Ai = float4(1.0, -1.0, -1.0, 1.0);
static const float4 B45 = float4(1.0, 1.0, -1.0, -1.0);
static const float4 C45 = float4(1.5, 0.5, -0.5, 0.5);
static const float4 B30 = float4(0.5, 2.0, -0.5, -2.0);
static const float4 C30 = float4(1.0, 1.0, -0.5, 0.0);
static const float4 B60 = float4(2.0, 0.5, -2.0, -0.5);
static const float4 C60 = float4(2.0, 0.0, -1.0, 0.5);
static const float4 M45 = float4(0.4, 0.4, 0.4, 0.4);
static const float4 M30 = float4(0.2, 0.4, 0.2, 0.4);
static const float4 M60 = M30.yxwz;
static const float4 Mshift = ((float4)0.2);
static const float coef = 2.0;
static const float4 threshold = ((float4)0.32);
static const float3 lum = float3(0.21, 0.72, 0.07);

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexSize;
static float2 tc;
static float4 xyp_1_2_3;
static float4 xyp_5_10_15;
static float4 xyp_6_7_8;
static float4 xyp_9_14_9;
static float4 xyp_11_12_13;
static float4 xyp_16_17_18;
static float4 xyp_21_22_23;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexSize : TEXCOORD0;
	float2 tc : TEXCOORD1;
	float4 xyp_1_2_3 : TEXCOORD2;
	float4 xyp_5_10_15 : TEXCOORD3;
	float4 xyp_6_7_8 : TEXCOORD4;
	float4 xyp_9_14_9 : TEXCOORD5;
	float4 xyp_11_12_13 : TEXCOORD6;
	float4 xyp_16_17_18 : TEXCOORD7;
	float4 xyp_21_22_23 : TEXCOORD8;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexSize = texRect.xy;
	tc = aPosition * float2(1.0004, 1.0);
	float x = 1.0 / vTexSize.x;
	float y = 1.0 / vTexSize.y;
	xyp_1_2_3 = tc.xxxy + float4(-x, 0.0, x, -2.0 * y);
	xyp_6_7_8 = tc.xxxy + float4(-x, 0.0, x, -y);
	xyp_11_12_13 = tc.xxxy + float4(-x, 0.0, x, 0.0);
	xyp_16_17_18 = tc.xxxy + float4(-x, 0.0, x, y);
	xyp_21_22_23 = tc.xxxy + float4(-x, 0.0, x, 2.0 * y);
	xyp_5_10_15 = tc.xyyy + float4(-2.0 * x, -y, 0.0, y);
	xyp_9_14_9 = tc.xyyy + float4(2.0 * x, -y, 0.0, y);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexSize = vTexSize;
	_output.tc = tc;
	_output.xyp_1_2_3 = xyp_1_2_3;
	_output.xyp_5_10_15 = xyp_5_10_15;
	_output.xyp_6_7_8 = xyp_6_7_8;
	_output.xyp_9_14_9 = xyp_9_14_9;
	_output.xyp_11_12_13 = xyp_11_12_13;
	_output.xyp_16_17_18 = xyp_16_17_18;
	_output.xyp_21_22_23 = xyp_21_22_23;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static const float4 Ai = float4(1.0, -1.0, -1.0, 1.0);
static const float4 B45 = float4(1.0, 1.0, -1.0, -1.0);
static const float4 C45 = float4(1.5, 0.5, -0.5, 0.5);
static const float4 B30 = float4(0.5, 2.0, -0.5, -2.0);
static const float4 C30 = float4(1.0, 1.0, -0.5, 0.0);
static const float4 B60 = float4(2.0, 0.5, -2.0, -0.5);
static const float4 C60 = float4(2.0, 0.0, -1.0, 0.5);
static const float4 M45 = float4(0.4, 0.4, 0.4, 0.4);
static const float4 M30 = float4(0.2, 0.4, 0.2, 0.4);
static const float4 M60 = M30.yxwz;
static const float4 Mshift = ((float4)0.2);
static const float coef = 2.0;
static const float4 threshold = ((float4)0.32);
static const float3 lum = float3(0.21, 0.72, 0.07);

static float2 vTexSize;
static float2 tc;
static float4 xyp_1_2_3;
static float4 xyp_5_10_15;
static float4 xyp_6_7_8;
static float4 xyp_9_14_9;
static float4 xyp_11_12_13;
static float4 xyp_16_17_18;
static float4 xyp_21_22_23;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexSize : TEXCOORD0;
	float2 tc : TEXCOORD1;
	float4 xyp_1_2_3 : TEXCOORD2;
	float4 xyp_5_10_15 : TEXCOORD3;
	float4 xyp_6_7_8 : TEXCOORD4;
	float4 xyp_9_14_9 : TEXCOORD5;
	float4 xyp_11_12_13 : TEXCOORD6;
	float4 xyp_16_17_18 : TEXCOORD7;
	float4 xyp_21_22_23 : TEXCOORD8;
};

bool4 _and_(bool4 A, bool4 B)
{
	return bool4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w);
}

bool4 _or_(bool4 A, bool4 B)
{
	return bool4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w);
}

float4 lum_to(float3 v0, float3 v1, float3 v2, float3 v3)
{
	return float4(dot(lum, v0), dot(lum, v1), dot(lum, v2), dot(lum, v3));
}

float4 lum_df(float4 A, float4 B)
{
	return abs(A - B);
}

bool4 lum_eq(float4 A, float4 B)
{
	return (lum_df(A, B) < threshold);
}

float4 lum_wd(float4 a, float4 b, float4 c, float4 d, float4 e, float4 f, float4 g, float4 h)
{
	return lum_df(a, b) + lum_df(a, c) + lum_df(d, e) + lum_df(d, f) + 4.0 * lum_df(g, h);
}

float c_df(float3 c1, float3 c2)
{
	float3 df = abs(c1 - c2);
	return df.x + df.y + df.z;
}

float4 main(PsInput _input) : COLOR
{
	vTexSize = _input.vTexSize;
	tc = _input.tc;
	xyp_1_2_3 = _input.xyp_1_2_3;
	xyp_5_10_15 = _input.xyp_5_10_15;
	xyp_6_7_8 = _input.xyp_6_7_8;
	xyp_9_14_9 = _input.xyp_9_14_9;
	xyp_11_12_13 = _input.xyp_11_12_13;
	xyp_16_17_18 = _input.xyp_16_17_18;
	xyp_21_22_23 = _input.xyp_21_22_23;
	float3 P1 = tex2D(uTexture, xyp_1_2_3.xw).xyz;
	float3 P2 = tex2D(uTexture, xyp_1_2_3.yw).xyz;
	float3 P3 = tex2D(uTexture, xyp_1_2_3.zw).xyz;
	float3 P6 = tex2D(uTexture, xyp_6_7_8.xw).xyz;
	float3 P7 = tex2D(uTexture, xyp_6_7_8.yw).xyz;
	float3 P8 = tex2D(uTexture, xyp_6_7_8.zw).xyz;
	float3 P11 = tex2D(uTexture, xyp_11_12_13.xw).xyz;
	float3 P12 = tex2D(uTexture, xyp_11_12_13.yw).xyz;
	float3 P13 = tex2D(uTexture, xyp_11_12_13.zw).xyz;
	float3 P16 = tex2D(uTexture, xyp_16_17_18.xw).xyz;
	float3 P17 = tex2D(uTexture, xyp_16_17_18.yw).xyz;
	float3 P18 = tex2D(uTexture, xyp_16_17_18.zw).xyz;
	float3 P21 = tex2D(uTexture, xyp_21_22_23.xw).xyz;
	float3 P22 = tex2D(uTexture, xyp_21_22_23.yw).xyz;
	float3 P23 = tex2D(uTexture, xyp_21_22_23.zw).xyz;
	float3 P5 = tex2D(uTexture, xyp_5_10_15.xy).xyz;
	float3 P10 = tex2D(uTexture, xyp_5_10_15.xz).xyz;
	float3 P15 = tex2D(uTexture, xyp_5_10_15.xw).xyz;
	float3 P9 = tex2D(uTexture, xyp_9_14_9.xy).xyz;
	float3 P14 = tex2D(uTexture, xyp_9_14_9.xz).xyz;
	float3 P19 = tex2D(uTexture, xyp_9_14_9.xw).xyz;
	float4 p7 = lum_to(P7, P11, P17, P13);
	float4 p8 = lum_to(P8, P6, P16, P18);
	float4 p11 = p7.yzwx;
	float4 p12 = lum_to(P12, P12, P12, P12);
	float4 p13 = p7.wxyz;
	float4 p14 = lum_to(P14, P2, P10, P22);
	float4 p16 = p8.zwxy;
	float4 p17 = p7.zwxy;
	float4 p18 = p8.wxyz;
	float4 p19 = lum_to(P19, P3, P5, P21);
	float4 p22 = p14.wxyz;
	float4 p23 = lum_to(P23, P9, P1, P15);
	float2 fp = frac(tc * vTexSize);
	float4 ma45 = smoothstep(C45 - M45, C45 + M45, Ai * fp.y + B45 * fp.x);
	float4 ma30 = smoothstep(C30 - M30, C30 + M30, Ai * fp.y + B30 * fp.x);
	float4 ma60 = smoothstep(C60 - M60, C60 + M60, Ai * fp.y + B60 * fp.x);
	float4 marn = smoothstep(C45 - M45 + Mshift, C45 + M45 + Mshift, Ai * fp.y + B45 * fp.x);
	float4 e45 = lum_wd(p12, p8, p16, p18, p22, p14, p17, p13);
	float4 econt = lum_wd(p17, p11, p23, p13, p7, p19, p12, p18);
	float4 e30 = lum_df(p13, p16);
	float4 e60 = lum_df(p8, p17);
	bool4 r45_1 = _and_((p12 != p13), (p12 != p17));
	bool4 r45_2 = _and_((!lum_eq(p13, p7)), (!lum_eq(p13, p8)));
	bool4 r45_3 = _and_((!lum_eq(p17, p11)), (!lum_eq(p17, p16)));
	bool4 r45_4_1 = _and_((!lum_eq(p13, p14)), (!lum_eq(p13, p19)));
	bool4 r45_4_2 = _and_((!lum_eq(p17, p22)), (!lum_eq(p17, p23)));
	bool4 r45_4 = _and_(lum_eq(p12, p18), _or_(r45_4_1, r45_4_2));
	bool4 r45_5 = _or_(lum_eq(p12, p16), lum_eq(p12, p8));
	bool4 r45 = _and_(r45_1, _or_(_or_(_or_(r45_2, r45_3), r45_4), r45_5));
	bool4 r30 = _and_((p12 != p16), (p11 != p16));
	bool4 r60 = _and_((p12 != p8), (p7 != p8));
	bool4 edr45 = _and_((e45 < econt), r45);
	bool4 edrrn = (e45 <= econt);
	bool4 edr30 = _and_((coef * e30 <= e60), r30);
	bool4 edr60 = _and_((coef * e60 <= e30), r60);
	float4 final45 = ((float4)_and_(_and_((!edr30), (!edr60)), edr45));
	float4 final30 = ((float4)_and_(_and_(edr45, (!edr60)), edr30));
	float4 final60 = ((float4)_and_(_and_(edr45, (!edr30)), edr60));
	float4 final36 = ((float4)_and_(_and_(edr60, edr30), edr45));
	float4 finalrn = ((float4)_and_((!edr45), edrrn));
	float4 px = step(lum_df(p12, p17), lum_df(p12, p13));
	float4 mac = final36 * max(ma30, ma60) + final30 * ma30 + final60 * ma60 + final45 * ma45 + finalrn * marn;
	float3 res1 = P12;
	res1 = lerp(res1, lerp(P13, P17, px.x), mac.x);
	res1 = lerp(res1, lerp(P7, P13, px.y), mac.y);
	res1 = lerp(res1, lerp(P11, P7, px.z), mac.z);
	res1 = lerp(res1, lerp(P17, P11, px.w), mac.w);
	float3 res2 = P12;
	res2 = lerp(res2, lerp(P17, P11, px.w), mac.w);
	res2 = lerp(res2, lerp(P11, P7, px.z), mac.z);
	res2 = lerp(res2, lerp(P7, P13, px.y), mac.y);
	res2 = lerp(res2, lerp(P13, P17, px.x), mac.x);
	COLOR = float4(lerp(res1, res2, step(c_df(P12, res1), c_df(P12, res2))), 1.0);
	return COLOR;
}
)" },
			{ "ShieldFire", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float4 vTexCoords;
static float4 vColor;
static float2 vPos;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = texRect;
	vColor = color;
	vPos = aPosition * ((float2)2.0) - ((float2)1.0);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPos = vPos;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float4 vTexCoords;
static float4 vColor;
static float2 vPos;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float triangleWave(float x, float period)
{
	float p = x / period;
	float f = frac(p);
	return abs(f - 0.5) * 2.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPos = _input.vPos;
	float2 scale = vColor.xy;
	float2 shift1 = vTexCoords.xy;
	float2 shift2 = vTexCoords.zw;
	float darkness = vColor.z;
	float alpha = vColor.w;
	float dist = length(vPos);
	if (dist > 1.0) {
		COLOR = float4(0.0, 0.0, 0.0, 0.0);
	} else {
		float3 v = float3(vPos.x, vPos.y, sqrt(1.0 - vPos.x * vPos.x - vPos.y * vPos.y));
		float3 n = normalize(v);
		float b = dot(n, float3(0.0, 0.0, 1.0));
		float2 q = float2(0.5 - 0.5 * atan2(n.z, n.x) / 3.1415926, -acos(vPos.y) / 3.1415926);
		float isNearBorder = 1.0 - aastep(0.96, dist);
		float mask1 = tex2D(uTexture, (shift1 + q * scale - (1.0) * floor((shift1 + q * scale) / (1.0)))).x;
		float maskNormalized1 = max(1.0 - abs(triangleWave(shift2.y + 0.5, 2.0) - mask1) * 6.0, 0.0);
		float mask2 = tex2D(uTexture, (shift2 + q * scale - (1.0) * floor((shift2 + q * scale) / (1.0)))).x;
		float maskNormalized2 = max(1.0 - abs(triangleWave(shift1.x, 1.333) - mask2) * 6.0, 0.0);
		float maskSum = min(maskNormalized1 + maskNormalized2, 1.0);
		COLOR = float4(lerp(float3(1.0, 0.3, 0.0), float3(1.0, 1.0, 1.0), max(maskSum * 2.0 - 1.0, 0.0)) * darkness, min(maskSum * b * isNearBorder * 1.3 + 0.1, 1.0) * alpha);
	}
	return COLOR;
}
)" },
			{ "ShieldLightning", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float4 vTexCoords;
static float4 vColor;
static float2 vPos;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = texRect;
	vColor = color;
	vPos = aPosition * ((float2)2.0) - ((float2)1.0);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPos = vPos;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float4 vTexCoords;
static float4 vColor;
static float2 vPos;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float4 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float2 vPos : TEXCOORD2;
};

float aastep(float threshold, float value)
{
	float afwidth = length(float2(ddx(value), ddy(value))) * 0.70710678118654757;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

float triangleWave(float x, float period)
{
	float p = x / period;
	float f = frac(p);
	return abs(f - 0.5) * 2.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPos = _input.vPos;
	float2 scale = vColor.xy;
	float2 shift1 = vTexCoords.xy;
	float2 shift2 = vTexCoords.zw;
	float darkness = vColor.z;
	float alpha = vColor.w;
	float dist = length(vPos);
	if (dist > 1.0) {
		COLOR = float4(0.0, 0.0, 0.0, 0.0);
	} else {
		float3 v = float3(vPos.x, vPos.y, sqrt(1.0 - vPos.x * vPos.x - vPos.y * vPos.y));
		float3 n = normalize(v);
		float b = dot(n, float3(0.0, 0.0, 1.0));
		float2 q = float2(0.5 - 0.5 * atan2(n.z, n.x) / 3.1415926, -acos(vPos.y) / 3.1415926);
		float isNearBorder = 1.0 - aastep(0.96, dist);
		float mask = tex2D(uTexture, (shift1 + q * scale - (1.0) * floor((shift1 + q * scale) / (1.0)))).x;
		float maskNormalized = max(1.0 - abs(triangleWave(shift2.y + 0.5, 2.0) - mask) * 8.0, 0.0);
		float isVeryNearBorder = 1.0 - aastep(0.024, abs(dist - 0.94));
		float maskSum = max(maskNormalized, isVeryNearBorder);
		COLOR = float4(lerp(float3(0.1, 1.0, 0.0), float3(1.0, 1.0, 1.0), max(maskSum * 2.0 - 1.0, 0.0)) * darkness, min(maskSum * b * isNearBorder * 1.3 + 0.1, 1.0) * alpha);
	}
	return COLOR;
}
)" },
			{ "TexturedBackground", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float2 uViewSize;
uniform float2 uCameraPos;
uniform float4 uHorizonColor;
uniform float2 uShift;

uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float3 voronoi(float2 p)
{
	float2 n = floor(p);
	float2 f = frac(p);
	float2 mg;
	float2 mr;
	float md = 8.0;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			float2 g = float2(float(i), float(j));
			float2 o = hash2D(n + g);
			float2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return float3(md, mr);
}

float addStarField(float2 samplePosition, float threshold)
{
	float3 starValue = voronoi(samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0 - starValue.x / threshold;
		return min(power * power * power, 0.5);
	}
	return 0.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	float distance_ = 1.3 - abs(2.0 * vTexCoords.y - 1.0);
	float horizonDepth = pow(distance_, 1.4);
	float yShift = vTexCoords.y > 0.5 ? 1.0 : 0.0;
	float correction = uViewSize.x * 9.0 / (uViewSize.y * 16.0);
	float2 texturePos = float2(uShift.x / 256.0 + (vTexCoords.x - 0.5) * (0.5 + 1.5 * horizonDepth) * correction, uShift.y / 256.0 + (vTexCoords.y - yShift) * 1.4 * distance_);
	float4 texColor = tex2D(uTexture, texturePos);
	float horizonOpacity = clamp(pow(distance_, 1.5) - 0.3, 0.0, 1.0);
	float4 horizonColorWithStars = float4(uHorizonColor.xyz, 1.0);
	if (uHorizonColor.w > 0.0) {
		float2 samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00012;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
		samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00018 + 0.5;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
	}
	COLOR = lerp(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "TexturedBackground", "DITHER",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float2 uViewSize;
uniform float2 uCameraPos;
uniform float4 uHorizonColor;
uniform float2 uShift;

uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float3 voronoi(float2 p)
{
	float2 n = floor(p);
	float2 f = frac(p);
	float2 mg;
	float2 mr;
	float md = 8.0;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			float2 g = float2(float(i), float(j));
			float2 o = hash2D(n + g);
			float2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return float3(md, mr);
}

float addStarField(float2 samplePosition, float threshold)
{
	float3 starValue = voronoi(samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0 - starValue.x / threshold;
		return min(power * power * power, 0.5);
	}
	return 0.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	float distance_ = 1.3 - abs(2.0 * vTexCoords.y - 1.0);
	float horizonDepth = pow(distance_, 1.4);
	float yShift = vTexCoords.y > 0.5 ? 1.0 : 0.0;
	float correction = uViewSize.x * 9.0 / (uViewSize.y * 16.0);
	float2 texturePos = float2(uShift.x / 256.0 + (vTexCoords.x - 0.5) * (0.5 + 1.5 * horizonDepth) * correction, uShift.y / 256.0 + (vTexCoords.y - yShift) * 1.4 * distance_);
	float4 texColor = tex2D(uTexture, texturePos);
	texturePos += hash2D(vTexCoords * uViewSize + (uCameraPos + uShift) * 0.001).xy * 8.0 / uViewSize;
	texColor = lerp(texColor, tex2D(uTexture, texturePos), 0.333);
	float horizonOpacity = clamp(pow(distance_, 1.5) - 0.3, 0.0, 1.0);
	float4 horizonColorWithStars = float4(uHorizonColor.xyz, 1.0);
	if (uHorizonColor.w > 0.0) {
		float2 samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00012;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
		samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00018 + 0.5;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
	}
	COLOR = lerp(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "TexturedBackgroundCircle", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float2 uViewSize;
uniform float2 uCameraPos;
uniform float4 uHorizonColor;
uniform float2 uShift;

uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float3 voronoi(float2 p)
{
	float2 n = floor(p);
	float2 f = frac(p);
	float2 mg;
	float2 mr;
	float md = 8.0;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			float2 g = float2(float(i), float(j));
			float2 o = hash2D(n + g);
			float2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return float3(md, mr);
}

float addStarField(float2 samplePosition, float threshold)
{
	float3 starValue = voronoi(samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0 - starValue.x / threshold;
		return min(power * power * power, 0.5);
	}
	return 0.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	float2 targetCoord = ((float2)2.0) * vTexCoords - ((float2)1.0);
	targetCoord.x *= uViewSize.x / uViewSize.y;
	float distance_ = length(targetCoord);
	float xShift = targetCoord.x == 0.0 ? sign(targetCoord.y) * 0.5 : atan2(targetCoord.y, targetCoord.x) * 0.31830988618379067153776752675;
	float2 texturePos = float2(xShift * 1.0 + uShift.x * 0.01, 1.0 / distance_ * 1.4 + uShift.y * 0.002);
	float4 texColor = tex2D(uTexture, texturePos);
	float horizonOpacity = 1.0 - clamp(pow(distance_, 1.4) - 0.3, 0.0, 1.0);
	float4 horizonColorWithStars = float4(uHorizonColor.xyz, 1.0);
	if (uHorizonColor.w > 0.0) {
		float2 samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00012;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
		samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00018 + 0.5;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
	}
	COLOR = lerp(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "TexturedBackgroundCircle", "DITHER",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float2 uViewSize;
uniform float2 uCameraPos;
uniform float4 uHorizonColor;
uniform float2 uShift;

uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
};

float2 hash2D(float2 p)
{
	float h = dot(p, float2(12.9898, 78.233));
	float h2 = dot(p, float2(37.271, 377.632));
	return -1.0 + 2.0 * float2(frac(sin(h) * 43758.5453), frac(sin(h2) * 43758.5453));
}

float3 voronoi(float2 p)
{
	float2 n = floor(p);
	float2 f = frac(p);
	float2 mg;
	float2 mr;
	float md = 8.0;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			float2 g = float2(float(i), float(j));
			float2 o = hash2D(n + g);
			float2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return float3(md, mr);
}

float addStarField(float2 samplePosition, float threshold)
{
	float3 starValue = voronoi(samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0 - starValue.x / threshold;
		return min(power * power * power, 0.5);
	}
	return 0.0;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	float2 targetCoord = ((float2)2.0) * vTexCoords - ((float2)1.0);
	targetCoord.x *= uViewSize.x / uViewSize.y;
	float distance_ = length(targetCoord);
	float xShift = targetCoord.x == 0.0 ? sign(targetCoord.y) * 0.5 : atan2(targetCoord.y, targetCoord.x) * 0.31830988618379067153776752675;
	float2 texturePos = float2(xShift * 1.0 + uShift.x * 0.01, 1.0 / distance_ * 1.4 + uShift.y * 0.002);
	float4 texColor = tex2D(uTexture, texturePos);
	texturePos += hash2D(vTexCoords * uViewSize + (uCameraPos + uShift) * 0.001).xy * 8.0 / uViewSize;
	texColor = lerp(texColor, tex2D(uTexture, texturePos), 0.333);
	float horizonOpacity = 1.0 - clamp(pow(distance_, 1.4) - 0.3, 0.0, 1.0);
	float4 horizonColorWithStars = float4(uHorizonColor.xyz, 1.0);
	if (uHorizonColor.w > 0.0) {
		float2 samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00012;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
		samplePosition = vTexCoords * uViewSize / uViewSize.xx + uCameraPos.xy * 0.00018 + 0.5;
		horizonColorWithStars += ((float4)addStarField(samplePosition * 7.0, 0.00008));
	}
	COLOR = lerp(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.w = 1.0;
	return COLOR;
}
)" },
			{ "TileMapMesh", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aPosition;
static float2 aTexCoords;
static float4 aColor;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float2 aTexCoords : TEXCOORD1;
	float4 aColor : TEXCOORD2;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aTexCoords = _input.aTexCoords;
	aColor = _input.aColor;
	gl_Position = mul(float4(aPosition.x, aPosition.y, 0.0, 1.0), mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = aTexCoords;
	vColor = aColor * color;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	COLOR = tex2D(uTexture, vTexCoords) * vColor;
	return COLOR;
}
)" },
			{ "TileMapMeshPalette", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aPosition;
static float2 aTexCoords;
static float4 aColor;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aPosition : TEXCOORD0;
	float2 aTexCoords : TEXCOORD1;
	float4 aColor : TEXCOORD2;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aPosition = _input.aPosition;
	aTexCoords = _input.aTexCoords;
	aColor = _input.aColor;
	gl_Position = mul(float4(aPosition.x, aPosition.y, 0.0, 1.0), mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = aTexCoords;
	vColor = aColor * color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	float4 src = tex2D(uTexture, vTexCoords);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 color = tex2D(uTexturePalette, float2(palX, palY));
	COLOR = float4(color.xyz, color.w * src.w) * vColor;
	return COLOR;
}
)" },
			{ "Tinted", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 original = tex2D(uTexture, vTexCoords);
	float3 tinted = lerp(original.xyz, COLOR.xyz, 0.45);
	COLOR = float4(tinted.x, tinted.y, tinted.z, original.w * COLOR.w);
	return COLOR;
}
)" },
			{ "Tinted", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 src = tex2D(uTexture, vTexCoords);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 original = tex2D(uTexturePalette, float2(palX, palY));
	original.w *= src.w;
	float3 tinted = lerp(original.xyz, COLOR.xyz, 0.45);
	COLOR = float4(tinted.x, tinted.y, tinted.z, original.w * COLOR.w);
	return COLOR;
}
)" },
			{ "BatchedTinted", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 original = tex2D(uTexture, vTexCoords);
	float3 tinted = lerp(original.xyz, COLOR.xyz, 0.45);
	COLOR = float4(tinted.x, tinted.y, tinted.z, original.w * COLOR.w);
	return COLOR;
}
)" },
			{ "BatchedTinted", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 src = tex2D(uTexture, vTexCoords);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 original = tex2D(uTexturePalette, float2(palX, palY));
	original.w *= src.w;
	float3 tinted = lerp(original.xyz, COLOR.xyz, 0.45);
	COLOR = float4(tinted.x, tinted.y, tinted.z, original.w * COLOR.w);
	return COLOR;
}
)" },
			{ "TouchCircle", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vPos;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vPos : TEXCOORD0;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - aQuadCorner.x, aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vPos = aPosition - float2(0.5, 0.5);
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vPos = vPos;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 vPos;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vPos : TEXCOORD0;
};

float4 main(PsInput _input) : COLOR
{
	vPos = _input.vPos;
	float dist = length(vPos);
	float softness = texRect.y;
	float outerAlpha = 1.0 - smoothstep(0.5 - softness, 0.5, dist);
	float innerRadius = texRect.x * 0.5;
	float innerAlpha = innerRadius > 0.0 ? smoothstep(innerRadius - softness, innerRadius, dist) : 1.0;
	COLOR = float4(color.xyz, color.w * outerAlpha * innerAlpha);
	return COLOR;
}
)" },
			{ "Transition", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float2 vCorrection;
static float vProgressTime;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float2 vCorrection : TEXCOORD1;
	float vProgressTime : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vCorrection = spriteSize / ((float2)max(spriteSize.x, spriteSize.y));
	vProgressTime = color.w;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vCorrection = vCorrection;
	_output.vProgressTime = vProgressTime;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
static float2 vTexCoords;
static float2 vCorrection;
static float vProgressTime;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float2 vCorrection : TEXCOORD1;
	float vProgressTime : TEXCOORD2;
};

float rand(float2 xy)
{
	return frac(sin(dot(xy.xy, float2(12.9898, 78.233))) * 43758.5453);
}

float ease(float time)
{
	time *= 2.0;
	if (time < 1.0) {
		return 0.5 * time * time;
	}
	time -= 1.0;
	return -0.5 * (time * (time - 2.0) - 1.0);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vCorrection = _input.vCorrection;
	vProgressTime = _input.vProgressTime;
	float2 uv = (vTexCoords - ((float2)0.5)) * vCorrection;
	float distance_ = length(uv);
	float progressInner = vProgressTime - 0.22;
	distance_ = (clamp(distance_, progressInner, vProgressTime) - progressInner) / (vProgressTime - progressInner);
	float mixValue = ease(distance_);
	float noise = 1.0 + rand(uv) * 0.1;
	COLOR = float4(0.0, 0.0, 0.0, mixValue * noise);
	return COLOR;
}
)" },
			{ "WhiteMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	return src;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 6.0, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "WhiteMask", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform float4x4 modelMatrix;
uniform float4 color;
uniform float4 texRect;
uniform float2 spriteSize;
uniform float palOffset;

static float2 aQuadCorner;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), aQuadCorner.y);
	float4 position = float4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * texRect.x + texRect.y, aPosition.y * texRect.z + texRect.w);
	vColor = color;
	vPaletteOffset = palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 6.0, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "BatchedWhiteMask", "",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	return src;
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 6.0, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
			{ "BatchedWhiteMask", "USE_PALETTE",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
#define BATCH_SIZE 585

struct Instance
{
	float4x4 modelMatrix;
	float4 color;
	float4 texRect;
	float2 spriteSize;
	float palOffset;
};

uniform float4x4 uProjectionMatrix;
uniform float4x4 uViewMatrix;

uniform Instance instances[BATCH_SIZE];

static float2 aQuadCorner;
static float aInstanceIndex;
static float4 gl_Position;
static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;

struct VsInput
{
	float2 aQuadCorner : TEXCOORD0;
	float aInstanceIndex : TEXCOORD1;
};

struct VsOutput
{
	float4 _clipPosition : POSITION;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

VsOutput main(VsInput _input)
{
	aQuadCorner = _input.aQuadCorner;
	aInstanceIndex = _input.aInstanceIndex;
	float2 aPosition = float2(1.0 - (1.0 - aQuadCorner.x), 1.0 - (1.0 - aQuadCorner.y));
	float4 position = float4(aPosition.x * instances[int(aInstanceIndex)].spriteSize.x, aPosition.y * instances[int(aInstanceIndex)].spriteSize.y, 0.0, 1.0);
	gl_Position = mul(position, mul(instances[int(aInstanceIndex)].modelMatrix, mul(uViewMatrix, uProjectionMatrix)));
	vTexCoords = float2(aPosition.x * instances[int(aInstanceIndex)].texRect.x + instances[int(aInstanceIndex)].texRect.y, aPosition.y * instances[int(aInstanceIndex)].texRect.z + instances[int(aInstanceIndex)].texRect.w);
	vColor = instances[int(aInstanceIndex)].color;
	vPaletteOffset = instances[int(aInstanceIndex)].palOffset;
	VsOutput _output = (VsOutput)0;
	_output._clipPosition = gl_Position;
	_output.vTexCoords = vTexCoords;
	_output.vColor = vColor;
	_output.vPaletteOffset = vPaletteOffset;
	return _output;
}
)",
				R"(// Generated Cg (PS Vita, sceGxm) by ShaderCompiler. Do not edit manually.
uniform sampler2D uTexture : TEXUNIT0;
uniform sampler2D uTexturePalette : TEXUNIT1;

static float2 vTexCoords;
static float4 vColor;
static float vPaletteOffset;
static float4 COLOR;

struct PsInput
{
	float4 _fragCoord : WPOS;
	float2 vTexCoords : TEXCOORD0;
	float4 vColor : TEXCOORD1;
	float vPaletteOffset : TEXCOORD2;
};

float4 maskSample(float2 uv)
{
	float4 src = tex2D(uTexture, uv);
	float palIndex = floor(vPaletteOffset + 0.5) + floor(src.x * 255.0 + 0.5);
	float palX = ((palIndex - (256.0) * floor((palIndex) / (256.0))) + 0.5) / 256.0;
	float palY = (floor(palIndex / 256.0) + 0.5) / 256.0;
	float4 c = tex2D(uTexturePalette, float2(palX, palY));
	return float4(c.xyz, c.w * src.w);
}

float4 main(PsInput _input) : COLOR
{
	vTexCoords = _input.vTexCoords;
	vColor = _input.vColor;
	vPaletteOffset = _input.vPaletteOffset;
	COLOR = vColor;
	float4 tex = maskSample(vTexCoords);
	float color = min((0.299 * tex.x + 0.587 * tex.y + 0.114 * tex.z) * 6.0, 1.0);
	COLOR = float4(color, color, color, tex.w) * COLOR;
	return COLOR;
}
)" },
		};

		/**
			@brief Looks the sources of a program variant up by the identity the loader plumbed in

			Resolved from `ShaderProgram::SetProgramIdentity()` exactly as the console backends resolve
			their fixed-function effects, so a program absent from the table is a shader whose Cg
			transform the emitter declined rather than a lookup mistake.
		*/
		inline const GeneratedCgShader* FindGeneratedCgShader(const char* programName, const char* variantName)
		{
			if (programName == nullptr) {
				return nullptr;
			}
			const char* wantedVariant = (variantName != nullptr ? variantName : "");
			for (const GeneratedCgShader& s : GeneratedCgShaders) {
				if (std::strcmp(s.ProgramName, programName) == 0 && std::strcmp(s.VariantName, wantedVariant) == 0) {
					return &s;
				}
			}
			return nullptr;
		}
	}
}

#endif
