mirror of
https://github.com/4sval/FModel.git
synced 2026-08-26 03:14:39 -05:00
not perfect but better
This commit is contained in:
Submodule CUE4Parse updated: 1978194380...a70e6850b6
@@ -79,7 +79,7 @@ public partial class MainWindow
|
||||
#if DEBUG
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
_applicationView.CUE4Parse.Extract(cancellationToken,
|
||||
"FortniteGame/Content/Environments/Artemis/Sets/Seven/Village/Meshes/S_Seven_Village_Wall_01A_Window02.uasset"));
|
||||
"FortniteGame/Content/Athena/Artemis/Maps/Buildings/15x25/Artemis_Blimp_party.umap"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ in float fTexIndex;
|
||||
in vec4 fColor;
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuseMap[4];
|
||||
sampler2D normalMap[4];
|
||||
sampler2D specularMap[4];
|
||||
sampler2D diffuseMap[8];
|
||||
sampler2D normalMap[8];
|
||||
sampler2D specularMap[8];
|
||||
sampler2D emissionMap;
|
||||
|
||||
bool useSpecularMap;
|
||||
@@ -37,13 +37,13 @@ uniform bool display_vertex_colors;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 getValueFromSamplerArray(sampler2D array[4]) {
|
||||
vec4 getValueFromSamplerArray(sampler2D array[8]) {
|
||||
if (fTexIndex < 1.0) {
|
||||
return texture(array[0], fTexCoords);
|
||||
} if (fTexIndex < 2.0) {
|
||||
return texture(array[2], fTexCoords);
|
||||
} if (fTexIndex < 3.0) {
|
||||
return texture(array[1], fTexCoords);
|
||||
} if (fTexIndex < 3.0) {
|
||||
return texture(array[2], fTexCoords);
|
||||
} else {
|
||||
return texture(array[3], fTexCoords);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Material : IDisposable
|
||||
public Material()
|
||||
{
|
||||
Parameters = new CMaterialParams2();
|
||||
UvNumber = 1;
|
||||
DiffuseColor = Vector4.Zero;
|
||||
EmissionColor = Vector4.Zero;
|
||||
IsUsed = false;
|
||||
@@ -58,7 +59,7 @@ public class Material : IDisposable
|
||||
var guid = original.LightingGuid;
|
||||
if (cache.TryGetTexture(guid, out var texture))
|
||||
{
|
||||
array[index++] = texture;
|
||||
array[index] = texture;
|
||||
}
|
||||
else if (original.GetFirstMip() is { } mip)
|
||||
{
|
||||
@@ -66,27 +67,36 @@ public class Material : IDisposable
|
||||
|
||||
var t = new Texture(data, mip.SizeX, mip.SizeY, original);
|
||||
cache.AddTexture(guid, t);
|
||||
array[index++] = t;
|
||||
array[index] = t;
|
||||
}
|
||||
}
|
||||
|
||||
index = 0;
|
||||
Diffuse = new Texture[UvNumber];
|
||||
foreach (var d in Parameters.GetDiffuseTextures())
|
||||
{
|
||||
if (index < UvNumber && d is UTexture2D original)
|
||||
Add(Diffuse, original);
|
||||
index++;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
Normals = new Texture[UvNumber];
|
||||
foreach (var n in Parameters.GetNormalsTextures())
|
||||
{
|
||||
if (index < UvNumber && n is UTexture2D original)
|
||||
Add(Normals, original);
|
||||
index++;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
SpecularMasks = new Texture[UvNumber];
|
||||
foreach (var s in Parameters.GetSpecularMasksTextures())
|
||||
{
|
||||
if (index < UvNumber && s is UTexture2D original)
|
||||
Add(SpecularMasks, original);
|
||||
index++;
|
||||
}
|
||||
|
||||
// diffuse light is based on normal map, so increase ambient if no normal map
|
||||
_ambientLight = new Vector3(Normals[0] == null ? 1.0f : 0.2f);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Model : IDisposable
|
||||
for (int m = 0; m < Materials.Length; m++)
|
||||
{
|
||||
if ((materials[m]?.TryLoad(out var material) ?? false) && material is UMaterialInterface unrealMaterial)
|
||||
Materials[m] = new Material(lod.NumTexCoords, unrealMaterial);
|
||||
Materials[m] = new Material(4, unrealMaterial); // lod.NumTexCoords
|
||||
else Materials[m] = new Material();
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class Model : IDisposable
|
||||
_vao.BindInstancing(); // VertexAttributePointer 7, 8, 9, 10
|
||||
}
|
||||
|
||||
{ // setup all materials for use in different UV channels
|
||||
{ // setup all used materials for use in different UV channels
|
||||
for (var i = 0; i < Materials.Length; i++)
|
||||
{
|
||||
if (!Materials[i].IsUsed) continue;
|
||||
|
||||
Reference in New Issue
Block a user