// Generated by ShaderCompiler from DefaultBatchedMeshSprites.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 nCine::ShadersGen
{
#if defined(WITH_RHI_GL) && !defined(RHI_GL_PROFILE_ES2)
	inline constexpr char DefaultBatchedMeshSprites_Vs[] =
R"__SHDR__(#line 1

in vec2 aPosition;
in vec2 aTexCoords;
in uint aMeshIndex;

out vec2 vTexCoords;
out vec4 vColor;

uniform mat4 uProjectionMatrix;
uniform mat4 uViewMatrix;

struct Instance
{
	mat4 modelMatrix;
	vec4 color;
	vec4 texRect;
	vec2 spriteSize;
};

layout (std140) uniform InstancesBlock
{
#ifndef BATCH_SIZE
	#define BATCH_SIZE (585) // 64 Kb / 112 b
#endif
	Instance[BATCH_SIZE] instances;
} block;


#define i block.instances[aMeshIndex]



void main()
{
	vec4 position = vec4(aPosition.x * i.spriteSize.x, aPosition.y * i.spriteSize.y, 0.0, 1.0);

	gl_Position = uProjectionMatrix * uViewMatrix * i.modelMatrix * position;
	vTexCoords = vec2(aTexCoords.x * i.texRect.x + i.texRect.y, aTexCoords.y * i.texRect.z + i.texRect.w);
	vColor = i.color;
}
)__SHDR__";
#endif

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

attribute vec2 aPosition;
attribute vec2 aTexCoords;
attribute float aMeshIndex;

varying vec2 vTexCoords;
varying vec4 vColor;

uniform mat4 uProjectionMatrix;
uniform mat4 uViewMatrix;

struct Instance
{
	mat4 modelMatrix;
	vec4 color;
	vec4 texRect;
	vec2 spriteSize;
};

#ifndef BATCH_SIZE
	#define BATCH_SIZE (585) // 64 Kb / 112 b
#endif
	uniform Instance instances[BATCH_SIZE];


#define i instances[int(aMeshIndex)]



void main()
{
	vec4 position = vec4(aPosition.x * i.spriteSize.x, aPosition.y * i.spriteSize.y, 0.0, 1.0);

	gl_Position = uProjectionMatrix * uViewMatrix * i.modelMatrix * position;
	vTexCoords = vec2(aTexCoords.x * i.texRect.x + i.texRect.y, aTexCoords.y * i.texRect.z + i.texRect.w);
	vColor = i.color;
}
)__SHDR__";
#endif

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

#ifdef GL_ES
precision mediump float;
#endif

in vec2 vTexCoords;
in vec4 vColor;

uniform sampler2D uTexture;

out vec4 COLOR;

void main() {
	COLOR = texture(uTexture, vTexCoords) * vColor;
}

)__SHDR__";
#endif

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

precision mediump float;

varying vec2 vTexCoords;
varying vec4 vColor;

uniform sampler2D uTexture;


void main() {
	vec4 COLOR;
	COLOR = texture2D(uTexture, vTexCoords) * vColor;
	gl_FragColor = COLOR;
}

)__SHDR__";
#endif

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

	inline constexpr ShaderCompiler::BlockMember DefaultBatchedMeshSprites_Block0_Members[] = {
		{ "instances", ShaderCompiler::UniformType::Struct, ShaderCompiler::SymbolicArraySize, 0 },
	};

	inline constexpr ShaderCompiler::UniformBlock DefaultBatchedMeshSprites_Blocks[] = {
		{ "InstancesBlock", 0, 112, 1, DefaultBatchedMeshSprites_Block0_Members },
	};

	inline constexpr ShaderCompiler::TextureBinding DefaultBatchedMeshSprites_Textures[] = {
		{ "uTexture", 0 },
	};

	inline constexpr ShaderCompiler::Attribute DefaultBatchedMeshSprites_Attributes[] = {
		{ "aPosition", ShaderCompiler::UniformType::Vec2, -1 },
		{ "aTexCoords", ShaderCompiler::UniformType::Vec2, -1 },
		{ "aMeshIndex", ShaderCompiler::UniformType::UInt, -1 },
	};

	inline constexpr ShaderCompiler::ProgramVariant DefaultBatchedMeshSprites_Variants[] = {
		{ "", "",
#if defined(WITH_RHI_GL) && !defined(RHI_GL_PROFILE_ES2)
			DefaultBatchedMeshSprites_Vs, DefaultBatchedMeshSprites_Fs,
#else
			nullptr, nullptr,
#endif
			2, DefaultBatchedMeshSprites_Uniforms, 1, DefaultBatchedMeshSprites_Blocks, 1, DefaultBatchedMeshSprites_Textures, 3, DefaultBatchedMeshSprites_Attributes,
#if defined(WITH_RHI_GL) && defined(RHI_GL_PROFILE_ES2)
			DefaultBatchedMeshSprites_Vs100, DefaultBatchedMeshSprites_Fs100,
#else
			nullptr, nullptr,
#endif
#if defined(WITH_RHI_D3D11)
			DefaultBatchedMeshSprites_VsHlsl, DefaultBatchedMeshSprites_FsHlsl,
			DefaultBatchedMeshSprites_VsDxbc, DefaultBatchedMeshSprites_VsDxbcSize, DefaultBatchedMeshSprites_FsDxbc, DefaultBatchedMeshSprites_FsDxbcSize,
#else
			nullptr, nullptr,
			nullptr, 0, nullptr, 0,
#endif
#if defined(WITH_RHI_VULKAN)
			DefaultBatchedMeshSprites_VkVs, DefaultBatchedMeshSprites_VkVsSize, DefaultBatchedMeshSprites_VkFs, DefaultBatchedMeshSprites_VkFsSize },
#else
			nullptr, 0, nullptr, 0 },
#endif
	};

	inline constexpr ShaderCompiler::Program DefaultBatchedMeshSprites = { "DefaultBatchedMeshSprites", 0, 1, DefaultBatchedMeshSprites_Variants };
}
#endif
