diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c8eb65..1046739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### v? +##### Breaking Changes + +- vsgCs now requires VSG 1.1.11 and vsgimgui 0.3.0 + ##### Additions - vsgCs now uses Cesium Native v0.50.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7941c7f..7193edb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,13 +43,13 @@ if (VULKAN_SDK) set(ENV{VULKAN_SDK} ${VULKAN_SDK}) endif() -set(VSG_MIN_VERSION 1.1.0) +set(VSG_MIN_VERSION 1.1.11) find_package(vsg ${VSG_MIN_VERSION} REQUIRED) find_package(vsgXchange) -set(VSGIMGUI_MIN_VERSION 0.1.0) +set(VSGIMGUI_MIN_VERSION 0.3.0) find_package(vsgImGui ${VSGIMGUI_MIN_VERSION} REQUIRED) diff --git a/data/shaders/csstandard_pbr.frag b/data/shaders/csstandard_pbr.frag index 8b5a679..6a640a9 100644 --- a/data/shaders/csstandard_pbr.frag +++ b/data/shaders/csstandard_pbr.frag @@ -304,7 +304,7 @@ float microfacetDistribution(PBRInfo pbrInputs) return roughnessSq / (f * f); } -vec3 BRDF(vec3 u_LightColor, vec3 v, vec3 n, vec3 l, vec3 h, PBRNode pbrNode, float ao) +vec3 BRDF(vec3 u_LightColor, vec3 v, vec3 n, vec3 l, vec3 h, PBRNode pbrNode) { float unclmapped_NdotL = dot(n, l); vec3 reflection = -normalize(reflect(v, n)); @@ -342,8 +342,6 @@ vec3 BRDF(vec3 u_LightColor, vec3 v, vec3 n, vec3 l, vec3 h, PBRNode pbrNode, fl // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law) vec3 color = NdotL * u_LightColor * (diffuseContrib + specContrib); - color *= ao; - #ifdef VSG_EMISSIVE_MAP vec3 emissive = texture(emissiveMap, texCoord[0]).rgb * pbr.emissiveFactor.rgb; #else @@ -508,8 +506,7 @@ void main() vec3 h = normalize(l+v); // Half vector between both l and v float scale = brightness; - color.rgb += BRDF(lightColor.rgb * scale, v, n, l, h, pbrNode, - ambientOcclusion); + color.rgb += BRDF(lightColor.rgb * scale, v, n, l, h, pbrNode); } } @@ -529,8 +526,7 @@ void main() float scale = lightColor.a / distance2; color.rgb += BRDF(lightColor.rgb * scale, v, n, l, h, - pbrNode, - ambientOcclusion); + pbrNode); } } @@ -553,8 +549,8 @@ void main() float scale = (lightColor.a * smoothstep(lightDirection_cosOuterAngle.w, position_cosInnerAngle.w, dot_lightdirection)) / distance2; color.rgb += BRDF(lightColor.rgb * scale, v, n, l, h, - pbrNode, - ambientOcclusion); + pbrNode); + } } // Blend tiles based on blue noise dithering. At every pixel we choose to render either the fading diff --git a/src/applications/worldviewer/worldviewer.cpp b/src/applications/worldviewer/worldviewer.cpp index 7b3f19a..2531db0 100644 --- a/src/applications/worldviewer/worldviewer.cpp +++ b/src/applications/worldviewer/worldviewer.cpp @@ -59,6 +59,7 @@ SOFTWARE. #include "vsgCs/Tracing.h" #include "vsgCs/TracingCommandGraph.h" #include "vsgCs/RuntimeEnvironment.h" +#include "vsgCs/runtimeSupport.h" #include "vsgCs/WorldNode.h" #include "UI.h" #include "CsApp/CsViewer.h" @@ -103,10 +104,16 @@ class VsgCsScenegraphBuilder std::string argString(arguments[i]); if (argString == "--world-file") { + if (i + 1 < arguments.argc()) + { + addVsgCsObject(arguments[++i]); + } continue; } - if (argString.ends_with("tileset.json")) - { + if (vsgCs::isUrl(argString) || + argString.ends_with("tileset.json") || + (argString.ends_with(".json") + && vsgCs::isTilesetJson(argString, env->options))) { if (auto tilesetNode = createTileset(argString)) { tilesetNodes.push_back(tilesetNode); @@ -172,8 +179,7 @@ class VsgCsScenegraphBuilder vsg::ref_ptr createTileset(const std::string& argString) { std::string url; - if (argString.starts_with("https:") || argString.starts_with("http:") - || argString.starts_with("file:")) + if (vsgCs::isUrl(argString)) { url = argString; } diff --git a/src/vsgCs/GraphicsEnvironment.cpp b/src/vsgCs/GraphicsEnvironment.cpp index 70ef12b..f266d65 100644 --- a/src/vsgCs/GraphicsEnvironment.cpp +++ b/src/vsgCs/GraphicsEnvironment.cpp @@ -93,7 +93,7 @@ vsg::CompileResult GraphicsEnvironment::miniCompile(vsg::ref_ptr ob auto& viewDetailsStack = requirements.viewDetailsStack; vsg::CompileResult result; - result.maxSlot = requirements.maxSlot; + result.maxSlots = requirements.maxSlots; result.containsPagedLOD = requirements.containsPagedLOD; result.views = requirements.views; result.dynamicData= requirements.dynamicData; diff --git a/src/vsgCs/jsonUtils.cpp b/src/vsgCs/jsonUtils.cpp index d46a300..28281fc 100644 --- a/src/vsgCs/jsonUtils.cpp +++ b/src/vsgCs/jsonUtils.cpp @@ -24,6 +24,8 @@ SOFTWARE. #include "jsonUtils.h" +#include "runtimeSupport.h" + #include #include @@ -75,6 +77,32 @@ std::string vsgCs::getStringOrError(const rapidjson::Value& json, const std::str throw std::runtime_error(errorMsg); } +bool vsgCs::isTilesetJson(std::span data) +{ + rapidjson::Document document; + document.Parse(data.data(), data.size()); + if (document.HasParseError()) + { + return false; + } + const auto itr = document.FindMember("asset"); + if (itr == document.MemberEnd() || !itr->value.IsObject()) + { + return false; + } + auto assetObj = itr->value.GetObject(); + auto versionString + = CesiumUtility::JsonHelpers::getStringOrDefault(assetObj, "version", ""); + return !versionString.empty(); +} + +bool vsgCs::isTilesetJson(const vsg::Path &path, + const vsg::ref_ptr& options) +{ + auto jsonSource = vsgCs::readFile(path, options); + return isTilesetJson(jsonSource); +} + // XXX Very gross workaround to static library problems... namespace vsgCs diff --git a/src/vsgCs/jsonUtils.h b/src/vsgCs/jsonUtils.h index 36682ec..eba0bf7 100644 --- a/src/vsgCs/jsonUtils.h +++ b/src/vsgCs/jsonUtils.h @@ -26,9 +26,11 @@ SOFTWARE. #include #include +#include #include #include +#include #include namespace vsgCs @@ -137,4 +139,8 @@ namespace vsgCs { return getStringOrError(json, key, errorMsg.c_str()); } + + bool isTilesetJson(const vsg::Path &path, + const vsg::ref_ptr& options); + bool isTilesetJson(std::span data); } diff --git a/src/vsgCs/pbr.cpp b/src/vsgCs/pbr.cpp index eb4d4be..9b75468 100644 --- a/src/vsgCs/pbr.cpp +++ b/src/vsgCs/pbr.cpp @@ -109,8 +109,8 @@ namespace vsgCs::pbr shaderSet->addPushConstantRange("pc", "", VK_SHADER_STAGE_VERTEX_BIT, 0, 128); - shaderSet->definesArrayStates.push_back(vsg::DefinesArrayState{{"VSG_INSTANCE_POSITIONS", "VSG_DISPLACEMENT_MAP"}, vsg::PositionAndDisplacementMapArrayState::create()}); - shaderSet->definesArrayStates.push_back(vsg::DefinesArrayState{{"VSG_INSTANCE_POSITIONS"}, vsg::PositionArrayState::create()}); + shaderSet->definesArrayStates.push_back(vsg::DefinesArrayState{{"VSG_INSTANCE_POSITIONS", "VSG_DISPLACEMENT_MAP"}, vsg::TranslationAndDisplacementMapArrayState::create()}); + shaderSet->definesArrayStates.push_back(vsg::DefinesArrayState{{"VSG_INSTANCE_POSITIONS"}, vsg::TranslationArrayState::create()}); shaderSet->definesArrayStates.push_back(vsg::DefinesArrayState{{"VSG_DISPLACEMENT_MAP"}, vsg::DisplacementMapArrayState::create()}); shaderSet->customDescriptorSetBindings.push_back(vsg::ViewDependentStateBinding::create(VIEW_DESCRIPTOR_SET)); } diff --git a/src/vsgCs/runtimeSupport.cpp b/src/vsgCs/runtimeSupport.cpp index a6bb224..5269756 100644 --- a/src/vsgCs/runtimeSupport.cpp +++ b/src/vsgCs/runtimeSupport.cpp @@ -562,4 +562,14 @@ vsg::ref_ptr loadImage(CesiumUtility::IntrusivePointer ptr; }; + + /** + * Returns true if string begins with https: or http:. + */ + bool isRemoteUrl(const std::string &str); + + /** + * Returns true of string is a remote URL or begins with file: + */ + bool isUrl(const std::string &str); } diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 0d20f50..f0e1a19 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json", "default-registry": { "kind": "git", - "baseline": "bc3512a509f9d29b37346a7e7e929f9a26e66c7e", + "baseline": "ca3258ea22d052238eebb80a4ef1a2458f552ac0", "repository": "https://github.com/microsoft/vcpkg" }, "registries": [