no fuck you

This commit is contained in:
4sval 2022-09-16 00:14:38 +02:00
parent 569558640a
commit 24e3d549f5
4 changed files with 15 additions and 18 deletions

View File

@ -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;

View File

@ -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<CSkelMeshBone> Skeleton;
public int TransformsCount;
@ -171,11 +171,10 @@ public class Model : IDisposable
_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);
@ -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();

View File

@ -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;
@ -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()

View File

@ -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();