From 759d976c997a180f4fecee4f79b909c0e950d0a2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jan 2025 11:14:42 +0000 Subject: [PATCH 01/19] Removed conversion to sRGB in final colour written out. --- data/shaders/standard_pbr.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/shaders/standard_pbr.frag b/data/shaders/standard_pbr.frag index f6f803ee..b8e8c628 100644 --- a/data/shaders/standard_pbr.frag +++ b/data/shaders/standard_pbr.frag @@ -552,5 +552,5 @@ void main() } } - outColor = LINEARtoSRGB(vec4(color, baseColor.a)); + outColor = vec4(color, baseColor.a); } From b3a7922798a3ee186f00e53a7e4934719de86c69 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jan 2025 12:39:45 +0000 Subject: [PATCH 02/19] Added SRGB conversions. --- data/shaders/standard_flat_shaded.frag | 17 +++++++++++++++-- data/shaders/standard_pbr.frag | 3 +-- data/shaders/standard_phong.frag | 17 +++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/data/shaders/standard_flat_shaded.frag b/data/shaders/standard_flat_shaded.frag index 8a14ce82..4f23563b 100644 --- a/data/shaders/standard_flat_shaded.frag +++ b/data/shaders/standard_flat_shaded.frag @@ -31,6 +31,19 @@ layout(location = 3) in vec2 texCoord0; layout(location = 0) out vec4 outColor; + +vec4 SRGBtoLINEAR(vec4 srgbIn) +{ + vec3 linOut = pow(srgbIn.xyz, vec3(2.2)); + return vec4(linOut,srgbIn.w); +} + +vec4 LINEARtoSRGB(vec4 srgbIn) +{ + vec3 linOut = pow(srgbIn.xyz, vec3(1.0 / 2.2)); + return vec4(linOut, srgbIn.w); +} + void main() { #ifdef VSG_POINT_SPRITE @@ -44,12 +57,12 @@ void main() float v = texture(diffuseMap, texCoord0.st).s; diffuseColor *= vec4(v, v, v, 1.0); #else - diffuseColor *= texture(diffuseMap, texCoord0.st); + diffuseColor *= SRGBtoLINEAR(texture(diffuseMap, texCoord0.st)); #endif #endif #ifdef VSG_DETAIL_MAP - vec4 detailColor = texture(detailMap, texCoord0.st); + vec4 detailColor = SRGBtoLINEAR(texture(detailMap, texCoord0.st)); diffuseColor.rgb = mix(diffuseColor.rgb, detailColor.rgb, detailColor.a); #endif diff --git a/data/shaders/standard_pbr.frag b/data/shaders/standard_pbr.frag index b8e8c628..5d167a28 100644 --- a/data/shaders/standard_pbr.frag +++ b/data/shaders/standard_pbr.frag @@ -90,7 +90,6 @@ struct PBRInfo vec3 specularColor; // color contribution from specular lighting }; - vec4 SRGBtoLINEAR(vec4 srgbIn) { vec3 linOut = pow(srgbIn.xyz, vec3(2.2)); @@ -341,7 +340,7 @@ void main() #ifdef VSG_DETAIL_MAP - vec4 detailColor = texture(detailMap, texCoord0.st); + vec4 detailColor = SRGBtoLINEAR(texture(detailMap, texCoord0.st)); baseColor.rgb = mix(baseColor.rgb, detailColor.rgb, detailColor.a); #endif diff --git a/data/shaders/standard_phong.frag b/data/shaders/standard_phong.frag index d6a89114..5bc18027 100644 --- a/data/shaders/standard_phong.frag +++ b/data/shaders/standard_phong.frag @@ -61,6 +61,19 @@ layout(location = 5) in vec3 viewDir; layout(location = 0) out vec4 outColor; + +vec4 SRGBtoLINEAR(vec4 srgbIn) +{ + vec3 linOut = pow(srgbIn.xyz, vec3(2.2)); + return vec4(linOut,srgbIn.w); +} + +vec4 LINEARtoSRGB(vec4 srgbIn) +{ + vec3 linOut = pow(srgbIn.xyz, vec3(1.0 / 2.2)); + return vec4(linOut, srgbIn.w); +} + // include the calculateShadowCoverageForDirectionalLight(..) implementation #include "shadows.glsl" @@ -131,12 +144,12 @@ void main() float v = texture(diffuseMap, texCoord0.st).s; diffuseColor *= vec4(v, v, v, 1.0); #else - diffuseColor *= texture(diffuseMap, texCoord0.st); + diffuseColor *= SRGBtoLINEAR(texture(diffuseMap, texCoord0.st)); #endif #endif #ifdef VSG_DETAIL_MAP - vec4 detailColor = texture(detailMap, texCoord0.st); + vec4 detailColor = SRGBtoLINEAR(texture(detailMap, texCoord0.st)); diffuseColor.rgb = mix(diffuseColor.rgb, detailColor.rgb, detailColor.a); #endif From 65c505ea1c4959e2d0f0014e52e5c8b9ec43f825 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jan 2025 12:49:49 +0000 Subject: [PATCH 03/19] Updated clear colours to use sRGB to linear conversion. --- examples/nodes/vsgtiledatabase/vsgtiledatabase.cpp | 5 ++--- examples/text/vsgtext/vsgtext.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/nodes/vsgtiledatabase/vsgtiledatabase.cpp b/examples/nodes/vsgtiledatabase/vsgtiledatabase.cpp index 2862751c..5ce16e9d 100644 --- a/examples/nodes/vsgtiledatabase/vsgtiledatabase.cpp +++ b/examples/nodes/vsgtiledatabase/vsgtiledatabase.cpp @@ -45,8 +45,7 @@ int main(int argc, char** argv) arguments.read("--file-cache", options->fileCache); bool osgEarthStyleMouseButtons = arguments.read({"--osgearth", "-e"}); - VkClearColorValue clearColor{{0.2f, 0.2f, 0.4f, 1.0f}}; - arguments.read({"--bc", "--background-color"}, clearColor.float32[0], clearColor.float32[1], clearColor.float32[2], clearColor.float32[3]); + auto clearColor = arguments.value(vsg::vec4(0.2f, 0.2f, 0.4f, 1.0f), "--clear"); uint32_t numOperationThreads = 0; if (arguments.read("--ot", numOperationThreads)) options->operationThreads = vsg::OperationThreads::create(numOperationThreads); @@ -266,7 +265,7 @@ int main(int argc, char** argv) } auto rendergraph = vsg::createRenderGraphForView(window, camera, vsg_scene); - rendergraph->setClearValues(clearColor); + rendergraph->setClearValues(vsg::sRGB_to_linear(clearColor)); auto commandGraph = vsg::CommandGraph::create(window, rendergraph); viewer->assignRecordAndSubmitTaskAndPresentation({commandGraph}); diff --git a/examples/text/vsgtext/vsgtext.cpp b/examples/text/vsgtext/vsgtext.cpp index 6e41d192..52556266 100644 --- a/examples/text/vsgtext/vsgtext.cpp +++ b/examples/text/vsgtext/vsgtext.cpp @@ -569,7 +569,7 @@ int main(int argc, char** argv) return 1; } - window->clearColor() = VkClearColorValue{{clearColor.r, clearColor.g, clearColor.b, clearColor.a}}; + window->clearColor() = vsg::sRGB_to_linear(clearColor); viewer->addWindow(window); From 3056353e4af2e8b88342e6239bb34f0cc30bdc43 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jan 2025 12:54:07 +0000 Subject: [PATCH 04/19] Converted texture formats from linear RGBA to sRGBA --- data/models/lz.vsgt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/models/lz.vsgt b/data/models/lz.vsgt index 3e3396a2..cb151a77 100644 --- a/data/models/lz.vsgt +++ b/data/models/lz.vsgt @@ -615,7 +615,7 @@ void main() image id=31 vsg::ubvec4Array2D { userObjects 0 - properties 37 4 1 1 1 1 2 -1 0 + properties 43 4 1 1 1 1 2 -1 0 width 128 height 128 storage id=0 @@ -14238,7 +14238,7 @@ void main() image id=825 vsg::ubvec4Array2D { userObjects 0 - properties 37 4 1 1 1 1 2 -1 0 + properties 43 4 1 1 1 1 2 -1 0 width 256 height 256 storage id=0 @@ -36657,7 +36657,7 @@ void main() image id=851 vsg::ubvec4Array2D { userObjects 0 - properties 37 4 1 1 1 1 2 -1 0 + properties 43 4 1 1 1 1 2 -1 0 width 64 height 64 storage id=0 From 98df6264c626a7ae707cd909a3bc9d019e2e7ec1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jan 2025 13:27:39 +0000 Subject: [PATCH 05/19] Added sRGB_to_linear conversions. --- examples/platform/vsgwin32/vsgwin32.cpp | 2 +- examples/text/vsgtextgroup/vsgtextgroup.cpp | 2 +- examples/threading/vsgdynamicviews/vsgdynamicviews.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/platform/vsgwin32/vsgwin32.cpp b/examples/platform/vsgwin32/vsgwin32.cpp index 6caaf5e0..d0790484 100644 --- a/examples/platform/vsgwin32/vsgwin32.cpp +++ b/examples/platform/vsgwin32/vsgwin32.cpp @@ -62,7 +62,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, i // register the vsgWin32::Win32_Window object so that we can have events processed by the VSG event handler SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(window.get())); - window->clearColor() = VkClearColorValue{{0.2f, 0.2f, 0.2f, 0}}; + window->clearColor() = vsg::sRGB_to_linear(vsg::vec4{0.2f, 0.2f, 0.2f, 1.0f}); auto viewer = vsg::Viewer::create(); viewer->addWindow(window); diff --git a/examples/text/vsgtextgroup/vsgtextgroup.cpp b/examples/text/vsgtextgroup/vsgtextgroup.cpp index 30330a57..07db353c 100644 --- a/examples/text/vsgtextgroup/vsgtextgroup.cpp +++ b/examples/text/vsgtextgroup/vsgtextgroup.cpp @@ -326,7 +326,7 @@ int main(int argc, char** argv) return 1; } - window->clearColor() = VkClearColorValue{{clearColor.r, clearColor.g, clearColor.b, clearColor.a}}; + window->clearColor() = vsg::sRGB_to_linear(clearColor); viewer->addWindow(window); diff --git a/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp b/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp index 4e9fd56d..072fcc5a 100644 --- a/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp +++ b/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp @@ -92,7 +92,7 @@ struct LoadViewOperation : public vsg::InheritaddChild(vsg::createHeadlight()); auto renderGraph = vsg::RenderGraph::create(ref_window, view); - renderGraph->setClearValues({{0.2f, 0.2f, 0.2f, 1.0f}}); + renderGraph->setClearValues(vsg::sRGB_to_linear(vsg::vec4{0.2f, 0.2f, 0.2f, 1.0f})); // need to add view to compileManager ref_viewer->compileManager->add(*ref_window, view); From 0d2051f49bf3634e16c8f1c374e4c0442cfdf7e6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 17 Jan 2025 11:02:51 +0000 Subject: [PATCH 06/19] Updated to use sRGB colour conversion. --- examples/nodes/vsgcoordinateframe/vsgcoordinateframe.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/nodes/vsgcoordinateframe/vsgcoordinateframe.cpp b/examples/nodes/vsgcoordinateframe/vsgcoordinateframe.cpp index bb8fcf07..4cfaf990 100644 --- a/examples/nodes/vsgcoordinateframe/vsgcoordinateframe.cpp +++ b/examples/nodes/vsgcoordinateframe/vsgcoordinateframe.cpp @@ -608,7 +608,7 @@ int main(int argc, char** argv) deviceFeatures->get().depthClamp = VK_TRUE; } - VkClearColorValue clearColor{{0.0f, 0.0f, 0.0f, 1.0f}}; + auto clearColor = arguments.value(vsg::vec4(0.0f, 0.0f, 0.0f, 1.0f), "--clear"); bool playAnimations = arguments.read("--play"); @@ -796,8 +796,6 @@ int main(int argc, char** argv) return 1; } - window->clearColor().set(0.0f, 0.0f, 0.0f, 1.0f); - viewer->addWindow(window); // compute the bounds of the scene graph to help position camera @@ -906,7 +904,7 @@ int main(int argc, char** argv) } auto renderGraph = vsg::createRenderGraphForView(window, camera, universe, VK_SUBPASS_CONTENTS_INLINE, false); - renderGraph->setClearValues(clearColor); + renderGraph->setClearValues(vsg::sRGB_to_linear(clearColor)); auto commandGraph = vsg::CommandGraph::create(window, renderGraph); From 4c1a855dc300aebb2ddb1709ae612ca50a526e3c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 17 Jan 2025 11:18:36 +0000 Subject: [PATCH 07/19] Updated shaders to not do any sRGB to Linear conversions, leaving this to the texture samplers based on the image format. --- data/shaders/standard_flat_shaded.frag | 17 ++--------------- data/shaders/standard_pbr.frag | 22 +++++----------------- data/shaders/standard_phong.frag | 17 ++--------------- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/data/shaders/standard_flat_shaded.frag b/data/shaders/standard_flat_shaded.frag index 4f23563b..8a14ce82 100644 --- a/data/shaders/standard_flat_shaded.frag +++ b/data/shaders/standard_flat_shaded.frag @@ -31,19 +31,6 @@ layout(location = 3) in vec2 texCoord0; layout(location = 0) out vec4 outColor; - -vec4 SRGBtoLINEAR(vec4 srgbIn) -{ - vec3 linOut = pow(srgbIn.xyz, vec3(2.2)); - return vec4(linOut,srgbIn.w); -} - -vec4 LINEARtoSRGB(vec4 srgbIn) -{ - vec3 linOut = pow(srgbIn.xyz, vec3(1.0 / 2.2)); - return vec4(linOut, srgbIn.w); -} - void main() { #ifdef VSG_POINT_SPRITE @@ -57,12 +44,12 @@ void main() float v = texture(diffuseMap, texCoord0.st).s; diffuseColor *= vec4(v, v, v, 1.0); #else - diffuseColor *= SRGBtoLINEAR(texture(diffuseMap, texCoord0.st)); + diffuseColor *= texture(diffuseMap, texCoord0.st); #endif #endif #ifdef VSG_DETAIL_MAP - vec4 detailColor = SRGBtoLINEAR(texture(detailMap, texCoord0.st)); + vec4 detailColor = texture(detailMap, texCoord0.st); diffuseColor.rgb = mix(diffuseColor.rgb, detailColor.rgb, detailColor.a); #endif diff --git a/data/shaders/standard_pbr.frag b/data/shaders/standard_pbr.frag index 5d167a28..308b9674 100644 --- a/data/shaders/standard_pbr.frag +++ b/data/shaders/standard_pbr.frag @@ -90,18 +90,6 @@ struct PBRInfo vec3 specularColor; // color contribution from specular lighting }; -vec4 SRGBtoLINEAR(vec4 srgbIn) -{ - vec3 linOut = pow(srgbIn.xyz, vec3(2.2)); - return vec4(linOut,srgbIn.w); -} - -vec4 LINEARtoSRGB(vec4 srgbIn) -{ - vec3 linOut = pow(srgbIn.xyz, vec3(1.0 / 2.2)); - return vec4(linOut, srgbIn.w); -} - float rcp(const in float value) { return 1.0 / value; @@ -288,7 +276,7 @@ vec3 BRDF(vec3 u_LightColor, vec3 v, vec3 n, vec3 l, vec3 h, float perceptualRou color *= ao; #ifdef VSG_EMISSIVE_MAP - vec3 emissive = SRGBtoLINEAR(texture(emissiveMap, texCoord0)).rgb * pbr.emissiveFactor.rgb; + vec3 emissive = texture(emissiveMap, texCoord0).rgb * pbr.emissiveFactor.rgb; #else vec3 emissive = pbr.emissiveFactor.rgb; #endif @@ -332,7 +320,7 @@ void main() float v = texture(diffuseMap, texCoord0.st).s * pbr.baseColorFactor; baseColor = vertexColor * vec4(v, v, v, 1.0); #else - baseColor = vertexColor * SRGBtoLINEAR(texture(diffuseMap, texCoord0)) * pbr.baseColorFactor; + baseColor = vertexColor * texture(diffuseMap, texCoord0) * pbr.baseColorFactor; #endif #else baseColor = vertexColor * pbr.baseColorFactor; @@ -340,7 +328,7 @@ void main() #ifdef VSG_DETAIL_MAP - vec4 detailColor = SRGBtoLINEAR(texture(detailMap, texCoord0.st)); + vec4 detailColor = texture(detailMap, texCoord0.st); baseColor.rgb = mix(baseColor.rgb, detailColor.rgb, detailColor.a); #endif @@ -351,14 +339,14 @@ void main() #ifdef VSG_WORKFLOW_SPECGLOSS #ifdef VSG_DIFFUSE_MAP - vec4 diffuse = SRGBtoLINEAR(texture(diffuseMap, texCoord0)); + vec4 diffuse = texture(diffuseMap, texCoord0); #else vec4 diffuse = vec4(1.0); #endif #ifdef VSG_SPECULAR_MAP vec4 specular_texel = texture(specularMap, texCoord0); - vec3 specular = SRGBtoLINEAR(specular_texel).rgb; + vec3 specular = specular_texel.rgb; perceptualRoughness = 1.0 - specular_texel.a; #else vec3 specular = vec3(0.0); diff --git a/data/shaders/standard_phong.frag b/data/shaders/standard_phong.frag index 5bc18027..d6a89114 100644 --- a/data/shaders/standard_phong.frag +++ b/data/shaders/standard_phong.frag @@ -61,19 +61,6 @@ layout(location = 5) in vec3 viewDir; layout(location = 0) out vec4 outColor; - -vec4 SRGBtoLINEAR(vec4 srgbIn) -{ - vec3 linOut = pow(srgbIn.xyz, vec3(2.2)); - return vec4(linOut,srgbIn.w); -} - -vec4 LINEARtoSRGB(vec4 srgbIn) -{ - vec3 linOut = pow(srgbIn.xyz, vec3(1.0 / 2.2)); - return vec4(linOut, srgbIn.w); -} - // include the calculateShadowCoverageForDirectionalLight(..) implementation #include "shadows.glsl" @@ -144,12 +131,12 @@ void main() float v = texture(diffuseMap, texCoord0.st).s; diffuseColor *= vec4(v, v, v, 1.0); #else - diffuseColor *= SRGBtoLINEAR(texture(diffuseMap, texCoord0.st)); + diffuseColor *= texture(diffuseMap, texCoord0.st); #endif #endif #ifdef VSG_DETAIL_MAP - vec4 detailColor = SRGBtoLINEAR(texture(detailMap, texCoord0.st)); + vec4 detailColor = texture(detailMap, texCoord0.st); diffuseColor.rgb = mix(diffuseColor.rgb, detailColor.rgb, detailColor.a); #endif From dfaf0b7e8cfaf9564dda3dcbccb31a206224bc23 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 17 Jan 2025 16:07:01 +0000 Subject: [PATCH 08/19] Bumped version to 1.1.8 for Color Space work. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad078ca5..b245e1a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7) project(vsgExamples - VERSION 1.1.7 + VERSION 1.1.8 DESCRIPTION "Set of example programs that test and illustrate how to use the VulkanSceneGraph" LANGUAGES CXX C ) @@ -21,13 +21,13 @@ if (VULKAN_SDK) set(ENV{VULKAN_SDK} ${VULKAN_SDK}) endif() -find_package(vsg 1.1.9) +find_package(vsg 1.1.10) vsg_setup_dir_vars() vsg_setup_build_vars() # find the optional vsgXchange that can be used for reading a range of image and 3d model formats and shader compilation -find_package(vsgXchange 1.0.5 QUIET) +find_package(vsgXchange 1.1.6 QUIET) # find the optional vsgImGui that can be used for GUI elements added into graphics windows. find_package(vsgImGui QUIET) From 6c53cb2dc7e475611b040037d0ceff519805e806 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 20 Jan 2025 14:51:57 +0000 Subject: [PATCH 09/19] Revised lighting to better fit with sRGB framebuffer. --- data/models/teapot.vsgt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/models/teapot.vsgt b/data/models/teapot.vsgt index ae8416f3..38b68d25 100644 --- a/data/models/teapot.vsgt +++ b/data/models/teapot.vsgt @@ -5839,7 +5839,7 @@ void main() { userObjects 0 properties 0 0 0 1 1 1 0 -1 0 - value 1 0.929412 0.137255 1 + value 1 0.846874 0.0168074 1 } } } From 76dda4541c76c578dd4d8e90f2dc0d82c2d78d51 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 20 Jan 2025 15:07:27 +0000 Subject: [PATCH 10/19] Updated format to sRGB. --- data/textures/lz.vsgb | Bin 262213 -> 262214 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/data/textures/lz.vsgb b/data/textures/lz.vsgb index 388f14efc6ae0b41a541975f622f003cc9cce310..54524ed8248d87a408554793c8e422f464b9490d 100644 GIT binary patch delta 39 tcmX@wAaJZffJeEkI6X Date: Mon, 20 Jan 2025 17:27:32 +0000 Subject: [PATCH 11/19] Fixed shader and default skybox image filename. --- examples/app/vsgskybox/skybox.h | 12 ++++++------ examples/app/vsgskybox/vsgskybox.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/app/vsgskybox/skybox.h b/examples/app/vsgskybox/skybox.h index 2fda4a18..8e62309e 100644 --- a/examples/app/vsgskybox/skybox.h +++ b/examples/app/vsgskybox/skybox.h @@ -9,20 +9,20 @@ layout(push_constant) uniform PushConstants { mat4 modelView; } pc; -layout(location = 0) in vec3 osg_Vertex; -layout(location = 0) out vec3 outUVW; +layout(location = 0) in vec3 vsg_Vertex; +layout(location = 0) out vec3 UVW; out gl_PerVertex{ vec4 gl_Position; }; void main() { - outUVW = osg_Vertex; + UVW = vsg_Vertex; // Remove translation mat4 modelView = pc.modelView; modelView[3] = vec4(0.0, 0.0, 0.0, 1.0); - vec4 pos = pc.projection * modelView * vec4(osg_Vertex, 1.0); + vec4 pos = pc.projection * modelView * vec4(vsg_Vertex, 1.0); gl_Position = vec4(pos.xy, 0.0, pos.w); } )"; @@ -32,11 +32,11 @@ const auto skybox_frag = R"( #extension GL_ARB_separate_shader_objects : enable layout(binding = 0) uniform samplerCube envMap; -layout(location = 0) in vec3 inUVW; +layout(location = 0) in vec3 UVW; layout(location = 0) out vec4 outColor; void main() { - outColor = textureLod(envMap, inUVW, 0); + outColor = textureLod(envMap, UVW, 0); } )"; diff --git a/examples/app/vsgskybox/vsgskybox.cpp b/examples/app/vsgskybox/vsgskybox.cpp index 8a636237..51f5bd63 100644 --- a/examples/app/vsgskybox/vsgskybox.cpp +++ b/examples/app/vsgskybox/vsgskybox.cpp @@ -188,7 +188,7 @@ int main(int argc, char** argv) arguments.read("--samples", windowTraits->samples); auto numFrames = arguments.value(-1, "-f"); auto horizonMountainHeight = arguments.value(0.0, "--hmh"); - auto skyboxFilename = arguments.value("", "--skybox"); + auto skyboxFilename = arguments.value("textures/skybox.dds", "--skybox"); auto outputFilename = arguments.value("", "-o"); if (arguments.errors()) return arguments.writeErrorMessages(std::cerr); From 5c6cf21e328b9c6ff389d13a7fd4074cfa69602f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 21 Jan 2025 13:16:30 +0000 Subject: [PATCH 12/19] Added CoordinateSpace specifier. --- examples/utils/vsgshaderset/pbr.cpp | 4 ++-- examples/utils/vsgshaderset/phong.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/utils/vsgshaderset/pbr.cpp b/examples/utils/vsgshaderset/pbr.cpp index e8004a1d..2030d118 100644 --- a/examples/utils/vsgshaderset/pbr.cpp +++ b/examples/utils/vsgshaderset/pbr.cpp @@ -49,13 +49,13 @@ vsg::ref_ptr pbr_ShaderSet(vsg::ref_ptr opti shaderSet->addDescriptorBinding("diffuseMap", "VSG_DIFFUSE_MAP", MATERIAL_DESCRIPTOR_SET, 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("detailMap", "VSG_DETAIL_MAP", MATERIAL_DESCRIPTOR_SET, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); - shaderSet->addDescriptorBinding("normalMap", "VSG_NORMAL_MAP", MATERIAL_DESCRIPTOR_SET, 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec3Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32B32_SFLOAT})); + shaderSet->addDescriptorBinding("normalMap", "VSG_NORMAL_MAP", MATERIAL_DESCRIPTOR_SET, 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec3Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32B32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("aoMap", "VSG_LIGHTMAP_MAP", MATERIAL_DESCRIPTOR_SET, 3, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("specularMap", "VSG_SPECULAR_MAP", MATERIAL_DESCRIPTOR_SET, 5, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("mrMap", "VSG_METALLROUGHNESS_MAP", MATERIAL_DESCRIPTOR_SET, 6, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec2Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32_SFLOAT})); - shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); + shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PbrMaterialValue::create()); diff --git a/examples/utils/vsgshaderset/phong.cpp b/examples/utils/vsgshaderset/phong.cpp index f3dd7fd7..46059e1c 100644 --- a/examples/utils/vsgshaderset/phong.cpp +++ b/examples/utils/vsgshaderset/phong.cpp @@ -50,8 +50,8 @@ vsg::ref_ptr phong_ShaderSet(vsg::ref_ptr op shaderSet->addDescriptorBinding("detailMap", "VSG_DETAIL_MAP", MATERIAL_DESCRIPTOR_SET, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("normalMap", "VSG_NORMAL_MAP", MATERIAL_DESCRIPTOR_SET, 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec3Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32B32_SFLOAT})); shaderSet->addDescriptorBinding("aoMap", "VSG_LIGHTMAP_MAP", MATERIAL_DESCRIPTOR_SET, 3, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); - shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); - shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); + shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM}), vsg::CoordinateSpace::LINEAR); + shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PhongMaterialValue::create()); From 090a7e2fcc14234f54246aa461adf030b6dd553c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 21 Jan 2025 14:41:18 +0000 Subject: [PATCH 13/19] Fixed the CoordinateSpace settings --- examples/utils/vsgshaderset/pbr.cpp | 2 +- examples/utils/vsgshaderset/phong.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/utils/vsgshaderset/pbr.cpp b/examples/utils/vsgshaderset/pbr.cpp index 2030d118..f9438a0c 100644 --- a/examples/utils/vsgshaderset/pbr.cpp +++ b/examples/utils/vsgshaderset/pbr.cpp @@ -53,7 +53,7 @@ vsg::ref_ptr pbr_ShaderSet(vsg::ref_ptr opti shaderSet->addDescriptorBinding("aoMap", "VSG_LIGHTMAP_MAP", MATERIAL_DESCRIPTOR_SET, 3, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("specularMap", "VSG_SPECULAR_MAP", MATERIAL_DESCRIPTOR_SET, 5, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); - shaderSet->addDescriptorBinding("mrMap", "VSG_METALLROUGHNESS_MAP", MATERIAL_DESCRIPTOR_SET, 6, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec2Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32_SFLOAT})); + shaderSet->addDescriptorBinding("mrMap", "VSG_METALLROUGHNESS_MAP", MATERIAL_DESCRIPTOR_SET, 6, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec2Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); diff --git a/examples/utils/vsgshaderset/phong.cpp b/examples/utils/vsgshaderset/phong.cpp index 46059e1c..e330a8b4 100644 --- a/examples/utils/vsgshaderset/phong.cpp +++ b/examples/utils/vsgshaderset/phong.cpp @@ -48,9 +48,9 @@ vsg::ref_ptr phong_ShaderSet(vsg::ref_ptr op shaderSet->addDescriptorBinding("diffuseMap", "VSG_DIFFUSE_MAP", MATERIAL_DESCRIPTOR_SET, 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("detailMap", "VSG_DETAIL_MAP", MATERIAL_DESCRIPTOR_SET, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); - shaderSet->addDescriptorBinding("normalMap", "VSG_NORMAL_MAP", MATERIAL_DESCRIPTOR_SET, 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec3Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32B32_SFLOAT})); + shaderSet->addDescriptorBinding("normalMap", "VSG_NORMAL_MAP", MATERIAL_DESCRIPTOR_SET, 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec3Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32B32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("aoMap", "VSG_LIGHTMAP_MAP", MATERIAL_DESCRIPTOR_SET, 3, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); - shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM}), vsg::CoordinateSpace::LINEAR); + shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); From b747d3c0a004073d285331632f8c4b8f1c0201b3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 21 Jan 2025 17:13:18 +0000 Subject: [PATCH 14/19] Added LINEAR hint to material --- examples/utils/vsgshaderset/flat.cpp | 6 ++---- examples/utils/vsgshaderset/pbr.cpp | 2 +- examples/utils/vsgshaderset/phong.cpp | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/utils/vsgshaderset/flat.cpp b/examples/utils/vsgshaderset/flat.cpp index 06e51624..88613214 100644 --- a/examples/utils/vsgshaderset/flat.cpp +++ b/examples/utils/vsgshaderset/flat.cpp @@ -47,8 +47,6 @@ vsg::ref_ptr flat_ShaderSet(vsg::ref_ptr opt shaderSet->addAttributeBinding("vsg_TexCoord0", "", 2, VK_FORMAT_R32G32_SFLOAT, vsg::vec2Array::create(1)); shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); - shaderSet->addAttributeBinding("vsg_DisplacementScale", "VSG_DISPLACEMENT_MAP", 4, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); - shaderSet->addAttributeBinding("vsg_position", "VSG_INSTANCE_POSITIONS", 4, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_position_scaleDistance", "VSG_BILLBOARD", 4, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); @@ -58,10 +56,10 @@ vsg::ref_ptr flat_ShaderSet(vsg::ref_ptr opt shaderSet->addDescriptorBinding("diffuseMap", "VSG_DIFFUSE_MAP", MATERIAL_DESCRIPTOR_SET, 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); shaderSet->addDescriptorBinding("detailMap", "VSG_DETAIL_MAP", MATERIAL_DESCRIPTOR_SET, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::ubvec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); - shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); + shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); - shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PhongMaterialValue::create()); + shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PhongMaterialValue::create(), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("jointMatrices", "VSG_SKINNING", MATERIAL_DESCRIPTOR_SET, 11, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::mat4Value::create()); diff --git a/examples/utils/vsgshaderset/pbr.cpp b/examples/utils/vsgshaderset/pbr.cpp index f9438a0c..9103ebf9 100644 --- a/examples/utils/vsgshaderset/pbr.cpp +++ b/examples/utils/vsgshaderset/pbr.cpp @@ -58,7 +58,7 @@ vsg::ref_ptr pbr_ShaderSet(vsg::ref_ptr opti shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); - shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PbrMaterialValue::create()); + shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PbrMaterialValue::create(), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("jointMatrices", "VSG_SKINNING", MATERIAL_DESCRIPTOR_SET, 11, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::mat4Value::create()); diff --git a/examples/utils/vsgshaderset/phong.cpp b/examples/utils/vsgshaderset/phong.cpp index e330a8b4..ff58bbd4 100644 --- a/examples/utils/vsgshaderset/phong.cpp +++ b/examples/utils/vsgshaderset/phong.cpp @@ -51,10 +51,11 @@ vsg::ref_ptr phong_ShaderSet(vsg::ref_ptr op shaderSet->addDescriptorBinding("normalMap", "VSG_NORMAL_MAP", MATERIAL_DESCRIPTOR_SET, 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec3Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32G32B32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("aoMap", "VSG_LIGHTMAP_MAP", MATERIAL_DESCRIPTOR_SET, 3, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT})); shaderSet->addDescriptorBinding("emissiveMap", "VSG_EMISSIVE_MAP", MATERIAL_DESCRIPTOR_SET, 4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::vec4Array2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM})); + shaderSet->addDescriptorBinding("displacementMap", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 7, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::floatArray2D::create(1, 1, vsg::Data::Properties{VK_FORMAT_R32_SFLOAT}), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("displacementMapScale", "VSG_DISPLACEMENT_MAP", MATERIAL_DESCRIPTOR_SET, 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::vec3Value::create(1.0f, 1.0f, 1.0f)); - shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PhongMaterialValue::create()); + shaderSet->addDescriptorBinding("material", "", MATERIAL_DESCRIPTOR_SET, 10, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, vsg::PhongMaterialValue::create(), vsg::CoordinateSpace::LINEAR); shaderSet->addDescriptorBinding("jointMatrices", "VSG_SKINNING", MATERIAL_DESCRIPTOR_SET, 11, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, vsg::mat4Value::create()); From a08ca39ba101de5bdbab03ec5da7d0bdf16c5179 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Jan 2025 12:23:14 +0000 Subject: [PATCH 15/19] Added LINEAR setting for colour vertex arrays --- examples/utils/vsgshaderset/flat.cpp | 2 +- examples/utils/vsgshaderset/pbr.cpp | 2 +- examples/utils/vsgshaderset/phong.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/utils/vsgshaderset/flat.cpp b/examples/utils/vsgshaderset/flat.cpp index 88613214..d687da6f 100644 --- a/examples/utils/vsgshaderset/flat.cpp +++ b/examples/utils/vsgshaderset/flat.cpp @@ -45,7 +45,7 @@ vsg::ref_ptr flat_ShaderSet(vsg::ref_ptr opt shaderSet->addAttributeBinding("vsg_Vertex", "", 0, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_Normal", "", 1, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_TexCoord0", "", 2, VK_FORMAT_R32G32_SFLOAT, vsg::vec2Array::create(1)); - shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); + shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1), vsg::CoordinateSpace::LINEAR); shaderSet->addAttributeBinding("vsg_position", "VSG_INSTANCE_POSITIONS", 4, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_position_scaleDistance", "VSG_BILLBOARD", 4, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); diff --git a/examples/utils/vsgshaderset/pbr.cpp b/examples/utils/vsgshaderset/pbr.cpp index 9103ebf9..59308b46 100644 --- a/examples/utils/vsgshaderset/pbr.cpp +++ b/examples/utils/vsgshaderset/pbr.cpp @@ -39,7 +39,7 @@ vsg::ref_ptr pbr_ShaderSet(vsg::ref_ptr opti shaderSet->addAttributeBinding("vsg_Vertex", "", 0, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_Normal", "", 1, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_TexCoord0", "", 2, VK_FORMAT_R32G32_SFLOAT, vsg::vec2Array::create(1)); - shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); + shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1), vsg::CoordinateSpace::LINEAR); shaderSet->addAttributeBinding("vsg_position", "VSG_INSTANCE_POSITIONS", 4, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_position_scaleDistance", "VSG_BILLBOARD", 4, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); diff --git a/examples/utils/vsgshaderset/phong.cpp b/examples/utils/vsgshaderset/phong.cpp index ff58bbd4..865c2b6e 100644 --- a/examples/utils/vsgshaderset/phong.cpp +++ b/examples/utils/vsgshaderset/phong.cpp @@ -38,7 +38,7 @@ vsg::ref_ptr phong_ShaderSet(vsg::ref_ptr op shaderSet->addAttributeBinding("vsg_Vertex", "", 0, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_Normal", "", 1, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_TexCoord0", "", 2, VK_FORMAT_R32G32_SFLOAT, vsg::vec2Array::create(1)); - shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); + shaderSet->addAttributeBinding("vsg_Color", "", 3, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1), vsg::CoordinateSpace::LINEAR); shaderSet->addAttributeBinding("vsg_position", "VSG_INSTANCE_POSITIONS", 4, VK_FORMAT_R32G32B32_SFLOAT, vsg::vec3Array::create(1)); shaderSet->addAttributeBinding("vsg_position_scaleDistance", "VSG_BILLBOARD", 4, VK_FORMAT_R32G32B32A32_SFLOAT, vsg::vec4Array::create(1)); From 4bfeb63add9d6287238a7f12af20253f81372b21 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Jan 2025 14:47:50 +0000 Subject: [PATCH 16/19] Pulled in changes from ColorSpace2 --- examples/animation/vsganimation/vsganimation.cpp | 4 ++-- examples/app/vsgcameras/vsgcameras.cpp | 2 +- examples/app/vsgmultiviews/vsgmultiviews.cpp | 2 +- examples/app/vsgortho/CMakeLists.txt | 5 +++++ examples/app/vsgortho/vsgortho.cpp | 10 ++++++++++ examples/app/vsgrendertotexture/vsgrendertotexture.cpp | 6 +++--- .../vsgrendertotexturearray.cpp | 4 ++-- 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/examples/animation/vsganimation/vsganimation.cpp b/examples/animation/vsganimation/vsganimation.cpp index 1eb8feb5..d79fbd71 100644 --- a/examples/animation/vsganimation/vsganimation.cpp +++ b/examples/animation/vsganimation/vsganimation.cpp @@ -407,7 +407,7 @@ int main(int argc, char** argv) auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; directionalLight->color.set(1.0f, 1.0f, 1.0f); - directionalLight->intensity = 0.9f; + directionalLight->intensity = 0.98f; directionalLight->direction = direction; directionalLight->shadowSettings = shadowSettings; @@ -416,7 +416,7 @@ int main(int argc, char** argv) auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; ambientLight->color.set(1.0f, 1.0f, 1.0f); - ambientLight->intensity = 0.1f; + ambientLight->intensity = 0.02f; scene->addChild(ambientLight); } diff --git a/examples/app/vsgcameras/vsgcameras.cpp b/examples/app/vsgcameras/vsgcameras.cpp index 69bd33f2..844e67b7 100644 --- a/examples/app/vsgcameras/vsgcameras.cpp +++ b/examples/app/vsgcameras/vsgcameras.cpp @@ -252,7 +252,7 @@ int main(int argc, char** argv) auto secondary_view = vsg::View::create(secondary_camera, scenegraph); auto secondary_RenderGraph = vsg::RenderGraph::create(window, secondary_view); - secondary_RenderGraph->clearValues[0].color = {{0.2f, 0.2f, 0.2f, 1.0f}}; + secondary_RenderGraph->clearValues[0].color = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f); commandGraph->addChild(secondary_RenderGraph); y += secondary_height + margin; diff --git a/examples/app/vsgmultiviews/vsgmultiviews.cpp b/examples/app/vsgmultiviews/vsgmultiviews.cpp index 11edf507..af649d98 100644 --- a/examples/app/vsgmultiviews/vsgmultiviews.cpp +++ b/examples/app/vsgmultiviews/vsgmultiviews.cpp @@ -158,7 +158,7 @@ int main(int argc, char** argv) // clear the depth buffer before view2 gets rendered VkClearValue colorClearValue{}; - colorClearValue.color = {{0.2f, 0.2f, 0.2f, 1.0f}}; + colorClearValue.color = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f); VkClearAttachment color_attachment{VK_IMAGE_ASPECT_COLOR_BIT, 0, colorClearValue}; VkClearValue depthClearValue{}; diff --git a/examples/app/vsgortho/CMakeLists.txt b/examples/app/vsgortho/CMakeLists.txt index 3d403b57..4f7c894d 100644 --- a/examples/app/vsgortho/CMakeLists.txt +++ b/examples/app/vsgortho/CMakeLists.txt @@ -6,4 +6,9 @@ add_executable(vsgortho ${SOURCES}) target_link_libraries(vsgortho vsg::vsg) +if (vsgXchange_FOUND) + target_compile_definitions(vsgortho PRIVATE vsgXchange_FOUND) + target_link_libraries(vsgortho vsgXchange::vsgXchange) +endif() + install(TARGETS vsgortho RUNTIME DESTINATION bin) diff --git a/examples/app/vsgortho/vsgortho.cpp b/examples/app/vsgortho/vsgortho.cpp index 38ec0585..eee28cef 100644 --- a/examples/app/vsgortho/vsgortho.cpp +++ b/examples/app/vsgortho/vsgortho.cpp @@ -1,5 +1,9 @@ #include +#ifdef vsgXchange_FOUND +# include +#endif + #include #include #include @@ -29,6 +33,12 @@ int main(int argc, char** argv) auto options = vsg::Options::create(); options->fileCache = vsg::getEnv("VSG_FILE_CACHE"); options->paths = vsg::getEnvPaths("VSG_FILE_PATH"); + +#ifdef vsgXchange_all + // add vsgXchange's support for reading and writing 3rd party file formats + options->add(vsgXchange::all::create()); +#endif + vsg::Path filename = arguments[1]; auto vsg_scene = vsg::read_cast(filename, options); diff --git a/examples/app/vsgrendertotexture/vsgrendertotexture.cpp b/examples/app/vsgrendertotexture/vsgrendertotexture.cpp index ae06c725..fe335e19 100644 --- a/examples/app/vsgrendertotexture/vsgrendertotexture.cpp +++ b/examples/app/vsgrendertotexture/vsgrendertotexture.cpp @@ -50,7 +50,7 @@ vsg::ref_ptr createOffscreenRendergraph(vsg::Context& context, // create image for color attachment auto colorImage = vsg::Image::create(); colorImage->imageType = VK_IMAGE_TYPE_2D; - colorImage->format = VK_FORMAT_R8G8B8A8_UNORM; + colorImage->format = VK_FORMAT_R8G8B8A8_SRGB; colorImage->extent = attachmentExtent; colorImage->mipLevels = 1; colorImage->arrayLayers = 1; @@ -104,7 +104,7 @@ vsg::ref_ptr createOffscreenRendergraph(vsg::Context& context, // attachment descriptions vsg::RenderPass::Attachments attachments(2); // Color attachment - attachments[0].format = VK_FORMAT_R8G8B8A8_UNORM; + attachments[0].format = VK_FORMAT_R8G8B8A8_SRGB; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; @@ -166,7 +166,7 @@ vsg::ref_ptr createOffscreenRendergraph(vsg::Context& context, rendergraph->framebuffer = fbuf; rendergraph->clearValues.resize(2); - rendergraph->clearValues[0].color = {{0.4f, 0.2f, 0.4f, 1.0f}}; + rendergraph->clearValues[0].color = vsg::sRGB_to_linear(0.4f, 0.2f, 0.4f, 1.0f); rendergraph->clearValues[1].depthStencil = VkClearDepthStencilValue{0.0f, 0}; return rendergraph; diff --git a/examples/app/vsgrendertotexturearray/vsgrendertotexturearray.cpp b/examples/app/vsgrendertotexturearray/vsgrendertotexturearray.cpp index 217b806f..89fba190 100644 --- a/examples/app/vsgrendertotexturearray/vsgrendertotexturearray.cpp +++ b/examples/app/vsgrendertotexturearray/vsgrendertotexturearray.cpp @@ -168,7 +168,7 @@ vsg::ref_ptr createOffscreenRendergraph(vsg::Context& context, rendergraph->framebuffer = fbuf; rendergraph->clearValues.resize(2); - rendergraph->clearValues[0].color = {{0.4f, 0.2f, 0.4f, 1.0f}}; + rendergraph->clearValues[0].color = vsg::sRGB_to_linear(0.4f, 0.2f, 0.4f, 1.0f); rendergraph->clearValues[1].depthStencil = VkClearDepthStencilValue{0.0f, 0}; return rendergraph; @@ -579,7 +579,7 @@ int main(int argc, char** argv) VkExtent2D targetExtent{512, 512}; // create the color and depth image 2D arrays to render to/read from. - auto colorImage = createImage(*context, targetExtent.width, targetExtent.height, numLayers, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); + auto colorImage = createImage(*context, targetExtent.width, targetExtent.height, numLayers, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); auto depthImage = createImage(*context, targetExtent.width, targetExtent.height, numLayers, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT); // use the TraverseChildrenOfNode to decorate the main view3D so it's children can be travesed by the render to texture without invoking the view3D camera/ViewDependentState From 969596121486052ec3021b31b7b0b9eb97498d4b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Jan 2025 15:47:55 +0000 Subject: [PATCH 17/19] Merged changes from ColorSpace2 branch. --- examples/app/vsgscreenshot/vsgscreenshot.cpp | 4 ++-- examples/app/vsgwindows/vsgwindows.cpp | 2 +- examples/lighting/vsglights/vsglights.cpp | 4 ++-- examples/lighting/vsgshadow/vsgshadow.cpp | 4 ++-- .../vsgtextureprojection/vsgtextureprojection.cpp | 11 ++++++----- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/app/vsgscreenshot/vsgscreenshot.cpp b/examples/app/vsgscreenshot/vsgscreenshot.cpp index 15f5a42e..639384e4 100644 --- a/examples/app/vsgscreenshot/vsgscreenshot.cpp +++ b/examples/app/vsgscreenshot/vsgscreenshot.cpp @@ -106,7 +106,7 @@ class ScreenshotHandler : public vsg::Inherit vkGetPhysicalDeviceFormatProperties(*(physicalDevice), sourceImageFormat, &srcFormatProperties); VkFormatProperties destFormatProperties; - vkGetPhysicalDeviceFormatProperties(*(physicalDevice), VK_FORMAT_R8G8B8A8_UNORM, &destFormatProperties); + vkGetPhysicalDeviceFormatProperties(*(physicalDevice), VK_FORMAT_R8G8B8A8_SRGB, &destFormatProperties); bool supportsBlit = ((srcFormatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) != 0) && ((destFormatProperties.linearTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT) != 0); @@ -114,7 +114,7 @@ class ScreenshotHandler : public vsg::Inherit if (supportsBlit) { // we can automatically convert the image format when blit, so take advantage of it to ensure RGBA - targetImageFormat = VK_FORMAT_R8G8B8A8_UNORM; + targetImageFormat = VK_FORMAT_R8G8B8A8_SRGB; } vsg::info("supportsBlit = ", supportsBlit); diff --git a/examples/app/vsgwindows/vsgwindows.cpp b/examples/app/vsgwindows/vsgwindows.cpp index 437e47a2..3d9a238d 100644 --- a/examples/app/vsgwindows/vsgwindows.cpp +++ b/examples/app/vsgwindows/vsgwindows.cpp @@ -140,7 +140,7 @@ int main(int argc, char** argv) auto main_RenderGraph = vsg::RenderGraph::create(window1, main_view); auto secondary_RenderGraph = vsg::RenderGraph::create(window2, secondary_view); - secondary_RenderGraph->clearValues[0].color = {{0.2f, 0.2f, 0.2f, 1.0f}}; + secondary_RenderGraph->clearValues[0].color = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f); auto commandGraph1 = vsg::CommandGraph::create(window1); commandGraph1->addChild(main_RenderGraph); diff --git a/examples/lighting/vsglights/vsglights.cpp b/examples/lighting/vsglights/vsglights.cpp index 426ebfd9..8df8c10d 100644 --- a/examples/lighting/vsglights/vsglights.cpp +++ b/examples/lighting/vsglights/vsglights.cpp @@ -187,12 +187,12 @@ int main(int argc, char** argv) auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; ambientLight->color.set(1.0f, 1.0f, 1.0f); - ambientLight->intensity = 0.1f; + ambientLight->intensity = 0.0044f; auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "head light"; directionalLight->color.set(1.0f, 1.0f, 1.0f); - directionalLight->intensity = 0.9f; + directionalLight->intensity = 0.9956f; directionalLight->direction.set(0.0f, 0.0f, -1.0f); auto absoluteTransform = vsg::AbsoluteTransform::create(); diff --git a/examples/lighting/vsgshadow/vsgshadow.cpp b/examples/lighting/vsgshadow/vsgshadow.cpp index af0d6186..196635cd 100644 --- a/examples/lighting/vsgshadow/vsgshadow.cpp +++ b/examples/lighting/vsgshadow/vsgshadow.cpp @@ -538,7 +538,7 @@ int main(int argc, char** argv) directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; directionalLight->color.set(1.0f, 1.0f, 1.0f); - directionalLight->intensity = 0.9f; + directionalLight->intensity = 0.98f; directionalLight->direction = direction; directionalLight->angleSubtended = angleSubtended; directionalLight->shadowSettings = shadowSettings; @@ -552,7 +552,7 @@ int main(int argc, char** argv) ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; ambientLight->color.set(1.0f, 1.0f, 1.0f); - ambientLight->intensity = 0.2f; + ambientLight->intensity = 0.02f; group->addChild(ambientLight); } diff --git a/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp b/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp index 444711a0..503bb1a9 100644 --- a/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp +++ b/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp @@ -344,7 +344,8 @@ int main(int argc, char** argv) vsg::Path filename = argv[i]; if (auto data = vsg::read_cast(filename, options)) { - if (data->properties.format == VK_FORMAT_R8G8B8A8_UNORM) + data->properties.format = vsg::uNorm_to_sRGB(data->properties.format); + if (data->properties.format == VK_FORMAT_R8G8B8A8_SRGB) { if (!firstImage) { @@ -364,7 +365,7 @@ int main(int argc, char** argv) } else { - std::cout << "Image file : " << filename << " loaded, but does not match required VK_FORMAT_R8G8B8A8_UNORM format." << std::endl; + std::cout << "Image file : " << filename << " loaded, but does not match required VK_FORMAT_R8G8B8A8_SRGB format." << std::endl; } } else @@ -456,7 +457,7 @@ int main(int argc, char** argv) auto texgenMatrices = vsg::mat4Array::create(depth); texgenMatrices->properties.dataVariance = vsg::DYNAMIC_DATA; - auto texture2DArray = vsg::ubvec4Array3D::create(firstImage->width(), firstImage->height(), depth, vsg::ubvec4(255, 255, 255, 255), vsg::Data::Properties{VK_FORMAT_R8G8B8A8_UNORM}); + auto texture2DArray = vsg::ubvec4Array3D::create(firstImage->width(), firstImage->height(), depth, vsg::ubvec4(255, 255, 255, 255), vsg::Data::Properties{VK_FORMAT_R8G8B8A8_SRGB}); texture2DArray->properties.imageViewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; texgenDescritor->bufferInfoList.push_back(vsg::BufferInfo::create(texgenMatrices)); @@ -562,7 +563,7 @@ int main(int argc, char** argv) auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; directionalLight->color.set(1.0, 1.0, 1.0); - directionalLight->intensity = 0.9f; + directionalLight->intensity = 0.98f; directionalLight->direction = direction; if (numShadowMapsPerLight > 0) { @@ -573,7 +574,7 @@ int main(int argc, char** argv) auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; ambientLight->color.set(1.0, 1.0, 1.0); - ambientLight->intensity = 0.2f; + ambientLight->intensity = 0.02f; group->addChild(ambientLight); } From af124697f6a6b1daba606dbc004d38659c7377a2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Jan 2025 16:01:13 +0000 Subject: [PATCH 18/19] Merged changes from ColorSpace2 branch --- examples/platform/vsgwin32/vsgwin32.cpp | 2 +- examples/state/vsgstateswitch/vsgstateswitch.cpp | 4 ++-- examples/state/vsgtexturearray/vsgtexturearray.cpp | 2 +- examples/threading/vsgdynamicviews/vsgdynamicviews.cpp | 2 +- examples/threading/vsgdynamicwindows/vsgdynamicwindows.cpp | 2 +- examples/ui/vsgimgui_example/vsgimgui_example.cpp | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/platform/vsgwin32/vsgwin32.cpp b/examples/platform/vsgwin32/vsgwin32.cpp index d0790484..ab43379e 100644 --- a/examples/platform/vsgwin32/vsgwin32.cpp +++ b/examples/platform/vsgwin32/vsgwin32.cpp @@ -62,7 +62,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, i // register the vsgWin32::Win32_Window object so that we can have events processed by the VSG event handler SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(window.get())); - window->clearColor() = vsg::sRGB_to_linear(vsg::vec4{0.2f, 0.2f, 0.2f, 1.0f}); + window->clearColor() = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 0.0f); auto viewer = vsg::Viewer::create(); viewer->addWindow(window); diff --git a/examples/state/vsgstateswitch/vsgstateswitch.cpp b/examples/state/vsgstateswitch/vsgstateswitch.cpp index 1841297f..98051cfd 100644 --- a/examples/state/vsgstateswitch/vsgstateswitch.cpp +++ b/examples/state/vsgstateswitch/vsgstateswitch.cpp @@ -192,7 +192,7 @@ int main(int argc, char** argv) std::cout << "Using a RenderGraph per View" << std::endl; auto main_RenderGraph = vsg::RenderGraph::create(window, main_view); auto secondary_RenderGraph = vsg::RenderGraph::create(window, secondary_view); - secondary_RenderGraph->clearValues[0].color = {{0.2f, 0.2f, 0.2f, 1.0f}}; + secondary_RenderGraph->clearValues[0].color = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f); auto commandGraph = vsg::CommandGraph::create(window); commandGraph->addChild(main_RenderGraph); @@ -210,7 +210,7 @@ int main(int argc, char** argv) // clear the depth buffer before view2 gets rendered VkClearValue colorClearValue{}; - colorClearValue.color = {{0.2f, 0.2f, 0.2f, 1.0f}}; + colorClearValue.color = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f); VkClearAttachment color_attachment{VK_IMAGE_ASPECT_COLOR_BIT, 0, colorClearValue}; VkClearValue depthClearValue{}; diff --git a/examples/state/vsgtexturearray/vsgtexturearray.cpp b/examples/state/vsgtexturearray/vsgtexturearray.cpp index d6b6b78f..f11d0b6b 100644 --- a/examples/state/vsgtexturearray/vsgtexturearray.cpp +++ b/examples/state/vsgtexturearray/vsgtexturearray.cpp @@ -204,7 +204,7 @@ int main(int argc, char** argv) for (uint32_t i = 0; i < numTiles; ++i) { auto textureData = vsg::ubvec4Array2D::create(256, 256); - textureData->properties.format = VK_FORMAT_R8G8B8A8_UNORM; + textureData->properties.format = VK_FORMAT_R8G8B8A8_SRGB; if (update) textureData->properties.dataVariance = vsg::DYNAMIC_DATA; updateBaseTexture(*textureData, 1.0f); diff --git a/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp b/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp index 072fcc5a..4f84b571 100644 --- a/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp +++ b/examples/threading/vsgdynamicviews/vsgdynamicviews.cpp @@ -92,7 +92,7 @@ struct LoadViewOperation : public vsg::InheritaddChild(vsg::createHeadlight()); auto renderGraph = vsg::RenderGraph::create(ref_window, view); - renderGraph->setClearValues(vsg::sRGB_to_linear(vsg::vec4{0.2f, 0.2f, 0.2f, 1.0f})); + renderGraph->setClearValues(vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f)); // need to add view to compileManager ref_viewer->compileManager->add(*ref_window, view); diff --git a/examples/threading/vsgdynamicwindows/vsgdynamicwindows.cpp b/examples/threading/vsgdynamicwindows/vsgdynamicwindows.cpp index 18049738..f69cb201 100644 --- a/examples/threading/vsgdynamicwindows/vsgdynamicwindows.cpp +++ b/examples/threading/vsgdynamicwindows/vsgdynamicwindows.cpp @@ -114,7 +114,7 @@ struct LoadWindowOperation : public vsg::InheritaddChild(vsg::createHeadlight()); auto renderGraph = vsg::RenderGraph::create(second_window, view); - renderGraph->clearValues[0].color = {{0.2f, 0.2f, 0.2f, 1.0f}}; + renderGraph->clearValues[0].color = vsg::sRGB_to_linear(0.2f, 0.2f, 0.2f, 1.0f); auto commandGraph = vsg::CommandGraph::create(second_window); commandGraph->addChild(renderGraph); diff --git a/examples/ui/vsgimgui_example/vsgimgui_example.cpp b/examples/ui/vsgimgui_example/vsgimgui_example.cpp index 716ddc87..5718d304 100644 --- a/examples/ui/vsgimgui_example/vsgimgui_example.cpp +++ b/examples/ui/vsgimgui_example/vsgimgui_example.cpp @@ -62,7 +62,7 @@ class MyGui : public vsg::Inherit } ImGui::SliderFloat("float", ¶ms->dist, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)¶ms->clearColor); // Edit 3 floats representing a color + ImGui::ColorEdit3("clear color", (float*)¶ms->clearColor); // Edit 3 floats representing a color. Beware: the color space will match the rendering color space, typically linear, whereas colour pickers are typically sRGB. if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) params->counter++; @@ -129,7 +129,7 @@ class MyGui : public vsg::Inherit if (params->showImagesWindow) { ImGui::Begin("Image Window", ¶ms->showImagesWindow); - ImGui::Text("An texture:"); + ImGui::Text("A texture:"); // The logo texture is big, show it at half size ImGui::Image(texture->id(cb.deviceID), ImVec2(texture->width / 2.0f, texture->height / 2.0f)); From c8b44c5466ce19e232d3de3dc1f0960add8386fc Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Jan 2025 17:54:15 +0000 Subject: [PATCH 19/19] Added option for selecting sRGB or RGB frame buffer. --- examples/ui/vsgimgui_example/vsgimgui_example.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/ui/vsgimgui_example/vsgimgui_example.cpp b/examples/ui/vsgimgui_example/vsgimgui_example.cpp index 5718d304..c87f1a00 100644 --- a/examples/ui/vsgimgui_example/vsgimgui_example.cpp +++ b/examples/ui/vsgimgui_example/vsgimgui_example.cpp @@ -175,6 +175,8 @@ int main(int argc, char** argv) windowTraits->debugLayer = arguments.read({"--debug", "-d"}); windowTraits->apiDumpLayer = arguments.read({"--api", "-a"}); + if (arguments.read("--sRGB")) windowTraits->swapchainPreferences.surfaceFormat = {VK_FORMAT_B8G8R8A8_SRGB, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR}; + if (arguments.read("--RGB")) windowTraits->swapchainPreferences.surfaceFormat = {VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR}; arguments.read("--screen", windowTraits->screenNum); arguments.read("--display", windowTraits->display); arguments.read("--samples", windowTraits->samples);