point clouds for now + reduced opacity

This commit is contained in:
Asval
2024-05-06 23:22:59 +02:00
parent 7e69adf978
commit 967ffefbe0
7 changed files with 44 additions and 39 deletions

View File

@@ -89,6 +89,7 @@ uniform Parameters uParameters;
uniform Light uLights[MAX_LIGHT_COUNT]; uniform Light uLights[MAX_LIGHT_COUNT];
uniform int uNumLights; uniform int uNumLights;
uniform int uUvCount; uniform int uUvCount;
uniform float uOpacity;
uniform bool uHasVertexColors; uniform bool uHasVertexColors;
uniform vec3 uSectionColor; uniform vec3 uSectionColor;
uniform bool bVertexColors[6]; uniform bool bVertexColors[6];
@@ -214,7 +215,7 @@ void main()
{ {
if (bVertexColors[1]) if (bVertexColors[1])
{ {
FragColor = vec4(uSectionColor, 1.0); FragColor = vec4(uSectionColor, uOpacity);
} }
else if (bVertexColors[2] && uHasVertexColors) else if (bVertexColors[2] && uHasVertexColors)
{ {
@@ -224,7 +225,7 @@ void main()
{ {
int layer = LayerToIndex(); int layer = LayerToIndex();
vec3 normals = ComputeNormals(layer); vec3 normals = ComputeNormals(layer);
FragColor = vec4(normals, 1.0); FragColor = vec4(normals, uOpacity);
} }
else if (bVertexColors[4]) else if (bVertexColors[4])
{ {
@@ -281,6 +282,6 @@ void main()
} }
result = result / (result + vec3(1.0)); result = result / (result + vec3(1.0));
FragColor = vec4(pow(result, vec3(1.0 / 2.2)), 1.0); FragColor = vec4(pow(result, vec3(1.0 / 2.2)), uOpacity);
} }
} }

View File

@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using CUE4Parse_Conversion;
using CUE4Parse_Conversion.Animations;
using CUE4Parse.UE4.Versions; using CUE4Parse.UE4.Versions;
using CUE4Parse_Conversion.Meshes; using CUE4Parse_Conversion.Meshes;
using CUE4Parse_Conversion.Textures; using CUE4Parse_Conversion.Textures;
@@ -48,6 +50,25 @@ namespace FModel.Settings
return endpoint.Overwrite || endpoint.IsValid; return endpoint.Overwrite || endpoint.IsValid;
} }
[JsonIgnore]
public ExporterOptions ExportOptions => new()
{
LodFormat = Default.LodExportFormat,
MeshFormat = Default.MeshExportFormat,
AnimFormat = Default.MeshExportFormat switch
{
EMeshFormat.UEFormat => EAnimFormat.UEFormat,
_ => EAnimFormat.ActorX
},
MaterialFormat = Default.MaterialExportFormat,
TextureFormat = Default.TextureExportFormat,
SocketFormat = Default.SocketExportFormat,
CompressionFormat = Default.CompressionFormat,
Platform = Default.CurrentDir.TexturePlatform,
ExportMorphTargets = Default.SaveMorphTargets,
ExportMaterials = Default.SaveEmbeddedMaterials
};
private bool _showChangelog = true; private bool _showChangelog = true;
public bool ShowChangelog public bool ShowChangelog
{ {

View File

@@ -959,24 +959,7 @@ public class CUE4ParseViewModel : ViewModel
private void SaveExport(UObject export, bool auto) private void SaveExport(UObject export, bool auto)
{ {
var exportOptions = new ExporterOptions var toSave = new Exporter(export, UserSettings.Default.ExportOptions);
{
LodFormat = UserSettings.Default.LodExportFormat,
MeshFormat = UserSettings.Default.MeshExportFormat,
AnimFormat = UserSettings.Default.MeshExportFormat switch
{
EMeshFormat.ActorX => EAnimFormat.ActorX,
_ => EAnimFormat.UEFormat // i think we said ueformat default is okay
},
MaterialFormat = UserSettings.Default.MaterialExportFormat,
TextureFormat = UserSettings.Default.TextureExportFormat,
SocketFormat = UserSettings.Default.SocketExportFormat,
CompressionFormat = UserSettings.Default.CompressionFormat,
Platform = UserSettings.Default.CurrentDir.TexturePlatform,
ExportMorphTargets = UserSettings.Default.SaveMorphTargets,
ExportMaterials = UserSettings.Default.SaveEmbeddedMaterials
};
var toSave = new Exporter(export, exportOptions);
string dir; string dir;
if (!auto) if (!auto)

View File

@@ -134,7 +134,7 @@ public class Animation : IDisposable
if (ImGui.MenuItem("Save")) if (ImGui.MenuItem("Save"))
{ {
s.WindowShouldFreeze(true); s.WindowShouldFreeze(true);
saver.Value = new Exporter(_export).TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out saver.Label, out saver.Path); saver.Value = new Exporter(_export, UserSettings.Default.ExportOptions).TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out saver.Label, out saver.Path);
s.WindowShouldFreeze(false); s.WindowShouldFreeze(false);
} }
ImGui.Separator(); ImGui.Separator();

View File

@@ -46,9 +46,14 @@ public class Collision : IDisposable
shader.SetUniform("uCollisionMatrix", _transform.Matrix); shader.SetUniform("uCollisionMatrix", _transform.Matrix);
_vao.Bind(); _vao.Bind();
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); if (_indexData.Length > 0)
GL.DrawElements(PrimitiveType.Triangles, _ebo.Size, DrawElementsType.UnsignedInt, 0); {
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GL.DrawElements(PrimitiveType.Triangles, _ebo.Size, DrawElementsType.UnsignedInt, 0);
}
else
{
GL.DrawArrays(PrimitiveType.Points, 0, _vbo.Size);
}
_vao.Unbind(); _vao.Unbind();
} }

View File

@@ -151,7 +151,7 @@ public abstract class UModel : IRenderableModel
Vertices[baseIndex + count++] = vert.Tangent.Y; Vertices[baseIndex + count++] = vert.Tangent.Y;
Vertices[baseIndex + count++] = vert.UV.U; Vertices[baseIndex + count++] = vert.UV.U;
Vertices[baseIndex + count++] = vert.UV.V; Vertices[baseIndex + count++] = vert.UV.V;
Vertices[baseIndex + count++] = hasCustomUvs ? lod.ExtraUV.Value[0][i].U : .5f; Vertices[baseIndex + count++] = hasCustomUvs ? lod.ExtraUV.Value[0][i].U - 1 : .5f;
if (HasVertexColors) if (HasVertexColors)
{ {
@@ -250,6 +250,7 @@ public abstract class UModel : IRenderableModel
if (!outline) if (!outline)
{ {
shader.SetUniform("uUvCount", UvCount); shader.SetUniform("uUvCount", UvCount);
shader.SetUniform("uOpacity", ShowCollisions && IsSelected ? 0.75f : 1f);
shader.SetUniform("uHasVertexColors", HasVertexColors); shader.SetUniform("uHasVertexColors", HasVertexColors);
} }
@@ -308,10 +309,15 @@ public abstract class UModel : IRenderableModel
{ {
shader.SetUniform("uInstanceMatrix", GetTransform().Matrix); shader.SetUniform("uInstanceMatrix", GetTransform().Matrix);
shader.SetUniform("uScaleDown", Constants.SCALE_DOWN_RATIO); shader.SetUniform("uScaleDown", Constants.SCALE_DOWN_RATIO);
GL.Disable(EnableCap.CullFace);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
foreach (var collision in Collisions) foreach (var collision in Collisions)
{ {
collision.Render(shader); collision.Render(shader);
} }
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.Enable(EnableCap.CullFace);
} }
public void Update(Options options) public void Update(Options options)
@@ -375,18 +381,7 @@ public abstract class UModel : IRenderableModel
public bool Save(out string label, out string savedFilePath) public bool Save(out string label, out string savedFilePath)
{ {
var exportOptions = new ExporterOptions var toSave = new Exporter(_export, UserSettings.Default.ExportOptions);
{
LodFormat = UserSettings.Default.LodExportFormat,
MeshFormat = UserSettings.Default.MeshExportFormat,
MaterialFormat = UserSettings.Default.MaterialExportFormat,
TextureFormat = UserSettings.Default.TextureExportFormat,
SocketFormat = UserSettings.Default.SocketExportFormat,
Platform = UserSettings.Default.CurrentDir.TexturePlatform,
ExportMorphTargets = UserSettings.Default.SaveMorphTargets,
ExportMaterials = UserSettings.Default.SaveEmbeddedMaterials
};
var toSave = new Exporter(_export, exportOptions);
return toSave.TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out label, out savedFilePath); return toSave.TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out label, out savedFilePath);
} }