1
0
mirror of synced 2024-12-05 04:17:59 +01:00
Switch-Toolbox/Toolbox/Shader/Bfres/BFRES_Debug.frag
KillzXGaming d1f03b161f Add files for the new one.
Rework UI from scratch with proper themes and custom controls. MDI windows are now used for workspaces, comparing docs, and multiple usages. Tabs organise multiple workspaces and you can keep mdi windows maximized if you want to only use tabs. Themes currently include dark and white theme but plan to have XML files with list of color and styles
Alot of things optimized. UI is very fast and snappy now
Dae rigging fixed.
Dae bones can be imported.
Dae with textures can be imported and exported to a folder
Custom sampler editor for sampler data.
Texture refs, shader options, params, render info, and basically all material data can be added/removed and edited
User data editor
Update opengl framework by JuPaHe64 to the newest. Includes an origintation cube, multiple models in a scene, and many improvements
Skeleton can be viewed
GFPAK with some fixes in saving
NUTEXB has proper mip map viewing
PTCL Editor (Wii U and Switch). Can edit colors ( Wii U) and view textures. Also EFFN files in smash ultimate can be previewed
Files can be associated with the program and opened with on clicking them
ASTC textures can be viewed
UVs can be viewed. Includes wrap modes and also translating and scaling for some basic edits
Textures use a new editor. It includes channel viewing and some new editing options
Fixed black textures on some wii u bfres
Fixed saving sarcs in sarcs
Shortcut keys have been added in. CTRL + S can save the active file in the currently used window
Fix more issues with bfres crashing
File - New includes BNTX for creating new bntx files from scatch
Raw shader binaries can be extracted from bnsh and bfsha. Yuzu and Ryujinx can decompile these
Sharc files can have source data previewed and shader programs in XML
Aamp v1 and v2 data can be previewed. v1 can be edited and saved atm, v2 will be at a later update
Byaml uses it's own editor instead of a seperate window for easy saving within sarcs
Archives have a hex viewer
Dae exporting greatly improved and can export rigged meshes
Scene, shader param, srt, color, and texture pattern animations can all be previewed (in a list)
Memory usage is greatly improved
Narc (Nitro Archives) can be viewed and extracted.
Fixed importing TGA images
Support importing ASTC textures for bntx
Added in PBR lighting for bfres from my implimentaion in forge
Added gradient background for viewport. This can be edited in the settings
Added skybox background option for viewport. Can load cubemaps
Added grid with customizable cells for viewport.
DDS decompression no longer requires Direct X tex.
Zlib decompression has been improved for opening files that use it
Rigid bones are properly ordered on importing a mesh. May fix some exploding issues.
Endianness for KCL can be toggled for saving. Will be set to what it was using orignally
Tangents can be filled with a constant value. Will allow them to not cause seams nor flat lighting however normal maps may not work as good
Vertex buffers can be added and removed. Also re encoded
Parameters now use drop down panels with values for easier editing
Reworked the bone editor. Everything for a bone can be fully edited now besides the index, billboard index and parent index  which get set automatically
Fixed animation scaling for skeletal animations finally!
Textures can be loaded in a tab now with thumbnail displaying for easy real time edits while previewing in the viewport

Fixed support for audio files to be big endian in BARS
Textures for switch now use their own folder. You can easily add textures to this and add textures to bfres that have no bntx. If there are no textures then the bfres will automatically not have one on save.
Animations are split into multiple sub sections for switch's material animation for easier access
Bfres for wii u has better binary exporting and is fully compatiable with Wexos Toolbox (to and from)
Every section can be added in as new for both wii u and switch.
Every section can be renamed properly and mostly everything can be edited. (Key frame editing and a more in depth curve editor later)
Added option to copy UV channel
Bone weights can be previewed
Tons of fixes for the switch bfres library with more games working. Splatoon 2 (more work now), BOTW, Kirby Star Allies, and more!
Fixed 3.3 Wii U bfres from not opening
Wii U Sharcfb files can have shader program data previewed (XML)

And possibly alot more things i missed! All this is still experimental but will improve over the next few weeks
2019-03-23 12:55:09 -04:00

330 lines
8.0 KiB
GLSL

#version 330
in vec2 f_texcoord0;
in vec2 f_texcoord1;
in vec2 f_texcoord2;
in vec2 f_texcoord3;
in vec3 objectPosition;
in vec3 normal;
in vec3 viewNormal;
in vec4 vertexColor;
in vec3 tangent;
in vec3 bitangent;
in vec3 boneWeightsColored;
// Viewport Camera/Lighting
uniform mat4 mtxMdl;
uniform mat4 mtxCam;
uniform vec3 specLightDirection;
uniform vec3 difLightDirection;
uniform mat4 projMatrix;
uniform mat4 normalMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 rotationMatrix;
uniform int useImageBasedLighting;
uniform int enableCellShading;
uniform vec3 camPos;
uniform vec3 light1Pos;
const float levels = 3.0;
// Viewport Settings
uniform int uvChannel;
uniform int renderType;
uniform int useNormalMap;
uniform vec4 colorSamplerUV;
uniform int renderVertColor;
uniform vec3 difLightColor;
uniform vec3 ambLightColor;
uniform int colorOverride;
uniform float DefaultMetalness;
uniform float DefaultRoughness;
// Channel Toggles
uniform int renderR;
uniform int renderG;
uniform int renderB;
uniform int renderAlpha;
// Texture Samplers
uniform sampler2D DiffuseMap;
uniform sampler2D BakeShadowMap;
uniform sampler2D NormalMap;
uniform sampler2D BakeLightMap;
uniform sampler2D UVTestPattern;
uniform sampler2D TransparencyMap;
uniform sampler2D EmissionMap;
uniform sampler2D SpecularMap;
uniform sampler2D DiffuseLayer;
uniform sampler2D MetalnessMap;
uniform sampler2D RoughnessMap;
uniform sampler2D MRA;
uniform sampler2D TeamColorMap;
uniform sampler2D SphereMap;
uniform sampler2D SubSurfaceScatteringMap;
uniform samplerCube irradianceMap;
uniform samplerCube specularIbl;
uniform sampler2D brdfLUT;
// Shader Params
uniform float normal_map_weight;
uniform float ao_density;
uniform float emission_intensity;
uniform vec4 fresnelParams;
uniform vec4 base_color_mul_color;
uniform vec3 emission_color;
uniform vec3 specular_color;
// Shader Options
uniform float uking_texture2_texcoord;
uniform float bake_shadow_type;
uniform float enable_fresnel;
uniform float enable_emission;
uniform float cSpecularType;
// Texture Map Toggles
uniform int HasDiffuse;
uniform int HasNormalMap;
uniform int HasSpecularMap;
uniform int HasShadowMap;
uniform int HasAmbientOcclusionMap;
uniform int HasLightMap;
uniform int HasTransparencyMap;
uniform int HasEmissionMap;
uniform int HasDiffuseLayer;
uniform int HasMetalnessMap;
uniform int HasRoughnessMap;
uniform int HasMRA;
uniform int HasSubSurfaceScatteringMap;
uniform int roughnessAmount;
uniform int UseAOMap;
uniform int UseCavityMap;
uniform int UseMetalnessMap;
uniform int UseRoughnessMap;
int isTransparent;
struct VertexAttributes {
vec3 objectPosition;
vec2 texCoord;
vec2 texCoord2;
vec2 texCoord3;
vec4 vertexColor;
vec3 normal;
vec3 viewNormal;
vec3 tangent;
vec3 bitangent;
};
out vec4 fragColor;
#define gamma 2.2
// Defined in Utility.frag.
//float Luminance(vec3 rgb);
// Defined in BFRES_Utility.frag.
vec3 CalcBumpedNormal(vec3 normal, sampler2D normalMap, VertexAttributes vert, float texCoordIndex);
//float AmbientOcclusionBlend(sampler2D BakeShadowMap, VertexAttributes vert, float ao_density);
//vec3 EmissionPass(sampler2D EmissionMap, float emission_intensity, VertexAttributes vert, float texCoordIndex, vec3 emission_color);
vec2 displayTexCoord = f_texcoord0;
void main()
{
fragColor = vec4(vec3(0), 1);
// Create a struct for passing all the vertex attributes to other functions.
VertexAttributes vert;
vert.objectPosition = objectPosition;
vert.texCoord = f_texcoord0;
vert.texCoord2 = f_texcoord1;
vert.texCoord3 = f_texcoord2;
vert.vertexColor = vertexColor;
vert.normal = normal;
vert.viewNormal = viewNormal;
vert.tangent = tangent;
vert.bitangent = bitangent;
// Wireframe color.
if (colorOverride == 1)
{
if (renderVertColor == 1)
fragColor = vec4(vertexColor);
else
fragColor = vec4(1);
return;
}
vec3 N = normal;
if (HasNormalMap == 1 && useNormalMap == 1)
N = CalcBumpedNormal(normal, NormalMap, vert, uking_texture2_texcoord);
if (renderType == 1) // normals vertexColor
{
vec3 displayNormal = (N * 0.5) + 0.5;
fragColor = vec4(displayNormal,1);
}
else if (renderType == 2) // Lighting
{
float halfLambert = dot(difLightDirection, N) * 0.5 + 0.5;
fragColor = vec4(vec3(halfLambert), 1);
}
else if (renderType == 4) //Display Normal
{
if (uking_texture2_texcoord == 1)
fragColor.rgb = texture(NormalMap, f_texcoord1).rgb;
else
fragColor.rgb = texture(NormalMap, displayTexCoord).rgb;
}
else if (renderType == 3) //DiffuseColor
fragColor = vec4(texture(DiffuseMap, displayTexCoord).rgb, 1);
else if (renderType == 5) // vertexColor
fragColor = vertexColor;
else if (renderType == 6) //Display Ambient Occlusion
{
if (HasShadowMap == 1)
{
float Shadow = texture(BakeShadowMap, f_texcoord1).r;
fragColor = vec4(vec3(Shadow), 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 7) // uv coords
fragColor = vec4(displayTexCoord.x, displayTexCoord.y, 1, 1);
else if (renderType == 8) // uv test pattern
{
fragColor = vec4(texture(UVTestPattern, displayTexCoord).rgb, 1);
}
else if (renderType == 9) //Display tangents
{
vec3 displayTangent = (tangent * 0.5) + 0.5;
if (dot(tangent, vec3(1)) == 0)
displayTangent = vec3(0);
fragColor = vec4(displayTangent,1);
}
else if (renderType == 10) //Display bitangents
{
vec3 displayBitangent = (bitangent * 0.5) + 0.5;
if (dot(bitangent, vec3(1)) == 0)
displayBitangent = vec3(0);
fragColor = vec4(displayBitangent,1);
}
else if (renderType == 12)
{
fragColor.rgb = boneWeightsColored;
}
else if (renderType == 11) //Light map
{
if (HasLightMap == 1)
{
vec4 lightMap = texture(BakeLightMap, f_texcoord2);
fragColor = vec4(lightMap.rgb, 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 13) //Specular
{
if (HasSpecularMap == 1)
{
vec3 Specular = texture(SpecularMap, f_texcoord0).rrr;
fragColor = vec4(Specular, 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 14) //Shadow
{
if (HasShadowMap == 1)
{
float Shadow = texture(BakeShadowMap, f_texcoord1).g;
fragColor = vec4(vec3(Shadow), 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 15) //MetalnessMap
{
if (HasMetalnessMap == 1)
{
float mtl = texture(MetalnessMap, displayTexCoord).r;
fragColor = vec4(vec3(mtl), 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 16) //RoughnessMap
{
if (HasRoughnessMap == 1)
{
float rgh = texture(RoughnessMap, displayTexCoord).r;
fragColor = vec4(vec3(rgh), 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 17) //SubSurfaceScatteringMap
{
if (HasSubSurfaceScatteringMap == 1)
{
vec3 sss = texture(SubSurfaceScatteringMap, displayTexCoord).rgb;
fragColor = vec4(sss, 1);
}
else
{
fragColor = vec4(1);
}
}
else if (renderType == 18) //EmmissionMap
{
if (HasEmissionMap == 1)
{
vec3 emm = texture(EmissionMap, displayTexCoord).rgb;
fragColor = vec4(emm, 1);
}
else
{
fragColor = vec4(1);
}
}
// Toggles rendering of individual color channels for all render modes.
fragColor.rgb *= vec3(renderR, renderG, renderB);
if (renderR == 1 && renderG == 0 && renderB == 0)
fragColor.rgb = fragColor.rrr;
else if (renderG == 1 && renderR == 0 && renderB == 0)
fragColor.rgb = fragColor.ggg;
else if (renderB == 1 && renderR == 0 && renderG == 0)
fragColor.rgb = fragColor.bbb;
}