Skip to content

Commit

Permalink
point clouds for now + reduced opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed May 6, 2024
1 parent 7e69adf commit 967ffef
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 39 deletions.
7 changes: 4 additions & 3 deletions FModel/Resources/default.frag
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ uniform Parameters uParameters;
uniform Light uLights[MAX_LIGHT_COUNT];
uniform int uNumLights;
uniform int uUvCount;
uniform float uOpacity;
uniform bool uHasVertexColors;
uniform vec3 uSectionColor;
uniform bool bVertexColors[6];
Expand Down Expand Up @@ -214,7 +215,7 @@ void main()
{
if (bVertexColors[1])
{
FragColor = vec4(uSectionColor, 1.0);
FragColor = vec4(uSectionColor, uOpacity);
}
else if (bVertexColors[2] && uHasVertexColors)
{
Expand All @@ -224,7 +225,7 @@ void main()
{
int layer = LayerToIndex();
vec3 normals = ComputeNormals(layer);
FragColor = vec4(normals, 1.0);
FragColor = vec4(normals, uOpacity);
}
else if (bVertexColors[4])
{
Expand Down Expand Up @@ -281,6 +282,6 @@ void main()
}

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);
}
}
21 changes: 21 additions & 0 deletions FModel/Settings/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using CUE4Parse_Conversion;
using CUE4Parse_Conversion.Animations;
using CUE4Parse.UE4.Versions;
using CUE4Parse_Conversion.Meshes;
using CUE4Parse_Conversion.Textures;
Expand Down Expand Up @@ -48,6 +50,25 @@ public static bool IsEndpointValid(EEndpointType type, out EndpointSettings endp
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;
public bool ShowChangelog
{
Expand Down
19 changes: 1 addition & 18 deletions FModel/ViewModels/CUE4ParseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -959,24 +959,7 @@ private void SaveAndPlaySound(string fullPath, string ext, byte[] data)

private void SaveExport(UObject export, bool auto)
{
var exportOptions = new ExporterOptions
{
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);
var toSave = new Exporter(export, UserSettings.Default.ExportOptions);

string dir;
if (!auto)
Expand Down
2 changes: 1 addition & 1 deletion FModel/Views/Snooper/Animations/Animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void Popup(Snooper s, Save saver, int i)
if (ImGui.MenuItem("Save"))
{
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);
}
ImGui.Separator();
Expand Down
11 changes: 8 additions & 3 deletions FModel/Views/Snooper/Models/Collision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ public void Render(Shader shader)
shader.SetUniform("uCollisionMatrix", _transform.Matrix);

_vao.Bind();
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.DrawElements(PrimitiveType.Triangles, _ebo.Size, DrawElementsType.UnsignedInt, 0);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
if (_indexData.Length > 0)
{
GL.DrawElements(PrimitiveType.Triangles, _ebo.Size, DrawElementsType.UnsignedInt, 0);
}
else
{
GL.DrawArrays(PrimitiveType.Points, 0, _vbo.Size);
}
_vao.Unbind();
}

Expand Down
21 changes: 8 additions & 13 deletions FModel/Views/Snooper/Models/UModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected UModel(UObject export, CBaseMeshLod lod, IReadOnlyList<ResolvedObject>
Vertices[baseIndex + count++] = vert.Tangent.Y;
Vertices[baseIndex + count++] = vert.UV.U;
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)
{
Expand Down Expand Up @@ -250,6 +250,7 @@ public virtual void Render(Shader shader, Texture checker = null, bool outline =
if (!outline)
{
shader.SetUniform("uUvCount", UvCount);
shader.SetUniform("uOpacity", ShowCollisions && IsSelected ? 0.75f : 1f);
shader.SetUniform("uHasVertexColors", HasVertexColors);
}

Expand Down Expand Up @@ -308,10 +309,15 @@ public void RenderCollision(Shader shader)
{
shader.SetUniform("uInstanceMatrix", GetTransform().Matrix);
shader.SetUniform("uScaleDown", Constants.SCALE_DOWN_RATIO);

GL.Disable(EnableCap.CullFace);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
foreach (var collision in Collisions)
{
collision.Render(shader);
}
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.Enable(EnableCap.CullFace);
}

public void Update(Options options)
Expand Down Expand Up @@ -375,18 +381,7 @@ public Matrix4x4 GetSocketTransform(int index)

public bool Save(out string label, out string savedFilePath)
{
var exportOptions = new ExporterOptions
{
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);
var toSave = new Exporter(_export, UserSettings.Default.ExportOptions);
return toSave.TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out label, out savedFilePath);
}

Expand Down

0 comments on commit 967ffef

Please sign in to comment.