// Generated by ShaderCompiler from TouchCircle.shader. Do not edit manually.
#pragma once

#include "ShaderCompilerTypes.h"
#if defined(WITH_RHI_D3D11)
#	include "D3d11GeneratedShaders.h"
#endif
#if defined(WITH_RHI_VULKAN)
#	include "VulkanGeneratedShaders.h"
#endif

#ifndef DOXYGEN_GENERATING_OUTPUT
namespace Jazz2::ShadersGen
{
#if defined(WITH_RHI_GL) && !defined(RHI_GL_PROFILE_ES2)
	inline constexpr char TouchCircle_Vs[] =
R"__SHDR__(#line 1

out vec2 vPos;

// Keeps InstanceBlock at one precision across both stages, see TileMapMeshPalette

// The InstanceBlock is deliberately shared by both stages - the fragment stage reads color/texRect directly
layout (std140) uniform InstanceBlock
{
	mat4 modelMatrix;
	vec4 color;
	vec4 texRect;
	vec2 spriteSize;
};

uniform mat4 uProjectionMatrix;
uniform mat4 uViewMatrix;

void main()
{
	vec2 aPosition = vec2(float(gl_VertexID >> 1), float(gl_VertexID % 2));
	vec4 position = vec4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = uProjectionMatrix * uViewMatrix * modelMatrix * position;
	vPos = aPosition - vec2(0.5, 0.5);
}
)__SHDR__";
#endif

#if defined(WITH_RHI_GL) && defined(RHI_GL_PROFILE_ES2)
	inline constexpr char TouchCircle_Vs100[] =
R"__SHDR__(attribute vec2 aQuadCorner;
#line 1

varying vec2 vPos;

// Keeps InstanceBlock at one precision across both stages, see TileMapMeshPalette

// The InstanceBlock is deliberately shared by both stages - the fragment stage reads color/texRect directly
	uniform mat4 modelMatrix;
	uniform vec4 color;
	uniform vec4 texRect;
	uniform vec2 spriteSize;

uniform mat4 uProjectionMatrix;
uniform mat4 uViewMatrix;

void main()
{
	vec2 aPosition = vec2((1.0 - aQuadCorner.x), aQuadCorner.y);
	vec4 position = vec4(aPosition.x * spriteSize.x, aPosition.y * spriteSize.y, 0.0, 1.0);
	gl_Position = uProjectionMatrix * uViewMatrix * modelMatrix * position;
	vPos = aPosition - vec2(0.5, 0.5);
}
)__SHDR__";
#endif

#if defined(WITH_RHI_GL) && !defined(RHI_GL_PROFILE_ES2)
	inline constexpr char TouchCircle_Fs[] =
R"__SHDR__(#line 1

#ifdef GL_ES
#	ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#	else
precision mediump float;
#	endif
#endif

in vec2 vPos;

// Keeps InstanceBlock at one precision across both stages, see TileMapMeshPalette

// The InstanceBlock is deliberately shared by both stages - the fragment stage reads color/texRect directly
layout (std140) uniform InstanceBlock
{
	mat4 modelMatrix;
	vec4 color;
	vec4 texRect;
	vec2 spriteSize;
};

out vec4 COLOR;

void main() {
	float dist = length(vPos);
	float softness = texRect.y;
	float outerAlpha = 1.0 - smoothstep(0.5 - softness, 0.5, dist);
	float innerRadius = texRect.x * 0.5;
	float innerAlpha = (innerRadius > 0.0) ? smoothstep(innerRadius - softness, innerRadius, dist) : 1.0;
	COLOR = vec4(color.rgb, color.a * outerAlpha * innerAlpha);
}

)__SHDR__";
#endif

#if defined(WITH_RHI_GL) && defined(RHI_GL_PROFILE_ES2)
	inline constexpr char TouchCircle_Fs100[] =
R"__SHDR__(#line 1

#	ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#	else
precision mediump float;
#	endif

varying vec2 vPos;

// Keeps InstanceBlock at one precision across both stages, see TileMapMeshPalette

// The InstanceBlock is deliberately shared by both stages - the fragment stage reads color/texRect directly
	uniform mat4 modelMatrix;
	uniform vec4 color;
	uniform vec4 texRect;
	uniform vec2 spriteSize;


void main() {
	vec4 COLOR;
	float dist = length(vPos);
	float softness = texRect.y;
	float outerAlpha = 1.0 - smoothstep(0.5 - softness, 0.5, dist);
	float innerRadius = texRect.x * 0.5;
	float innerAlpha = (innerRadius > 0.0) ? smoothstep(innerRadius - softness, innerRadius, dist) : 1.0;
	COLOR = vec4(color.rgb, color.a * outerAlpha * innerAlpha);
	gl_FragColor = COLOR;
}

)__SHDR__";
#endif

	inline constexpr ShaderCompiler::Uniform TouchCircle_Uniforms[] = {
		{ "uProjectionMatrix", ShaderCompiler::UniformType::Mat4, 0 },
		{ "uViewMatrix", ShaderCompiler::UniformType::Mat4, 0 },
	};

	inline constexpr ShaderCompiler::BlockMember TouchCircle_Block0_Members[] = {
		{ "modelMatrix", ShaderCompiler::UniformType::Mat4, 0, 0 },
		{ "color", ShaderCompiler::UniformType::Vec4, 0, 64 },
		{ "texRect", ShaderCompiler::UniformType::Vec4, 0, 80 },
		{ "spriteSize", ShaderCompiler::UniformType::Vec2, 0, 96 },
	};

	inline constexpr ShaderCompiler::UniformBlock TouchCircle_Blocks[] = {
		{ "InstanceBlock", 112, 0, 4, TouchCircle_Block0_Members },
	};

	inline constexpr ShaderCompiler::ProgramVariant TouchCircle_Variants[] = {
		{ "", "",
#if defined(WITH_RHI_GL) && !defined(RHI_GL_PROFILE_ES2)
			TouchCircle_Vs, TouchCircle_Fs,
#else
			nullptr, nullptr,
#endif
			2, TouchCircle_Uniforms, 1, TouchCircle_Blocks, 0, nullptr, 0, nullptr,
#if defined(WITH_RHI_GL) && defined(RHI_GL_PROFILE_ES2)
			TouchCircle_Vs100, TouchCircle_Fs100,
#else
			nullptr, nullptr,
#endif
#if defined(WITH_RHI_D3D11)
			TouchCircle_VsHlsl, TouchCircle_FsHlsl,
			TouchCircle_VsDxbc, TouchCircle_VsDxbcSize, TouchCircle_FsDxbc, TouchCircle_FsDxbcSize,
#else
			nullptr, nullptr,
			nullptr, 0, nullptr, 0,
#endif
#if defined(WITH_RHI_VULKAN)
			TouchCircle_VkVs, TouchCircle_VkVsSize, TouchCircle_VkFs, TouchCircle_VkFsSize },
#else
			nullptr, 0, nullptr, 0 },
#endif
	};

	inline constexpr ShaderCompiler::Program TouchCircle = { "TouchCircle", 0, 1, TouchCircle_Variants };
}
#endif
