From 4b24de9ef863f54eb09a5fa1f18e2905cedcc439 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 31 Oct 2021 17:13:50 +0800 Subject: + shader command --- Data/Scripts/Editor/AssetBrowser.lua | 48 +++--------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) (limited to 'Data/Scripts') diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua index 5f00dc1..7c73ec3 100644 --- a/Data/Scripts/Editor/AssetBrowser.lua +++ b/Data/Scripts/Editor/AssetBrowser.lua @@ -3,6 +3,8 @@ local AssetBrowser = GameLab.Editor.GUI.EditorWindow.Extend("GameLab.Editor.Asse local GL = GameLab.Engine.GL local Matrix44 = GameLab.Engine.Math.Matrix44 local Engine = GameLab.Engine +local IO = GameLab.IO + local inspect = require("inspect") AssetBrowser.Ctor = function(self) @@ -10,49 +12,6 @@ AssetBrowser.Ctor = function(self) end local shader = nil - -local glsl = [[ - -#version 330 core - -VSH_BEGIN - -layout (location = 0) in vec2 vPos; -layout (location = 1) in vec2 vUV; - -uniform mat4 mvp; - -out vec2 uv; - -void main() -{ - vec4 clip = mvp * vec4(vPos, -1, 1.0); - gl_Position = clip; - uv = vUV; -} - -VSH_END - -FSH_BEGIN -uniform sampler2D uiTex; - -in vec2 uv; - -out vec4 FragColor; - -void main() -{ - vec2 uv = vec2(uv.x, 1 - uv.y); - vec4 sampled = vec4(1,1,1,texture(uiTex, uv).r); - FragColor = sampled; -// FragColor = texture(uiTex, uv); -// FragColor.rgb = vec3(1,0,0); -// FragColor.a = 1; -} -FSH_END - -]] - local tex AssetBrowser.OnGUI = function(self) @@ -63,6 +22,7 @@ AssetBrowser.OnGUI = function(self) end if shader == nil then + local glsl = IO.ReadFile("./Resources/Shaders/Editor-Text.glsl", IO.EFileMode.Text) shader = Engine.Rendering.Shader.New(glsl) end @@ -81,7 +41,7 @@ AssetBrowser.OnGUI = function(self) -- GL.End() Engine.Rendering.UseShader(shader) - Engine.Rendering.SetMatrix44("mvp", ortho) + Engine.Rendering.SetMatrix44("gamelab_mat_mvp", ortho) Engine.Rendering.SetTexture("uiTex", tex) Engine.Rendering.DrawUIQuad({10, 30, 300, 300}) -- cgit v1.1-26-g67d0