From 430def68f4e38c9165c92e5de0f9e31c5b748c36 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 8 Nov 2022 07:48:50 +0100 Subject: precompute the scale shader uniform --- shaders/tile.cpp | 2 +- shaders/tile.vert | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'shaders') 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; } -- cgit v1.2.3