Skip to content

Commit

Permalink
Release v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
webermm committed Jan 27, 2023
1 parent fb0a18f commit a2eef8e
Show file tree
Hide file tree
Showing 33 changed files with 350 additions and 13 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions EditorApp/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions components/libRamsesBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <ramses-client-api/TextureSamplerExternal.h>

#include <memory>

namespace raco::ramses_adaptor {

class TextureExternalAdaptor : public TypedObjectAdaptor<user_types::TextureExternal, ramses::TextureSamplerExternal> {
public:
explicit TextureExternalAdaptor(SceneAdaptor* sceneAdaptor, std::shared_ptr<user_types::TextureExternal> editorObject);

bool sync(core::Errors* errors) override;
std::vector<ExportInformation> getExportInformation() const override;

private:
std::array<components::Subscription, 2> subscriptions_;
};

}; // namespace raco::ramses_adaptor
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ struct fmt::formatter<ramses::ERamsesObjectType> : formatter<string_view> {
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");
}
Expand Down
13 changes: 12 additions & 1 deletion components/libRamsesBase/include/ramses_base/RamsesHandles.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <ramses-client-api/TextureCube.h>
#include <ramses-client-api/TextureSampler.h>
#include <ramses-client-api/TextureSamplerMS.h>
#include <ramses-client-api/TextureSamplerExternal.h>
#include <ramses-client-api/UniformInput.h>

#include <ramses-logic/AnchorPoint.h>
Expand Down Expand Up @@ -74,6 +75,7 @@ using RamsesRenderBuffer = RamsesHandle<ramses::RenderBuffer>;
using RamsesRenderTarget = RamsesHandle<ramses::RenderTarget>;
using RamsesTextureSampler = RamsesHandle<ramses::TextureSampler>;
using RamsesTextureSamplerMS = RamsesHandle<ramses::TextureSamplerMS>;
using RamsesTextureSamplerExternal = RamsesHandle<ramses::TextureSamplerExternal>;
using RamsesTimerNode = RamsesHandle<rlogic::TimerNode>;
using RamsesLuaModule = RamsesHandle<rlogic::LuaModule>;
using RamsesLuaScript = RamsesHandle<rlogic::LuaScript>;
Expand Down Expand Up @@ -140,9 +142,10 @@ struct RamsesAppearanceHandle {
return appearance_;
}

void replaceTrackedSamplers(std::vector<raco::ramses_base::RamsesTextureSampler>& newSamplers, std::vector<raco::ramses_base::RamsesTextureSamplerMS>& newSamplersMS) {
void replaceTrackedSamplers(std::vector<raco::ramses_base::RamsesTextureSampler>& newSamplers, std::vector<raco::ramses_base::RamsesTextureSamplerMS>& newSamplersMS, std::vector<raco::ramses_base::RamsesTextureSamplerExternal>& newSamplersExternal) {
trackedSamplers_ = newSamplers;
trackedSamplersMS_ = newSamplersMS;
trackedSamplersExternal_ = newSamplersExternal;
}

RamsesEffect effect() {
Expand All @@ -162,6 +165,7 @@ struct RamsesAppearanceHandle {
// Samplers currently in use by the appearance_. Needed to keep the samplers alive in ramses.
std::vector<raco::ramses_base::RamsesTextureSampler> trackedSamplers_;
std::vector<raco::ramses_base::RamsesTextureSamplerMS> trackedSamplersMS_;
std::vector<raco::ramses_base::RamsesTextureSamplerExternal> trackedSamplersExternal_;
};

using RamsesAppearance = std::shared_ptr<RamsesAppearanceHandle>;
Expand Down Expand Up @@ -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<ramses::TextureSamplerExternal>(scene)
};
}

/** RESOURCE FACTORIES */

inline RamsesEffect ramsesEffect(ramses::Scene* scene, const ramses::EffectDescription& description, const char* name = nullptr) {
Expand Down
2 changes: 2 additions & 0 deletions components/libRamsesBase/src/ramses_adaptor/Factories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<MaterialAdaptor>(sceneAdaptor, std::dynamic_pointer_cast<user_types::Material>(obj)); }},
{user_types::Mesh::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique<MeshAdaptor>(sceneAdaptor, std::dynamic_pointer_cast<user_types::Mesh>(obj)); }},
{user_types::Texture::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique<TextureSamplerAdaptor>(sceneAdaptor, std::dynamic_pointer_cast<user_types::Texture>(obj)); }},
{user_types::TextureExternal::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique<TextureExternalAdaptor>(sceneAdaptor, std::dynamic_pointer_cast<user_types::TextureExternal>(obj)); }},
{user_types::CubeMap::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique<CubeMapAdaptor>(sceneAdaptor, std::dynamic_pointer_cast<user_types::CubeMap>(obj)); }},
{user_types::LuaScriptModule::typeDescription.typeName, [](SceneAdaptor* sceneAdaptor, core::SEditorObject obj) { return std::make_unique<LuaScriptModuleAdaptor>(sceneAdaptor, std::dynamic_pointer_cast<user_types::LuaScriptModule>(obj)); }},

Expand Down
19 changes: 18 additions & 1 deletion components/libRamsesBase/src/ramses_adaptor/MaterialAdaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -161,6 +162,7 @@ void updateAppearance(core::Errors* errors, SceneAdaptor* sceneAdaptor, raco::ra

std::vector<raco::ramses_base::RamsesTextureSampler> newSamplers;
std::vector<raco::ramses_base::RamsesTextureSamplerMS> newSamplersMS;
std::vector<raco::ramses_base::RamsesTextureSamplerExternal> newSamplersExternal;

for (size_t i{0}; i < uniformsHandle.size(); i++) {
setUniform(appearance->get(), uniformsHandle[i]);
Expand All @@ -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<user_types::TextureExternal>()) {
if (auto adaptor = sceneAdaptor->lookup<TextureExternalAdaptor>(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) {
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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<user_types::TextureExternal> 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<ramses::ETextureSamplingMethod>(*editorObject()->minSamplingMethod_),
static_cast<ramses::ETextureSamplingMethod>(*editorObject()->magSamplingMethod_)));

tagDirty(false);
return true;
}

std::vector<ExportInformation> TextureExternalAdaptor::getExportInformation() const {
if (getRamsesObjectPointer()) {
return {
ExportInformation{ramsesObject().getType(), ramsesObject().getName()},
};
}
return {};
}

} // namespace raco::ramses_adaptor
4 changes: 3 additions & 1 deletion components/libRamsesBase/src/ramses_base/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ static std::map<ramses::EEffectInputDataType, raco::core::EnginePrimitive> 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<ramses::EffectDescription> createEffectDescription(const std::string &vertexShader, const std::string &geometryShader, const std::string &fragmentShader, const std::string &shaderDefines) {
std::unique_ptr<ramses::EffectDescription> description{new ramses::EffectDescription};
Expand Down
1 change: 1 addition & 0 deletions components/libRamsesBase/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions components/libRamsesBase/tests/TextureExternalAdaptor_test.cpp
Original file line number Diff line number Diff line change
@@ -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 <gtest/gtest.h>

#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<raco::user_types::TextureExternal>("test");

dispatch();

auto engineSampler = select<ramses::TextureSamplerExternal>(*sceneContext.scene(), "test");
EXPECT_TRUE(engineSampler != nullptr);
EXPECT_EQ(engineSampler->getName(), std::string("test"));
}

TEST_F(TextureExternalAdaptorFixture, change_name) {
auto texture = create<raco::user_types::TextureExternal>("test");

dispatch();
{
auto engineSamplers{select<ramses::TextureSamplerExternal>(*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<ramses::TextureSamplerExternal>(*sceneContext.scene(), ramses::ERamsesObjectType::ERamsesObjectType_TextureSamplerExternal)};
EXPECT_EQ(engineSamplers.size(), 1);
EXPECT_STREQ("newName", engineSamplers[0]->getName());
}
}
3 changes: 2 additions & 1 deletion datamodel/libCore/include/core/CoreFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ struct fmt::formatter<raco::core::EnginePrimitive> : formatter<string_view> {
{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<string_view>::format(nameMap.at(type), ctx);
}
};
Expand Down
7 changes: 5 additions & 2 deletions datamodel/libCore/include/core/EngineInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion datamodel/libCore/include/core/ProjectMigration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading

0 comments on commit a2eef8e

Please sign in to comment.