Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions data/models/lz.vsgt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/models/teapot.vsgt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
23 changes: 5 additions & 18 deletions data/shaders/standard_pbr.frag
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +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;
Expand Down Expand Up @@ -289,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
Expand Down Expand Up @@ -333,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;
Expand All @@ -352,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);
Expand Down Expand Up @@ -552,5 +539,5 @@ void main()
}
}

outColor = LINEARtoSRGB(vec4(color, baseColor.a));
outColor = vec4(color, baseColor.a);
}
Binary file modified data/textures/lz.vsgb
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/animation/vsganimation/vsganimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/app/vsgcameras/vsgcameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/app/vsgmultiviews/vsgmultiviews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
5 changes: 5 additions & 0 deletions examples/app/vsgortho/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 10 additions & 0 deletions examples/app/vsgortho/vsgortho.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <vsg/all.h>

#ifdef vsgXchange_FOUND
# include <vsgXchange/all.h>
#endif

#include <algorithm>
#include <chrono>
#include <iostream>
Expand Down Expand Up @@ -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<vsg::Node>(filename, options);
Expand Down
6 changes: 3 additions & 3 deletions examples/app/vsgrendertotexture/vsgrendertotexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vsg::ref_ptr<vsg::RenderGraph> 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;
Expand Down Expand Up @@ -104,7 +104,7 @@ vsg::ref_ptr<vsg::RenderGraph> 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;
Expand Down Expand Up @@ -166,7 +166,7 @@ vsg::ref_ptr<vsg::RenderGraph> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ vsg::ref_ptr<vsg::RenderGraph> 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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/app/vsgscreenshot/vsgscreenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ class ScreenshotHandler : public vsg::Inherit<vsg::Visitor, ScreenshotHandler>
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);

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);
Expand Down
12 changes: 6 additions & 6 deletions examples/app/vsgskybox/skybox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
)";
Expand All @@ -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);
}
)";
2 changes: 1 addition & 1 deletion examples/app/vsgskybox/vsgskybox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vsg::Path>("", "--skybox");
auto skyboxFilename = arguments.value<vsg::Path>("textures/skybox.dds", "--skybox");
auto outputFilename = arguments.value<vsg::Path>("", "-o");

if (arguments.errors()) return arguments.writeErrorMessages(std::cerr);
Expand Down
2 changes: 1 addition & 1 deletion examples/app/vsgwindows/vsgwindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting/vsglights/vsglights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting/vsgshadow/vsgshadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
6 changes: 2 additions & 4 deletions examples/nodes/vsgcoordinateframe/vsgcoordinateframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
Loading