From a2eef8e540bc9bea2ffdc18f78d1d7f5d5e08832 Mon Sep 17 00:00:00 2001 From: Marcus Weber Date: Fri, 27 Jan 2023 17:26:17 +0100 Subject: [PATCH] Release v1.7.0 --- CHANGELOG.md | 12 +++++ CMakeLists.txt | 2 +- EditorApp/mainwindow.cpp | 2 + components/libRamsesBase/CMakeLists.txt | 2 + .../ramses_adaptor/TextureExternalAdaptor.h | 32 ++++++++++++ .../include/ramses_base/RamsesFormatter.h | 2 + .../include/ramses_base/RamsesHandles.h | 13 ++++- .../src/ramses_adaptor/Factories.cpp | 2 + .../src/ramses_adaptor/MaterialAdaptor.cpp | 19 ++++++- .../ramses_adaptor/TextureExternalAdaptor.cpp | 48 ++++++++++++++++++ .../libRamsesBase/src/ramses_base/Utils.cpp | 4 +- components/libRamsesBase/tests/CMakeLists.txt | 1 + .../tests/TextureExternalAdaptor_test.cpp | 46 +++++++++++++++++ .../libCore/include/core/CoreFormatter.h | 3 +- .../libCore/include/core/EngineInterface.h | 7 ++- .../libCore/include/core/ProjectMigration.h | 3 +- .../libCore/include/core/ProxyObjectFactory.h | 4 ++ datamodel/libCore/include/core/ProxyTypes.h | 5 ++ datamodel/libCore/src/ProxyObjectFactory.cpp | 1 + datamodel/libCore/src/ProxyTypes.cpp | 1 + .../migrationTestData/version-current.rca | 24 +++++++-- datamodel/libUserTypes/CMakeLists.txt | 1 + .../include/user_types/TextureExternal.h | 50 +++++++++++++++++++ .../include/user_types/UserObjectFactory.h | 7 +++ .../src/SyncTableWithEngineInterface.cpp | 4 ++ .../libUserTypes/src/TextureExternal.cpp | 14 ++++++ .../libUserTypes/src/UserObjectFactory.cpp | 2 + .../ObjectTreeViewDefaultModel.h | 1 + .../ObjectTreeViewResourceModel_test.cpp | 3 ++ resources/CMakeLists.txt | 8 +++ resources/shaders/texture-external.frag | 21 ++++++++ resources/shaders/texture-external.vert | 17 +++++++ third_party/ramses-logic | 2 +- 33 files changed, 350 insertions(+), 13 deletions(-) create mode 100644 components/libRamsesBase/include/ramses_adaptor/TextureExternalAdaptor.h create mode 100644 components/libRamsesBase/src/ramses_adaptor/TextureExternalAdaptor.cpp create mode 100644 components/libRamsesBase/tests/TextureExternalAdaptor_test.cpp create mode 100644 datamodel/libUserTypes/include/user_types/TextureExternal.h create mode 100644 datamodel/libUserTypes/src/TextureExternal.cpp create mode 100644 resources/shaders/texture-external.frag create mode 100644 resources/shaders/texture-external.vert diff --git a/CHANGELOG.md b/CHANGELOG.md index 799c25e9..9a629217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,18 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h --> +## [1.7.0] External Textures +* **File version number has changed. Files saved with RaCo 1.7.0 cannot be opened by previous versions.** + +### Added +* Added new TextureExternal type and support for the corresponding `samplerExternalOES` uniform type. + * To use `samplerExternalOES` uniforms the shader needs to enable the extension for it with `#extension GL_OES_EGL_image_external_essl3 : require`. + * This can be used to create textures which may be connected at runtime to external buffers also created at runtime. Since no external buffers can be set up in RamsesComposer these will be rendered in black in the preview. + +### Changes +* Update ramses-logic from 1.4.1 to 1.4.2. +* Update ramses from 27.0.128 to 27.0.130. + ## [1.6.0] Skinning, Morphing, property copy/paste, modules for Lua interfaces, misc bugfixes * **File version number has changed. Files saved with RaCo 1.6.0 cannot be opened by previous versions.** diff --git a/CMakeLists.txt b/CMakeLists.txt index 682e1c4d..8cbc313a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.19) SET(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo") -project(RaCoOS VERSION 1.6.0) +project(RaCoOS VERSION 1.7.0) SET(RACO_RELEASE_DIRECTORY ${CMAKE_BINARY_DIR}/release) diff --git a/EditorApp/mainwindow.cpp b/EditorApp/mainwindow.cpp index b99f8d46..6d29838c 100644 --- a/EditorApp/mainwindow.cpp +++ b/EditorApp/mainwindow.cpp @@ -69,6 +69,7 @@ #include "user_types/RenderTarget.h" #include "user_types/Skin.h" #include "user_types/Texture.h" +#include "user_types/TextureExternal.h" #include "user_types/Timer.h" #include "utils/u8path.h" @@ -219,6 +220,7 @@ ads::CDockAreaWidget* createAndAddResourceTree(MainWindow* mainWindow, const cha Material::typeDescription.typeName, Mesh::typeDescription.typeName, Texture::typeDescription.typeName, + TextureExternal::typeDescription.typeName, Timer::typeDescription.typeName, RenderBuffer::typeDescription.typeName, RenderBufferMS::typeDescription.typeName, diff --git a/components/libRamsesBase/CMakeLists.txt b/components/libRamsesBase/CMakeLists.txt index f2d11db6..bab91daf 100644 --- a/components/libRamsesBase/CMakeLists.txt +++ b/components/libRamsesBase/CMakeLists.txt @@ -24,6 +24,7 @@ add_library(libRamsesBase include/ramses_base/HeadlessEngineBackend.h src/ramses_base/HeadlessEngineBackend.cpp include/ramses_base/LogicEngine.h include/ramses_base/RamsesHandles.h + include/ramses_base/RamsesFormatter.h include/ramses_base/Utils.h src/ramses_base/Utils.cpp src/ramses_base/EnumerationDescriptions.h @@ -54,6 +55,7 @@ add_library(libRamsesBase include/ramses_adaptor/SceneAdaptor.h src/ramses_adaptor/SceneAdaptor.cpp include/ramses_adaptor/SkinAdaptor.h src/ramses_adaptor/SkinAdaptor.cpp include/ramses_adaptor/SceneBackend.h src/ramses_adaptor/SceneBackend.cpp + include/ramses_adaptor/TextureExternalAdaptor.h src/ramses_adaptor/TextureExternalAdaptor.cpp include/ramses_adaptor/TextureSamplerAdaptor.h src/ramses_adaptor/TextureSamplerAdaptor.cpp include/ramses_adaptor/TimerAdaptor.h src/ramses_adaptor/TimerAdaptor.cpp include/ramses_adaptor/utilities.h src/ramses_adaptor/utilities.cpp diff --git a/components/libRamsesBase/include/ramses_adaptor/TextureExternalAdaptor.h b/components/libRamsesBase/include/ramses_adaptor/TextureExternalAdaptor.h new file mode 100644 index 00000000..a38bcb8c --- /dev/null +++ b/components/libRamsesBase/include/ramses_adaptor/TextureExternalAdaptor.h @@ -0,0 +1,32 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * + * This file is part of Ramses Composer + * (see https://github.com/bmwcarit/ramses-composer). + * + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include "ramses_adaptor/ObjectAdaptor.h" +#include "user_types/TextureExternal.h" + +#include + +#include + +namespace raco::ramses_adaptor { + +class TextureExternalAdaptor : public TypedObjectAdaptor { +public: + explicit TextureExternalAdaptor(SceneAdaptor* sceneAdaptor, std::shared_ptr editorObject); + + bool sync(core::Errors* errors) override; + std::vector getExportInformation() const override; + +private: + std::array subscriptions_; +}; + +}; // namespace raco::ramses_adaptor \ No newline at end of file diff --git a/components/libRamsesBase/include/ramses_base/RamsesFormatter.h b/components/libRamsesBase/include/ramses_base/RamsesFormatter.h index bb564e4d..e7c0f436 100644 --- a/components/libRamsesBase/include/ramses_base/RamsesFormatter.h +++ b/components/libRamsesBase/include/ramses_base/RamsesFormatter.h @@ -248,6 +248,8 @@ struct fmt::formatter : formatter { return format_to(ctx.out(), "StreamTexture"); case ramses::ERamsesObjectType::ERamsesObjectType_SceneReference: return format_to(ctx.out(), "SceneReference"); + case ramses::ERamsesObjectType::ERamsesObjectType_TextureSamplerExternal: + return format_to(ctx.out(), "TextureSamplerExternal"); default: return format_to(ctx.out(), "Unknown"); } diff --git a/components/libRamsesBase/include/ramses_base/RamsesHandles.h b/components/libRamsesBase/include/ramses_base/RamsesHandles.h index 9ed0104e..3ffeef9a 100644 --- a/components/libRamsesBase/include/ramses_base/RamsesHandles.h +++ b/components/libRamsesBase/include/ramses_base/RamsesHandles.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,7 @@ using RamsesRenderBuffer = RamsesHandle; using RamsesRenderTarget = RamsesHandle; using RamsesTextureSampler = RamsesHandle; using RamsesTextureSamplerMS = RamsesHandle; +using RamsesTextureSamplerExternal = RamsesHandle; using RamsesTimerNode = RamsesHandle; using RamsesLuaModule = RamsesHandle; using RamsesLuaScript = RamsesHandle; @@ -140,9 +142,10 @@ struct RamsesAppearanceHandle { return appearance_; } - void replaceTrackedSamplers(std::vector& newSamplers, std::vector& newSamplersMS) { + void replaceTrackedSamplers(std::vector& newSamplers, std::vector& newSamplersMS, std::vector& newSamplersExternal) { trackedSamplers_ = newSamplers; trackedSamplersMS_ = newSamplersMS; + trackedSamplersExternal_ = newSamplersExternal; } RamsesEffect effect() { @@ -162,6 +165,7 @@ struct RamsesAppearanceHandle { // Samplers currently in use by the appearance_. Needed to keep the samplers alive in ramses. std::vector trackedSamplers_; std::vector trackedSamplersMS_; + std::vector trackedSamplersExternal_; }; using RamsesAppearance = std::shared_ptr; @@ -552,6 +556,13 @@ inline RamsesTextureSamplerMS ramsesTextureSamplerMS(ramses::Scene* scene, Ramse }}; } +inline RamsesTextureSamplerExternal ramsesTextureSamplerExternal(ramses::Scene* scene, ramses::ETextureSamplingMethod minSamplingMethod, ramses::ETextureSamplingMethod magSamplingMethod, const char* name = nullptr) { + return { + scene->createTextureSamplerExternal(minSamplingMethod, magSamplingMethod, name), + createRamsesObjectDeleter(scene) + }; +} + /** RESOURCE FACTORIES */ inline RamsesEffect ramsesEffect(ramses::Scene* scene, const ramses::EffectDescription& description, const char* name = nullptr) { diff --git a/components/libRamsesBase/src/ramses_adaptor/Factories.cpp b/components/libRamsesBase/src/ramses_adaptor/Factories.cpp index b852ceec..a49b20a4 100644 --- a/components/libRamsesBase/src/ramses_adaptor/Factories.cpp +++ b/components/libRamsesBase/src/ramses_adaptor/Factories.cpp @@ -32,6 +32,7 @@ #include "ramses_adaptor/SkinAdaptor.h" #include "ramses_adaptor/TimerAdaptor.h" #include "ramses_adaptor/TextureSamplerAdaptor.h" +#include "ramses_adaptor/TextureExternalAdaptor.h" #include "user_types/CubeMap.h" #include "user_types/Texture.h" #include "user_types/PrefabInstance.h" @@ -61,6 +62,7 @@ UniqueObjectAdaptor Factories::createAdaptor(SceneAdaptor* sceneAdaptor, core::S {user_types::Material::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique(sceneAdaptor, std::dynamic_pointer_cast(obj)); }}, {user_types::Mesh::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique(sceneAdaptor, std::dynamic_pointer_cast(obj)); }}, {user_types::Texture::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique(sceneAdaptor, std::dynamic_pointer_cast(obj)); }}, + {user_types::TextureExternal::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique(sceneAdaptor, std::dynamic_pointer_cast(obj)); }}, {user_types::CubeMap::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique(sceneAdaptor, std::dynamic_pointer_cast(obj)); }}, {user_types::LuaScriptModule::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique(sceneAdaptor, std::dynamic_pointer_cast(obj)); }}, diff --git a/components/libRamsesBase/src/ramses_adaptor/MaterialAdaptor.cpp b/components/libRamsesBase/src/ramses_adaptor/MaterialAdaptor.cpp index cd659462..a7271277 100644 --- a/components/libRamsesBase/src/ramses_adaptor/MaterialAdaptor.cpp +++ b/components/libRamsesBase/src/ramses_adaptor/MaterialAdaptor.cpp @@ -17,6 +17,7 @@ #include "ramses_adaptor/RenderBufferMSAdaptor.h" #include "ramses_adaptor/SceneAdaptor.h" #include "ramses_adaptor/TextureSamplerAdaptor.h" +#include "ramses_adaptor/TextureExternalAdaptor.h" #include "ramses_base/Utils.h" #include "user_types/EngineTypeAnnotation.h" #include "user_types/Material.h" @@ -161,6 +162,7 @@ void updateAppearance(core::Errors* errors, SceneAdaptor* sceneAdaptor, raco::ra std::vector newSamplers; std::vector newSamplersMS; + std::vector newSamplersExternal; for (size_t i{0}; i < uniformsHandle.size(); i++) { setUniform(appearance->get(), uniformsHandle[i]); @@ -184,6 +186,21 @@ void updateAppearance(core::Errors* errors, SceneAdaptor* sceneAdaptor, raco::ra } else { errors->addError(raco::core::ErrorCategory::GENERAL, raco::core::ErrorLevel::ERROR, uniformsHandle[i], "RenderBufferMS needed for this uniform."); } + } else if (engineType == raco::core::EnginePrimitive::TextureSamplerExternal) { + if (auto texture = uniformsHandle[i].asTypedRef()) { + if (auto adaptor = sceneAdaptor->lookup(texture)) { + if (auto sampler = adaptor->getRamsesObjectPointer()) { + ramses::UniformInput input; + (*appearance)->getEffect().findUniformInput(uniformsHandle[i].getPropName().c_str(), input); + (*appearance)->setInputTexture(input, *sampler); + newSamplersExternal.emplace_back(sampler); + } else { + errors->addError(raco::core::ErrorCategory::GENERAL, raco::core::ErrorLevel::ERROR, uniformsHandle[i], "Sampler for this TextureExternal not available."); + } + } + } else { + errors->addError(raco::core::ErrorCategory::GENERAL, raco::core::ErrorLevel::ERROR, uniformsHandle[i], "TextureExternal needed for this uniform."); + } } else { raco::ramses_base::RamsesTextureSampler sampler = nullptr; if (engineType == raco::core::EnginePrimitive::TextureSampler2D) { @@ -220,7 +237,7 @@ void updateAppearance(core::Errors* errors, SceneAdaptor* sceneAdaptor, raco::ra } } } - appearance->replaceTrackedSamplers(newSamplers, newSamplersMS); + appearance->replaceTrackedSamplers(newSamplers, newSamplersMS, newSamplersExternal); } }; // namespace raco::ramses_adaptor diff --git a/components/libRamsesBase/src/ramses_adaptor/TextureExternalAdaptor.cpp b/components/libRamsesBase/src/ramses_adaptor/TextureExternalAdaptor.cpp new file mode 100644 index 00000000..9722de86 --- /dev/null +++ b/components/libRamsesBase/src/ramses_adaptor/TextureExternalAdaptor.cpp @@ -0,0 +1,48 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * + * This file is part of Ramses Composer + * (see https://github.com/bmwcarit/ramses-composer). + * + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#include "ramses_adaptor/TextureExternalAdaptor.h" + +#include "ramses_adaptor/SceneAdaptor.h" +#include "ramses_base/RamsesHandles.h" + +namespace raco::ramses_adaptor { + +using namespace raco::ramses_base; + +TextureExternalAdaptor::TextureExternalAdaptor(SceneAdaptor* sceneAdaptor, std::shared_ptr editorObject) + : TypedObjectAdaptor(sceneAdaptor, editorObject, {}), + subscriptions_{ + sceneAdaptor->dispatcher()->registerOn(core::ValueHandle{editorObject, &user_types::TextureExternal::minSamplingMethod_}, [this]() { + tagDirty(); + }), + sceneAdaptor->dispatcher()->registerOn(core::ValueHandle{editorObject, &user_types::TextureExternal::magSamplingMethod_}, [this]() { + tagDirty(); + })} { +} + +bool TextureExternalAdaptor::sync(core::Errors* errors) { + reset(ramsesTextureSamplerExternal(sceneAdaptor_->scene(), + static_cast(*editorObject()->minSamplingMethod_), + static_cast(*editorObject()->magSamplingMethod_))); + + tagDirty(false); + return true; +} + +std::vector TextureExternalAdaptor::getExportInformation() const { + if (getRamsesObjectPointer()) { + return { + ExportInformation{ramsesObject().getType(), ramsesObject().getName()}, + }; + } + return {}; +} + +} // namespace raco::ramses_adaptor diff --git a/components/libRamsesBase/src/ramses_base/Utils.cpp b/components/libRamsesBase/src/ramses_base/Utils.cpp index dafc6030..8158a44b 100644 --- a/components/libRamsesBase/src/ramses_base/Utils.cpp +++ b/components/libRamsesBase/src/ramses_base/Utils.cpp @@ -176,7 +176,9 @@ static std::map shade {ramses::EEffectInputDataType_TextureSampler2D, raco::core::EnginePrimitive::TextureSampler2D}, {ramses::EEffectInputDataType_TextureSampler2DMS, raco::core::EnginePrimitive::TextureSampler2DMS}, {ramses::EEffectInputDataType_TextureSampler3D, raco::core::EnginePrimitive::TextureSampler3D}, - {ramses::EEffectInputDataType_TextureSamplerCube, raco::core::EnginePrimitive::TextureSamplerCube}}; + {ramses::EEffectInputDataType_TextureSamplerCube, raco::core::EnginePrimitive::TextureSamplerCube}, + {ramses::EEffectInputDataType_TextureSamplerExternal, raco::core::EnginePrimitive::TextureSamplerExternal} +}; std::unique_ptr createEffectDescription(const std::string &vertexShader, const std::string &geometryShader, const std::string &fragmentShader, const std::string &shaderDefines) { std::unique_ptr description{new ramses::EffectDescription}; diff --git a/components/libRamsesBase/tests/CMakeLists.txt b/components/libRamsesBase/tests/CMakeLists.txt index 0baff408..688bba5f 100644 --- a/components/libRamsesBase/tests/CMakeLists.txt +++ b/components/libRamsesBase/tests/CMakeLists.txt @@ -36,6 +36,7 @@ set(TEST_SOURCES SkinAdaptor_test.cpp TimerAdaptor_test.cpp TextureAdaptor_test.cpp + TextureExternalAdaptor_test.cpp utilities_test.cpp ) set(TEST_LIBRARIES diff --git a/components/libRamsesBase/tests/TextureExternalAdaptor_test.cpp b/components/libRamsesBase/tests/TextureExternalAdaptor_test.cpp new file mode 100644 index 00000000..8d452900 --- /dev/null +++ b/components/libRamsesBase/tests/TextureExternalAdaptor_test.cpp @@ -0,0 +1,46 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * + * This file is part of Ramses Composer + * (see https://github.com/bmwcarit/ramses-composer). + * + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#include + +#include "RamsesBaseFixture.h" +#include "ramses_adaptor/TextureExternalAdaptor.h" +#include "testing/TestUtil.h" + +class TextureExternalAdaptorFixture : public RamsesBaseFixture<> {}; + +TEST_F(TextureExternalAdaptorFixture, creation_sets_name) { + auto texture = create("test"); + + dispatch(); + + auto engineSampler = select(*sceneContext.scene(), "test"); + EXPECT_TRUE(engineSampler != nullptr); + EXPECT_EQ(engineSampler->getName(), std::string("test")); +} + +TEST_F(TextureExternalAdaptorFixture, change_name) { + auto texture = create("test"); + + dispatch(); + { + auto engineSamplers{select(*sceneContext.scene(), ramses::ERamsesObjectType::ERamsesObjectType_TextureSamplerExternal)}; + EXPECT_EQ(engineSamplers.size(), 1); + EXPECT_STREQ("test", engineSamplers[0]->getName()); + } + + commandInterface.set({texture, &raco::user_types::TextureExternal::objectName_}, std::string("newName")); + + dispatch(); + { + auto engineSamplers{select(*sceneContext.scene(), ramses::ERamsesObjectType::ERamsesObjectType_TextureSamplerExternal)}; + EXPECT_EQ(engineSamplers.size(), 1); + EXPECT_STREQ("newName", engineSamplers[0]->getName()); + } +} \ No newline at end of file diff --git a/datamodel/libCore/include/core/CoreFormatter.h b/datamodel/libCore/include/core/CoreFormatter.h index dc9f7818..de708dcf 100644 --- a/datamodel/libCore/include/core/CoreFormatter.h +++ b/datamodel/libCore/include/core/CoreFormatter.h @@ -78,7 +78,8 @@ struct fmt::formatter : formatter { {raco::core::EnginePrimitive::TextureSampler2D, "TextureSampler2D"}, {raco::core::EnginePrimitive::TextureSampler2DMS, "TextureSampler2DMS"}, {raco::core::EnginePrimitive::TextureSampler3D, "TextureSampler3D"}, - {raco::core::EnginePrimitive::TextureSamplerCube, "TextureSamplerCube"}}; + {raco::core::EnginePrimitive::TextureSamplerCube, "TextureSamplerCube"}, + {raco::core::EnginePrimitive::TextureSamplerExternal, "TextureSamplerExternal"}}; return formatter::format(nameMap.at(type), ctx); } }; diff --git a/datamodel/libCore/include/core/EngineInterface.h b/datamodel/libCore/include/core/EngineInterface.h index dd7282ea..7a34d266 100644 --- a/datamodel/libCore/include/core/EngineInterface.h +++ b/datamodel/libCore/include/core/EngineInterface.h @@ -61,7 +61,8 @@ enum class EnginePrimitive { TextureSamplerCube, // Types added later, in the bottom of the enum to avoid file format changing Int64, - TextureSampler2DMS + TextureSampler2DMS, + TextureSamplerExternal }; struct PropertyInterface; @@ -101,7 +102,9 @@ struct PropertyInterface { {EnginePrimitive::TextureSampler2D, data_storage::PrimitiveType::Ref}, {EnginePrimitive::TextureSampler2DMS, data_storage::PrimitiveType::Ref}, {EnginePrimitive::TextureSampler3D, data_storage::PrimitiveType::Ref}, - {EnginePrimitive::TextureSamplerCube, data_storage::PrimitiveType::Ref}}; + {EnginePrimitive::TextureSamplerCube, data_storage::PrimitiveType::Ref}, + {EnginePrimitive::TextureSamplerExternal, data_storage::PrimitiveType::Ref} + }; auto it = typeMap.find(type); assert(it != typeMap.end()); diff --git a/datamodel/libCore/include/core/ProjectMigration.h b/datamodel/libCore/include/core/ProjectMigration.h index 38a0bd9c..b79392c9 100644 --- a/datamodel/libCore/include/core/ProjectMigration.h +++ b/datamodel/libCore/include/core/ProjectMigration.h @@ -94,9 +94,10 @@ namespace raco::serialization { * Added ExpectEmptyReference annotation to RenderTarget::buffer0 property. * 47: Added Skin user type. * 48: Added LuaInterface "stdModules" and "luaModules" properties. + * 49: Added TextureExternal user type. */ -constexpr int RAMSES_PROJECT_FILE_VERSION = 48; +constexpr int RAMSES_PROJECT_FILE_VERSION = 49; void migrateProject(ProjectDeserializationInfoIR& deserializedIR, raco::serialization::proxy::ProxyObjectFactory& factory); diff --git a/datamodel/libCore/include/core/ProxyObjectFactory.h b/datamodel/libCore/include/core/ProxyObjectFactory.h index 1cec11c3..9549e72d 100644 --- a/datamodel/libCore/include/core/ProxyObjectFactory.h +++ b/datamodel/libCore/include/core/ProxyObjectFactory.h @@ -86,6 +86,7 @@ class ProxyObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, Property, @@ -104,6 +105,7 @@ class ProxyObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, Property, @@ -122,6 +124,7 @@ class ProxyObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, Property, @@ -139,6 +142,7 @@ class ProxyObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, diff --git a/datamodel/libCore/include/core/ProxyTypes.h b/datamodel/libCore/include/core/ProxyTypes.h index db95ad8d..1d7fa30e 100644 --- a/datamodel/libCore/include/core/ProxyTypes.h +++ b/datamodel/libCore/include/core/ProxyTypes.h @@ -84,6 +84,11 @@ using STexture = std::shared_ptr; // BaseTexture -> TextureSampler2DBase -> Texture // -> RenderBuffer +extern const char textureExternalTypeName[]; +using TextureExternal = Proxy; +using STextureExternal = std::shared_ptr; + + extern const char blitPassTypeName[]; using BlitPass = Proxy; using SBlitPass = std::shared_ptr; diff --git a/datamodel/libCore/src/ProxyObjectFactory.cpp b/datamodel/libCore/src/ProxyObjectFactory.cpp index 95daeec6..addeaa41 100644 --- a/datamodel/libCore/src/ProxyObjectFactory.cpp +++ b/datamodel/libCore/src/ProxyObjectFactory.cpp @@ -79,6 +79,7 @@ namespace raco::serialization::proxy { LuaInterface, LuaScriptModule, Texture, + TextureExternal, RenderBuffer, RenderBufferMS, RenderLayer, diff --git a/datamodel/libCore/src/ProxyTypes.cpp b/datamodel/libCore/src/ProxyTypes.cpp index 03448060..edf01a14 100644 --- a/datamodel/libCore/src/ProxyTypes.cpp +++ b/datamodel/libCore/src/ProxyTypes.cpp @@ -24,6 +24,7 @@ const char animationTypeName[] = "Animation"; const char animationChannelTypeName[] = "AnimationChannel"; const char textureSampler2DBaseTypeName[] = "TextureSampler2DBase"; const char textureTypeName[] = "Texture"; +const char textureExternalTypeName[] = "TextureExternal"; const char blitPassTypeName[] = "BlitPass"; const char cubeMapTypeName[] = "CubeMap"; const char baseCameraTypeName[] = "BaseCamera"; diff --git a/datamodel/libCore/tests/migrationTestData/version-current.rca b/datamodel/libCore/tests/migrationTestData/version-current.rca index 1404abaf..bc28dcb3 100644 --- a/datamodel/libCore/tests/migrationTestData/version-current.rca +++ b/datamodel/libCore/tests/migrationTestData/version-current.rca @@ -2,7 +2,7 @@ "externalProjects": { }, "featureLevel": 5, - "fileVersion": 48, + "fileVersion": 49, "instances": [ { "properties": { @@ -1867,7 +1867,7 @@ "objectID": "9c2eeeea-cef0-42a5-9815-d32d38ccfd60", "objectName": "Timer", "outputs": { - "ticker_us": "106445207921" + "ticker_us": "675091740822" } }, "typeName": "Timer" @@ -2038,6 +2038,15 @@ }, "typeName": "LuaInterface" }, + { + "properties": { + "magSamplingMethod": 0, + "minSamplingMethod": 0, + "objectID": "d14f0900-fcb0-4222-bda6-e475629d30fe", + "objectName": "TextureExternal" + }, + "typeName": "TextureExternal" + }, { "properties": { "animationIndex": 0, @@ -2229,7 +2238,7 @@ "logicEngineVersion": [ 1, 4, - 0 + 1 ], "racoVersion": [ 1, @@ -2239,7 +2248,7 @@ "ramsesVersion": [ 27, 0, - 126 + 129 ], "structPropMap": { "AnchorPointOutputs": { @@ -2631,6 +2640,13 @@ "wrapUMode": "Int::DisplayNameAnnotation::EnumerationAnnotation", "wrapVMode": "Int::DisplayNameAnnotation::EnumerationAnnotation" }, + "TextureExternal": { + "children": "Table::ArraySemanticAnnotation::HiddenProperty", + "magSamplingMethod": "Int::DisplayNameAnnotation::EnumerationAnnotation", + "minSamplingMethod": "Int::DisplayNameAnnotation::EnumerationAnnotation", + "objectID": "String::HiddenProperty", + "objectName": "String::DisplayNameAnnotation" + }, "Timer": { "children": "Table::ArraySemanticAnnotation::HiddenProperty", "inputs": "TimerInput::DisplayNameAnnotation", diff --git a/datamodel/libUserTypes/CMakeLists.txt b/datamodel/libUserTypes/CMakeLists.txt index 2a3d2b82..83dffb0b 100644 --- a/datamodel/libUserTypes/CMakeLists.txt +++ b/datamodel/libUserTypes/CMakeLists.txt @@ -40,6 +40,7 @@ add_library(libUserTypes include/user_types/Skin.h src/Skin.cpp include/user_types/SyncTableWithEngineInterface.h src/SyncTableWithEngineInterface.cpp include/user_types/Texture.h src/Texture.cpp + include/user_types/TextureExternal.h src/TextureExternal.cpp include/user_types/Timer.h src/Timer.cpp include/user_types/UserObjectFactory.h src/UserObjectFactory.cpp src/Validation.h diff --git a/datamodel/libUserTypes/include/user_types/TextureExternal.h b/datamodel/libUserTypes/include/user_types/TextureExternal.h new file mode 100644 index 00000000..7c69de33 --- /dev/null +++ b/datamodel/libUserTypes/include/user_types/TextureExternal.h @@ -0,0 +1,50 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * + * This file is part of Ramses Composer + * (see https://github.com/bmwcarit/ramses-composer). + * + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#pragma once + +#include "user_types/BaseObject.h" +#include "user_types/DefaultValues.h" +#include "core/EngineInterface.h" + +namespace raco::user_types { + +class TextureExternal : public BaseObject { +public: + static inline const TypeDescriptor typeDescription = {"TextureExternal", true}; + TypeDescriptor const& getTypeDescription() const override { + return typeDescription; + } + + TextureExternal(TextureExternal const& other) + : BaseObject(other), + minSamplingMethod_(other.minSamplingMethod_), + magSamplingMethod_(other.magSamplingMethod_) { + fillPropertyDescription(); + } + + TextureExternal(const std::string& name, const std::string& id) : BaseObject(name, id) { + fillPropertyDescription(); + } + + void fillPropertyDescription() { + properties_.emplace_back("minSamplingMethod", &minSamplingMethod_); + properties_.emplace_back("magSamplingMethod", &magSamplingMethod_); + } + + // Using TextureMagSamplingMethod enumeration for min sampler is weird, but for external textures + // only nearest and linear are allowed by ramses so instead of creating a new enumeration with the same + // content we just reuse the mag sampling method one. + Property minSamplingMethod_{DEFAULT_VALUE_TEXTURE_SAMPLER_TEXTURE_MAG_SAMPLING_METHOD_NEAREST, DisplayNameAnnotation("Min Sampling Method"), EnumerationAnnotation{TextureMagSamplingMethod}}; + Property magSamplingMethod_{DEFAULT_VALUE_TEXTURE_SAMPLER_TEXTURE_MAG_SAMPLING_METHOD_NEAREST, DisplayNameAnnotation("Mag Sampling Method"), EnumerationAnnotation{TextureMagSamplingMethod}}; +}; + +using STextureExternal = std::shared_ptr; + +} // namespace raco::user_types diff --git a/datamodel/libUserTypes/include/user_types/UserObjectFactory.h b/datamodel/libUserTypes/include/user_types/UserObjectFactory.h index 76f03fbf..8e75932e 100644 --- a/datamodel/libUserTypes/include/user_types/UserObjectFactory.h +++ b/datamodel/libUserTypes/include/user_types/UserObjectFactory.h @@ -45,6 +45,9 @@ using STexture = std::shared_ptr; class TextureSampler2DBase; using STextureSampler2DBase = std::shared_ptr; +class TextureExternal; +using STextureExternal = std::shared_ptr; + class RenderBuffer; using SRenderBuffer = std::shared_ptr; @@ -117,6 +120,7 @@ class UserObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, Property, @@ -135,6 +139,7 @@ class UserObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, Property, @@ -153,6 +158,7 @@ class UserObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, Property, @@ -170,6 +176,7 @@ class UserObjectFactory : public raco::core::UserObjectFactoryInterface { Property, Property, Property, + Property, Property, Property, diff --git a/datamodel/libUserTypes/src/SyncTableWithEngineInterface.cpp b/datamodel/libUserTypes/src/SyncTableWithEngineInterface.cpp index a4728d99..e785ba27 100644 --- a/datamodel/libUserTypes/src/SyncTableWithEngineInterface.cpp +++ b/datamodel/libUserTypes/src/SyncTableWithEngineInterface.cpp @@ -16,6 +16,7 @@ #include "user_types/CubeMap.h" #include "user_types/Texture.h" +#include "user_types/TextureExternal.h" #include "user_types/EngineTypeAnnotation.h" #include "user_types/UserObjectFactory.h" #include "user_types/RenderBufferMS.h" @@ -84,6 +85,9 @@ raco::data_storage::ValueBase* createDynamicProperty(EnginePrimitive type) { case EnginePrimitive::TextureSamplerCube: return UserObjectFactory::staticCreateProperty({}, {type}, {Args()}...); break; + case EnginePrimitive::TextureSamplerExternal: + return UserObjectFactory::staticCreateProperty({}, {type}, {Args()}...); + break; } return nullptr; } diff --git a/datamodel/libUserTypes/src/TextureExternal.cpp b/datamodel/libUserTypes/src/TextureExternal.cpp new file mode 100644 index 00000000..7e34697e --- /dev/null +++ b/datamodel/libUserTypes/src/TextureExternal.cpp @@ -0,0 +1,14 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * + * This file is part of Ramses Composer + * (see https://github.com/bmwcarit/ramses-composer). + * + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#include "user_types/TextureExternal.h" + +namespace raco::user_types { + +} // namespace raco::user_types diff --git a/datamodel/libUserTypes/src/UserObjectFactory.cpp b/datamodel/libUserTypes/src/UserObjectFactory.cpp index 5cb4d37f..8d751abc 100644 --- a/datamodel/libUserTypes/src/UserObjectFactory.cpp +++ b/datamodel/libUserTypes/src/UserObjectFactory.cpp @@ -38,6 +38,7 @@ #include "user_types/RenderPass.h" #include "user_types/Skin.h" #include "user_types/Texture.h" +#include "user_types/TextureExternal.h" #include "user_types/Timer.h" namespace raco::user_types { @@ -103,6 +104,7 @@ UserObjectFactory::UserObjectFactory() { LuaScript, LuaScriptModule, Texture, + TextureExternal, Timer, RenderBuffer, RenderBufferMS, diff --git a/gui/libObjectTree/include/object_tree_view_model/ObjectTreeViewDefaultModel.h b/gui/libObjectTree/include/object_tree_view_model/ObjectTreeViewDefaultModel.h index aa006237..103d6e7c 100644 --- a/gui/libObjectTree/include/object_tree_view_model/ObjectTreeViewDefaultModel.h +++ b/gui/libObjectTree/include/object_tree_view_model/ObjectTreeViewDefaultModel.h @@ -152,6 +152,7 @@ public Q_SLOTS: {"PerspectiveCamera", raco::style::Icons::instance().typeCamera}, {"OrthographicCamera", raco::style::Icons::instance().typeCamera}, {"Texture", raco::style::Icons::instance().typeTexture}, + {"TextureExternal", raco::style::Icons::instance().typeTexture}, {"CubeMap", raco::style::Icons::instance().typeCubemap}, {"LuaScript", raco::style::Icons::instance().typeLuaScript}, {"LuaInterface", raco::style::Icons::instance().typeLuaInterface}, diff --git a/gui/libObjectTree/tests/ObjectTreeViewResourceModel_test.cpp b/gui/libObjectTree/tests/ObjectTreeViewResourceModel_test.cpp index 7253c8cf..ce3f64af 100644 --- a/gui/libObjectTree/tests/ObjectTreeViewResourceModel_test.cpp +++ b/gui/libObjectTree/tests/ObjectTreeViewResourceModel_test.cpp @@ -22,6 +22,7 @@ #include "user_types/RenderLayer.h" #include "user_types/RenderTarget.h" #include "user_types/RenderPass.h" +#include "user_types/TextureExternal.h" #include "user_types/Timer.h" using namespace raco::user_types; @@ -39,6 +40,7 @@ class ObjectTreeViewResourceModelTest : public ObjectTreeViewDefaultModelTest { Mesh::typeDescription.typeName, LuaScriptModule::typeDescription.typeName, Texture::typeDescription.typeName, + TextureExternal::typeDescription.typeName, Timer::typeDescription.typeName, RenderBuffer::typeDescription.typeName, RenderBufferMS::typeDescription.typeName, @@ -59,6 +61,7 @@ TEST_F(ObjectTreeViewResourceModelTest, TypesAllowedIntoIndexEmptyIndex) { Mesh::typeDescription.typeName, LuaScriptModule::typeDescription.typeName, Texture::typeDescription.typeName, + TextureExternal::typeDescription.typeName, Timer::typeDescription.typeName, RenderBuffer::typeDescription.typeName, RenderBufferMS::typeDescription.typeName, diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 882a5227..5e1e22ae 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -49,10 +49,18 @@ set(RESOURCE_FILES shaders/cubemap.vert shaders/default.frag shaders/default.vert + shaders/morphing-template.vert + shaders/morphing-template.frag shaders/multisampler.frag shaders/multisampler.vert shaders/simple_texture.frag shaders/simple_texture.vert + shaders/skinning-template.vert + shaders/skinning-template.frag + shaders/tangent.vert + shaders/tangent.frag + shaders/uniform-array.vert + shaders/uniform-array.frag example_scene.rca ) diff --git a/resources/shaders/texture-external.frag b/resources/shaders/texture-external.frag new file mode 100644 index 00000000..32d4b7be --- /dev/null +++ b/resources/shaders/texture-external.frag @@ -0,0 +1,21 @@ +#version 300 es +#extension GL_OES_EGL_image_external_essl3 : require + +precision mediump float; + +uniform samplerExternalOES utex; + +uniform bool enableFlatColor; +uniform vec4 color; + +in vec2 v_TextureCoordinate; + +out vec4 fragColor; + +void main() { + if (enableFlatColor) { + fragColor = color; + } else { + fragColor = texture(utex, v_TextureCoordinate); + } +} \ No newline at end of file diff --git a/resources/shaders/texture-external.vert b/resources/shaders/texture-external.vert new file mode 100644 index 00000000..753af567 --- /dev/null +++ b/resources/shaders/texture-external.vert @@ -0,0 +1,17 @@ +#version 300 es +#extension GL_OES_EGL_image_external_essl3 : require + +precision mediump float; + +in vec3 a_Position; +in vec2 a_TextureCoordinate; + +out vec2 v_TextureCoordinate; + +uniform mat4 u_MVPMatrix; + +void main() { + v_TextureCoordinate = a_TextureCoordinate; + + gl_Position = u_MVPMatrix * vec4(a_Position, 1.0); +} \ No newline at end of file diff --git a/third_party/ramses-logic b/third_party/ramses-logic index 3fca2451..a58dd77f 160000 --- a/third_party/ramses-logic +++ b/third_party/ramses-logic @@ -1 +1 @@ -Subproject commit 3fca24512befe735a1ee6996282bd7a63a8313f0 +Subproject commit a58dd77f2b3f87ed18181a9599e3e697a0451ec8