diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index f7980e15..03b56d8e 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 63c4ead7..4cef924e 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 15196192..66eb8557 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/GL/BFRES_Render.cs b/Switch_FileFormatsMain/GL/BFRES_Render.cs index ff3dc3e1..2a0085e3 100644 --- a/Switch_FileFormatsMain/GL/BFRES_Render.cs +++ b/Switch_FileFormatsMain/GL/BFRES_Render.cs @@ -166,7 +166,7 @@ namespace FirstPlugin normalsShaderProgram = new ShaderProgram(new Shader[] { normalsFrag, normalsVert, normalsGeom }); debugShaderProgram = new ShaderProgram(new Shader[] { bfresUtiltyFrag, utiltyFrag, debugFrag, defaultVert, utiltyFrag, shadowMapAGL }); - pbrShaderProgram = new ShaderProgram(new Shader[] { bfresUtiltyFrag, utiltyFrag, PbrFrag, defaultVert }); + pbrShaderProgram = new ShaderProgram(new Shader[] { bfresUtiltyFrag, utiltyFrag, PbrFrag, defaultVert, shadowMapAGL }); solidColorShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert); } diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll index b4d3c689..0faaa3ab 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb index a9c04344..677bf09f 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index b4f16abf..6593dba1 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/Toolbox/GUI/Settings.cs b/Toolbox/GUI/Settings.cs index 9712ecf1..05e6034d 100644 --- a/Toolbox/GUI/Settings.cs +++ b/Toolbox/GUI/Settings.cs @@ -105,13 +105,13 @@ namespace Toolbox private void camMoveComboBox_SelectedIndexChanged(object sender, EventArgs e) { Runtime.cameraMovement = (Runtime.CameraMovement)camMoveComboBox.SelectedIndex; - UpdateViewportSettings(); + UpdateViewportSettings(true); } private void checkBox1_CheckedChanged_1(object sender, EventArgs e) { Runtime.stereoscopy = chkBoxStereoscopy.Checked; - UpdateViewportSettings(); + UpdateViewportSettings(true); } private void camNearNumUD_ValueChanged(object sender, EventArgs e) { @@ -165,7 +165,7 @@ namespace Toolbox UpdateViewportSettings(); } - private void UpdateViewportSettings() + private void UpdateViewportSettings(bool UpdateRuntimeValues = false) { if (IsStartup) return; @@ -174,7 +174,9 @@ namespace Toolbox if (viewport == null) return; - viewport.LoadViewportRuntimeValues(); + if (UpdateRuntimeValues) //Update only if necessary since it can be slow + viewport.LoadViewportRuntimeValues(); + viewport.UpdateViewport(); } diff --git a/Toolbox/Shader/Bfres/BFRESTurboShadow.frag b/Toolbox/Shader/Bfres/BFRESTurboShadow.frag index 2e2e1193..c5ea0886 100644 --- a/Toolbox/Shader/Bfres/BFRESTurboShadow.frag +++ b/Toolbox/Shader/Bfres/BFRESTurboShadow.frag @@ -30,13 +30,14 @@ struct BakedData BakedData ShadowMapBaked(sampler2D ShadowMap, sampler2D LightMap, vec2 texCoordBake0, vec2 texCoordBake1, int ShadowType, int LightType, int CalcType, vec3 NormalMap) { BakedData bake0; + bake0.indirectLighting = vec3(0); + if (CalcType != -1) { vec4 bakeTex0 = texture(ShadowMap, texCoordBake0); if (CalcType == 0 || CalcType == 1) { - bake0.indirectLighting = gsys_bake_light_scale * bakeTex0.rgb; } } else diff --git a/Toolbox/Shader/Bfres/BFRES_PBR.frag b/Toolbox/Shader/Bfres/BFRES_PBR.frag index 86245942..af46cadc 100644 --- a/Toolbox/Shader/Bfres/BFRES_PBR.frag +++ b/Toolbox/Shader/Bfres/BFRES_PBR.frag @@ -91,6 +91,9 @@ uniform float enable_fresnel; uniform float enable_emission; uniform float cSpecularType; +// Shader Options +uniform float bake_light_type; +uniform float bake_calc_type; // Texture Map Toggles uniform int HasDiffuse; @@ -134,7 +137,17 @@ out vec4 fragColor; #define gamma 2.2 const float PI = 3.14159265359; +struct BakedData +{ + float shadowIntensity; + float aoIntensity; + vec3 indirectLighting; +}; + // Defined in BFRES_Utility.frag. + +BakedData ShadowMapBaked(sampler2D ShadowMap, sampler2D LightMap, vec2 texCoordBake0, vec2 texCoordBake1, int ShadowType, int LightType, int CalcType, vec3 NormalMap); + 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); @@ -281,6 +294,15 @@ void main() vec3 kD = 1.0 - kS; kD *= 1.0 - metallic; + BakedData ShadowBake = ShadowMapBaked(BakeShadowMap,BakeLightMap, f_texcoord1, f_texcoord2, int(bake_shadow_type),int(bake_light_type), int(bake_calc_type), N ); + + vec3 LightingDiffuse = vec3(0); + if (HasLightMap == 1) + { + vec3 LightIntensity = vec3(0.1); + LightingDiffuse += ShadowBake.indirectLighting.rgb * LightIntensity; + } + // Diffuse pass vec3 diffuseIblColor = texture(irradianceMap, N).rgb; vec3 diffuseTerm = diffuseIblColor * albedo; @@ -288,6 +310,7 @@ void main() diffuseTerm *= cavity; diffuseTerm *= ao; diffuseTerm *= shadow; + diffuseTerm += LightingDiffuse; // Adjust for metalness. // diffuseTerm *= clamp(1 - metallic, 0, 1);