From 5887e460e6479a0533456eeecc255d56c5b96256 Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Fri, 16 Aug 2024 11:13:21 -0400 Subject: [PATCH] [Examples] Minor update in EampleBase and PBR example. - Added report output to ExampleBase to log failure reason when render system could not be loaded. - Lowered GLSL version in PBR example from 450 to 410 to make it work on Mac. --- examples/Cpp/ExampleBase/ExampleBase.cpp | 4 +++- examples/Cpp/PBR/Example.Mesh.frag | 2 +- examples/Cpp/PBR/Example.Mesh.vert | 2 +- examples/Cpp/PBR/Example.Sky.frag | 2 +- examples/Cpp/PBR/Example.Sky.vert | 2 +- examples/Cpp/PBR/Example.metal | 4 +++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/Cpp/ExampleBase/ExampleBase.cpp b/examples/Cpp/ExampleBase/ExampleBase.cpp index 87010b5bbd..48f71fc5fa 100644 --- a/examples/Cpp/ExampleBase/ExampleBase.cpp +++ b/examples/Cpp/ExampleBase/ExampleBase.cpp @@ -523,13 +523,15 @@ ExampleBase::ExampleBase(const LLGL::UTF8String& title) } // Create render system + LLGL::Report report; rendererDesc.flags |= g_Config.flags; - renderer = LLGL::RenderSystem::Load(rendererDesc); + renderer = LLGL::RenderSystem::Load(rendererDesc, &report); // Fallback to null device if selected renderer cannot be loaded if (!renderer) { LLGL::Log::Errorf("Failed to load \"%s\" module. Falling back to \"Null\" device.\n", rendererDesc.moduleName.c_str()); + LLGL::Log::Errorf("Reason for failure: %s", report.HasErrors() ? report.GetText() : "Unknown\n"); renderer = LLGL::RenderSystem::Load("Null"); if (!renderer) { diff --git a/examples/Cpp/PBR/Example.Mesh.frag b/examples/Cpp/PBR/Example.Mesh.frag index ccd5b4a5ba..b7bd7e2512 100644 --- a/examples/Cpp/PBR/Example.Mesh.frag +++ b/examples/Cpp/PBR/Example.Mesh.frag @@ -1,6 +1,6 @@ // PBR GLSL Mesh Fragment Shader -#version 450 core +#version 410 core #define M_PI 3.141592654 diff --git a/examples/Cpp/PBR/Example.Mesh.vert b/examples/Cpp/PBR/Example.Mesh.vert index 0d336444a2..517c0c62de 100644 --- a/examples/Cpp/PBR/Example.Mesh.vert +++ b/examples/Cpp/PBR/Example.Mesh.vert @@ -1,6 +1,6 @@ // PBR GLSL Mesh Vertex Shader -#version 450 core +#version 410 core uniform Settings { diff --git a/examples/Cpp/PBR/Example.Sky.frag b/examples/Cpp/PBR/Example.Sky.frag index f59171b483..5e554608e8 100644 --- a/examples/Cpp/PBR/Example.Sky.frag +++ b/examples/Cpp/PBR/Example.Sky.frag @@ -1,6 +1,6 @@ // PBR GLSL Skybox Fragment Shader -#version 450 core +#version 410 core uniform Settings { diff --git a/examples/Cpp/PBR/Example.Sky.vert b/examples/Cpp/PBR/Example.Sky.vert index d98f5cd3ca..d5a73ff223 100644 --- a/examples/Cpp/PBR/Example.Sky.vert +++ b/examples/Cpp/PBR/Example.Sky.vert @@ -1,6 +1,6 @@ // PBR GLSL Skybox Vertex Shader -#version 450 core +#version 410 core uniform Settings { diff --git a/examples/Cpp/PBR/Example.metal b/examples/Cpp/PBR/Example.metal index a26af75e52..ae0cb8aed7 100644 --- a/examples/Cpp/PBR/Example.metal +++ b/examples/Cpp/PBR/Example.metal @@ -189,7 +189,9 @@ float3 BRDF( float3 color = (diffuse + specular) * NdotL; - //color += SampleEnvironment(envMap, envMapLayer, smpl, roughness, reflection) * 0.2; + // Sample incoming light from environment map + float3 reflection = -normalize(reflect(viewDir, normal)); + color += SampleEnvironment(envMap, envMapLayer, smpl, roughness, reflection) * 0.2; return color; }