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

#if defined(WITH_RHI_SOFTWARE)

#include "../../nCine/Graphics/RHI/Software/SwShaderRuntime.h"

#include <cstddef>
#include <cstdint>
#include <cstring>

namespace nCine::RHI::Software
{
	namespace
	{
		// --- BatchedShieldFire ---
struct BatchedShieldFire_Uniforms
{
	nCine::RHI::Software::sw::vec4 vShieldRect;
};

void BatchedShieldFire_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedShieldFire_Uniforms* io = static_cast<BatchedShieldFire_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vShieldRect = (*reinterpret_cast<const vec4*>(instanceBlock + 80));
}

static float BatchedShieldFire_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedShieldFire_Uniforms* unis = static_cast<const BatchedShieldFire_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static float BatchedShieldFire_triangleWave(const nCine::RHI::Software::FragmentShaderInput& in, float x, float period)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedShieldFire_Uniforms* unis = static_cast<const BatchedShieldFire_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float p = x / period;
	float f = fract(p);
	return abs(f - 0.5f) * 2.0f;
}

void BatchedShieldFire_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedShieldFire_Uniforms* unis = static_cast<const BatchedShieldFire_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 scale = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).xy();
	vec2 shift1 = unis->vShieldRect.xy();
	vec2 shift2 = unis->vShieldRect.zw();
	vec2 vPos = vec2(in.u, in.v).xy() * vec2(2.0f) - vec2(1.0f);
	float darkness = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).z;
	float alpha = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).w;
	float dist = length(vPos);
	if (dist > 1.0f) {
		COLOR = vec4(0.0f, 0.0f, 0.0f, 0.0f);
	} else {
		vec3 v = vec3(vPos.x, vPos.y, sqrt(1.0f - vPos.x * vPos.x - vPos.y * vPos.y));
		vec3 n = normalize(v);
		float b = dot(n, vec3(0.0f, 0.0f, 1.0f));
		vec2 q = vec2(0.5f - 0.5f * atan(n.z, n.x) / 3.1415926f, -acos(vPos.y) / 3.1415926f);
		float isNearBorder = 1.0f - BatchedShieldFire_aastep(in, 0.96f, dist);
		float mask1 = swTexture(in, 0, mod(shift1 + q * scale, 1.0f)).r;
		float maskNormalized1 = max(1.0f - abs(BatchedShieldFire_triangleWave(in, shift2.y + 0.5f, 2.0f) - mask1) * 6.0f, 0.0f);
		float mask2 = swTexture(in, 0, mod(shift2 + q * scale, 1.0f)).r;
		float maskNormalized2 = max(1.0f - abs(BatchedShieldFire_triangleWave(in, shift1.x, 1.333f) - mask2) * 6.0f, 0.0f);
		float maskSum = min(maskNormalized1 + maskNormalized2, 1.0f);
		COLOR = vec4(mix(vec3(1.0f, 0.3f, 0.0f), vec3(1.0f, 1.0f, 1.0f), max(maskSum * 2.0f - 1.0f, 0.0f)) * darkness, min(maskSum * b * isNearBorder * 1.3f + 0.1f, 1.0f) * alpha);
	}
	packColor(COLOR, in.rgba);
}

		// --- BatchedShieldLightning ---
struct BatchedShieldLightning_Uniforms
{
	nCine::RHI::Software::sw::vec4 vShieldRect;
};

void BatchedShieldLightning_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedShieldLightning_Uniforms* io = static_cast<BatchedShieldLightning_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vShieldRect = (*reinterpret_cast<const vec4*>(instanceBlock + 80));
}

static float BatchedShieldLightning_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedShieldLightning_Uniforms* unis = static_cast<const BatchedShieldLightning_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static float BatchedShieldLightning_triangleWave(const nCine::RHI::Software::FragmentShaderInput& in, float x, float period)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedShieldLightning_Uniforms* unis = static_cast<const BatchedShieldLightning_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float p = x / period;
	float f = fract(p);
	return abs(f - 0.5f) * 2.0f;
}

void BatchedShieldLightning_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedShieldLightning_Uniforms* unis = static_cast<const BatchedShieldLightning_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 scale = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).xy();
	vec2 shift1 = unis->vShieldRect.xy();
	vec2 shift2 = unis->vShieldRect.zw();
	vec2 vPos = vec2(in.u, in.v).xy() * vec2(2.0f) - vec2(1.0f);
	float darkness = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).z;
	float alpha = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).w;
	float dist = length(vPos);
	if (dist > 1.0f) {
		COLOR = vec4(0.0f, 0.0f, 0.0f, 0.0f);
	} else {
		vec3 v = vec3(vPos.x, vPos.y, sqrt(1.0f - vPos.x * vPos.x - vPos.y * vPos.y));
		vec3 n = normalize(v);
		float b = dot(n, vec3(0.0f, 0.0f, 1.0f));
		vec2 q = vec2(0.5f - 0.5f * atan(n.z, n.x) / 3.1415926f, -acos(vPos.y) / 3.1415926f);
		float isNearBorder = 1.0f - BatchedShieldLightning_aastep(in, 0.96f, dist);
		float mask = swTexture(in, 0, mod(shift1 + q * scale, 1.0f)).r;
		float maskNormalized = max(1.0f - abs(BatchedShieldLightning_triangleWave(in, shift2.y + 0.5f, 2.0f) - mask) * 8.0f, 0.0f);
		float isVeryNearBorder = 1.0f - BatchedShieldLightning_aastep(in, 0.024f, abs(dist - 0.94f));
		float maskSum = max(maskNormalized, isVeryNearBorder);
		COLOR = vec4(mix(vec3(0.1f, 1.0f, 0.0f), vec3(1.0f, 1.0f, 1.0f), max(maskSum * 2.0f - 1.0f, 0.0f)) * darkness, min(maskSum * b * isNearBorder * 1.3f + 0.1f, 1.0f) * alpha);
	}
	packColor(COLOR, in.rgba);
}

		// --- Blur ---
struct Blur_Uniforms
{
	nCine::RHI::Software::sw::vec2 uPixelOffset;
	nCine::RHI::Software::sw::vec2 uDirection;
};

void Blur_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Blur_Uniforms* unis = static_cast<const Blur_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec4 color = vec4(0.0f);
	vec2 off1 = vec2(1.3846153846f) * unis->uPixelOffset * unis->uDirection;
	vec2 off2 = vec2(3.2307692308f) * unis->uPixelOffset * unis->uDirection;
	color += swTexturePrimary(in, 0) * 0.2270270270f;
	color += swTexture(in, 0, vec2(in.u, in.v) + off1) * 0.3162162162f;
	color += swTexture(in, 0, vec2(in.u, in.v) - off1) * 0.3162162162f;
	color += swTexture(in, 0, vec2(in.u, in.v) + off2) * 0.0702702703f;
	color += swTexture(in, 0, vec2(in.u, in.v) - off2) * 0.0702702703f;
	COLOR = color;
	packColor(COLOR, in.rgba);
}

		// --- Colorized ---
struct Colorized_Uniforms
{
};

void Colorized_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Colorized_Uniforms* unis = static_cast<const Colorized_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 dye = vec4(1.0f) + (COLOR - vec4(0.5f)) * vec4(4.0f);
	vec4 original = swTexturePrimary(in, 0);
	float average = (original.r + original.g + original.b) * 0.5f;
	vec4 gray = vec4(average, average, average, original.a);
	COLOR = gray * dye;
	packColor(COLOR, in.rgba);
}

		// --- BatchedColorized ---
struct BatchedColorized_Uniforms
{
};

void BatchedColorized_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedColorized_Uniforms* unis = static_cast<const BatchedColorized_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 dye = vec4(1.0f) + (COLOR - vec4(0.5f)) * vec4(4.0f);
	vec4 original = swTexturePrimary(in, 0);
	float average = (original.r + original.g + original.b) * 0.5f;
	vec4 gray = vec4(average, average, average, original.a);
	COLOR = gray * dye;
	packColor(COLOR, in.rgba);
}

		// --- Combine ---
struct Combine_Uniforms
{
	nCine::RHI::Software::sw::vec4 uAmbientColor;
	float uTime;
	nCine::RHI::Software::sw::vec2 vViewSizeInv;
};

void Combine_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	Combine_Uniforms* io = static_cast<Combine_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vViewSizeInv = (vec2(1.0f) / (*reinterpret_cast<const vec2*>(instanceBlock + 96)));
}

static nCine::RHI::Software::sw::vec2 Combine_hash2D(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const Combine_Uniforms* unis = static_cast<const Combine_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float h = dot(p, vec2(12.9898f, 78.233f));
	float h2 = dot(p, vec2(37.271f, 377.632f));
	return -1.0f + 2.0f * vec2(fract(sin(h) * 43758.5453f), fract(sin(h2) * 43758.5453f));
}

static nCine::RHI::Software::sw::vec2 Combine_noiseTexCoords(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 position)
{
	using namespace nCine::RHI::Software::sw;
	const Combine_Uniforms* unis = static_cast<const Combine_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 seed = position + fract(unis->uTime * 0.01f);
	return clamp(position + Combine_hash2D(in, seed) * unis->vViewSizeInv * 1.4f, vec2(0.0f), vec2(1.0f));
}

void Combine_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Combine_Uniforms* unis = static_cast<const Combine_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec4 blur1 = swTexture(in, 2, vec2(in.u, in.v));
	vec4 blur2 = swTexture(in, 3, vec2(in.u, in.v));
	vec4 main = swTexturePrimary(in, 0);
	vec4 light = swTexture(in, 1, Combine_noiseTexCoords(in, vec2(in.u, in.v)));
	vec4 blur = (blur1 + blur2) * vec4(0.5f);
	float gray = dot(blur.rgb(), vec3(0.299f, 0.587f, 0.114f));
	blur = vec4(gray, gray, gray, blur.a);
	COLOR = mix(mix(main * (1.0f + light.g) + max(light.g - 0.7f, 0.0f) * vec4(1.0f), blur, vec4(clamp((1.0f - light.r) / sqrt(max(unis->uAmbientColor.w, 0.35f)), 0.0f, 1.0f))), unis->uAmbientColor, vec4(1.0f - light.r));
	COLOR.a = 1.0f;
	packColor(COLOR, in.rgba);
}

		// --- CombineWithWaterLow ---
struct CombineWithWaterLow_Uniforms
{
	nCine::RHI::Software::sw::vec4 uAmbientColor;
	float uTime;
	nCine::RHI::Software::sw::vec2 uCameraPos;
	float uWaterLevel;
	nCine::RHI::Software::sw::vec2 vViewSizeInv;
};

void CombineWithWaterLow_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	CombineWithWaterLow_Uniforms* io = static_cast<CombineWithWaterLow_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vViewSizeInv = (vec2(1.0f) / (*reinterpret_cast<const vec2*>(instanceBlock + 96)));
}

static nCine::RHI::Software::sw::vec2 CombineWithWaterLow_hash2D(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const CombineWithWaterLow_Uniforms* unis = static_cast<const CombineWithWaterLow_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float h = dot(p, vec2(12.9898f, 78.233f));
	float h2 = dot(p, vec2(37.271f, 377.632f));
	return -1.0f + 2.0f * vec2(fract(sin(h) * 43758.5453f), fract(sin(h2) * 43758.5453f));
}

static nCine::RHI::Software::sw::vec2 CombineWithWaterLow_noiseTexCoords(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 position)
{
	using namespace nCine::RHI::Software::sw;
	const CombineWithWaterLow_Uniforms* unis = static_cast<const CombineWithWaterLow_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 seed = position + fract(unis->uTime * 0.01f);
	return clamp(position + CombineWithWaterLow_hash2D(in, seed) * unis->vViewSizeInv * 1.4f, vec2(0.0f), vec2(1.0f));
}

void CombineWithWaterLow_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const CombineWithWaterLow_Uniforms* unis = static_cast<const CombineWithWaterLow_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec3 waterColor = vec3(0.4f, 0.6f, 0.8f);
	vec2 uvLocal = vec2(in.u, in.v);
	vec2 uvWorldCenter = unis->uCameraPos.xy() * unis->vViewSizeInv.xy();
	vec2 uvWorld = uvLocal + uvWorldCenter;
	float isTexelBelow = 1.0f - step(uvLocal.y, unis->uWaterLevel);
	float isTexelAbove = 1.0f - isTexelBelow;
	vec2 uv = clamp(uvLocal + vec2(0.008f * sin(unis->uTime * 16.0f + uvWorld.y * 20.0f) * isTexelBelow, 0.0f), vec2(0.0f), vec2(1.0f));
	vec4 main = swTexture(in, 0, uv);
	float topDist = abs(uvLocal.y - unis->uWaterLevel);
	float topGradient = max(1.0f - topDist, 0.0f);
	float isNearTop = 0.2f * topGradient * topGradient;
	float isVeryNearTop = 1.0f - step(unis->vViewSizeInv.y, topDist);
	main.rgb() = mix(main.rgb(), waterColor, vec3(isTexelBelow * 0.4f)) + vec3((isNearTop + 0.2f * isVeryNearTop) * isTexelBelow);
	vec4 blur1 = swTexture(in, 2, uv);
	vec4 blur2 = swTexture(in, 3, uv);
	vec4 light = swTexture(in, 1, CombineWithWaterLow_noiseTexCoords(in, uv));
	vec4 blur = (blur1 + blur2) * vec4(0.5f);
	float gray = dot(blur.rgb(), vec3(0.299f, 0.587f, 0.114f));
	blur = vec4(gray, gray, gray, blur.a);
	float darknessStrength = 1.0f - light.r;
	if (unis->uWaterLevel < 0.4f) {
		float aboveWaterDarkness = isTexelAbove * (0.4f - unis->uWaterLevel);
		darknessStrength = min(1.0f, darknessStrength + aboveWaterDarkness);
	}
	COLOR = mix(mix(main * (1.0f + light.g) + max(light.g - 0.7f, 0.0f) * vec4(1.0f), blur, vec4(clamp((1.0f - light.r) / sqrt(max(unis->uAmbientColor.w, 0.35f)), 0.0f, 1.0f))), unis->uAmbientColor, vec4(darknessStrength));
	COLOR.a = 1.0f;
	packColor(COLOR, in.rgba);
}

		// --- DefaultBatchedMeshSprites ---
struct DefaultBatchedMeshSprites_Uniforms
{
};

void DefaultBatchedMeshSprites_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultBatchedMeshSprites_Uniforms* unis = static_cast<const DefaultBatchedMeshSprites_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = swTexturePrimary(in, 0) * vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- DefaultBatchedMeshSpritesNoTexture ---
struct DefaultBatchedMeshSpritesNoTexture_Uniforms
{
};

void DefaultBatchedMeshSpritesNoTexture_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultBatchedMeshSpritesNoTexture_Uniforms* unis = static_cast<const DefaultBatchedMeshSpritesNoTexture_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- DefaultBatchedSpritesNoTexture ---
struct DefaultBatchedSpritesNoTexture_Uniforms
{
};

void DefaultBatchedSpritesNoTexture_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultBatchedSpritesNoTexture_Uniforms* unis = static_cast<const DefaultBatchedSpritesNoTexture_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- DefaultImGui ---
struct DefaultImGui_Uniforms
{
};

void DefaultImGui_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultImGui_Uniforms* unis = static_cast<const DefaultImGui_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]) * swTexturePrimary(in, 0);
	packColor(COLOR, in.rgba);
}

		// --- DefaultMeshSprite ---
struct DefaultMeshSprite_Uniforms
{
};

void DefaultMeshSprite_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultMeshSprite_Uniforms* unis = static_cast<const DefaultMeshSprite_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = swTexturePrimary(in, 0) * vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- DefaultMeshSpriteNoTexture ---
struct DefaultMeshSpriteNoTexture_Uniforms
{
};

void DefaultMeshSpriteNoTexture_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultMeshSpriteNoTexture_Uniforms* unis = static_cast<const DefaultMeshSpriteNoTexture_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- DefaultSprite ---
struct DefaultSprite_Uniforms
{
};

void DefaultSprite_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultSprite_Uniforms* unis = static_cast<const DefaultSprite_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	COLOR = swTexturePrimary(in, 0) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- DefaultBatchedSprites ---
struct DefaultBatchedSprites_Uniforms
{
};

void DefaultBatchedSprites_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultBatchedSprites_Uniforms* unis = static_cast<const DefaultBatchedSprites_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	COLOR = swTexturePrimary(in, 0) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- DefaultSpriteNoTexture ---
struct DefaultSpriteNoTexture_Uniforms
{
};

void DefaultSpriteNoTexture_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const DefaultSpriteNoTexture_Uniforms* unis = static_cast<const DefaultSpriteNoTexture_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- Downsample ---
struct Downsample_Uniforms
{
	nCine::RHI::Software::sw::vec2 uPixelOffset;
};

void Downsample_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Downsample_Uniforms* unis = static_cast<const Downsample_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec4 color = swTexturePrimary(in, 0);
	color += swTexture(in, 0, vec2(in.u, in.v) + vec2(0.0f, unis->uPixelOffset.y));
	color += swTexture(in, 0, vec2(in.u, in.v) + vec2(unis->uPixelOffset.x, 0.0f));
	color += swTexture(in, 0, vec2(in.u, in.v) + unis->uPixelOffset);
	COLOR = vec4(0.25f) * color;
	packColor(COLOR, in.rgba);
}

		// --- FrozenMask ---
struct FrozenMask_Uniforms
{
};

static float FrozenMask_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const FrozenMask_Uniforms* unis = static_cast<const FrozenMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static nCine::RHI::Software::sw::vec4 FrozenMask_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const FrozenMask_Uniforms* unis = static_cast<const FrozenMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	return src;
}

void FrozenMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const FrozenMask_Uniforms* unis = static_cast<const FrozenMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy() * COLOR.a * 2.0f;
	vec4 tex = FrozenMask_maskSample(in, vec2(in.u, in.v));
	vec4 tex1 = FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, 0));
	vec4 tex2 = FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(0, size.y));
	vec4 tex3 = FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(size.x, 0));
	vec4 tex4 = FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(0, -size.y));
	float outline = tex1.a;
	outline += tex2.a;
	outline += tex3.a;
	outline += tex4.a;
	outline += FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, size.y)).a;
	outline += FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(size.x, size.y)).a;
	outline += FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, -size.y)).a;
	outline += FrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(size.x, -size.y)).a;
	outline = FrozenMask_aastep(in, 1.0f, outline);
	vec4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0f;
	float grey = min((0.299f * color.r + 0.587f * color.g + 0.114f * color.b) * 2.6f, 1.0f);
	COLOR = mix(tex, vec4(0.2f * grey, 0.2f + grey * 0.62f, 0.6f + 0.2f * grey, outline * 0.95f), COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- FrozenMask_USE_PALETTE ---
struct FrozenMask_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void FrozenMask_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	FrozenMask_USE_PALETTE_Uniforms* io = static_cast<FrozenMask_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static float FrozenMask_USE_PALETTE_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const FrozenMask_USE_PALETTE_Uniforms* unis = static_cast<const FrozenMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static nCine::RHI::Software::sw::vec4 FrozenMask_USE_PALETTE_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const FrozenMask_USE_PALETTE_Uniforms* unis = static_cast<const FrozenMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

void FrozenMask_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const FrozenMask_USE_PALETTE_Uniforms* unis = static_cast<const FrozenMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy() * COLOR.a * 2.0f;
	vec4 tex = FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v));
	vec4 tex1 = FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, 0));
	vec4 tex2 = FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(0, size.y));
	vec4 tex3 = FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(size.x, 0));
	vec4 tex4 = FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(0, -size.y));
	float outline = tex1.a;
	outline += tex2.a;
	outline += tex3.a;
	outline += tex4.a;
	outline += FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, size.y)).a;
	outline += FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(size.x, size.y)).a;
	outline += FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, -size.y)).a;
	outline += FrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(size.x, -size.y)).a;
	outline = FrozenMask_USE_PALETTE_aastep(in, 1.0f, outline);
	vec4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0f;
	float grey = min((0.299f * color.r + 0.587f * color.g + 0.114f * color.b) * 2.6f, 1.0f);
	COLOR = mix(tex, vec4(0.2f * grey, 0.2f + grey * 0.62f, 0.6f + 0.2f * grey, outline * 0.95f), COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- BatchedFrozenMask ---
struct BatchedFrozenMask_Uniforms
{
};

static float BatchedFrozenMask_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedFrozenMask_Uniforms* unis = static_cast<const BatchedFrozenMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static nCine::RHI::Software::sw::vec4 BatchedFrozenMask_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedFrozenMask_Uniforms* unis = static_cast<const BatchedFrozenMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	return src;
}

void BatchedFrozenMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedFrozenMask_Uniforms* unis = static_cast<const BatchedFrozenMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy() * COLOR.a * 2.0f;
	vec4 tex = BatchedFrozenMask_maskSample(in, vec2(in.u, in.v));
	vec4 tex1 = BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, 0));
	vec4 tex2 = BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(0, size.y));
	vec4 tex3 = BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(size.x, 0));
	vec4 tex4 = BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(0, -size.y));
	float outline = tex1.a;
	outline += tex2.a;
	outline += tex3.a;
	outline += tex4.a;
	outline += BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, size.y)).a;
	outline += BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(size.x, size.y)).a;
	outline += BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, -size.y)).a;
	outline += BatchedFrozenMask_maskSample(in, vec2(in.u, in.v) + vec2(size.x, -size.y)).a;
	outline = BatchedFrozenMask_aastep(in, 1.0f, outline);
	vec4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0f;
	float grey = min((0.299f * color.r + 0.587f * color.g + 0.114f * color.b) * 2.6f, 1.0f);
	COLOR = mix(tex, vec4(0.2f * grey, 0.2f + grey * 0.62f, 0.6f + 0.2f * grey, outline * 0.95f), COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- BatchedFrozenMask_USE_PALETTE ---
struct BatchedFrozenMask_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void BatchedFrozenMask_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedFrozenMask_USE_PALETTE_Uniforms* io = static_cast<BatchedFrozenMask_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static float BatchedFrozenMask_USE_PALETTE_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedFrozenMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedFrozenMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static nCine::RHI::Software::sw::vec4 BatchedFrozenMask_USE_PALETTE_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedFrozenMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedFrozenMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

void BatchedFrozenMask_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedFrozenMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedFrozenMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy() * COLOR.a * 2.0f;
	vec4 tex = BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v));
	vec4 tex1 = BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, 0));
	vec4 tex2 = BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(0, size.y));
	vec4 tex3 = BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(size.x, 0));
	vec4 tex4 = BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(0, -size.y));
	float outline = tex1.a;
	outline += tex2.a;
	outline += tex3.a;
	outline += tex4.a;
	outline += BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, size.y)).a;
	outline += BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(size.x, size.y)).a;
	outline += BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(-size.x, -size.y)).a;
	outline += BatchedFrozenMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v) + vec2(size.x, -size.y)).a;
	outline = BatchedFrozenMask_USE_PALETTE_aastep(in, 1.0f, outline);
	vec4 color = (tex + tex + tex1 + tex2 + tex3 + tex4) / 6.0f;
	float grey = min((0.299f * color.r + 0.587f * color.g + 0.114f * color.b) * 2.6f, 1.0f);
	COLOR = mix(tex, vec4(0.2f * grey, 0.2f + grey * 0.62f, 0.6f + 0.2f * grey, outline * 0.95f), COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- Outline ---
struct Outline_Uniforms
{
};

static float Outline_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const Outline_Uniforms* unis = static_cast<const Outline_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

void Outline_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Outline_Uniforms* unis = static_cast<const Outline_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy();
	float outline = swTexture(in, 0, vec2(in.u, in.v) + vec2(-size.x, 0)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(size.x, 0)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, -size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(-size.x, size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(size.x, size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(-size.x, -size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(size.x, -size.y)).a;
	outline = Outline_aastep(in, 1.0f, outline);
	float outline2 = swTexture(in, 0, vec2(in.u, in.v) + vec2(-2.0f * size.x, 0)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, 2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(2.0f * size.x, 0)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, -2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(-2.0f * size.x, 2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(2.0f * size.x, 2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(-2.0f * size.x, -2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(2.0f * size.x, -2.0f * size.y)).a;
	outline2 = Outline_aastep(in, 1.0f, outline2);
	vec4 color = swTexturePrimary(in, 0);
	COLOR = mix(color, mix(vec4(0.0f, 0.0f, 0.0f, COLOR.w * 0.5f), vec4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.a);
	packColor(COLOR, in.rgba);
}

		// --- BatchedOutline ---
struct BatchedOutline_Uniforms
{
};

static float BatchedOutline_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedOutline_Uniforms* unis = static_cast<const BatchedOutline_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

void BatchedOutline_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedOutline_Uniforms* unis = static_cast<const BatchedOutline_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy();
	float outline = swTexture(in, 0, vec2(in.u, in.v) + vec2(-size.x, 0)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(size.x, 0)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, -size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(-size.x, size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(size.x, size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(-size.x, -size.y)).a;
	outline += swTexture(in, 0, vec2(in.u, in.v) + vec2(size.x, -size.y)).a;
	outline = BatchedOutline_aastep(in, 1.0f, outline);
	float outline2 = swTexture(in, 0, vec2(in.u, in.v) + vec2(-2.0f * size.x, 0)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, 2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(2.0f * size.x, 0)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(0, -2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(-2.0f * size.x, 2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(2.0f * size.x, 2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(-2.0f * size.x, -2.0f * size.y)).a;
	outline2 += swTexture(in, 0, vec2(in.u, in.v) + vec2(2.0f * size.x, -2.0f * size.y)).a;
	outline2 = BatchedOutline_aastep(in, 1.0f, outline2);
	vec4 color = swTexturePrimary(in, 0);
	COLOR = mix(color, mix(vec4(0.0f, 0.0f, 0.0f, COLOR.w * 0.5f), vec4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.a);
	packColor(COLOR, in.rgba);
}

		// --- OutlinePalette ---
struct OutlinePalette_Uniforms
{
	float vPaletteOffset;
};

void OutlinePalette_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	OutlinePalette_Uniforms* io = static_cast<OutlinePalette_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static float OutlinePalette_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const OutlinePalette_Uniforms* unis = static_cast<const OutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static nCine::RHI::Software::sw::vec4 OutlinePalette_palette(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const OutlinePalette_Uniforms* unis = static_cast<const OutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

static float OutlinePalette_alphaAt(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const OutlinePalette_Uniforms* unis = static_cast<const OutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	return swTexture(in, 1, vec2(palX, palY)).a * src.a;
}

void OutlinePalette_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const OutlinePalette_Uniforms* unis = static_cast<const OutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy();
	float outline = OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-size.x, 0));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, size.y));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(size.x, 0));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, -size.y));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-size.x, size.y));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(size.x, size.y));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-size.x, -size.y));
	outline += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(size.x, -size.y));
	outline = OutlinePalette_aastep(in, 1.0f, outline);
	float outline2 = OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-2.0f * size.x, 0));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, 2.0f * size.y));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(2.0f * size.x, 0));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, -2.0f * size.y));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-2.0f * size.x, 2.0f * size.y));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(2.0f * size.x, 2.0f * size.y));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-2.0f * size.x, -2.0f * size.y));
	outline2 += OutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(2.0f * size.x, -2.0f * size.y));
	outline2 = OutlinePalette_aastep(in, 1.0f, outline2);
	vec4 color = OutlinePalette_palette(in, vec2(in.u, in.v));
	COLOR = mix(color, mix(vec4(0.0f, 0.0f, 0.0f, COLOR.w * 0.5f), vec4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.a);
	packColor(COLOR, in.rgba);
}

		// --- BatchedOutlinePalette ---
struct BatchedOutlinePalette_Uniforms
{
	float vPaletteOffset;
};

void BatchedOutlinePalette_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedOutlinePalette_Uniforms* io = static_cast<BatchedOutlinePalette_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static float BatchedOutlinePalette_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedOutlinePalette_Uniforms* unis = static_cast<const BatchedOutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static nCine::RHI::Software::sw::vec4 BatchedOutlinePalette_palette(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedOutlinePalette_Uniforms* unis = static_cast<const BatchedOutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

static float BatchedOutlinePalette_alphaAt(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedOutlinePalette_Uniforms* unis = static_cast<const BatchedOutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	return swTexture(in, 1, vec2(palX, palY)).a * src.a;
}

void BatchedOutlinePalette_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedOutlinePalette_Uniforms* unis = static_cast<const BatchedOutlinePalette_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec2 size = COLOR.xy();
	float outline = BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-size.x, 0));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, size.y));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(size.x, 0));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, -size.y));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-size.x, size.y));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(size.x, size.y));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-size.x, -size.y));
	outline += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(size.x, -size.y));
	outline = BatchedOutlinePalette_aastep(in, 1.0f, outline);
	float outline2 = BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-2.0f * size.x, 0));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, 2.0f * size.y));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(2.0f * size.x, 0));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(0, -2.0f * size.y));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-2.0f * size.x, 2.0f * size.y));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(2.0f * size.x, 2.0f * size.y));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(-2.0f * size.x, -2.0f * size.y));
	outline2 += BatchedOutlinePalette_alphaAt(in, vec2(in.u, in.v) + vec2(2.0f * size.x, -2.0f * size.y));
	outline2 = BatchedOutlinePalette_aastep(in, 1.0f, outline2);
	vec4 color = BatchedOutlinePalette_palette(in, vec2(in.u, in.v));
	COLOR = mix(color, mix(vec4(0.0f, 0.0f, 0.0f, COLOR.w * 0.5f), vec4(COLOR.z, COLOR.z, COLOR.z, COLOR.w), outline), max(outline, outline2) - color.a);
	packColor(COLOR, in.rgba);
}

		// --- PaletteRemap ---
struct PaletteRemap_Uniforms
{
	float vPaletteOffset;
};

void PaletteRemap_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	PaletteRemap_Uniforms* io = static_cast<PaletteRemap_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

void PaletteRemap_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const PaletteRemap_Uniforms* unis = static_cast<const PaletteRemap_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 src = swTexturePrimary(in, 0);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 color = swTexture(in, 1, vec2(palX, palY));
	COLOR = vec4(color.rgb(), color.a * src.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- BatchedPaletteRemap ---
struct BatchedPaletteRemap_Uniforms
{
	float vPaletteOffset;
};

void BatchedPaletteRemap_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedPaletteRemap_Uniforms* io = static_cast<BatchedPaletteRemap_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

void BatchedPaletteRemap_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedPaletteRemap_Uniforms* unis = static_cast<const BatchedPaletteRemap_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 src = swTexturePrimary(in, 0);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 color = swTexture(in, 1, vec2(palX, palY));
	COLOR = vec4(color.rgb(), color.a * src.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- PartialWhiteMask ---
struct PartialWhiteMask_Uniforms
{
};

static nCine::RHI::Software::sw::vec4 PartialWhiteMask_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const PartialWhiteMask_Uniforms* unis = static_cast<const PartialWhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	return src;
}

void PartialWhiteMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const PartialWhiteMask_Uniforms* unis = static_cast<const PartialWhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = PartialWhiteMask_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 2.5f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- PartialWhiteMask_USE_PALETTE ---
struct PartialWhiteMask_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void PartialWhiteMask_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	PartialWhiteMask_USE_PALETTE_Uniforms* io = static_cast<PartialWhiteMask_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static nCine::RHI::Software::sw::vec4 PartialWhiteMask_USE_PALETTE_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const PartialWhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const PartialWhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

void PartialWhiteMask_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const PartialWhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const PartialWhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = PartialWhiteMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 2.5f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- BatchedPartialWhiteMask ---
struct BatchedPartialWhiteMask_Uniforms
{
};

static nCine::RHI::Software::sw::vec4 BatchedPartialWhiteMask_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedPartialWhiteMask_Uniforms* unis = static_cast<const BatchedPartialWhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	return src;
}

void BatchedPartialWhiteMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedPartialWhiteMask_Uniforms* unis = static_cast<const BatchedPartialWhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = BatchedPartialWhiteMask_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 2.5f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- BatchedPartialWhiteMask_USE_PALETTE ---
struct BatchedPartialWhiteMask_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void BatchedPartialWhiteMask_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedPartialWhiteMask_USE_PALETTE_Uniforms* io = static_cast<BatchedPartialWhiteMask_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static nCine::RHI::Software::sw::vec4 BatchedPartialWhiteMask_USE_PALETTE_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedPartialWhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedPartialWhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

void BatchedPartialWhiteMask_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedPartialWhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedPartialWhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = BatchedPartialWhiteMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 2.5f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- ResizeCrtApertureGrille ---
struct ResizeCrtApertureGrille_Uniforms
{
	nCine::RHI::Software::sw::vec2 vTexSize;
	nCine::RHI::Software::sw::vec2 vViewSize;
};

void ResizeCrtApertureGrille_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	ResizeCrtApertureGrille_Uniforms* io = static_cast<ResizeCrtApertureGrille_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vTexSize = (*reinterpret_cast<const vec4*>(instanceBlock + 80)).xy();
	io->vViewSize = (*reinterpret_cast<const vec2*>(instanceBlock + 96));
}

static float ResizeCrtApertureGrille_ToLinear1(const nCine::RHI::Software::FragmentShaderInput& in, float c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return c <= 0.04045f ? c / 12.92f : pow((c + 0.055f) / 1.055f, 2.4f);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_ToLinear(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec3 c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return vec3(ResizeCrtApertureGrille_ToLinear1(in, c.r), ResizeCrtApertureGrille_ToLinear1(in, c.g), ResizeCrtApertureGrille_ToLinear1(in, c.b));
}

static float ResizeCrtApertureGrille_ToSrgb1(const nCine::RHI::Software::FragmentShaderInput& in, float c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return c < 0.0031308f ? c * 12.92f : 1.055f * pow(c, 0.41666f) - 0.055f;
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_ToSrgb(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec3 c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return vec3(ResizeCrtApertureGrille_ToSrgb1(in, c.r), ResizeCrtApertureGrille_ToSrgb1(in, c.g), ResizeCrtApertureGrille_ToSrgb1(in, c.b));
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Fetch(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	pos = (floor(pos * texture_size.xy() + off) + vec2(0.5f, 0.5f)) / texture_size.xy();
	return ResizeCrtApertureGrille_ToLinear(in, vec3(1.1f) * swTexture(in, 0, pos.xy()).rgb());
}

static nCine::RHI::Software::sw::vec2 ResizeCrtApertureGrille_Dist(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	pos = pos * texture_size.xy();
	return -(pos - floor(pos) - vec2(0.5f, 0.5f));
}

static float ResizeCrtApertureGrille_Gaus(const nCine::RHI::Software::FragmentShaderInput& in, float pos, float scale)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	return exp2(scale * pow(abs(pos), 2.0f));
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Horz3(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 b = ResizeCrtApertureGrille_Fetch(in, pos, vec2(-1.0f, off), texture_size);
	vec3 c = ResizeCrtApertureGrille_Fetch(in, pos, vec2(0.0f, off), texture_size);
	vec3 d = ResizeCrtApertureGrille_Fetch(in, pos, vec2(1.0f, off), texture_size);
	float dst = ResizeCrtApertureGrille_Dist(in, pos, texture_size).x;
	float scale = -3.0f;
	float wb = ResizeCrtApertureGrille_Gaus(in, dst - 1.0f, scale);
	float wc = ResizeCrtApertureGrille_Gaus(in, dst + 0.0f, scale);
	float wd = ResizeCrtApertureGrille_Gaus(in, dst + 1.0f, scale);
	return (b * wb + c * wc + d * wd) / (wb + wc + wd);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Horz5(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtApertureGrille_Fetch(in, pos, vec2(-2.0f, off), texture_size);
	vec3 b = ResizeCrtApertureGrille_Fetch(in, pos, vec2(-1.0f, off), texture_size);
	vec3 c = ResizeCrtApertureGrille_Fetch(in, pos, vec2(0.0f, off), texture_size);
	vec3 d = ResizeCrtApertureGrille_Fetch(in, pos, vec2(1.0f, off), texture_size);
	vec3 e = ResizeCrtApertureGrille_Fetch(in, pos, vec2(2.0f, off), texture_size);
	float dst = ResizeCrtApertureGrille_Dist(in, pos, texture_size).x;
	float scale = -3.0f;
	float wa = ResizeCrtApertureGrille_Gaus(in, dst - 2.0f, scale);
	float wb = ResizeCrtApertureGrille_Gaus(in, dst - 1.0f, scale);
	float wc = ResizeCrtApertureGrille_Gaus(in, dst + 0.0f, scale);
	float wd = ResizeCrtApertureGrille_Gaus(in, dst + 1.0f, scale);
	float we = ResizeCrtApertureGrille_Gaus(in, dst + 2.0f, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we) / (wa + wb + wc + wd + we);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Horz7(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtApertureGrille_Fetch(in, pos, vec2(-3.0f, off), texture_size);
	vec3 b = ResizeCrtApertureGrille_Fetch(in, pos, vec2(-2.0f, off), texture_size);
	vec3 c = ResizeCrtApertureGrille_Fetch(in, pos, vec2(-1.0f, off), texture_size);
	vec3 d = ResizeCrtApertureGrille_Fetch(in, pos, vec2(0.0f, off), texture_size);
	vec3 e = ResizeCrtApertureGrille_Fetch(in, pos, vec2(1.0f, off), texture_size);
	vec3 f = ResizeCrtApertureGrille_Fetch(in, pos, vec2(2.0f, off), texture_size);
	vec3 g = ResizeCrtApertureGrille_Fetch(in, pos, vec2(3.0f, off), texture_size);
	float dst = ResizeCrtApertureGrille_Dist(in, pos, texture_size).x;
	float scale = -1.5f;
	float wa = ResizeCrtApertureGrille_Gaus(in, dst - 3.0f, scale);
	float wb = ResizeCrtApertureGrille_Gaus(in, dst - 2.0f, scale);
	float wc = ResizeCrtApertureGrille_Gaus(in, dst - 1.0f, scale);
	float wd = ResizeCrtApertureGrille_Gaus(in, dst + 0.0f, scale);
	float we = ResizeCrtApertureGrille_Gaus(in, dst + 1.0f, scale);
	float wf = ResizeCrtApertureGrille_Gaus(in, dst + 2.0f, scale);
	float wg = ResizeCrtApertureGrille_Gaus(in, dst + 3.0f, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we + f * wf + g * wg) / (wa + wb + wc + wd + we + wf + wg);
}

static float ResizeCrtApertureGrille_Scan(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float dst = ResizeCrtApertureGrille_Dist(in, pos, texture_size).y;
	return ResizeCrtApertureGrille_Gaus(in, dst + off, -8.0f);
}

static float ResizeCrtApertureGrille_BloomScan(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float dst = ResizeCrtApertureGrille_Dist(in, pos, texture_size).y;
	return ResizeCrtApertureGrille_Gaus(in, dst + off, -2.0f);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Tri(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtApertureGrille_Horz3(in, pos, -1.0f, texture_size);
	vec3 b = ResizeCrtApertureGrille_Horz5(in, pos, 0.0f, texture_size);
	vec3 c = ResizeCrtApertureGrille_Horz3(in, pos, 1.0f, texture_size);
	float wa = ResizeCrtApertureGrille_Scan(in, pos, -1.0f, texture_size);
	float wb = ResizeCrtApertureGrille_Scan(in, pos, 0.0f, texture_size);
	float wc = ResizeCrtApertureGrille_Scan(in, pos, 1.0f, texture_size);
	return a * wa + b * wb + c * wc;
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Bloom(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtApertureGrille_Horz5(in, pos, -2.0f, texture_size);
	vec3 b = ResizeCrtApertureGrille_Horz7(in, pos, -1.0f, texture_size);
	vec3 c = ResizeCrtApertureGrille_Horz7(in, pos, 0.0f, texture_size);
	vec3 d = ResizeCrtApertureGrille_Horz7(in, pos, 1.0f, texture_size);
	vec3 e = ResizeCrtApertureGrille_Horz5(in, pos, 2.0f, texture_size);
	float wa = ResizeCrtApertureGrille_BloomScan(in, pos, -2.0f, texture_size);
	float wb = ResizeCrtApertureGrille_BloomScan(in, pos, -1.0f, texture_size);
	float wc = ResizeCrtApertureGrille_BloomScan(in, pos, 0.0f, texture_size);
	float wd = ResizeCrtApertureGrille_BloomScan(in, pos, 1.0f, texture_size);
	float we = ResizeCrtApertureGrille_BloomScan(in, pos, 2.0f, texture_size);
	return a * wa + b * wb + c * wc + d * wd + e * we;
}

static nCine::RHI::Software::sw::vec2 ResizeCrtApertureGrille_Warp(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	pos = pos * 2.0f - 1.0f;
	pos *= vec2(1.0f + pos.y * pos.y * 0.0155f, 1.0f + pos.x * pos.x * 0.0205f);
	return pos * 0.5f + 0.5f;
}

static nCine::RHI::Software::sw::vec3 ResizeCrtApertureGrille_Mask(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 mask = vec3(0.7f, 0.7f, 0.7f);
	pos.x = fract(pos.x / 3.0f);
	if (pos.x < 0.333f) {
		mask.r = 1.5f;
	} else {
		if (pos.x < 0.666f) {
			mask.g = 1.5f;
		} else {
			mask.b = 1.5f;
		}
	}
	return mask;
}

static nCine::RHI::Software::sw::vec4 ResizeCrtApertureGrille_crt_lottes(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 texture_size, nCine::RHI::Software::sw::vec2 video_size, nCine::RHI::Software::sw::vec2 output_size, nCine::RHI::Software::sw::vec2 tex)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 pos = ResizeCrtApertureGrille_Warp(in, tex.xy() * (texture_size.xy() / video_size.xy())) * (video_size.xy() / texture_size.xy());
	vec3 outColor = ResizeCrtApertureGrille_Tri(in, pos, texture_size);
	outColor.rgb() += ResizeCrtApertureGrille_Bloom(in, pos, texture_size) * 1.0f / 16.0f;
	outColor.rgb() *= ResizeCrtApertureGrille_Mask(in, floor(tex.xy() * (texture_size.xy() / video_size.xy()) * output_size.xy()) + vec2(0.5f, 0.5f));
	return vec4(ResizeCrtApertureGrille_ToSrgb(in, outColor.rgb()), 1.0f);
}

void ResizeCrtApertureGrille_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtApertureGrille_Uniforms* unis = static_cast<const ResizeCrtApertureGrille_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = ResizeCrtApertureGrille_crt_lottes(in, unis->vTexSize, unis->vTexSize, unis->vViewSize, vec2(in.u, in.v));
	packColor(COLOR, in.rgba);
}

		// --- ResizeCrtShadowMask ---
struct ResizeCrtShadowMask_Uniforms
{
	nCine::RHI::Software::sw::vec2 vTexSize;
	nCine::RHI::Software::sw::vec2 vViewSize;
};

void ResizeCrtShadowMask_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	ResizeCrtShadowMask_Uniforms* io = static_cast<ResizeCrtShadowMask_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vTexSize = (*reinterpret_cast<const vec4*>(instanceBlock + 80)).xy();
	io->vViewSize = (*reinterpret_cast<const vec2*>(instanceBlock + 96));
}

static float ResizeCrtShadowMask_ToLinear1(const nCine::RHI::Software::FragmentShaderInput& in, float c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return c <= 0.04045f ? c / 12.92f : pow((c + 0.055f) / 1.055f, 2.4f);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_ToLinear(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec3 c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return vec3(ResizeCrtShadowMask_ToLinear1(in, c.r), ResizeCrtShadowMask_ToLinear1(in, c.g), ResizeCrtShadowMask_ToLinear1(in, c.b));
}

static float ResizeCrtShadowMask_ToSrgb1(const nCine::RHI::Software::FragmentShaderInput& in, float c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return c < 0.0031308f ? c * 12.92f : 1.055f * pow(c, 0.41666f) - 0.055f;
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_ToSrgb(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec3 c)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	if (1 == 0) {
		return c;
	}
	return vec3(ResizeCrtShadowMask_ToSrgb1(in, c.r), ResizeCrtShadowMask_ToSrgb1(in, c.g), ResizeCrtShadowMask_ToSrgb1(in, c.b));
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Fetch(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	pos = (floor(pos * texture_size.xy() + off) + vec2(0.5f, 0.5f)) / texture_size.xy();
	return ResizeCrtShadowMask_ToLinear(in, vec3(1.0f) * swTexture(in, 0, pos.xy()).rgb());
}

static nCine::RHI::Software::sw::vec2 ResizeCrtShadowMask_Dist(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	pos = pos * texture_size.xy();
	return -(pos - floor(pos) - vec2(0.5f, 0.5f));
}

static float ResizeCrtShadowMask_Gaus(const nCine::RHI::Software::FragmentShaderInput& in, float pos, float scale)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	return exp2(scale * pow(abs(pos), 2.0f));
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Horz3(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 b = ResizeCrtShadowMask_Fetch(in, pos, vec2(-1.0f, off), texture_size);
	vec3 c = ResizeCrtShadowMask_Fetch(in, pos, vec2(0.0f, off), texture_size);
	vec3 d = ResizeCrtShadowMask_Fetch(in, pos, vec2(1.0f, off), texture_size);
	float dst = ResizeCrtShadowMask_Dist(in, pos, texture_size).x;
	float scale = -3.0f;
	float wb = ResizeCrtShadowMask_Gaus(in, dst - 1.0f, scale);
	float wc = ResizeCrtShadowMask_Gaus(in, dst + 0.0f, scale);
	float wd = ResizeCrtShadowMask_Gaus(in, dst + 1.0f, scale);
	return (b * wb + c * wc + d * wd) / (wb + wc + wd);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Horz5(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtShadowMask_Fetch(in, pos, vec2(-2.0f, off), texture_size);
	vec3 b = ResizeCrtShadowMask_Fetch(in, pos, vec2(-1.0f, off), texture_size);
	vec3 c = ResizeCrtShadowMask_Fetch(in, pos, vec2(0.0f, off), texture_size);
	vec3 d = ResizeCrtShadowMask_Fetch(in, pos, vec2(1.0f, off), texture_size);
	vec3 e = ResizeCrtShadowMask_Fetch(in, pos, vec2(2.0f, off), texture_size);
	float dst = ResizeCrtShadowMask_Dist(in, pos, texture_size).x;
	float scale = -3.0f;
	float wa = ResizeCrtShadowMask_Gaus(in, dst - 2.0f, scale);
	float wb = ResizeCrtShadowMask_Gaus(in, dst - 1.0f, scale);
	float wc = ResizeCrtShadowMask_Gaus(in, dst + 0.0f, scale);
	float wd = ResizeCrtShadowMask_Gaus(in, dst + 1.0f, scale);
	float we = ResizeCrtShadowMask_Gaus(in, dst + 2.0f, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we) / (wa + wb + wc + wd + we);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Horz7(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtShadowMask_Fetch(in, pos, vec2(-3.0f, off), texture_size);
	vec3 b = ResizeCrtShadowMask_Fetch(in, pos, vec2(-2.0f, off), texture_size);
	vec3 c = ResizeCrtShadowMask_Fetch(in, pos, vec2(-1.0f, off), texture_size);
	vec3 d = ResizeCrtShadowMask_Fetch(in, pos, vec2(0.0f, off), texture_size);
	vec3 e = ResizeCrtShadowMask_Fetch(in, pos, vec2(1.0f, off), texture_size);
	vec3 f = ResizeCrtShadowMask_Fetch(in, pos, vec2(2.0f, off), texture_size);
	vec3 g = ResizeCrtShadowMask_Fetch(in, pos, vec2(3.0f, off), texture_size);
	float dst = ResizeCrtShadowMask_Dist(in, pos, texture_size).x;
	float scale = -1.5f;
	float wa = ResizeCrtShadowMask_Gaus(in, dst - 3.0f, scale);
	float wb = ResizeCrtShadowMask_Gaus(in, dst - 2.0f, scale);
	float wc = ResizeCrtShadowMask_Gaus(in, dst - 1.0f, scale);
	float wd = ResizeCrtShadowMask_Gaus(in, dst + 0.0f, scale);
	float we = ResizeCrtShadowMask_Gaus(in, dst + 1.0f, scale);
	float wf = ResizeCrtShadowMask_Gaus(in, dst + 2.0f, scale);
	float wg = ResizeCrtShadowMask_Gaus(in, dst + 3.0f, scale);
	return (a * wa + b * wb + c * wc + d * wd + e * we + f * wf + g * wg) / (wa + wb + wc + wd + we + wf + wg);
}

static float ResizeCrtShadowMask_Scan(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float dst = ResizeCrtShadowMask_Dist(in, pos, texture_size).y;
	return ResizeCrtShadowMask_Gaus(in, dst + off, -6.0f);
}

static float ResizeCrtShadowMask_BloomScan(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, float off, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float dst = ResizeCrtShadowMask_Dist(in, pos, texture_size).y;
	return ResizeCrtShadowMask_Gaus(in, dst + off, -2.0f);
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Tri(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtShadowMask_Horz3(in, pos, -1.0f, texture_size);
	vec3 b = ResizeCrtShadowMask_Horz5(in, pos, 0.0f, texture_size);
	vec3 c = ResizeCrtShadowMask_Horz3(in, pos, 1.0f, texture_size);
	float wa = ResizeCrtShadowMask_Scan(in, pos, -1.0f, texture_size);
	float wb = ResizeCrtShadowMask_Scan(in, pos, 0.0f, texture_size);
	float wc = ResizeCrtShadowMask_Scan(in, pos, 1.0f, texture_size);
	return a * wa + b * wb + c * wc;
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Bloom(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos, nCine::RHI::Software::sw::vec2 texture_size)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 a = ResizeCrtShadowMask_Horz5(in, pos, -2.0f, texture_size);
	vec3 b = ResizeCrtShadowMask_Horz7(in, pos, -1.0f, texture_size);
	vec3 c = ResizeCrtShadowMask_Horz7(in, pos, 0.0f, texture_size);
	vec3 d = ResizeCrtShadowMask_Horz7(in, pos, 1.0f, texture_size);
	vec3 e = ResizeCrtShadowMask_Horz5(in, pos, 2.0f, texture_size);
	float wa = ResizeCrtShadowMask_BloomScan(in, pos, -2.0f, texture_size);
	float wb = ResizeCrtShadowMask_BloomScan(in, pos, -1.0f, texture_size);
	float wc = ResizeCrtShadowMask_BloomScan(in, pos, 0.0f, texture_size);
	float wd = ResizeCrtShadowMask_BloomScan(in, pos, 1.0f, texture_size);
	float we = ResizeCrtShadowMask_BloomScan(in, pos, 2.0f, texture_size);
	return a * wa + b * wb + c * wc + d * wd + e * we;
}

static nCine::RHI::Software::sw::vec2 ResizeCrtShadowMask_Warp(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	pos = pos * 2.0f - 1.0f;
	pos *= vec2(1.0f + pos.y * pos.y * 0.031f, 1.0f + pos.x * pos.x * 0.041f);
	return pos * 0.5f + 0.5f;
}

static nCine::RHI::Software::sw::vec3 ResizeCrtShadowMask_Mask(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 pos)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 mask = vec3(0.55f, 0.55f, 0.55f);
	pos.xy() = floor(pos.xy() * vec2(1.0f, 0.5f));
	pos.x += pos.y * 3.0f;
	pos.x = fract(pos.x / 6.0f);
	if (pos.x < 0.333f) {
		mask.r = 1.5f;
	} else {
		if (pos.x < 0.666f) {
			mask.g = 1.5f;
		} else {
			mask.b = 1.5f;
		}
	}
	return mask;
}

static nCine::RHI::Software::sw::vec4 ResizeCrtShadowMask_crt_lottes(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 texture_size, nCine::RHI::Software::sw::vec2 video_size, nCine::RHI::Software::sw::vec2 output_size, nCine::RHI::Software::sw::vec2 tex)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 pos = ResizeCrtShadowMask_Warp(in, tex.xy() * (texture_size.xy() / video_size.xy())) * (video_size.xy() / texture_size.xy());
	vec3 outColor = ResizeCrtShadowMask_Tri(in, pos, texture_size);
	outColor.rgb() += ResizeCrtShadowMask_Bloom(in, pos, texture_size) * 1.0f / 12.0f;
	outColor.rgb() *= ResizeCrtShadowMask_Mask(in, floor(tex.xy() * (texture_size.xy() / video_size.xy()) * output_size.xy()) + vec2(0.5f, 0.5f));
	return vec4(ResizeCrtShadowMask_ToSrgb(in, outColor.rgb()), 1.0f);
}

void ResizeCrtShadowMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const ResizeCrtShadowMask_Uniforms* unis = static_cast<const ResizeCrtShadowMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = ResizeCrtShadowMask_crt_lottes(in, unis->vTexSize, unis->vTexSize, unis->vViewSize, vec2(in.u, in.v));
	packColor(COLOR, in.rgba);
}

		// --- ShieldFire ---
struct ShieldFire_Uniforms
{
	nCine::RHI::Software::sw::vec4 vShieldRect;
};

void ShieldFire_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	ShieldFire_Uniforms* io = static_cast<ShieldFire_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vShieldRect = (*reinterpret_cast<const vec4*>(instanceBlock + 80));
}

static float ShieldFire_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const ShieldFire_Uniforms* unis = static_cast<const ShieldFire_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static float ShieldFire_triangleWave(const nCine::RHI::Software::FragmentShaderInput& in, float x, float period)
{
	using namespace nCine::RHI::Software::sw;
	const ShieldFire_Uniforms* unis = static_cast<const ShieldFire_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float p = x / period;
	float f = fract(p);
	return abs(f - 0.5f) * 2.0f;
}

void ShieldFire_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const ShieldFire_Uniforms* unis = static_cast<const ShieldFire_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 scale = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).xy();
	vec2 shift1 = unis->vShieldRect.xy();
	vec2 shift2 = unis->vShieldRect.zw();
	vec2 vPos = vec2(in.u, in.v).xy() * vec2(2.0f) - vec2(1.0f);
	float darkness = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).z;
	float alpha = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).w;
	float dist = length(vPos);
	if (dist > 1.0f) {
		COLOR = vec4(0.0f, 0.0f, 0.0f, 0.0f);
	} else {
		vec3 v = vec3(vPos.x, vPos.y, sqrt(1.0f - vPos.x * vPos.x - vPos.y * vPos.y));
		vec3 n = normalize(v);
		float b = dot(n, vec3(0.0f, 0.0f, 1.0f));
		vec2 q = vec2(0.5f - 0.5f * atan(n.z, n.x) / 3.1415926f, -acos(vPos.y) / 3.1415926f);
		float isNearBorder = 1.0f - ShieldFire_aastep(in, 0.96f, dist);
		float mask1 = swTexture(in, 0, mod(shift1 + q * scale, 1.0f)).r;
		float maskNormalized1 = max(1.0f - abs(ShieldFire_triangleWave(in, shift2.y + 0.5f, 2.0f) - mask1) * 6.0f, 0.0f);
		float mask2 = swTexture(in, 0, mod(shift2 + q * scale, 1.0f)).r;
		float maskNormalized2 = max(1.0f - abs(ShieldFire_triangleWave(in, shift1.x, 1.333f) - mask2) * 6.0f, 0.0f);
		float maskSum = min(maskNormalized1 + maskNormalized2, 1.0f);
		COLOR = vec4(mix(vec3(1.0f, 0.3f, 0.0f), vec3(1.0f, 1.0f, 1.0f), max(maskSum * 2.0f - 1.0f, 0.0f)) * darkness, min(maskSum * b * isNearBorder * 1.3f + 0.1f, 1.0f) * alpha);
	}
	packColor(COLOR, in.rgba);
}

		// --- ShieldLightning ---
struct ShieldLightning_Uniforms
{
	nCine::RHI::Software::sw::vec4 vShieldRect;
};

void ShieldLightning_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	ShieldLightning_Uniforms* io = static_cast<ShieldLightning_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vShieldRect = (*reinterpret_cast<const vec4*>(instanceBlock + 80));
}

static float ShieldLightning_aastep(const nCine::RHI::Software::FragmentShaderInput& in, float threshold, float value)
{
	using namespace nCine::RHI::Software::sw;
	const ShieldLightning_Uniforms* unis = static_cast<const ShieldLightning_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757f;
	return smoothstep(threshold - afwidth, threshold + afwidth, value);
}

static float ShieldLightning_triangleWave(const nCine::RHI::Software::FragmentShaderInput& in, float x, float period)
{
	using namespace nCine::RHI::Software::sw;
	const ShieldLightning_Uniforms* unis = static_cast<const ShieldLightning_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float p = x / period;
	float f = fract(p);
	return abs(f - 0.5f) * 2.0f;
}

void ShieldLightning_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const ShieldLightning_Uniforms* unis = static_cast<const ShieldLightning_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 scale = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).xy();
	vec2 shift1 = unis->vShieldRect.xy();
	vec2 shift2 = unis->vShieldRect.zw();
	vec2 vPos = vec2(in.u, in.v).xy() * vec2(2.0f) - vec2(1.0f);
	float darkness = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).z;
	float alpha = vec4(in.color[0], in.color[1], in.color[2], in.color[3]).w;
	float dist = length(vPos);
	if (dist > 1.0f) {
		COLOR = vec4(0.0f, 0.0f, 0.0f, 0.0f);
	} else {
		vec3 v = vec3(vPos.x, vPos.y, sqrt(1.0f - vPos.x * vPos.x - vPos.y * vPos.y));
		vec3 n = normalize(v);
		float b = dot(n, vec3(0.0f, 0.0f, 1.0f));
		vec2 q = vec2(0.5f - 0.5f * atan(n.z, n.x) / 3.1415926f, -acos(vPos.y) / 3.1415926f);
		float isNearBorder = 1.0f - ShieldLightning_aastep(in, 0.96f, dist);
		float mask = swTexture(in, 0, mod(shift1 + q * scale, 1.0f)).r;
		float maskNormalized = max(1.0f - abs(ShieldLightning_triangleWave(in, shift2.y + 0.5f, 2.0f) - mask) * 8.0f, 0.0f);
		float isVeryNearBorder = 1.0f - ShieldLightning_aastep(in, 0.024f, abs(dist - 0.94f));
		float maskSum = max(maskNormalized, isVeryNearBorder);
		COLOR = vec4(mix(vec3(0.1f, 1.0f, 0.0f), vec3(1.0f, 1.0f, 1.0f), max(maskSum * 2.0f - 1.0f, 0.0f)) * darkness, min(maskSum * b * isNearBorder * 1.3f + 0.1f, 1.0f) * alpha);
	}
	packColor(COLOR, in.rgba);
}

		// --- TexturedBackground ---
struct TexturedBackground_Uniforms
{
	nCine::RHI::Software::sw::vec2 uViewSize;
	nCine::RHI::Software::sw::vec2 uCameraPos;
	nCine::RHI::Software::sw::vec4 uHorizonColor;
	nCine::RHI::Software::sw::vec2 uShift;
};

static nCine::RHI::Software::sw::vec2 TexturedBackground_hash2D(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_Uniforms* unis = static_cast<const TexturedBackground_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float h = dot(p, vec2(12.9898f, 78.233f));
	float h2 = dot(p, vec2(37.271f, 377.632f));
	return -1.0f + 2.0f * vec2(fract(sin(h) * 43758.5453f), fract(sin(h2) * 43758.5453f));
}

static nCine::RHI::Software::sw::vec3 TexturedBackground_voronoi(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_Uniforms* unis = static_cast<const TexturedBackground_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 n = floor(p);
	vec2 f = fract(p);
	vec2 mg;
	vec2 mr;
	float md = 8.0f;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			vec2 g = vec2(float(i), float(j));
			vec2 o = TexturedBackground_hash2D(in, n + g);
			vec2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return vec3(md, mr);
}

static float TexturedBackground_addStarField(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 samplePosition, float threshold)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_Uniforms* unis = static_cast<const TexturedBackground_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 starValue = TexturedBackground_voronoi(in, samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0f - starValue.x / threshold;
		return min(power * power * power, 0.5f);
	}
	return 0.0f;
}

void TexturedBackground_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_Uniforms* unis = static_cast<const TexturedBackground_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	float distance = 1.3f - abs(2.0f * vec2(in.u, in.v).y - 1.0f);
	float horizonDepth = distance;
	float yShift = vec2(in.u, in.v).y > 0.5f ? 1.0f : 0.0f;
	float correction = unis->uViewSize.x * 9.0f / (unis->uViewSize.y * 16.0f);
	vec2 texturePos = vec2(unis->uShift.x / 256.0f + (vec2(in.u, in.v).x - 0.5f) * (0.5f + 1.5f * horizonDepth) * correction, unis->uShift.y / 256.0f + (vec2(in.u, in.v).y - yShift) * 1.4f * distance);
	vec4 texColor = swTexture(in, 0, texturePos);
	float horizonOpacity = clamp(distance * distance - 0.3f, 0.0f, 1.0f);
	vec4 horizonColorWithStars = vec4(unis->uHorizonColor.xyz(), 1.0f);
	COLOR = mix(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.a = 1.0f;
	packColor(COLOR, in.rgba);
}

		// --- TexturedBackground_DITHER ---
struct TexturedBackground_DITHER_Uniforms
{
	nCine::RHI::Software::sw::vec2 uViewSize;
	nCine::RHI::Software::sw::vec2 uCameraPos;
	nCine::RHI::Software::sw::vec4 uHorizonColor;
	nCine::RHI::Software::sw::vec2 uShift;
};

static nCine::RHI::Software::sw::vec2 TexturedBackground_DITHER_hash2D(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_DITHER_Uniforms* unis = static_cast<const TexturedBackground_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float h = dot(p, vec2(12.9898f, 78.233f));
	float h2 = dot(p, vec2(37.271f, 377.632f));
	return -1.0f + 2.0f * vec2(fract(sin(h) * 43758.5453f), fract(sin(h2) * 43758.5453f));
}

static nCine::RHI::Software::sw::vec3 TexturedBackground_DITHER_voronoi(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_DITHER_Uniforms* unis = static_cast<const TexturedBackground_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 n = floor(p);
	vec2 f = fract(p);
	vec2 mg;
	vec2 mr;
	float md = 8.0f;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			vec2 g = vec2(float(i), float(j));
			vec2 o = TexturedBackground_DITHER_hash2D(in, n + g);
			vec2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return vec3(md, mr);
}

static float TexturedBackground_DITHER_addStarField(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 samplePosition, float threshold)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_DITHER_Uniforms* unis = static_cast<const TexturedBackground_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 starValue = TexturedBackground_DITHER_voronoi(in, samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0f - starValue.x / threshold;
		return min(power * power * power, 0.5f);
	}
	return 0.0f;
}

void TexturedBackground_DITHER_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackground_DITHER_Uniforms* unis = static_cast<const TexturedBackground_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	float distance = 1.3f - abs(2.0f * vec2(in.u, in.v).y - 1.0f);
	float horizonDepth = distance;
	float yShift = vec2(in.u, in.v).y > 0.5f ? 1.0f : 0.0f;
	float correction = unis->uViewSize.x * 9.0f / (unis->uViewSize.y * 16.0f);
	vec2 texturePos = vec2(unis->uShift.x / 256.0f + (vec2(in.u, in.v).x - 0.5f) * (0.5f + 1.5f * horizonDepth) * correction, unis->uShift.y / 256.0f + (vec2(in.u, in.v).y - yShift) * 1.4f * distance);
	vec4 texColor = swTexture(in, 0, texturePos);
	float horizonOpacity = clamp(distance * distance - 0.3f, 0.0f, 1.0f);
	vec4 horizonColorWithStars = vec4(unis->uHorizonColor.xyz(), 1.0f);
	COLOR = mix(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.a = 1.0f;
	packColor(COLOR, in.rgba);
}

		// --- TexturedBackgroundCircle ---
struct TexturedBackgroundCircle_Uniforms
{
	nCine::RHI::Software::sw::vec2 uViewSize;
	nCine::RHI::Software::sw::vec2 uCameraPos;
	nCine::RHI::Software::sw::vec4 uHorizonColor;
	nCine::RHI::Software::sw::vec2 uShift;
};

static nCine::RHI::Software::sw::vec2 TexturedBackgroundCircle_hash2D(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_Uniforms* unis = static_cast<const TexturedBackgroundCircle_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float h = dot(p, vec2(12.9898f, 78.233f));
	float h2 = dot(p, vec2(37.271f, 377.632f));
	return -1.0f + 2.0f * vec2(fract(sin(h) * 43758.5453f), fract(sin(h2) * 43758.5453f));
}

static nCine::RHI::Software::sw::vec3 TexturedBackgroundCircle_voronoi(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_Uniforms* unis = static_cast<const TexturedBackgroundCircle_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 n = floor(p);
	vec2 f = fract(p);
	vec2 mg;
	vec2 mr;
	float md = 8.0f;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			vec2 g = vec2(float(i), float(j));
			vec2 o = TexturedBackgroundCircle_hash2D(in, n + g);
			vec2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return vec3(md, mr);
}

static float TexturedBackgroundCircle_addStarField(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 samplePosition, float threshold)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_Uniforms* unis = static_cast<const TexturedBackgroundCircle_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 starValue = TexturedBackgroundCircle_voronoi(in, samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0f - starValue.x / threshold;
		return min(power * power * power, 0.5f);
	}
	return 0.0f;
}

void TexturedBackgroundCircle_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_Uniforms* unis = static_cast<const TexturedBackgroundCircle_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 targetCoord = vec2(2.0f) * vec2(in.u, in.v) - vec2(1.0f);
	targetCoord.x *= unis->uViewSize.x / unis->uViewSize.y;
	float distance = length(targetCoord);
	float xShift = targetCoord.x == 0.0f ? sign(targetCoord.y) * 0.5f : atan(targetCoord.y, targetCoord.x) * 0.31830988618379067153776752675f;
	vec2 texturePos = vec2(xShift * 1.0f + unis->uShift.x * 0.01f, 1.0f / distance * 1.4f + unis->uShift.y * 0.002f);
	vec4 texColor = swTexture(in, 0, texturePos);
	float horizonOpacity = 1.0f - clamp(distance * distance - 0.3f, 0.0f, 1.0f);
	vec4 horizonColorWithStars = vec4(unis->uHorizonColor.xyz(), 1.0f);
	COLOR = mix(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.a = 1.0f;
	packColor(COLOR, in.rgba);
}

		// --- TexturedBackgroundCircle_DITHER ---
struct TexturedBackgroundCircle_DITHER_Uniforms
{
	nCine::RHI::Software::sw::vec2 uViewSize;
	nCine::RHI::Software::sw::vec2 uCameraPos;
	nCine::RHI::Software::sw::vec4 uHorizonColor;
	nCine::RHI::Software::sw::vec2 uShift;
};

static nCine::RHI::Software::sw::vec2 TexturedBackgroundCircle_DITHER_hash2D(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_DITHER_Uniforms* unis = static_cast<const TexturedBackgroundCircle_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	float h = dot(p, vec2(12.9898f, 78.233f));
	float h2 = dot(p, vec2(37.271f, 377.632f));
	return -1.0f + 2.0f * vec2(fract(sin(h) * 43758.5453f), fract(sin(h2) * 43758.5453f));
}

static nCine::RHI::Software::sw::vec3 TexturedBackgroundCircle_DITHER_voronoi(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 p)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_DITHER_Uniforms* unis = static_cast<const TexturedBackgroundCircle_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec2 n = floor(p);
	vec2 f = fract(p);
	vec2 mg;
	vec2 mr;
	float md = 8.0f;
	for (int j = -1; j <= 1; ++j) {
		for (int i = -1; i <= 1; ++i) {
			vec2 g = vec2(float(i), float(j));
			vec2 o = TexturedBackgroundCircle_DITHER_hash2D(in, n + g);
			vec2 r = g + o - f;
			float d = dot(r, r);
			if (d < md) {
				md = d;
				mr = r;
				mg = g;
			}
		}
	}
	return vec3(md, mr);
}

static float TexturedBackgroundCircle_DITHER_addStarField(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 samplePosition, float threshold)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_DITHER_Uniforms* unis = static_cast<const TexturedBackgroundCircle_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec3 starValue = TexturedBackgroundCircle_DITHER_voronoi(in, samplePosition);
	if (starValue.x < threshold) {
		float power = 1.0f - starValue.x / threshold;
		return min(power * power * power, 0.5f);
	}
	return 0.0f;
}

void TexturedBackgroundCircle_DITHER_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const TexturedBackgroundCircle_DITHER_Uniforms* unis = static_cast<const TexturedBackgroundCircle_DITHER_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 targetCoord = vec2(2.0f) * vec2(in.u, in.v) - vec2(1.0f);
	targetCoord.x *= unis->uViewSize.x / unis->uViewSize.y;
	float distance = length(targetCoord);
	float xShift = targetCoord.x == 0.0f ? sign(targetCoord.y) * 0.5f : atan(targetCoord.y, targetCoord.x) * 0.31830988618379067153776752675f;
	vec2 texturePos = vec2(xShift * 1.0f + unis->uShift.x * 0.01f, 1.0f / distance * 1.4f + unis->uShift.y * 0.002f);
	vec4 texColor = swTexture(in, 0, texturePos);
	float horizonOpacity = 1.0f - clamp(distance * distance - 0.3f, 0.0f, 1.0f);
	vec4 horizonColorWithStars = vec4(unis->uHorizonColor.xyz(), 1.0f);
	COLOR = mix(texColor, horizonColorWithStars, horizonOpacity);
	COLOR.a = 1.0f;
	packColor(COLOR, in.rgba);
}

		// --- TileMapMesh ---
struct TileMapMesh_Uniforms
{
};

void TileMapMesh_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const TileMapMesh_Uniforms* unis = static_cast<const TileMapMesh_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = swTexturePrimary(in, 0) * vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	packColor(COLOR, in.rgba);
}

		// --- Tinted ---
struct Tinted_Uniforms
{
};

void Tinted_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Tinted_Uniforms* unis = static_cast<const Tinted_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 original = swTexturePrimary(in, 0);
	vec3 tinted = mix(original.rgb(), COLOR.rgb(), 0.45f);
	COLOR = vec4(tinted.r, tinted.g, tinted.b, original.a * COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- Tinted_USE_PALETTE ---
struct Tinted_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void Tinted_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	Tinted_USE_PALETTE_Uniforms* io = static_cast<Tinted_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

void Tinted_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Tinted_USE_PALETTE_Uniforms* unis = static_cast<const Tinted_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 src = swTexturePrimary(in, 0);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 original = swTexture(in, 1, vec2(palX, palY));
	original.a *= src.a;
	vec3 tinted = mix(original.rgb(), COLOR.rgb(), 0.45f);
	COLOR = vec4(tinted.r, tinted.g, tinted.b, original.a * COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- BatchedTinted ---
struct BatchedTinted_Uniforms
{
};

void BatchedTinted_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedTinted_Uniforms* unis = static_cast<const BatchedTinted_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 original = swTexturePrimary(in, 0);
	vec3 tinted = mix(original.rgb(), COLOR.rgb(), 0.45f);
	COLOR = vec4(tinted.r, tinted.g, tinted.b, original.a * COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- BatchedTinted_USE_PALETTE ---
struct BatchedTinted_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void BatchedTinted_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedTinted_USE_PALETTE_Uniforms* io = static_cast<BatchedTinted_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

void BatchedTinted_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedTinted_USE_PALETTE_Uniforms* unis = static_cast<const BatchedTinted_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 src = swTexturePrimary(in, 0);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 original = swTexture(in, 1, vec2(palX, palY));
	original.a *= src.a;
	vec3 tinted = mix(original.rgb(), COLOR.rgb(), 0.45f);
	COLOR = vec4(tinted.r, tinted.g, tinted.b, original.a * COLOR.a);
	packColor(COLOR, in.rgba);
}

		// --- Transition ---
struct Transition_Uniforms
{
	nCine::RHI::Software::sw::vec2 vCorrection;
	float vProgressTime;
};

void Transition_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	Transition_Uniforms* io = static_cast<Transition_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vCorrection = ((*reinterpret_cast<const vec2*>(instanceBlock + 96)) / vec2(max((*reinterpret_cast<const vec2*>(instanceBlock + 96)).x, (*reinterpret_cast<const vec2*>(instanceBlock + 96)).y)));
	io->vProgressTime = (*reinterpret_cast<const vec4*>(instanceBlock + 64)).a;
}

static float Transition_rand(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 xy)
{
	using namespace nCine::RHI::Software::sw;
	const Transition_Uniforms* unis = static_cast<const Transition_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	return fract(sin(dot(xy.xy(), vec2(12.9898f, 78.233f))) * 43758.5453f);
}

static float Transition_ease(const nCine::RHI::Software::FragmentShaderInput& in, float time)
{
	using namespace nCine::RHI::Software::sw;
	const Transition_Uniforms* unis = static_cast<const Transition_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	time *= 2.0f;
	if (time < 1.0f) {
		return 0.5f * time * time;
	}
	time -= 1.0f;
	return -0.5f * (time * (time - 2.0f) - 1.0f);
}

void Transition_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const Transition_Uniforms* unis = static_cast<const Transition_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	vec2 uv = (vec2(in.u, in.v) - vec2(0.5f)) * unis->vCorrection;
	float distance = length(uv);
	float progressInner = unis->vProgressTime - 0.22f;
	distance = (clamp(distance, progressInner, unis->vProgressTime) - progressInner) / (unis->vProgressTime - progressInner);
	float mixValue = Transition_ease(in, distance);
	float noise = 1.0f + Transition_rand(in, uv) * 0.1f;
	COLOR = vec4(0.0f, 0.0f, 0.0f, mixValue * noise);
	packColor(COLOR, in.rgba);
}

		// --- WhiteMask ---
struct WhiteMask_Uniforms
{
};

static nCine::RHI::Software::sw::vec4 WhiteMask_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const WhiteMask_Uniforms* unis = static_cast<const WhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	return src;
}

void WhiteMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const WhiteMask_Uniforms* unis = static_cast<const WhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = WhiteMask_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 6.0f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- WhiteMask_USE_PALETTE ---
struct WhiteMask_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void WhiteMask_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	WhiteMask_USE_PALETTE_Uniforms* io = static_cast<WhiteMask_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static nCine::RHI::Software::sw::vec4 WhiteMask_USE_PALETTE_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const WhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const WhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

void WhiteMask_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const WhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const WhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = WhiteMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 6.0f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- BatchedWhiteMask ---
struct BatchedWhiteMask_Uniforms
{
};

static nCine::RHI::Software::sw::vec4 BatchedWhiteMask_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedWhiteMask_Uniforms* unis = static_cast<const BatchedWhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	return src;
}

void BatchedWhiteMask_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedWhiteMask_Uniforms* unis = static_cast<const BatchedWhiteMask_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = BatchedWhiteMask_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 6.0f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		// --- BatchedWhiteMask_USE_PALETTE ---
struct BatchedWhiteMask_USE_PALETTE_Uniforms
{
	float vPaletteOffset;
};

void BatchedWhiteMask_USE_PALETTE_ComputeVaryings(void* inputs, const std::uint8_t* instanceBlock)
{
	using namespace nCine::RHI::Software::sw;
	BatchedWhiteMask_USE_PALETTE_Uniforms* io = static_cast<BatchedWhiteMask_USE_PALETTE_Uniforms*>(inputs);
	(void)io;
	(void)instanceBlock;
	io->vPaletteOffset = (*reinterpret_cast<const float*>(instanceBlock + 104));
}

static nCine::RHI::Software::sw::vec4 BatchedWhiteMask_USE_PALETTE_maskSample(const nCine::RHI::Software::FragmentShaderInput& in, nCine::RHI::Software::sw::vec2 uv)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedWhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedWhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 src = swTexture(in, 0, uv);
	float palIndex = floor(unis->vPaletteOffset + 0.5f) + floor(src.r * 255.0f + 0.5f);
	float palX = (mod(palIndex, 256.0f) + 0.5f) / 256.0f;
	float palY = (floor(palIndex / 256.0f) + 0.5f) / 256.0f;
	vec4 c = swTexture(in, 1, vec2(palX, palY));
	return vec4(c.rgb(), c.a * src.a);
}

void BatchedWhiteMask_USE_PALETTE_Fragment(const nCine::RHI::Software::FragmentShaderInput& in)
{
	using namespace nCine::RHI::Software::sw;
	const BatchedWhiteMask_USE_PALETTE_Uniforms* unis = static_cast<const BatchedWhiteMask_USE_PALETTE_Uniforms*>(in.userData);
	(void)unis;
	(void)in;
	vec4 COLOR;
	COLOR = vec4(in.color[0], in.color[1], in.color[2], in.color[3]);
	vec4 tex = BatchedWhiteMask_USE_PALETTE_maskSample(in, vec2(in.u, in.v));
	float color = min((0.299f * tex.r + 0.587f * tex.g + 0.114f * tex.b) * 6.0f, 1.0f);
	COLOR = vec4(color, color, color, tex.a) * COLOR;
	packColor(COLOR, in.rgba);
}

		struct SwGeneratedUniformField { const char* name; std::uint32_t offset; std::uint32_t componentCount; };
		using SwGeneratedComputeVaryingsFn = void (*)(void* inputs, const std::uint8_t* instanceBlock);
		struct SwGeneratedShaderInfo { const char* name; nCine::RHI::Software::FragmentShaderFn fragment; std::uint32_t uniformsSize; const SwGeneratedUniformField* uniformFields; std::uint32_t uniformFieldCount; SwGeneratedComputeVaryingsFn computeVaryings; };

		const SwGeneratedUniformField Blur_Fields[] = {
			{ "uPixelOffset", (std::uint32_t)offsetof(Blur_Uniforms, uPixelOffset), 2 },
			{ "uDirection", (std::uint32_t)offsetof(Blur_Uniforms, uDirection), 2 },
		};
		const SwGeneratedUniformField Combine_Fields[] = {
			{ "uAmbientColor", (std::uint32_t)offsetof(Combine_Uniforms, uAmbientColor), 4 },
			{ "uTime", (std::uint32_t)offsetof(Combine_Uniforms, uTime), 1 },
		};
		const SwGeneratedUniformField CombineWithWaterLow_Fields[] = {
			{ "uAmbientColor", (std::uint32_t)offsetof(CombineWithWaterLow_Uniforms, uAmbientColor), 4 },
			{ "uTime", (std::uint32_t)offsetof(CombineWithWaterLow_Uniforms, uTime), 1 },
			{ "uCameraPos", (std::uint32_t)offsetof(CombineWithWaterLow_Uniforms, uCameraPos), 2 },
			{ "uWaterLevel", (std::uint32_t)offsetof(CombineWithWaterLow_Uniforms, uWaterLevel), 1 },
		};
		const SwGeneratedUniformField Downsample_Fields[] = {
			{ "uPixelOffset", (std::uint32_t)offsetof(Downsample_Uniforms, uPixelOffset), 2 },
		};
		const SwGeneratedUniformField TexturedBackground_Fields[] = {
			{ "uViewSize", (std::uint32_t)offsetof(TexturedBackground_Uniforms, uViewSize), 2 },
			{ "uCameraPos", (std::uint32_t)offsetof(TexturedBackground_Uniforms, uCameraPos), 2 },
			{ "uHorizonColor", (std::uint32_t)offsetof(TexturedBackground_Uniforms, uHorizonColor), 4 },
			{ "uShift", (std::uint32_t)offsetof(TexturedBackground_Uniforms, uShift), 2 },
		};
		const SwGeneratedUniformField TexturedBackground_DITHER_Fields[] = {
			{ "uViewSize", (std::uint32_t)offsetof(TexturedBackground_DITHER_Uniforms, uViewSize), 2 },
			{ "uCameraPos", (std::uint32_t)offsetof(TexturedBackground_DITHER_Uniforms, uCameraPos), 2 },
			{ "uHorizonColor", (std::uint32_t)offsetof(TexturedBackground_DITHER_Uniforms, uHorizonColor), 4 },
			{ "uShift", (std::uint32_t)offsetof(TexturedBackground_DITHER_Uniforms, uShift), 2 },
		};
		const SwGeneratedUniformField TexturedBackgroundCircle_Fields[] = {
			{ "uViewSize", (std::uint32_t)offsetof(TexturedBackgroundCircle_Uniforms, uViewSize), 2 },
			{ "uCameraPos", (std::uint32_t)offsetof(TexturedBackgroundCircle_Uniforms, uCameraPos), 2 },
			{ "uHorizonColor", (std::uint32_t)offsetof(TexturedBackgroundCircle_Uniforms, uHorizonColor), 4 },
			{ "uShift", (std::uint32_t)offsetof(TexturedBackgroundCircle_Uniforms, uShift), 2 },
		};
		const SwGeneratedUniformField TexturedBackgroundCircle_DITHER_Fields[] = {
			{ "uViewSize", (std::uint32_t)offsetof(TexturedBackgroundCircle_DITHER_Uniforms, uViewSize), 2 },
			{ "uCameraPos", (std::uint32_t)offsetof(TexturedBackgroundCircle_DITHER_Uniforms, uCameraPos), 2 },
			{ "uHorizonColor", (std::uint32_t)offsetof(TexturedBackgroundCircle_DITHER_Uniforms, uHorizonColor), 4 },
			{ "uShift", (std::uint32_t)offsetof(TexturedBackgroundCircle_DITHER_Uniforms, uShift), 2 },
		};

		const SwGeneratedShaderInfo SwGeneratedShaders[] = {
			{ "BatchedShieldFire", &BatchedShieldFire_Fragment, (std::uint32_t)sizeof(BatchedShieldFire_Uniforms), nullptr, 0, &BatchedShieldFire_ComputeVaryings },
			{ "BatchedShieldLightning", &BatchedShieldLightning_Fragment, (std::uint32_t)sizeof(BatchedShieldLightning_Uniforms), nullptr, 0, &BatchedShieldLightning_ComputeVaryings },
			{ "Blur", &Blur_Fragment, (std::uint32_t)sizeof(Blur_Uniforms), Blur_Fields, 2, nullptr },
			{ "Colorized", &Colorized_Fragment, (std::uint32_t)sizeof(Colorized_Uniforms), nullptr, 0, nullptr },
			{ "BatchedColorized", &BatchedColorized_Fragment, (std::uint32_t)sizeof(BatchedColorized_Uniforms), nullptr, 0, nullptr },
			{ "Combine", &Combine_Fragment, (std::uint32_t)sizeof(Combine_Uniforms), Combine_Fields, 2, &Combine_ComputeVaryings },
			{ "CombineWithWaterLow", &CombineWithWaterLow_Fragment, (std::uint32_t)sizeof(CombineWithWaterLow_Uniforms), CombineWithWaterLow_Fields, 4, &CombineWithWaterLow_ComputeVaryings },
			{ "DefaultBatchedMeshSprites", &DefaultBatchedMeshSprites_Fragment, (std::uint32_t)sizeof(DefaultBatchedMeshSprites_Uniforms), nullptr, 0, nullptr },
			{ "DefaultBatchedMeshSpritesNoTexture", &DefaultBatchedMeshSpritesNoTexture_Fragment, (std::uint32_t)sizeof(DefaultBatchedMeshSpritesNoTexture_Uniforms), nullptr, 0, nullptr },
			{ "DefaultBatchedSpritesNoTexture", &DefaultBatchedSpritesNoTexture_Fragment, (std::uint32_t)sizeof(DefaultBatchedSpritesNoTexture_Uniforms), nullptr, 0, nullptr },
			{ "DefaultImGui", &DefaultImGui_Fragment, (std::uint32_t)sizeof(DefaultImGui_Uniforms), nullptr, 0, nullptr },
			{ "DefaultMeshSprite", &DefaultMeshSprite_Fragment, (std::uint32_t)sizeof(DefaultMeshSprite_Uniforms), nullptr, 0, nullptr },
			{ "DefaultMeshSpriteNoTexture", &DefaultMeshSpriteNoTexture_Fragment, (std::uint32_t)sizeof(DefaultMeshSpriteNoTexture_Uniforms), nullptr, 0, nullptr },
			{ "DefaultSprite", &DefaultSprite_Fragment, (std::uint32_t)sizeof(DefaultSprite_Uniforms), nullptr, 0, nullptr },
			{ "DefaultBatchedSprites", &DefaultBatchedSprites_Fragment, (std::uint32_t)sizeof(DefaultBatchedSprites_Uniforms), nullptr, 0, nullptr },
			{ "DefaultSpriteNoTexture", &DefaultSpriteNoTexture_Fragment, (std::uint32_t)sizeof(DefaultSpriteNoTexture_Uniforms), nullptr, 0, nullptr },
			{ "Downsample", &Downsample_Fragment, (std::uint32_t)sizeof(Downsample_Uniforms), Downsample_Fields, 1, nullptr },
			{ "FrozenMask", &FrozenMask_Fragment, (std::uint32_t)sizeof(FrozenMask_Uniforms), nullptr, 0, nullptr },
			{ "FrozenMask_USE_PALETTE", &FrozenMask_USE_PALETTE_Fragment, (std::uint32_t)sizeof(FrozenMask_USE_PALETTE_Uniforms), nullptr, 0, &FrozenMask_USE_PALETTE_ComputeVaryings },
			{ "BatchedFrozenMask", &BatchedFrozenMask_Fragment, (std::uint32_t)sizeof(BatchedFrozenMask_Uniforms), nullptr, 0, nullptr },
			{ "BatchedFrozenMask_USE_PALETTE", &BatchedFrozenMask_USE_PALETTE_Fragment, (std::uint32_t)sizeof(BatchedFrozenMask_USE_PALETTE_Uniforms), nullptr, 0, &BatchedFrozenMask_USE_PALETTE_ComputeVaryings },
			{ "Outline", &Outline_Fragment, (std::uint32_t)sizeof(Outline_Uniforms), nullptr, 0, nullptr },
			{ "BatchedOutline", &BatchedOutline_Fragment, (std::uint32_t)sizeof(BatchedOutline_Uniforms), nullptr, 0, nullptr },
			{ "OutlinePalette", &OutlinePalette_Fragment, (std::uint32_t)sizeof(OutlinePalette_Uniforms), nullptr, 0, &OutlinePalette_ComputeVaryings },
			{ "BatchedOutlinePalette", &BatchedOutlinePalette_Fragment, (std::uint32_t)sizeof(BatchedOutlinePalette_Uniforms), nullptr, 0, &BatchedOutlinePalette_ComputeVaryings },
			{ "PaletteRemap", &PaletteRemap_Fragment, (std::uint32_t)sizeof(PaletteRemap_Uniforms), nullptr, 0, &PaletteRemap_ComputeVaryings },
			{ "BatchedPaletteRemap", &BatchedPaletteRemap_Fragment, (std::uint32_t)sizeof(BatchedPaletteRemap_Uniforms), nullptr, 0, &BatchedPaletteRemap_ComputeVaryings },
			{ "PartialWhiteMask", &PartialWhiteMask_Fragment, (std::uint32_t)sizeof(PartialWhiteMask_Uniforms), nullptr, 0, nullptr },
			{ "PartialWhiteMask_USE_PALETTE", &PartialWhiteMask_USE_PALETTE_Fragment, (std::uint32_t)sizeof(PartialWhiteMask_USE_PALETTE_Uniforms), nullptr, 0, &PartialWhiteMask_USE_PALETTE_ComputeVaryings },
			{ "BatchedPartialWhiteMask", &BatchedPartialWhiteMask_Fragment, (std::uint32_t)sizeof(BatchedPartialWhiteMask_Uniforms), nullptr, 0, nullptr },
			{ "BatchedPartialWhiteMask_USE_PALETTE", &BatchedPartialWhiteMask_USE_PALETTE_Fragment, (std::uint32_t)sizeof(BatchedPartialWhiteMask_USE_PALETTE_Uniforms), nullptr, 0, &BatchedPartialWhiteMask_USE_PALETTE_ComputeVaryings },
			{ "ResizeCrtApertureGrille", &ResizeCrtApertureGrille_Fragment, (std::uint32_t)sizeof(ResizeCrtApertureGrille_Uniforms), nullptr, 0, &ResizeCrtApertureGrille_ComputeVaryings },
			{ "ResizeCrtShadowMask", &ResizeCrtShadowMask_Fragment, (std::uint32_t)sizeof(ResizeCrtShadowMask_Uniforms), nullptr, 0, &ResizeCrtShadowMask_ComputeVaryings },
			{ "ShieldFire", &ShieldFire_Fragment, (std::uint32_t)sizeof(ShieldFire_Uniforms), nullptr, 0, &ShieldFire_ComputeVaryings },
			{ "ShieldLightning", &ShieldLightning_Fragment, (std::uint32_t)sizeof(ShieldLightning_Uniforms), nullptr, 0, &ShieldLightning_ComputeVaryings },
			{ "TexturedBackground", &TexturedBackground_Fragment, (std::uint32_t)sizeof(TexturedBackground_Uniforms), TexturedBackground_Fields, 4, nullptr },
			{ "TexturedBackground_DITHER", &TexturedBackground_DITHER_Fragment, (std::uint32_t)sizeof(TexturedBackground_DITHER_Uniforms), TexturedBackground_DITHER_Fields, 4, nullptr },
			{ "TexturedBackgroundCircle", &TexturedBackgroundCircle_Fragment, (std::uint32_t)sizeof(TexturedBackgroundCircle_Uniforms), TexturedBackgroundCircle_Fields, 4, nullptr },
			{ "TexturedBackgroundCircle_DITHER", &TexturedBackgroundCircle_DITHER_Fragment, (std::uint32_t)sizeof(TexturedBackgroundCircle_DITHER_Uniforms), TexturedBackgroundCircle_DITHER_Fields, 4, nullptr },
			{ "TileMapMesh", &TileMapMesh_Fragment, (std::uint32_t)sizeof(TileMapMesh_Uniforms), nullptr, 0, nullptr },
			{ "Tinted", &Tinted_Fragment, (std::uint32_t)sizeof(Tinted_Uniforms), nullptr, 0, nullptr },
			{ "Tinted_USE_PALETTE", &Tinted_USE_PALETTE_Fragment, (std::uint32_t)sizeof(Tinted_USE_PALETTE_Uniforms), nullptr, 0, &Tinted_USE_PALETTE_ComputeVaryings },
			{ "BatchedTinted", &BatchedTinted_Fragment, (std::uint32_t)sizeof(BatchedTinted_Uniforms), nullptr, 0, nullptr },
			{ "BatchedTinted_USE_PALETTE", &BatchedTinted_USE_PALETTE_Fragment, (std::uint32_t)sizeof(BatchedTinted_USE_PALETTE_Uniforms), nullptr, 0, &BatchedTinted_USE_PALETTE_ComputeVaryings },
			{ "Transition", &Transition_Fragment, (std::uint32_t)sizeof(Transition_Uniforms), nullptr, 0, &Transition_ComputeVaryings },
			{ "WhiteMask", &WhiteMask_Fragment, (std::uint32_t)sizeof(WhiteMask_Uniforms), nullptr, 0, nullptr },
			{ "WhiteMask_USE_PALETTE", &WhiteMask_USE_PALETTE_Fragment, (std::uint32_t)sizeof(WhiteMask_USE_PALETTE_Uniforms), nullptr, 0, &WhiteMask_USE_PALETTE_ComputeVaryings },
			{ "BatchedWhiteMask", &BatchedWhiteMask_Fragment, (std::uint32_t)sizeof(BatchedWhiteMask_Uniforms), nullptr, 0, nullptr },
			{ "BatchedWhiteMask_USE_PALETTE", &BatchedWhiteMask_USE_PALETTE_Fragment, (std::uint32_t)sizeof(BatchedWhiteMask_USE_PALETTE_Uniforms), nullptr, 0, &BatchedWhiteMask_USE_PALETTE_ComputeVaryings },
		};

		const SwGeneratedShaderInfo* FindGeneratedShader(const char* name)
		{
			if (name == nullptr) {
				return nullptr;
			}
			// Exact match first: for most programs the runtime object label (the shader name the
			// content pipeline registers) equals the generated prefix verbatim.
			for (const SwGeneratedShaderInfo& info : SwGeneratedShaders) {
				if (std::strcmp(info.name, name) == 0) {
					return &info;
				}
			}
			// Otherwise match ignoring '_' and letter case, so a variant label that bakes the variant
			// into the shader name (e.g. "TexturedBackgroundDither") still resolves to the generated
			// prefix that separates it with an underscore and upper-cases the define ("..._DITHER").
			// A "use" token is also skipped on both sides so a "USE_PALETTE" define matches a runtime
			// label that spells the same variant as "...Palette" (the engine drops the "USE_" prefix).
			for (const SwGeneratedShaderInfo& info : SwGeneratedShaders) {
				const char* a = info.name;
				const char* b = name;
				bool equal = true;
				for (;;) {
					while (*a == '_') { a++; }
					while (*b == '_') { b++; }
					if ((a[0] == 'u' || a[0] == 'U') && (a[1] == 's' || a[1] == 'S') && (a[2] == 'e' || a[2] == 'E')) { a += 3; continue; }
					if ((b[0] == 'u' || b[0] == 'U') && (b[1] == 's' || b[1] == 'S') && (b[2] == 'e' || b[2] == 'E')) { b += 3; continue; }
					char ca = (*a >= 'A' && *a <= 'Z') ? (char)(*a - 'A' + 'a') : *a;
					char cb = (*b >= 'A' && *b <= 'Z') ? (char)(*b - 'A' + 'a') : *b;
					if (ca != cb) { equal = false; break; }
					if (ca == '\0') { break; }
					a++; b++;
				}
				if (equal) {
					return &info;
				}
			}
			return nullptr;
		}
	}
}

#endif
