summaryrefslogtreecommitdiff
path: root/demo/SpatialShader.lua
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-03-01 22:49:53 -0600
committersanine <sanine.not@pm.me>2022-03-01 22:49:53 -0600
commit82cf18b9163f86e4d0a1cd999d4815cc3f85a3fd (patch)
tree1bc96ae80f509ef919bb7e74500dc6b37c9e59cf /demo/SpatialShader.lua
parent10288765588673645c1cc0a6e3d2245aff3f9080 (diff)
clear out demo/
Diffstat (limited to 'demo/SpatialShader.lua')
-rw-r--r--demo/SpatialShader.lua100
1 files changed, 0 insertions, 100 deletions
diff --git a/demo/SpatialShader.lua b/demo/SpatialShader.lua
deleted file mode 100644
index 68760ef..0000000
--- a/demo/SpatialShader.lua
+++ /dev/null
@@ -1,100 +0,0 @@
-local VertexCode = [[
-#version 330 core
-
-layout(location = 0) in vec3 position;
-layout(location = 1) in vec3 normal;
-layout(location = 4) in vec2 uv;
-
-uniform mat4 model;
-uniform mat4 view;
-uniform mat4 projection;
-
-out vec3 Position;
-out vec3 Normal;
-out vec2 UV;
-
-void main()
-{
- gl_Position = projection * view * model * vec4(position.xyz, 1);
- Position = gl_Position.xyz;
- Normal = normal;
- UV = uv;
-} ]]
-
-local FragmentCode = [[
-#version 330 core
-
-in vec3 Position;
-in vec3 Normal;
-in vec2 UV;
-
-uniform sampler2D albedo;
-
-out vec4 color;
-
-void main()
-{
- color = texture(albedo, UV);
-} ]]
-
-local SpatialShader = {}
-
-SpatialShader.prototype = {}
-
-SpatialShader.prototype.use = function(self)
- self.shader:use()
-end
-
-SpatialShader.prototype.setInteger = function(self, name, value)
- self.shader:setInteger(name, value)
-end
-
-SpatialShader.prototype.setFloat = function(self, name, value)
- self.shader:setFloat(name, value)
-end
-
-SpatialShader.prototype.setVec3 = function(self, name, value)
- self.shader:setVec3(name, value)
-end
-
-SpatialShader.prototype.setVec4 = function(self, name, value)
- self.shader:setVec4(name, value)
-end
-
-SpatialShader.prototype.setMat3 = function(self, name, value)
- self.shader:setMat3(name, value)
-end
-
-SpatialShader.prototype.setMat4 = function(self, name, value)
- self.shader:setMat4(name, value)
-end
-
-SpatialShader.prototype.setCamera = function(self, camera)
- self.shader:setMat4('view', camera.view)
- self.shader:setMat4('projection', camera.projection)
-end
-
-SpatialShader.prototype.drawMesh = function(self, meshInstance)
- self.shader:setMat4('model', meshInstance.transform)
- self.albedo:use(0)
- meshInstance.mesh:draw(self.shader)
-end
-
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-SpatialShader.mt = {}
-SpatialShader.mt.__index = SpatialShader.prototype
-
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-SpatialShader.new = function(albedo)
- local spatialshader = {}
- spatialshader.shader = honey.shader(VertexCode, FragmentCode)
- spatialshader.albedo = albedo
-
- setmetatable(spatialshader, SpatialShader.mt)
-
- return spatialshader
-end
-
-return SpatialShader