diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h
index c323fa06..596e37f2 100644
--- a/include/Engine/Rendering/SpriteJob.h
+++ b/include/Engine/Rendering/SpriteJob.h
@@ -48,6 +48,13 @@ struct SpriteJob : RenderJob
FillColor = fillColor;
FillPercentage = fillPercentage;
+
+ if((bool)cSprite["KeepRatioX"] == true) {
+ ScaleX = Transform::AbsoluteScale(world, cSprite.EntityID).x;
+ }
+ if ((bool)cSprite["KeepRatioZ"] == true) {
+ ScaleY = Transform::AbsoluteScale(world, cSprite.EntityID).y;
+ }
};
unsigned int TextureID;
@@ -69,6 +76,8 @@ struct SpriteJob : RenderJob
bool Pickable;
bool IsIndicator = false;
bool BlurBackground = false;
+ float ScaleX = 1;
+ float ScaleY = 1;
glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0;
diff --git a/resources/Schema/Components/Sprite.xml b/resources/Schema/Components/Sprite.xml
index e577ac96..19cd1313 100644
--- a/resources/Schema/Components/Sprite.xml
+++ b/resources/Schema/Components/Sprite.xml
@@ -5,5 +5,7 @@
true
true
+ false
+ false
false
diff --git a/resources/Schema/Components/Sprite.xsd b/resources/Schema/Components/Sprite.xsd
index e26d71c9..e727040c 100644
--- a/resources/Schema/Components/Sprite.xsd
+++ b/resources/Schema/Components/Sprite.xsd
@@ -24,6 +24,12 @@
Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD
+
+ Wether the sprite should repeat in x instead of stretch when scaled.
+
+
+ Wether the sprite should repeat in y instead of stretch when scaled.
+
Wether the background should be blurred begind this sprite.
diff --git a/resources/Shaders/Sprite.frag.glsl b/resources/Shaders/Sprite.frag.glsl
index abad7df1..5b6567eb 100644
--- a/resources/Shaders/Sprite.frag.glsl
+++ b/resources/Shaders/Sprite.frag.glsl
@@ -3,6 +3,8 @@
uniform vec4 Color;
uniform vec4 FillColor;
uniform float FillPercentage;
+uniform float ScaleX;
+uniform float ScaleY;
uniform mat4 P;
layout (binding = 1) uniform sampler2D DiffuseTexture;
@@ -21,15 +23,16 @@ out vec4 bloomColor;
void main()
{
- vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
- vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
+ vec4 diffuseTexel = texture2D(DiffuseTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
+ vec4 glowTexel = texture2D(GlowMapTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
vec4 color_result = Color * diffuseTexel;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
- if(pos <= FillPercentage) {
- color_result = FillColor*diffuseTexel.a;
- }
+ float fillResult = floor(pos*FillPercentage);
+
+ color_result = FillColor*diffuseTexel.a*fillResult + color_result*(1-fillResult);
+
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0);
diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp
index 81afd852..62ce846d 100644
--- a/src/Engine/Rendering/DrawFinalPass.cpp
+++ b/src/Engine/Rendering/DrawFinalPass.cpp
@@ -1284,6 +1284,8 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
+ glUniform1f(glGetUniformLocation(shaderHandle, "ScaleX"), spriteJob->ScaleX);
+ glUniform1f(glGetUniformLocation(shaderHandle, "ScaleY"), spriteJob->ScaleY);
glActiveTexture(GL_TEXTURE1);
if (spriteJob->DiffuseTexture != nullptr) {
diff --git a/src/Engine/Rendering/TextureSprite.cpp b/src/Engine/Rendering/TextureSprite.cpp
index 178aebf0..2a43e455 100644
--- a/src/Engine/Rendering/TextureSprite.cpp
+++ b/src/Engine/Rendering/TextureSprite.cpp
@@ -3,8 +3,8 @@
TextureSprite::TextureSprite(std::string path)
:Texture(path)
{
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
GLERROR("Texture load");