mirror of
https://github.com/4sval/FModel.git
synced 2026-04-05 00:26:17 -05:00
material improvements
This commit is contained in:
parent
b4df69fbeb
commit
321b82b458
|
|
@ -1 +1 @@
|
|||
Subproject commit 1cf7b4bc8e2f91e60fc5c9e60c6cb9a1ff1af315
|
||||
Subproject commit d2efb39f5fdc9bfbdae47cd7138601ecb0ef6812
|
||||
|
|
@ -239,7 +239,7 @@ outputColor = color * texture(in_fontTexture, texCoord);
|
|||
io.AddMouseButtonEvent(1, mState[MouseButton.Right]);
|
||||
io.AddMouseButtonEvent(2, mState[MouseButton.Middle]);
|
||||
|
||||
io.AddMousePosEvent(mState.PreviousX, mState.PreviousY);
|
||||
io.AddMousePosEvent(mState.X, mState.Y);
|
||||
|
||||
foreach (Keys key in Enum.GetValues(typeof(Keys)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CUE4Parse.UE4.Assets.Exports.Material;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
|
|
@ -64,32 +66,22 @@ public class Material : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
Diffuse = new Texture[UvNumber];
|
||||
for (int i = 0; i < Diffuse.Length; i++)
|
||||
if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.Diffuse[i]) && cache.TryGetCachedTexture(o, out var t))
|
||||
Diffuse[i] = t;
|
||||
Fill(cache, ref Diffuse, Parameters.HasTopDiffuse, CMaterialParams2.Diffuse, CMaterialParams2.FallbackDiffuse);
|
||||
Fill(cache, ref Normals, true, CMaterialParams2.Normals, CMaterialParams2.FallbackNormals);
|
||||
Fill(cache, ref SpecularMasks, true, CMaterialParams2.SpecularMasks, CMaterialParams2.FallbackSpecularMasks);
|
||||
Fill(cache, ref Emissive, true, CMaterialParams2.Emissive, CMaterialParams2.FallbackEmissive);
|
||||
|
||||
Normals = new Texture[UvNumber];
|
||||
for (int i = 0; i < Normals.Length; i++)
|
||||
if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.Normals[i]) && cache.TryGetCachedTexture(o, out var t))
|
||||
Normals[i] = t;
|
||||
|
||||
SpecularMasks = new Texture[UvNumber];
|
||||
for (int i = 0; i < SpecularMasks.Length; i++)
|
||||
if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.SpecularMasks[i]) && cache.TryGetCachedTexture(o, out var t))
|
||||
SpecularMasks[i] = t;
|
||||
|
||||
Emissive = new Texture[UvNumber];
|
||||
EmissionColor = new Vector4[UvNumber];
|
||||
for (int i = 0; i < Emissive.Length; i++)
|
||||
if (Parameters.TryGetTexture2d(out var o, CMaterialParams2.Emissive[i]) && cache.TryGetCachedTexture(o, out var t))
|
||||
{
|
||||
Emissive[i] = t;
|
||||
for (int i = 0; i < EmissionColor.Length; i++)
|
||||
{
|
||||
if (Emissive[i] == null) continue;
|
||||
|
||||
if (Parameters.TryGetLinearColor(out var color, $"Emissive{(i > 0 ? i + 1 : "")}") && color is { A: > 0})
|
||||
EmissionColor[i] = new Vector4(color.R, color.G, color.B, color.A);
|
||||
else EmissionColor[i] = Vector4.One;
|
||||
if (Parameters.TryGetLinearColor(out var color, $"Emissive{(i > 0 ? i + 1 : "")}") && color is { A: > 0 })
|
||||
{
|
||||
EmissionColor[i] = new Vector4(color.R, color.G, color.B, color.A);
|
||||
}
|
||||
else EmissionColor[i] = Vector4.One;
|
||||
}
|
||||
|
||||
// diffuse light is based on normal map, so increase ambient if no normal map
|
||||
_ambientLight = new Vector3(Normals[0] == null ? 1.0f : 0.2f);
|
||||
|
|
@ -99,6 +91,31 @@ public class Material : IDisposable
|
|||
HasDiffuseColor = DiffuseColor != Vector4.Zero;
|
||||
}
|
||||
|
||||
/// <param name="cache"></param>
|
||||
/// <param name="array"></param>
|
||||
/// <param name="top">has at least 1 clearly defined texture</param>
|
||||
/// <param name="triggers">list of texture parameter names</param>
|
||||
/// <param name="fallback">fallback texture parameter name</param>
|
||||
private void Fill(Cache cache, ref Texture[] array, bool top, IReadOnlyList<string[]> triggers, string fallback)
|
||||
{
|
||||
array = new Texture[UvNumber];
|
||||
if (top)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
if (Parameters.TryGetTexture2d(out var o, triggers[i]) && cache.TryGetCachedTexture(o, out var t))
|
||||
array[i] = t;
|
||||
}
|
||||
// else if (Parameters.Colors.TryGetValue("ColorMult", out var color) && color is { A: > 0})
|
||||
// {
|
||||
//
|
||||
// }
|
||||
else if (Parameters.Textures.TryGetValue(fallback, out var u) && u is UTexture2D o && cache.TryGetCachedTexture(o, out var t))
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = t;
|
||||
}
|
||||
}
|
||||
|
||||
public void Render(Shader shader)
|
||||
{
|
||||
var unit = 0;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class Model : IDisposable
|
|||
private BufferObject<Matrix4x4> _matrixVbo;
|
||||
private VertexArrayObject<float, uint> _vao;
|
||||
|
||||
private readonly int _vertexSize = 10; // VertexIndex + Position + Normal + UV + TextureIndex
|
||||
private readonly int _vertexSize = 10; // VertexIndex + Position + Normal + UV + TextureLayer
|
||||
private readonly uint[] _facesIndex = { 1, 0, 2 };
|
||||
private const int _faceSize = 3; // just so we don't have to do .Length
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class Renderer : IDisposable
|
|||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (persistentLevel.Actors[i].Load() is not { } actor ||actor.ExportType == "LODActor" ||
|
||||
!actor.TryGetValue(out FPackageIndex staticMeshComponent, "StaticMeshComponent") ||
|
||||
!actor.TryGetValue(out FPackageIndex staticMeshComponent, "StaticMeshComponent", "Mesh") ||
|
||||
staticMeshComponent.Load() is not { } staticMeshComp) continue;
|
||||
|
||||
if (!staticMeshComp.TryGetValue(out FPackageIndex staticMesh, "StaticMesh") && actor.Class is UBlueprintGeneratedClass)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ public class SnimGui
|
|||
DrawNavbar();
|
||||
|
||||
ImGui.Begin("Camera");
|
||||
ImGui.DragFloat("Speed", ref s.Camera.Speed, 0.01f);
|
||||
ImGui.DragFloat("Near", ref s.Camera.Near, 0.1f, 0.01f, s.Camera.Far - 0.1f, "%.2f m", ImGuiSliderFlags.AlwaysClamp);
|
||||
ImGui.DragFloat("Far", ref s.Camera.Far, 0.1f, s.Camera.Near + 0.1f, 0f, "%.2f m", ImGuiSliderFlags.AlwaysClamp);
|
||||
ImGui.End();
|
||||
ImGui.Begin("World");
|
||||
ImGui.End();
|
||||
|
|
@ -186,7 +189,11 @@ public class SnimGui
|
|||
|
||||
PushStyleCompact();
|
||||
ImGui.Columns(4, "Actions", false);
|
||||
// if (ImGui.Button("Go To")) s.Camera.Position = model.Transforms[s.Renderer.Settings.SelectedModelInstance].Position;
|
||||
if (ImGui.Button("Go To"))
|
||||
{
|
||||
var instancePos = model.Transforms[model.SelectedInstance].Position;
|
||||
s.Camera.Position = new Vector3(instancePos.X, instancePos.Z, instancePos.Y);
|
||||
}
|
||||
ImGui.NextColumn(); ImGui.Checkbox("Show", ref model.Show);
|
||||
ImGui.NextColumn(); ImGui.BeginDisabled(!model.HasVertexColors); ImGui.Checkbox("Colors", ref model.DisplayVertexColors); ImGui.EndDisabled();
|
||||
ImGui.NextColumn(); ImGui.BeginDisabled(!model.HasBones); ImGui.Checkbox("Bones", ref model.DisplayBones); ImGui.EndDisabled();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Threading;
|
||||
using System.Windows;
|
||||
using CUE4Parse.UE4.Assets.Exports;
|
||||
using ImGuiNET;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Mathematics;
|
||||
using OpenTK.Windowing.Common;
|
||||
|
|
@ -143,7 +144,7 @@ public class Snooper : GameWindow
|
|||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnUpdateFrame(e);
|
||||
if (!IsVisible)
|
||||
if (!IsVisible || ImGui.GetIO().WantTextInput)
|
||||
return;
|
||||
|
||||
var multiplier = KeyboardState.IsKeyDown(Keys.LeftShift) ? 2f : 1f;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user