diff options
author | chai <chaifix@163.com> | 2019-02-26 08:48:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-02-26 08:48:54 +0800 |
commit | 3f457498b9c39d40a16a0ec6328880854f8cf4de (patch) | |
tree | 061ef9974b4da4c472909a65e6ebd10e8156c1b3 /Source/Asura.Framework/scripts/graphics | |
parent | 684f71790401727cc45f4dad1822ddae46305072 (diff) |
*misc
Diffstat (limited to 'Source/Asura.Framework/scripts/graphics')
-rw-r--r-- | Source/Asura.Framework/scripts/graphics/material.lua | 1 | ||||
-rw-r--r-- | Source/Asura.Framework/scripts/graphics/shader.lua | 24 | ||||
-rw-r--r-- | Source/Asura.Framework/scripts/graphics/shaderHelper.lua | 14 |
3 files changed, 37 insertions, 2 deletions
diff --git a/Source/Asura.Framework/scripts/graphics/material.lua b/Source/Asura.Framework/scripts/graphics/material.lua index e985b3c..64d70f7 100644 --- a/Source/Asura.Framework/scripts/graphics/material.lua +++ b/Source/Asura.Framework/scripts/graphics/material.lua @@ -5,6 +5,7 @@ local Material = AsuraEngine.Material function Material.Ctor(self) self.uniforms = {} --uniform变量和值 + self.shader = nil self.isShared = false end diff --git a/Source/Asura.Framework/scripts/graphics/shader.lua b/Source/Asura.Framework/scripts/graphics/shader.lua index 728ab34..86ed8bb 100644 --- a/Source/Asura.Framework/scripts/graphics/shader.lua +++ b/Source/Asura.Framework/scripts/graphics/shader.lua @@ -1,10 +1,30 @@ AsuraEngine.Shader = AsuraEngine.Asset.Sub("Shader") +local helper = AsuraEngine.Framework.Require("graphics/shaderHelper") + local Shader = AsuraEngine.Shader -function Shader.Ctor(self, vert, frag) +function Shader.Ctor(self) + self.simShader = nil + self.uniforms = {} -- 映射uniform name到location +end + +--编译shader +function Shader.Load(self, vert, frag) + self.uniforms = {} self.simShader = AsuraEngine.SimShader.New(vert, frag) - self.uniforms = {} -- 映射uniform name到location + if self.simShader == nil then + --shader编译错误 + return + end + --在编译的时候就获得所有的uniform和loc + local uniforms = helper.GetUniforms(vert, frag) + if uniforms == nil then + return + end + for _, uniform in uniforms do + self.uniforms[uniform] = self.simShader:GetUniformLocation(uniform) + end end function Shader.GetUniformLocation(self, name) diff --git a/Source/Asura.Framework/scripts/graphics/shaderHelper.lua b/Source/Asura.Framework/scripts/graphics/shaderHelper.lua new file mode 100644 index 0000000..b1b42a6 --- /dev/null +++ b/Source/Asura.Framework/scripts/graphics/shaderHelper.lua @@ -0,0 +1,14 @@ +--[[ +解析vertex shader和 fragment shader,并取得两个shader里面定义的uniforms +]] +local helper = {} + +function helper.GetUniforms(vert, frag) + +end + +function helper.TryCompileShader(vert, frag) + +end + +return helper
\ No newline at end of file |