-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have no idea how I made multiple materials work
- Loading branch information
Showing
7 changed files
with
111 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using CUE4Parse.UE4.Assets.Exports.Material; | ||
using CUE4Parse.UE4.Assets.Exports.Texture; | ||
using CUE4Parse_Conversion.Meshes.PSK; | ||
using CUE4Parse_Conversion.Textures; | ||
using Silk.NET.OpenGL; | ||
|
||
namespace FModel.Views.Snooper; | ||
|
||
public class Section : IDisposable | ||
{ | ||
private uint _handle; | ||
private GL _gl; | ||
|
||
private Texture _albedoMap; | ||
// private Texture _normalMap; | ||
|
||
public uint FacesCount; | ||
public int FirstFaceIndex; | ||
public CMaterialParams Params; | ||
|
||
public Section(uint facesCount, int firstFaceIndex, CMeshSection section) | ||
{ | ||
FacesCount = facesCount; | ||
FirstFaceIndex = firstFaceIndex; | ||
Params = new CMaterialParams(); | ||
if (section.Material != null && section.Material.TryLoad(out var material) && material is UMaterialInterface unrealMaterial) | ||
{ | ||
unrealMaterial.GetParams(Params); | ||
} | ||
} | ||
|
||
public void Setup(GL gl) | ||
{ | ||
_gl = gl; | ||
|
||
_handle = _gl.CreateProgram(); | ||
|
||
if (Params.Diffuse is UTexture2D { IsVirtual: false } diffuse && diffuse.GetFirstMip() is { } mip) | ||
{ | ||
TextureDecoder.DecodeTexture(mip, diffuse.Format, diffuse.isNormalMap, out var data, out _); | ||
_albedoMap = new Texture(_gl, data, (uint) mip.SizeX, (uint) mip.SizeY); | ||
} | ||
} | ||
|
||
public void Bind(Shader shader) | ||
{ | ||
shader.SetUniform("material.albedo", 0); | ||
_albedoMap.Bind(TextureUnit.Texture0); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_albedoMap.Dispose(); | ||
_gl.DeleteProgram(_handle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters