From ec0ab456cf869f2daa6dea41158c54da745626d8 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Wed, 18 Sep 2019 12:07:48 -0400 Subject: Added basic UI shaders --- Scripts/init.lua | 8 ++++---- Shaders/ui.frag | 12 ++++++++++++ Shaders/ui.vert | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 Shaders/ui.frag create mode 100644 Shaders/ui.vert diff --git a/Scripts/init.lua b/Scripts/init.lua index 84d2073..d76a402 100644 --- a/Scripts/init.lua +++ b/Scripts/init.lua @@ -2,18 +2,18 @@ player = { Player = 0, EventListeners = { MoveLeftPressed = function(self) - self.Velocity.x = self.Velocity.x - 3 + self.Velocity.x = self.Velocity.x - 3.0 self.Render.flipx = true; end, MoveLeftReleased = function(self) - self.Velocity.x = self.Velocity.x + 3 + self.Velocity.x = self.Velocity.x + 3.0 end, MoveRightPressed = function(self) - self.Velocity.x = self.Velocity.x + 3 + self.Velocity.x = self.Velocity.x + 3.0 self.Render.flipx = false; end, MoveRightReleased = function(self) - self.Velocity.x = self.Velocity.x - 3 + self.Velocity.x = self.Velocity.x - 3.0 end, JumpKeyPressed = function(self) if self.Physics.standing == true then diff --git a/Shaders/ui.frag b/Shaders/ui.frag new file mode 100644 index 0000000..737344e --- /dev/null +++ b/Shaders/ui.frag @@ -0,0 +1,12 @@ +uniform sampler2D sampler; + +varying vec2 texCoord; +varying vec4 color; + +void main(){ + vec4 pixelColor = texture2D(sampler, vec2(texCoord.x, texCoord.y)); + //TODO allow antialiasing + //if (pixelColor.w != 1.0f) + // discard; + gl_FragColor = pixelColor * color; +} diff --git a/Shaders/ui.vert b/Shaders/ui.vert new file mode 100644 index 0000000..b2fcba4 --- /dev/null +++ b/Shaders/ui.vert @@ -0,0 +1,14 @@ +attribute vec3 coord2d; +attribute vec2 tex_coord; + +uniform mat4 ortho; +uniform vec4 tex_color; + +varying vec2 texCoord; +varying vec4 color; + +void main(){ + texCoord = tex_coord; + color = tex_color; + gl_Position = ortho * vec4(coord2d.xyz, 1.0); +} -- cgit v1.2.3