diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index d7a043e3..18cac611 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index 272e8f29..dfc22da4 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 011f127f..95926e1a 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs index 1bb55772..ce26e020 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs @@ -705,12 +705,14 @@ namespace FirstPlugin { if (useSampler == "_a0") { - if (AlbedoCount == 0) - { - m.HasDiffuseMap = true; - AlbedoCount++; - texture.Type = MatTexture.TextureType.Diffuse; - } + m.HasDiffuseMap = true; + AlbedoCount++; + texture.Type = MatTexture.TextureType.Diffuse; + } + if (useSampler == "_a1") + { + m.HasDiffuseLayer = true; + texture.Type = MatTexture.TextureType.DiffuseLayer2; } if (useSampler == "_n0") { @@ -847,13 +849,6 @@ namespace FirstPlugin AlbedoCount++; texture.Type = MatTexture.TextureType.Diffuse; } - if (AlbedoCount == 1) - { - // poly.material.HasDiffuseLayer = true; - // texture.hash = 19; - // texture.Type = MatTexture.TextureType.DiffuseLayer2; - - } } else if (TextureName.Contains("Nrm") || TextureName.Contains("Norm") || TextureName.Contains("norm") || TextureName.Contains("nrm")) diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs index 63515a6b..33604f45 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs @@ -491,12 +491,14 @@ namespace FirstPlugin { if (useSampler == "_a0") { - if (AlbedoCount == 0) - { - m.HasDiffuseMap = true; - AlbedoCount++; - texture.Type = MatTexture.TextureType.Diffuse; - } + m.HasDiffuseMap = true; + AlbedoCount++; + texture.Type = MatTexture.TextureType.Diffuse; + } + else if (useSampler == "_a1") + { + m.HasDiffuseLayer = true; + texture.Type = MatTexture.TextureType.DiffuseLayer2; } else if (useSampler == "_n0") { diff --git a/Switch_FileFormatsMain/GL/BFRES_Render.cs b/Switch_FileFormatsMain/GL/BFRES_Render.cs index 76cc8516..54185c01 100644 --- a/Switch_FileFormatsMain/GL/BFRES_Render.cs +++ b/Switch_FileFormatsMain/GL/BFRES_Render.cs @@ -947,7 +947,9 @@ namespace FirstPlugin shader.SetBoolToInt("UseSpecularColor", (mat.GetOptionValue("specular_mask_is_color") == 1) || mat.GetOptionValue("enable_specular_color") == 1); - + + shader.SetBoolToInt("UseMultiTexture", mat.GetOptionValue("enable_multi_texture") == 1); + //Colors shader.SetVector4("const_color0", new Vector4(1, 1, 1, 1)); shader.SetVector4("base_color_mul_color", new Vector4(1, 1, 1, 1)); diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 8de901e5..ea082303 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index c908624b..dcb9d662 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs index 1edc39a7..aeaaa2c9 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs @@ -105,6 +105,7 @@ namespace Switch_Toolbox.Library mat4.M31, mat4.M32, mat4.M33, mat4.M34, mat4.M41, mat4.M42, mat4.M43, mat4.M44); + outMat.Transpose(); return outMat; } diff --git a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs index 6ed5f73f..9d0643fc 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs @@ -136,8 +136,7 @@ namespace Switch_Toolbox.Library //Create a new assimp bone Bone bone = new Bone(); bone.Name = STbone.Text; - bone.OffsetMatrix = transform; - + bone.OffsetMatrix = STbone.invert.ToMatrix4x4(); mesh.Bones.Add(bone); BoneNames.Add(bone.Name); diff --git a/Toolbox/Shader/Bfres/BFRES.frag b/Toolbox/Shader/Bfres/BFRES.frag index 78e28fb7..594879ee 100644 --- a/Toolbox/Shader/Bfres/BFRES.frag +++ b/Toolbox/Shader/Bfres/BFRES.frag @@ -80,6 +80,7 @@ uniform float cSpecularType; uniform float cIsEnableNormalMap; uniform int UseSpecularColor; +uniform int UseMultiTexture; // Texture Map Toggles uniform int HasDiffuse; @@ -196,8 +197,6 @@ void main() if (HasNormalMap == 1 && useNormalMap == 1) N = CalcBumpedNormal(normal, NormalMap, vert, NormalMapUVIndex); - - // Light Map vec4 LightMapColor = texture(BakeLightMap, f_texcoord2); @@ -206,9 +205,14 @@ void main() // Diffuse lighting. float halfLambert = dot(difLightDirection, N) * 0.5 + 0.5; + vec4 diffuseMapColor = vec4(texture(DiffuseMap, f_texcoord0).rgba); + //Texture Overlay (Like an emblem in mk8) - if (HasDiffuseLayer == 1) - fragColor += vec4(texture(DiffuseLayer, f_texcoord3).rgb, 1) * vec4(1); + if (UseMultiTexture == 1 && HasDiffuseLayer == 1) + { + vec4 AlbLayer = vec4(texture(DiffuseLayer, f_texcoord3).rgba); + diffuseMapColor.rgb = mix(diffuseMapColor.rgb, AlbLayer.rgb, AlbLayer.a); + } // Default Shader vec4 alpha = texture2D(DiffuseMap, f_texcoord0).aaaa; @@ -220,7 +224,6 @@ void main() alpha *= 0.5; } - vec4 diffuseMapColor = vec4(texture(DiffuseMap, f_texcoord0).rgb, 1); //vec4 diffuseMapColor = vec4(1); diffuseMapColor *= halfLambert; diff --git a/Toolbox/Shader/Bfres/BFRES_utility.frag b/Toolbox/Shader/Bfres/BFRES_utility.frag index 394e6ad0..27633189 100644 --- a/Toolbox/Shader/Bfres/BFRES_utility.frag +++ b/Toolbox/Shader/Bfres/BFRES_utility.frag @@ -106,6 +106,13 @@ float AmbientOcclusionBlend(sampler2D BakeShadowMap, VertexAttributes vert, floa return mix(aoMap, 1, ao_density); } +vec3 CalculateTangent() +{ + vec3 tangent = vec3(0); + + return tangent; +} + vec3 CalcBumpedNormal(vec3 inputNormal, sampler2D normalMap, VertexAttributes vert, float texCoordIndex) { float normalIntensity = 1; @@ -126,11 +133,12 @@ vec3 CalcBumpedNormal(vec3 inputNormal, sampler2D normalMap, VertexAttributes ve // TBN Matrix. vec3 T = vert.tangent; - vec3 B = vert. bitangent; + vec3 B = vert.bitangent; + if (Luminance(B) < 0.01) B = normalize(cross(T, vert.normal)); mat3 tbnMatrix = mat3(T, B, vert.normal); vec3 newNormal = tbnMatrix * normalMapNormal; return normalize(newNormal); -} +} \ No newline at end of file