Skip to content

Commit

Permalink
no fuck you
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Sep 15, 2022
1 parent 5695586 commit 24e3d54
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
8 changes: 2 additions & 6 deletions FModel/Resources/default.vert
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions FModel/Views/Snooper/Model.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
Expand Down Expand Up @@ -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<CSkelMeshBone> Skeleton;

public int TransformsCount;
Expand Down Expand Up @@ -171,11 +171,10 @@ public void Setup(GL gl)
_matrixVbo = new BufferObject<Matrix4x4>(_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);
Expand All @@ -192,7 +191,6 @@ public void Bind(Shader shader)

_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);
Expand Down Expand Up @@ -232,6 +230,10 @@ public void Dispose()
_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();
Expand Down
4 changes: 2 additions & 2 deletions FModel/Views/Snooper/Morph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Morph : IDisposable
private BufferObject<float> _vbo;

public readonly string Name;
public float[] Vertices;
public readonly float[] Vertices;

public float Value;

Expand Down Expand Up @@ -57,7 +57,7 @@ public void Setup(GL gl)

public void Bind(Shader shader)
{
shader.SetUniform("morph_time", Value);
shader.SetUniform("uMorphTime", Value);
}

public void Dispose()
Expand Down
3 changes: 1 addition & 2 deletions FModel/Views/Snooper/SnimGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ private void DrawProperties(Camera camera, IDictionary<FGuid, Model> models)
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();
Expand Down

0 comments on commit 24e3d54

Please sign in to comment.