diff --git a/FModel/Resources/default.vert b/FModel/Resources/default.vert index 9d2aeded..b3c922e9 100644 --- a/FModel/Resources/default.vert +++ b/FModel/Resources/default.vert @@ -8,11 +8,8 @@ layout (location = 5) in ivec4 vBoneIds; layout (location = 6) in vec4 vWeights; layout (location = 7) in mat4 vInstanceMatrix; -layout (location = 11) in vec3 vPosTarget; - uniform mat4 uView; uniform mat4 uProjection; -uniform float morph_time; out vec3 fPos; out vec3 fNormal; @@ -21,10 +18,9 @@ out vec4 fColor; void main() { - vec3 pos = mix(vPos, vPosTarget, morph_time); - gl_Position = uProjection * uView * vInstanceMatrix * vec4(pos, 1.0); + gl_Position = uProjection * uView * vInstanceMatrix * vec4(vPos, 1.0); - fPos = vec3(vInstanceMatrix * vec4(pos, 1.0)); + fPos = vec3(vInstanceMatrix * vec4(vPos, 1.0)); fNormal = mat3(transpose(inverse(vInstanceMatrix))) * vNormal; fTexCoords = vTexCoords; fColor = vColor; diff --git a/FModel/Views/Snooper/Model.cs b/FModel/Views/Snooper/Model.cs index 1cc412b9..988a28c5 100644 --- a/FModel/Views/Snooper/Model.cs +++ b/FModel/Views/Snooper/Model.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Numerics; @@ -34,7 +34,7 @@ public class Model : IDisposable public uint[] Indices; public float[] Vertices; public Section[] Sections; - public Morph[] Morphs; + public readonly Morph[] Morphs; public readonly List Skeleton; public int TransformsCount; @@ -171,11 +171,10 @@ public class Model : IDisposable _matrixVbo = new BufferObject(_gl, instanceMatrix, BufferTargetARB.ArrayBuffer); _vao.BindInstancing(); - Morphs[0].Setup(gl); - _vao.Bind(); - _vao.VertexAttributePointer(11, 3, VertexAttribPointerType.Float, _vertexSize, 1); // target position - _vao.Unbind(); - + for (uint morph = 0; morph < Morphs.Length; morph++) + { + Morphs[morph].Setup(gl); + } for (int section = 0; section < Sections.Length; section++) { Sections[section].Setup(_gl); @@ -192,7 +191,6 @@ public class Model : IDisposable _vao.Bind(); shader.SetUniform("display_vertex_colors", DisplayVertexColors); - Morphs[0].Bind(shader); for (int section = 0; section < Sections.Length; section++) { Sections[section].Bind(shader, (uint) TransformsCount); @@ -232,6 +230,10 @@ public class Model : IDisposable _vbo.Dispose(); _matrixVbo.Dispose(); _vao.Dispose(); + for (var morph = 0; morph < Morphs.Length; morph++) + { + Morphs[morph].Dispose(); + } for (int section = 0; section < Sections.Length; section++) { Sections[section].Dispose(); diff --git a/FModel/Views/Snooper/Morph.cs b/FModel/Views/Snooper/Morph.cs index 6c0a25ff..885753b6 100644 --- a/FModel/Views/Snooper/Morph.cs +++ b/FModel/Views/Snooper/Morph.cs @@ -13,7 +13,7 @@ public class Morph : IDisposable private BufferObject _vbo; public readonly string Name; - public float[] Vertices; + public readonly float[] Vertices; public float Value; @@ -57,7 +57,7 @@ public class Morph : IDisposable public void Bind(Shader shader) { - shader.SetUniform("morph_time", Value); + shader.SetUniform("uMorphTime", Value); } public void Dispose() diff --git a/FModel/Views/Snooper/SnimGui.cs b/FModel/Views/Snooper/SnimGui.cs index 61954d9d..b3ce3d3c 100644 --- a/FModel/Views/Snooper/SnimGui.cs +++ b/FModel/Views/Snooper/SnimGui.cs @@ -319,8 +319,7 @@ public class SnimGui : IDisposable for (int i = 0; i < model.Morphs.Length; i++) { ImGui.PushID(i); - ImGui.Text(model.Morphs[i].Name); - ImGui.DragFloat("Value", ref model.Morphs[i].Value, 0.01f, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags.AlwaysClamp); + ImGui.DragFloat(model.Morphs[i].Name, ref model.Morphs[i].Value, 0.001f, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags.AlwaysClamp); ImGui.PopID(); } ImGui.EndTabItem();