diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 11f93dcb5..4eb29721d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,7 +24,7 @@ If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. mac/linux/windows] - - Version [e.g. 1.6.1] + - Version [e.g. 1.6.2] **Additional context** Add any other context about the problem here. diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b3cc49bc..81e29f758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.18.0) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version") -project(Griddly VERSION 1.6.1) +project(Griddly VERSION 1.6.2) string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE) diff --git a/bindings/python.cpp b/bindings/python.cpp index 060b153a5..f5d4e0742 100644 --- a/bindings/python.cpp +++ b/bindings/python.cpp @@ -12,7 +12,7 @@ namespace griddly { PYBIND11_MODULE(python_griddly, m) { m.doc() = "Griddly python bindings"; - m.attr("version") = "1.6.1"; + m.attr("version") = "1.6.2"; #ifndef NDEBUG spdlog::set_level(spdlog::level::debug); diff --git a/docs/conf.py b/docs/conf.py index 1b88ac720..c3ce9bb8e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'Chris Bamford' # The full version, including alpha/beta/rc tags -release = '1.6.1' +release = '1.6.2' # -- General configuration --------------------------------------------------- diff --git a/docs/reference/GDY/Actions/items/Trigger/Offset/index.rst b/docs/reference/GDY/Actions/items/Trigger/Offset/index.rst index 105d64b47..c6a7ad2be 100644 --- a/docs/reference/GDY/Actions/items/Trigger/Offset/index.rst +++ b/docs/reference/GDY/Actions/items/Trigger/Offset/index.rst @@ -25,7 +25,7 @@ Offset * - **Type** - **Description** - * - :ref:`Offset Coordinate<#/properties/Objects/items/properties/Observers/properties/Isometric/properties/Offset/item>` + * - :ref:`Offset Coordinate<#/properties/Objects/items/properties/Trigger/properties/Offset/item>` - Offset Coordinate diff --git a/docs/reference/GDY/Actions/items/Trigger/Offset/items/index.rst b/docs/reference/GDY/Actions/items/Trigger/Offset/items/index.rst index 56c7115d8..dbcfde9d8 100644 --- a/docs/reference/GDY/Actions/items/Trigger/Offset/items/index.rst +++ b/docs/reference/GDY/Actions/items/Trigger/Offset/items/index.rst @@ -1,6 +1,6 @@ -.. _#/properties/Objects/items/properties/Observers/properties/Isometric/properties/Offset/item: +.. _#/properties/Objects/items/properties/Trigger/properties/Offset/item: -.. #/properties/Objects/items/properties/Observers/properties/Isometric/properties/Offset/item +.. #/properties/Objects/items/properties/Trigger/properties/Offset/item Offset Coordinate ================= diff --git a/docs/tutorials/Custom Shaders/Global Lighting/index.rst b/docs/tutorials/Custom Shaders/Global Lighting/index.rst index 005bdccb8..7e76f72f1 100644 --- a/docs/tutorials/Custom Shaders/Global Lighting/index.rst +++ b/docs/tutorials/Custom Shaders/Global Lighting/index.rst @@ -145,6 +145,7 @@ We calculate the lighting level in the vertex shader (so we don't need to calcul layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/docs/tutorials/Custom Shaders/Health Bars/index.rst b/docs/tutorials/Custom Shaders/Health Bars/index.rst index 22cd24ae7..731fcb27c 100644 --- a/docs/tutorials/Custom Shaders/Health Bars/index.rst +++ b/docs/tutorials/Custom Shaders/Health Bars/index.rst @@ -193,6 +193,7 @@ How this ties in with the explanation of the normalized health calculations can layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/docs/tutorials/Custom Shaders/Object Lighting/index.rst b/docs/tutorials/Custom Shaders/Object Lighting/index.rst index 15b3ce73f..ad753b71d 100644 --- a/docs/tutorials/Custom Shaders/Object Lighting/index.rst +++ b/docs/tutorials/Custom Shaders/Object Lighting/index.rst @@ -183,6 +183,7 @@ Vertex layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; @@ -264,6 +265,7 @@ Fragment layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/docs/tutorials/Custom Shaders/index.rst b/docs/tutorials/Custom Shaders/index.rst index 7ab369ec3..fbb6ac295 100644 --- a/docs/tutorials/Custom Shaders/index.rst +++ b/docs/tutorials/Custom Shaders/index.rst @@ -77,6 +77,7 @@ The full shader layout is shown below.: layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/js/griddlyjs-app/package.json b/js/griddlyjs-app/package.json index 07110e47e..4f09ebe1c 100644 --- a/js/griddlyjs-app/package.json +++ b/js/griddlyjs-app/package.json @@ -1,6 +1,6 @@ { "name": "griddlyjs-app", - "version": "1.6.1", + "version": "1.6.2", "private": true, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.1.1", diff --git a/python/examples/Custom Shaders/Global Lighting/shaders/triangle-textured.vert b/python/examples/Custom Shaders/Global Lighting/shaders/triangle-textured.vert index f4179ee6d..d588b772d 100644 --- a/python/examples/Custom Shaders/Global Lighting/shaders/triangle-textured.vert +++ b/python/examples/Custom Shaders/Global Lighting/shaders/triangle-textured.vert @@ -36,6 +36,7 @@ struct ObjectData{ layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/python/examples/Custom Shaders/Health Bars/shaders/triangle-textured.vert b/python/examples/Custom Shaders/Health Bars/shaders/triangle-textured.vert index c534e66a8..47ad8a9e3 100644 --- a/python/examples/Custom Shaders/Health Bars/shaders/triangle-textured.vert +++ b/python/examples/Custom Shaders/Health Bars/shaders/triangle-textured.vert @@ -36,6 +36,7 @@ struct ObjectData{ layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.frag b/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.frag index 5a9944d75..98b506a4c 100644 --- a/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.frag +++ b/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.frag @@ -34,6 +34,7 @@ struct ObjectData{ layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.vert b/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.vert index 0d70ffa05..415650602 100644 --- a/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.vert +++ b/python/examples/Custom Shaders/Object Lighting/shaders/triangle-textured.vert @@ -24,6 +24,7 @@ struct ObjectData{ layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/python/setup.py b/python/setup.py index bbfad7fa0..3cac66739 100644 --- a/python/setup.py +++ b/python/setup.py @@ -71,7 +71,7 @@ def griddly_package_data(config='Debug'): setup( name='griddly', - version="1.6.1", + version="1.6.2", author_email="chrisbam4d@gmail.com", description="Griddly Python Libraries", long_description=long_description, diff --git a/resources/gdy-schema.json b/resources/gdy-schema.json index 49a4e377d..9b1d1c7b9 100644 --- a/resources/gdy-schema.json +++ b/resources/gdy-schema.json @@ -185,6 +185,21 @@ "default": "NONE", "enum": ["NONE", "GRAYSCALE", "DARKEN", "REMOVE"], "description": "The type of trigger to use." + }, + "ObserverAvatarHighlightColor": { + "$id": "#/properties/Environment/properties/Observers/properties/Shader/properties/ObserverAvatarHighlightColor", + "type": "array", + "title": "Color", + "description": "The color of the highlighting to use", + "additionalItems": false, + "minItems": 3, + "maxItems": 3, + "items": { + "$id": "#/properties/Objects/items/properties/Observers/properties/BackgroundColor/item", + "type": "number", + "title": "Color value", + "description": "A float value for RGB" + } } } }, @@ -210,6 +225,21 @@ } ] }, + "BackgroundColor": { + "$id": "#/properties/Environment/properties/Observers/properties/BackgroundColor", + "type": "array", + "title": "Color", + "description": "The color of the background of the game", + "additionalItems": false, + "minItems": 3, + "maxItems": 3, + "items": { + "$id": "#/properties/Objects/items/properties/Observers/properties/BackgroundColor/item", + "type": "number", + "title": "Color value", + "description": "A float value for RGB" + } + }, "BackgroundTile": { "$id": "#/properties/Environment/properties/Observers/properties/BackgroundTile", "type": "string", @@ -666,7 +696,7 @@ "type": "boolean", "title": "Relative", "description": "If the Offset of the collision detector should be relative to the direction that the object is facing." - }, + }, "Offset": { "$id": "#/properties/Actions/items/properties/Trigger/properties/Offset", "type": "array", @@ -676,7 +706,7 @@ "maxItems": 2, "minItems": 2, "items": { - "$id": "#/properties/Objects/items/properties/Observers/properties/Isometric/properties/Offset/item", + "$id": "#/properties/Objects/items/properties/Trigger/properties/Offset/item", "title": "Offset Coordinate", "description": "Coordinate for rendering offset of isometric tiles", "type": "integer" diff --git a/resources/images/block_shapes/fill.png b/resources/images/block_shapes/fill.png new file mode 100644 index 000000000..f4502b636 Binary files /dev/null and b/resources/images/block_shapes/fill.png differ diff --git a/resources/shaders/default/block/triangle-textured.frag b/resources/shaders/default/block/triangle-textured.frag index 26772c15c..758b8e147 100644 --- a/resources/shaders/default/block/triangle-textured.frag +++ b/resources/shaders/default/block/triangle-textured.frag @@ -27,6 +27,7 @@ struct ObjectData{ layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; @@ -96,7 +97,17 @@ void main() outFragColor=texture(samplerArray,inFragTextureCoords)*inColor; } - if(environmentData.globalObserverAvatarMode==3){ + if(environmentData.globalObserverAvatarMode==4){ + if(isInPlayerView()){ + + // outFragColor=vec4(mix(outFragColor.rgb,environmentData.globalObserverAvatarHighlightColor.rgb,0.7),1.); + outFragColor=vec4( + min(1.,outFragColor.x+environmentData.globalObserverAvatarHighlightColor.x), + min(1.,outFragColor.y+environmentData.globalObserverAvatarHighlightColor.y), + min(1.,outFragColor.z+environmentData.globalObserverAvatarHighlightColor.z), + outFragColor.w); + } + }else if(environmentData.globalObserverAvatarMode==3){ if(!isInPlayerView()){ outFragColor=vec4(0); } diff --git a/resources/shaders/default/block/triangle-textured.vert b/resources/shaders/default/block/triangle-textured.vert index f01cfdfc0..dd01e7f3f 100644 --- a/resources/shaders/default/block/triangle-textured.vert +++ b/resources/shaders/default/block/triangle-textured.vert @@ -36,6 +36,7 @@ struct ObjectData { layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/resources/shaders/default/isometric/triangle-textured.frag b/resources/shaders/default/isometric/triangle-textured.frag index e3ee6571f..b716a8926 100644 --- a/resources/shaders/default/isometric/triangle-textured.frag +++ b/resources/shaders/default/isometric/triangle-textured.frag @@ -17,7 +17,7 @@ struct PlayerInfo{ vec4 playerObservableGrid; }; -struct ObjectData { +struct ObjectData{ mat4 modelMatrix; vec4 color; vec4 gridPosition; @@ -30,6 +30,7 @@ struct ObjectData { layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; @@ -79,7 +80,15 @@ void main() outFragColor=texture(samplerArray,inFragTextureCoords)*inColor; } - if(inIsInView == 0){ + if(inIsInView==1){ + if(environmentData.globalObserverAvatarMode==4){ + outFragColor=vec4( + min(1.,outFragColor.x+environmentData.globalObserverAvatarHighlightColor.x), + min(1.,outFragColor.y+environmentData.globalObserverAvatarHighlightColor.y), + min(1.,outFragColor.z+environmentData.globalObserverAvatarHighlightColor.z), + outFragColor.w); + } + }else{ if(environmentData.globalObserverAvatarMode==3){ outFragColor=vec4(0); }else if(environmentData.globalObserverAvatarMode==2){ diff --git a/resources/shaders/default/isometric/triangle-textured.vert b/resources/shaders/default/isometric/triangle-textured.vert index 505daf79d..216dc211b 100644 --- a/resources/shaders/default/isometric/triangle-textured.vert +++ b/resources/shaders/default/isometric/triangle-textured.vert @@ -38,6 +38,7 @@ struct ObjectData { layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/resources/shaders/default/sprite/triangle-textured.frag b/resources/shaders/default/sprite/triangle-textured.frag index 56b513976..25524cd35 100644 --- a/resources/shaders/default/sprite/triangle-textured.frag +++ b/resources/shaders/default/sprite/triangle-textured.frag @@ -28,6 +28,7 @@ struct ObjectData{ layout(std140,binding=1)uniform EnvironmentData{ mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; @@ -97,7 +98,15 @@ void main() outFragColor=texture(samplerArray,inFragTextureCoords)*inColor; } - if(environmentData.globalObserverAvatarMode==3){ + if(environmentData.globalObserverAvatarMode==4){ + if(isInPlayerView()){ + outFragColor=vec4( + min(1.,outFragColor.x+environmentData.globalObserverAvatarHighlightColor.x), + min(1.,outFragColor.y+environmentData.globalObserverAvatarHighlightColor.y), + min(1.,outFragColor.z+environmentData.globalObserverAvatarHighlightColor.z), + outFragColor.w); + } + }else if(environmentData.globalObserverAvatarMode==3){ if(!isInPlayerView()){ outFragColor=vec4(0); } diff --git a/resources/shaders/default/sprite/triangle-textured.vert b/resources/shaders/default/sprite/triangle-textured.vert index 6adf5039d..13845423d 100644 --- a/resources/shaders/default/sprite/triangle-textured.vert +++ b/resources/shaders/default/sprite/triangle-textured.vert @@ -35,6 +35,7 @@ struct ObjectData { layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/src/Griddly/Core/GDY/GDYFactory.cpp b/src/Griddly/Core/GDY/GDYFactory.cpp index d7814af1e..3d767ddc3 100644 --- a/src/Griddly/Core/GDY/GDYFactory.cpp +++ b/src/Griddly/Core/GDY/GDYFactory.cpp @@ -383,6 +383,9 @@ BlockObserverConfig GDYFactory::parseNamedBlockObserverConfig(std::string observ config.highlightPlayers = resolveObserverConfigValue("HighlightPlayers", observerConfigNode, playerCount_ > 1, !isGlobalObserver); config.rotateAvatarImage = resolveObserverConfigValue("RotateAvatarImage", observerConfigNode, config.rotateAvatarImage, !isGlobalObserver); + auto backgroundColorNode = observerConfigNode["BackgroundColor"]; + config.backgroundColor = parseColorNode(observerConfigNode["BackgroundColor"]); + if (objectNames_.size() == 0) { return config; } @@ -473,6 +476,8 @@ void GDYFactory::parseNamedObserverShaderConfig(VulkanObserverConfig& config, YA return; } + config.globalObserverAvatarHighlightColor = parseColorNode(shaderConfigNode["ObserverAvatarHighlightColor"]); + auto globalObserverAvatarMode = shaderConfigNode["ObserverAvatarMode"]; if (globalObserverAvatarMode.IsDefined()) { auto avatarMode = globalObserverAvatarMode.as(); @@ -482,6 +487,8 @@ void GDYFactory::parseNamedObserverShaderConfig(VulkanObserverConfig& config, YA config.globalObserverAvatarMode = GlobalObserverAvatarMode::DARKEN_INVISIBLE; } else if (avatarMode == "REMOVE") { config.globalObserverAvatarMode = GlobalObserverAvatarMode::REMOVE_INVISIBLE; + } else if (avatarMode == "HIGHLIGHT") { + config.globalObserverAvatarMode = GlobalObserverAvatarMode::HIGHLIGHT_VISIBLE; } else { std::string error = fmt::format("No avatar mode called {0} exists.", avatarMode); throwParserError(error); diff --git a/src/Griddly/Core/GDY/YAMLUtils.hpp b/src/Griddly/Core/GDY/YAMLUtils.hpp index acc8a416a..632a48bda 100644 --- a/src/Griddly/Core/GDY/YAMLUtils.hpp +++ b/src/Griddly/Core/GDY/YAMLUtils.hpp @@ -53,4 +53,20 @@ inline YAML::iterator validateCommandPairNode(YAML::Node& commandPairNodeList) { return commandPairNodeList.begin(); } +inline glm::vec3 parseColorNode(YAML::Node colorNode) { + if (colorNode.IsDefined()) { + if (!colorNode.IsSequence() || colorNode.size() != 3) { + auto error = fmt::format("Color node misconfigured, must contain 3 values but contains {0}.", colorNode.size()); + throwParserError(error); + } else { + return glm::vec3{ + colorNode[0].as(0), + colorNode[1].as(0), + colorNode[2].as(0)}; + } + } + + return glm::vec3{}; +} + } // namespace griddly \ No newline at end of file diff --git a/src/Griddly/Core/Observers/BlockObserver.cpp b/src/Griddly/Core/Observers/BlockObserver.cpp index 62754eff3..402cab63e 100644 --- a/src/Griddly/Core/Observers/BlockObserver.cpp +++ b/src/Griddly/Core/Observers/BlockObserver.cpp @@ -12,6 +12,7 @@ const std::map BlockObserver::blockSpriteDefiniti {"square", {{"block_shapes/square.png"}}}, {"pentagon", {{"block_shapes/pentagon.png"}}}, {"hexagon", {{"block_shapes/hexagon.png"}}}, + {"fill", {{"block_shapes/fill.png"}}}, }; BlockObserver::BlockObserver(std::shared_ptr grid, BlockObserverConfig& config) @@ -32,6 +33,16 @@ void BlockObserver::updateObjectSSBOData(PartialObservableGrid& observableGrid, const auto& objects = grid_->getObjects(); const auto& objectIds = grid_->getObjectIds(); + vk::ObjectDataSSBO backgroundTiling; + backgroundTiling.modelMatrix = glm::translate(backgroundTiling.modelMatrix, glm::vec3(gridWidth_ / 2.0 - config_.gridXOffset, gridHeight_ / 2.0 - config_.gridYOffset, 0.0)); + backgroundTiling.modelMatrix = glm::scale(backgroundTiling.modelMatrix, glm::vec3(gridWidth_, gridHeight_, 1.0)); + backgroundTiling.gridPosition = {0, 0, -10, 0}; + backgroundTiling.color = glm::vec4(config_.backgroundColor, 1.0); + backgroundTiling.textureMultiply = {gridWidth_, gridHeight_}; + backgroundTiling.textureIndex = device_->getSpriteArrayLayer("fill"); + backgroundTiling.objectTypeId = 1000; + frameSSBOData_.objectSSBOData.push_back({backgroundTiling}); + for (auto& object : objects) { auto location = object->getLocation(); diff --git a/src/Griddly/Core/Observers/BlockObserver.hpp b/src/Griddly/Core/Observers/BlockObserver.hpp index 25532fe7e..9d1164668 100644 --- a/src/Griddly/Core/Observers/BlockObserver.hpp +++ b/src/Griddly/Core/Observers/BlockObserver.hpp @@ -17,6 +17,7 @@ struct BlockDefinition { struct BlockObserverConfig : public SpriteObserverConfig { std::map blockDefinitions; + glm::vec3 backgroundColor{}; }; class BlockObserver : public SpriteObserver { diff --git a/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp b/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp index 9ff0c59f9..a5c85dc06 100644 --- a/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp +++ b/src/Griddly/Core/Observers/Vulkan/VulkanDevice.hpp @@ -91,6 +91,7 @@ struct VulkanPipeline { struct EnvironmentUniform { glm::mat4 projectionMatrix{1.0}; glm::mat4 viewMatrix{1.0}; + glm::vec4 globalObserverAvatarHighlightColor; glm::vec2 gridDims; uint32_t playerCount; diff --git a/src/Griddly/Core/Observers/Vulkan/VulkanObserver.cpp b/src/Griddly/Core/Observers/Vulkan/VulkanObserver.cpp index e07a381d5..e3ba64a28 100644 --- a/src/Griddly/Core/Observers/Vulkan/VulkanObserver.cpp +++ b/src/Griddly/Core/Observers/Vulkan/VulkanObserver.cpp @@ -101,6 +101,7 @@ vk::PersistentSSBOData VulkanObserver::updatePersistentShaderBuffers() { spdlog::debug("Highlighting players {0}", config_.highlightPlayers ? "true" : "false"); + persistentSSBOData.environmentUniform.globalObserverAvatarHighlightColor = glm::vec4(config_.globalObserverAvatarHighlightColor, 1.0); persistentSSBOData.environmentUniform.globalObserverAvatarMode = static_cast(config_.globalObserverAvatarMode); persistentSSBOData.environmentUniform.viewMatrix = getViewMatrix(); persistentSSBOData.environmentUniform.gridDims = glm::vec2{gridWidth_, gridHeight_}; diff --git a/src/Griddly/Core/Observers/Vulkan/VulkanObserver.hpp b/src/Griddly/Core/Observers/Vulkan/VulkanObserver.hpp index 98f2c85cc..d4e8bfdfe 100644 --- a/src/Griddly/Core/Observers/Vulkan/VulkanObserver.hpp +++ b/src/Griddly/Core/Observers/Vulkan/VulkanObserver.hpp @@ -25,7 +25,8 @@ enum class GlobalObserverAvatarMode { NONE, GRAYSCALE_INVISIBLE, DARKEN_INVISIBLE, - REMOVE_INVISIBLE + REMOVE_INVISIBLE, + HIGHLIGHT_VISIBLE, }; struct VulkanObserverConfig : ObserverConfig { @@ -35,6 +36,7 @@ struct VulkanObserverConfig : ObserverConfig { bool highlightPlayers = false; std::vector playerColors{}; glm::ivec2 tileSize = {24, 24}; + glm::vec3 globalObserverAvatarHighlightColor{0.3, 0.3, 0.3}; GlobalObserverAvatarMode globalObserverAvatarMode = GlobalObserverAvatarMode::NONE; }; diff --git a/tests/resources/observer/block/render_player_observability_in_global_observer_greyscale.png b/tests/resources/observer/block/render_player_observability_in_global_observer_greyscale.png index 53c130aa1..73cca4a22 100644 Binary files a/tests/resources/observer/block/render_player_observability_in_global_observer_greyscale.png and b/tests/resources/observer/block/render_player_observability_in_global_observer_greyscale.png differ diff --git a/tests/resources/observer/block/render_player_observability_in_global_observer_highlight.png b/tests/resources/observer/block/render_player_observability_in_global_observer_highlight.png new file mode 100644 index 000000000..96b5b7d15 Binary files /dev/null and b/tests/resources/observer/block/render_player_observability_in_global_observer_highlight.png differ diff --git a/tests/resources/observer/isometric/render_player_observability_in_global_observer_highlight.png b/tests/resources/observer/isometric/render_player_observability_in_global_observer_highlight.png new file mode 100644 index 000000000..bb9a5ba99 Binary files /dev/null and b/tests/resources/observer/isometric/render_player_observability_in_global_observer_highlight.png differ diff --git a/tests/resources/observer/isometric/shaders/lighting/triangle-textured.frag b/tests/resources/observer/isometric/shaders/lighting/triangle-textured.frag index 9179464a2..a8ff057fe 100644 --- a/tests/resources/observer/isometric/shaders/lighting/triangle-textured.frag +++ b/tests/resources/observer/isometric/shaders/lighting/triangle-textured.frag @@ -34,6 +34,7 @@ struct ObjectData { layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/tests/resources/observer/isometric/shaders/lighting/triangle-textured.vert b/tests/resources/observer/isometric/shaders/lighting/triangle-textured.vert index d6b461009..554038f35 100644 --- a/tests/resources/observer/isometric/shaders/lighting/triangle-textured.vert +++ b/tests/resources/observer/isometric/shaders/lighting/triangle-textured.vert @@ -37,6 +37,7 @@ struct ObjectData { layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/tests/resources/observer/sprite/render_player_observability_in_global_observer_highlight.png b/tests/resources/observer/sprite/render_player_observability_in_global_observer_highlight.png new file mode 100644 index 000000000..ecc9594bc Binary files /dev/null and b/tests/resources/observer/sprite/render_player_observability_in_global_observer_highlight.png differ diff --git a/tests/resources/observer/sprite/shaders/health_bars/triangle-textured.vert b/tests/resources/observer/sprite/shaders/health_bars/triangle-textured.vert index 91284630d..ca0c544f3 100644 --- a/tests/resources/observer/sprite/shaders/health_bars/triangle-textured.vert +++ b/tests/resources/observer/sprite/shaders/health_bars/triangle-textured.vert @@ -41,6 +41,7 @@ struct ObjectData { layout(std140, binding = 1) uniform EnvironmentData { mat4 projectionMatrix; mat4 viewMatrix; + vec4 globalObserverAvatarHighlightColor; vec2 gridDims; int playerCount; int playerId; diff --git a/tests/src/Griddly/Core/GDY/GDYFactoryTest.cpp b/tests/src/Griddly/Core/GDY/GDYFactoryTest.cpp index 96ce0a5e0..4116b0ebe 100644 --- a/tests/src/Griddly/Core/GDY/GDYFactoryTest.cpp +++ b/tests/src/Griddly/Core/GDY/GDYFactoryTest.cpp @@ -234,6 +234,11 @@ TEST(GDYFactoryTest, loadEnvironment_ObserverShaderOptions) { Type: ISOMETRIC Shader: ObserverAvatarMode: REMOVE + BlockHighlighted: + Type: BLOCK_2D + Shader: + ObserverAvatarMode: HIGHLIGHT + ObserverAvatarHighlightColor: [0.3, 0.2, 0.1] )"; @@ -249,6 +254,10 @@ TEST(GDYFactoryTest, loadEnvironment_ObserverShaderOptions) { auto isometricObserverConfig = gdyFactory->generateConfigForObserver("Isometric"); ASSERT_EQ(isometricObserverConfig.globalObserverAvatarMode, GlobalObserverAvatarMode::REMOVE_INVISIBLE); + + auto blockHightlightedObserverConfig = gdyFactory->generateConfigForObserver("BlockHighlighted"); + ASSERT_EQ(blockHightlightedObserverConfig.globalObserverAvatarMode, GlobalObserverAvatarMode::HIGHLIGHT_VISIBLE); + ASSERT_EQ(blockHightlightedObserverConfig.globalObserverAvatarHighlightColor, glm::vec3(0.3, 0.2, 0.1)); } TEST(GDYFactoryTest, loadEnvironment_NamedObservers) { @@ -398,6 +407,7 @@ TEST(GDYFactoryTest, loadEnvironment_BlockObserverConfig) { Description: Test Description Observers: Block2D: + BackgroundColor: [0.3,0.3,0.3] TileSize: 24 )"; @@ -412,6 +422,7 @@ TEST(GDYFactoryTest, loadEnvironment_BlockObserverConfig) { auto config = gdyFactory->generateConfigForObserver("Block2D"); ASSERT_EQ(config.tileSize, glm::ivec2(24, 24)); + ASSERT_EQ(config.backgroundColor, glm::vec3(0.3, 0.3, 0.3)); ASSERT_EQ(config.gridXOffset, 0); ASSERT_EQ(config.gridYOffset, 0); @@ -737,7 +748,7 @@ TEST(GDYFactoryTest, loadEnvironment_MultiPlayerHighlight) { } TEST(GDYFactoryTest, loadEnvironment_termination_v1) { - //auto mockObjectGeneratorPtr = std::shared_ptr(new MockObjectGenerator()); + // auto mockObjectGeneratorPtr = std::shared_ptr(new MockObjectGenerator()); auto mockTerminationGeneratorPtr = std::make_shared(); auto gdyFactory = std::shared_ptr(new GDYFactory(nullptr, mockTerminationGeneratorPtr, {})); auto yamlString = R"( @@ -768,7 +779,7 @@ TEST(GDYFactoryTest, loadEnvironment_termination_v1) { } TEST(GDYFactoryTest, loadEnvironment_termination_v2) { - //auto mockObjectGeneratorPtr = std::shared_ptr(new MockObjectGenerator()); + // auto mockObjectGeneratorPtr = std::shared_ptr(new MockObjectGenerator()); auto mockTerminationGeneratorPtr = std::make_shared(); auto gdyFactory = std::shared_ptr(new GDYFactory(nullptr, mockTerminationGeneratorPtr, {})); auto yamlString = R"( @@ -895,7 +906,6 @@ void expectOpposingDefinitionNOP(ActionBehaviourType behaviourType, uint32_t beh .Times(1); } - void testBehaviourDefinition(std::string yamlString, ActionBehaviourDefinition expectedBehaviourDefinition, bool expectNOP) { auto mockObjectGeneratorPtr = std::make_shared(); auto mockTerminationGeneratorPtr = std::make_shared(); @@ -1737,7 +1747,7 @@ TEST(GDYFactoryTest, action_no_triggers) { auto mockTerminationGeneratorPtr = std::make_shared(); auto gdyFactory = std::shared_ptr(new GDYFactory(mockObjectGeneratorPtr, mockTerminationGeneratorPtr, {})); - auto objectsNode = loadFromStringAndGetNode(yamlString, "Objects"); + auto objectsNode = loadFromStringAndGetNode(yamlString, "Objects"); gdyFactory->loadObjects(objectsNode); auto actionsNode = loadFromStringAndGetNode(std::string(yamlString), "Actions"); diff --git a/tests/src/Griddly/Core/Observers/BlockObserverTest.cpp b/tests/src/Griddly/Core/Observers/BlockObserverTest.cpp index 01341ebf6..5cf7b1c3a 100644 --- a/tests/src/Griddly/Core/Observers/BlockObserverTest.cpp +++ b/tests/src/Griddly/Core/Observers/BlockObserverTest.cpp @@ -660,6 +660,25 @@ TEST(BlockObserverTest, render_player_observability_in_global_observer_remove) { runBlockObserverMultiAgentTest(config, {3, 200, 200}, {1, 4, 4 * 200}, "tests/resources/observer/block/render_player_observability_in_global_observer_remove.png"); } +TEST(BlockObserverTest, render_player_observability_in_global_observer_highlight) { + BlockObserverConfig config = { + 0, + 0, + 0, + 0, + false, + false}; + + config.shaderVariableConfig = { + {"_steps"}, + {}, + }; + + config.globalObserverAvatarMode = GlobalObserverAvatarMode::HIGHLIGHT_VISIBLE; + + runBlockObserverMultiAgentTest(config, {3, 200, 200}, {1, 4, 4 * 200}, "tests/resources/observer/block/render_player_observability_in_global_observer_highlight.png"); +} + TEST(BlockObserverTest, multiPlayer_Outline_Player1) { BlockObserverConfig config = {5, 5, 0, 0}; config.playerId = 1; diff --git a/tests/src/Griddly/Core/Observers/IsometricSpriteObserverTest.cpp b/tests/src/Griddly/Core/Observers/IsometricSpriteObserverTest.cpp index af81ce119..fb02afda8 100644 --- a/tests/src/Griddly/Core/Observers/IsometricSpriteObserverTest.cpp +++ b/tests/src/Griddly/Core/Observers/IsometricSpriteObserverTest.cpp @@ -635,6 +635,27 @@ TEST(IsometricSpriteObserverTest, render_player_observability_in_global_observer runIsometricObserverMultiAgentTest(config, {3, 320, 208}, {1, 4, 4 * 320}, "tests/resources/observer/isometric/render_player_observability_in_global_observer_remove.png"); } +TEST(IsometricSpriteObserverTest, render_player_observability_in_global_observer_highlight) { + IsometricSpriteObserverConfig config = { + 0, + 0, + 0, + 0, + false, + false}; + + config.shaderVariableConfig = { + {"_steps"}, + {}, + }; + + config.globalObserverAvatarMode = GlobalObserverAvatarMode::HIGHLIGHT_VISIBLE; + + config.resourceConfig = {"resources/games", "resources/images"}; + + runIsometricObserverMultiAgentTest(config, {3, 320, 208}, {1, 4, 4 * 320}, "tests/resources/observer/isometric/render_player_observability_in_global_observer_highlight.png"); +} + TEST(IsometricSpriteObserverTest, multiPlayer_Outline_Player1) { IsometricSpriteObserverConfig config = {5, 5, 0, 0}; config.playerId = 1; diff --git a/tests/src/Griddly/Core/Observers/SpriteObserverTest.cpp b/tests/src/Griddly/Core/Observers/SpriteObserverTest.cpp index 8a52b5db4..8096026b2 100644 --- a/tests/src/Griddly/Core/Observers/SpriteObserverTest.cpp +++ b/tests/src/Griddly/Core/Observers/SpriteObserverTest.cpp @@ -673,6 +673,27 @@ TEST(SpriteObserverTest, render_player_observability_in_global_observer_remove) runSpriteObserverMultiAgentTest(config, {3, 200, 200}, {1, 4, 4 * 200}, "tests/resources/observer/sprite/render_player_observability_in_global_observer_remove.png"); } +TEST(SpriteObserverTest, render_player_observability_in_global_observer_highlight) { + SpriteObserverConfig config = { + 0, + 0, + 0, + 0, + false, + false}; + + config.shaderVariableConfig = { + {"_steps"}, + {}, + }; + + config.globalObserverAvatarMode = GlobalObserverAvatarMode::HIGHLIGHT_VISIBLE; + + config.resourceConfig = {"resources/games", "resources/images"}; + + runSpriteObserverMultiAgentTest(config, {3, 200, 200}, {1, 4, 4 * 200}, "tests/resources/observer/sprite/render_player_observability_in_global_observer_highlight.png"); +} + TEST(SpriteObserverTest, multiPlayer_Outline_Player1) { SpriteObserverConfig config = {5, 5, 0, 0}; config.playerId = 1;