Skip to content

Commit

Permalink
Valorant MRAE MRAS MRA MRS
Browse files Browse the repository at this point in the history
  • Loading branch information
floxay committed Nov 24, 2021
1 parent ba017a4 commit 3da0750
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions FModel/ViewModels/ModelViewerViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
Expand Down Expand Up @@ -395,20 +395,36 @@ private void PushLod(CMeshSection[] sections, CMeshVertex[] verts, FRawStaticInd
}
case FGame.ShooterGame:
{
// Valorant's Specular Texture Channels
// R Metallic
// G Specular
// B Roughness
unsafe
var packedPBRType = specular.Name[(specular.Name.LastIndexOf('_') + 1)..];
switch (packedPBRType)
{
var offset = 0;
fixed (byte* d = data)
for (var i = 0; i < mip.SizeX * mip.SizeY; i++)
case "MRAE": // R: Metallic, G: AO (0-127) & Emissive (128-255), B: Roughness (Character PBR)
unsafe
{
(d[offset], d[offset+2]) = (d[offset+2], d[offset]); // swap R and B
(d[offset], d[offset+1]) = (d[offset+1], d[offset]); // swap B and G
offset += 4;
var offset = 0;
fixed (byte* d = data)
for (var i = 0; i < mip.SizeX * mip.SizeY; i++)
{
(d[offset], d[offset+2]) = (d[offset+2], d[offset]); // swap R and B
(d[offset], d[offset+1]) = (d[offset+1], d[offset]); // swap R and G
offset += 4;
}
}
break;
case "MRAS": // R: Metallic, B: Roughness, B: AO, A: Specular (Legacy PBR)
case "MRA": // R: Metallic, B: Roughness, B: AO (Environment PBR)
case "MRS": // R: Metallic, G: Roughness, B: Specular (Weapon PBR)
unsafe
{
var offset = 0;
fixed (byte* d = data)
for (var i = 0; i < mip.SizeX * mip.SizeY; i++)
{
(d[offset], d[offset+2]) = (d[offset+2], d[offset]); // swap R and B
offset += 4;
}
}
break;
}
parameters.RoughnessValue = 1;
parameters.MetallicValue = 1;
Expand Down

0 comments on commit 3da0750

Please sign in to comment.