diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-08 07:48:50 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-08 07:48:50 +0100 |
commit | 430def68f4e38c9165c92e5de0f9e31c5b748c36 (patch) | |
tree | d0da5570dd2689e6ff170369e7a26b944270629a /shaders | |
parent | 2cb3ba50b896fef785102b212fb172c3f7a45c28 (diff) |
precompute the scale shader uniform
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/tile.cpp | 2 | ||||
-rw-r--r-- | shaders/tile.vert | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/shaders/tile.cpp b/shaders/tile.cpp index 4fb7fe1b..2fb37cd8 100644 --- a/shaders/tile.cpp +++ b/shaders/tile.cpp @@ -37,7 +37,7 @@ tile_shader::~tile_shader() = default; tile_shader& tile_shader::set_scale(const Vector2& scale) { if (scale != _scale) - setUniform(ScaleUniform, _scale = scale); + setUniform(ScaleUniform, 1.f/(_scale = scale)); return *this; } diff --git a/shaders/tile.vert b/shaders/tile.vert index 8b3f2dba..b512b7ac 100644 --- a/shaders/tile.vert +++ b/shaders/tile.vert @@ -8,8 +8,7 @@ layout (location = 1) in vec2 texcoords; noperspective out vec2 frag_texcoords; void main() { - float cx = 1/scale.x, cy = 1/scale.y; float x = -position.y, y = -position.x, z = position.z; - gl_Position = vec4((x-y+offset.x)*cx, (x+y+z*2)*cy*.59-offset.y*cy, 0, 1); + gl_Position = vec4((x-y+offset.x)*scale.x, ((x+y+z*2)*.59-offset.y)*scale.y, 0, 1); frag_texcoords = texcoords; } |