Removes LuxCore (#6491)

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-12-22 09:06:28 -08:00
committed by GitHub
parent aafb9e8110
commit 74f0cb5b98
37 changed files with 6 additions and 1626 deletions
@@ -1,61 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli>
#include <Atom/Features/PostProcessing/FullscreenPixelInfo.azsli>
#include <Atom/Features/PostProcessing/FullscreenVertex.azsli>
ShaderResourceGroup PassSrg : SRG_PerPass
{
Texture2D m_sourceTexture;
Sampler TextureSampler
{
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
AddressW = Clamp;
};
}
float4 RestoreNormalMap(float4 normalMapSample)
{
float4 restoredNormal;
// [GFX TODO][ATOM-2404] For some reason, the image build pipeline swaps the R and G channels so we swap them back here.
restoredNormal.xy = normalMapSample.yx;
// The image build pipeline drops the B channel so we have to reconstruct it here.
restoredNormal.z = sqrt(1 - dot(restoredNormal.xy, restoredNormal.xy));
restoredNormal.xyz = restoredNormal.xyz * 0.5 + 0.5;
restoredNormal.a = 1;
return restoredNormal;
}
option bool o_isNormal;
PSOutput MainPS(VSOutput IN)
{
PSOutput OUT;
if(o_isNormal)
{
float4 sampledValue = PassSrg::m_sourceTexture.SampleLevel(PassSrg::TextureSampler, IN.m_texCoord, 0);
OUT.m_color = RestoreNormalMap(sampledValue);
}
else
{
OUT.m_color = PassSrg::m_sourceTexture.SampleLevel(PassSrg::TextureSampler, IN.m_texCoord, 0);
}
return OUT;
}
@@ -1,22 +0,0 @@
{
"Source" : "RenderTexture.azsl",
"DepthStencilState" : {
"Depth" : { "Enable" : false }
},
"ProgramSettings":
{
"EntryPoints":
[
{
"name": "MainVS",
"type": "Vertex"
},
{
"name": "MainPS",
"type": "Fragment"
}
]
}
}
@@ -1,17 +0,0 @@
{
"Shader" : "RenderTexture.shader",
"Variants" : [
{
"StableId": 1,
"Options": {
"o_isNormal": "false"
}
},
{
"StableId": 2,
"Options": {
"o_isNormal": "true"
}
}
]
}
@@ -366,8 +366,6 @@ set(FILES
Shaders/LightCulling/LightCullingRemap.shader
Shaders/LightCulling/LightCullingTilePrepare.azsl
Shaders/LightCulling/LightCullingTilePrepare.shader
Shaders/LuxCore/RenderTexture.azsl
Shaders/LuxCore/RenderTexture.shader
Shaders/MorphTargets/MorphTargetCS.azsl
Shaders/MorphTargets/MorphTargetCS.shader
Shaders/MorphTargets/MorphTargetSRG.azsli
@@ -40,7 +40,6 @@ ly_add_target(
Gem::Atom_Feature_Common.Public
Gem::ImGui.imguilib
3rdParty::TIFF
#3rdParty::lux_core # AZ_TRAIT_LUXCORE_SUPPORTED is disabled in every platform, Issue #3915 will remove
RUNTIME_DEPENDENCIES
Gem::ImGui.imguilib
)
@@ -91,7 +90,6 @@ ly_add_target(
AZ::AzFramework
Gem::Atom_Feature_Common.Static
Gem::Atom_Feature_Common.Public
#3rdParty::lux_core # AZ_TRAIT_LUXCORE_SUPPORTED is disabled in every platform, Issue #3915 will remove
)
if(PAL_TRAIT_BUILD_HOST_TOOLS)
@@ -1,63 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
#include <Atom/RPI.Reflect/Image/Image.h>
#include <Atom/RPI.Public/Material/Material.h>
namespace AZ
{
namespace Render
{
enum LuxCoreTextureType
{
Default = 0,
IBL,
Albedo,
Normal
};
class LuxCoreRequests
: public EBusTraits
{
public:
/// Overrides the default AZ::EBusTraits handler policy to allow one listener only.
static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Single;
virtual ~LuxCoreRequests() {}
virtual void SetCameraEntityID(AZ::EntityId id) = 0;
virtual void AddMesh(Data::Asset<RPI::ModelAsset> modelAsset) = 0;
virtual void AddMaterial(Data::Instance<RPI::Material> material) = 0;
virtual void AddTexture(Data::Instance<RPI::Image> texture, LuxCoreTextureType type) = 0;
virtual void AddObject(Data::Asset<RPI::ModelAsset> modelAsset, Data::InstanceId materialInstanceId) = 0;
virtual bool CheckTextureStatus() = 0;
virtual void RenderInLuxCore() = 0;
virtual void ClearLuxCore() = 0;
virtual void ClearObject() = 0;
};
typedef AZ::EBus<LuxCoreRequests> LuxCoreRequestsBus;
class LuxCoreNotification
: public EBusTraits
{
public:
static const EBusAddressPolicy AddressPolicy = EBusAddressPolicy::ById;
/**
* Overrides the default AZ::EBusTraits ID type so that AssetId are
* used to access the addresses of the bus.
*/
typedef Data::AssetId BusIdType;
virtual ~LuxCoreNotification() {}
virtual void OnRenderPrepare() {}
};
typedef AZ::EBus<LuxCoreNotification> LuxCoreNotificationBus;
}
}
@@ -1,51 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/Memory/SystemAllocator.h>
#include <Atom/RPI.Public/Pass/AttachmentReadback.h>
#include <Atom/RPI.Public/Pass/ParentPass.h>
#include <Atom/RPI.Reflect/Image/Image.h>
#include <Atom/Feature/LuxCore/RenderTexturePass.h>
namespace AZ
{
namespace Render
{
class LuxCoreTexturePass final
: public RPI::ParentPass
{
public:
AZ_RTTI(LuxCoreTexturePass, "{A6CA80C0-63A6-4686-A627-B5D1DA04B627}", ParentPass);
AZ_CLASS_ALLOCATOR(LuxCoreTexturePass, SystemAllocator, 0);
static RPI::Ptr<LuxCoreTexturePass> Create(const RPI::PassDescriptor& descriptor);
LuxCoreTexturePass(const RPI::PassDescriptor& descriptor);
~LuxCoreTexturePass();
void SetSourceTexture(Data::Instance<AZ::RPI::Image> image, RHI::Format format);
void SetIsNormalTexture(bool isNormal);
void SetReadbackCallback(RPI::AttachmentReadback::CallbackFunction callbackFunciton);
protected:
// Pass behavior overrides
void CreateChildPassesInternal() final;
void BuildInternal() final;
void FrameBeginInternal(FramePrepareParams params) final;
private:
RPI::Ptr<RPI::Pass> m_renderTargetPass = nullptr;
AZStd::shared_ptr<RPI::AttachmentReadback> m_readback = nullptr;
bool m_attachmentReadbackComplete = false;
};
}
}
@@ -1,55 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
namespace AZ
{
namespace Render
{
/*
* A simple pass to render a texture to an attachment render target
* The attachment size and format will be configure as the same as the input texture
*/
class RenderTexturePass final
: public RPI::FullscreenTrianglePass
{
AZ_RPI_PASS(RenderTexturePass);
public:
AZ_RTTI(RenderTexturePass, "{476A4E41-08D7-456C-B324-E0493A321FE7}", FullscreenTrianglePass);
AZ_CLASS_ALLOCATOR(RenderTexturePass, SystemAllocator, 0);
virtual ~RenderTexturePass();
static RPI::Ptr<RenderTexturePass> Create(const RPI::PassDescriptor& descriptor);
// Set the source image
void SetPassSrgImage(AZ::Data::Instance<AZ::RPI::Image> image, RHI::Format format);
RHI::AttachmentId GetRenderTargetId();
void InitShaderVariant(bool isNormal);
protected:
RenderTexturePass(const RPI::PassDescriptor& descriptor);
private:
void BuildInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
void UpdataAttachment();
RHI::ShaderInputImageIndex m_textureIndex;
RHI::Size m_attachmentSize;
RHI::Format m_attachmentFormat;
};
}
}
@@ -74,11 +74,6 @@
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include <Atom/Feature/LuxCore/RenderTexturePass.h>
#include <Atom/Feature/LuxCore/LuxCoreTexturePass.h>
#endif
#include <Checkerboard/CheckerboardPass.h>
#include <Checkerboard/CheckerboardColorResolvePass.h>
@@ -221,11 +216,6 @@ namespace AZ
passSystem->AddPassCreator(Name("DisplayMapperFullScreenPass"), &DisplayMapperFullScreenPass::Create);
passSystem->AddPassCreator(Name("OutputTransformPass"), &OutputTransformPass::Create);
passSystem->AddPassCreator(Name("EyeAdaptationPass"), &EyeAdaptationPass::Create);
// Add RenderTexture and LuxCoreTexture pass
#if AZ_TRAIT_LUXCORE_SUPPORTED
passSystem->AddPassCreator(Name("RenderTexturePass"), &RenderTexturePass::Create);
passSystem->AddPassCreator(Name("LuxCoreTexturePass"), &LuxCoreTexturePass::Create);
#endif
passSystem->AddPassCreator(Name("ImGuiPass"), &ImGuiPass::Create);
passSystem->AddPassCreator(Name("LightCullingPass"), &LightCullingPass::Create);
passSystem->AddPassCreator(Name("LightCullingRemapPass"), &LightCullingRemap::Create);
@@ -12,10 +12,6 @@
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include "LuxCore/LuxCoreRenderer.h"
#endif
namespace AZ
{
namespace Render
@@ -50,11 +46,6 @@ namespace AZ
RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler m_loadTemplatesHandler;
AZStd::unique_ptr<ModelReloaderSystem> m_modelReloaderSystem;
#if AZ_TRAIT_LUXCORE_SUPPORTED
// LuxCore
LuxCoreRenderer m_luxCore;
#endif
};
} // namespace Render
} // namespace AZ
@@ -1,139 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include "LuxCoreMaterial.h"
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
#include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
#include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
namespace AZ
{
namespace Render
{
LuxCoreMaterial::LuxCoreMaterial(const AZ::Data::Instance<AZ::RPI::Material>& material)
{
Init(material);
}
LuxCoreMaterial::LuxCoreMaterial(const LuxCoreMaterial &material)
{
Init(material.m_material);
}
LuxCoreMaterial::~LuxCoreMaterial()
{
if (m_material)
{
m_material = nullptr;
}
}
void LuxCoreMaterial::Init(const AZ::Data::Instance<AZ::RPI::Material>& material)
{
m_material = material;
m_luxCoreMaterialName = "scene.materials." + m_material->GetId().ToString<AZStd::string>();
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(m_luxCoreMaterialName.data()) + ".type")("disney");
ParseProperty(s_pbrColorGroup, ".basecolor");
ParseProperty(s_pbrMetallicGroup, ".metallic");
ParseProperty(s_pbrRoughnessGroup, ".roughness");
ParseProperty(s_pbrSpecularGroup, ".specular");
ParseProperty(s_pbrNormalGroup, ".bumptex");
}
bool LuxCoreMaterial::ParseTexture(const char* group, AZStd::string propertyName)
{
AZ::RPI::MaterialPropertyIndex propertyIndex;
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(group, s_pbrUseTextureProperty));
bool useTexture = m_material->GetPropertyValue<bool>(propertyIndex);
if (useTexture)
{
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(group, s_pbrTextureProperty));
Data::Instance<RPI::Image> texture = m_material->GetPropertyValue<Data::Instance<RPI::Image>>(propertyIndex);
if (texture)
{
if (group == s_pbrNormalGroup)
{
AZ::Render::LuxCoreRequestsBus::Broadcast(&AZ::Render::LuxCoreRequestsBus::Events::AddTexture, texture, LuxCoreTextureType::Normal);
}
else if (group == s_pbrColorGroup)
{
AZ::Render::LuxCoreRequestsBus::Broadcast(&AZ::Render::LuxCoreRequestsBus::Events::AddTexture, texture, LuxCoreTextureType::Albedo);
}
else
{
AZ::Render::LuxCoreRequestsBus::Broadcast(&AZ::Render::LuxCoreRequestsBus::Events::AddTexture, texture, LuxCoreTextureType::Default);
}
AZStd::string materialProperty = m_luxCoreMaterialName + propertyName;
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(materialProperty.data()))(std::string(texture->GetAssetId().ToString<AZStd::string>().data()));
return true;
}
}
return false;
}
AZ::Name LuxCoreMaterial::MakePbrPropertyName(const char* groupName, const char* propertyName) const
{
return AZ::Name{AZStd::string::format("%s.%s", groupName, propertyName)};
}
void LuxCoreMaterial::ParseProperty(const char* group, AZStd::string propertyName)
{
if (!ParseTexture(group, propertyName))
{
if (group == s_pbrNormalGroup)
{
// Normal should always be texture
return;
}
else if (group == s_pbrColorGroup)
{
AZ::RPI::MaterialPropertyIndex propertyIndex;
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(s_pbrColorGroup, s_pbrColorProperty));
Color color = m_material->GetPropertyValue<Color>(propertyIndex);
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(s_pbrColorGroup, s_pbrFactorProperty));
float factor = m_material->GetPropertyValue<float>(propertyIndex);
AZStd::string materialProperty = m_luxCoreMaterialName + propertyName;
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(materialProperty.data()))(float(color.GetR())* factor, float(color.GetG())*factor, float(color.GetB())*factor);
}
else
{
AZ::RPI::MaterialPropertyIndex propertyIndex;
propertyIndex = m_material->FindPropertyIndex(MakePbrPropertyName(group, s_pbrFactorProperty));
float factor = m_material->GetPropertyValue<float>(propertyIndex);
AZStd::string materialProperty = m_luxCoreMaterialName + propertyName;
m_luxCoreMaterial = m_luxCoreMaterial << luxrays::Property(std::string(materialProperty.data()))(factor);
}
}
}
luxrays::Properties LuxCoreMaterial::GetLuxCoreMaterialProperties()
{
return m_luxCoreMaterial;
}
AZ::Data::InstanceId LuxCoreMaterial::GetMaterialId()
{
return m_material->GetId();
}
}
}
#endif
@@ -1,61 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include <Atom/RPI.Public/Material/Material.h>
#include "LuxCoreTexture.h"
#include <luxcore/luxcore.h>
namespace AZ
{
namespace Render
{
// Manage mapping between Atom PBR material and LuxCore Disney material
class LuxCoreMaterial final
{
public:
LuxCoreMaterial() = default;
LuxCoreMaterial(const AZ::Data::Instance<AZ::RPI::Material>& material);
LuxCoreMaterial(const LuxCoreMaterial &material);
~LuxCoreMaterial();
luxrays::Properties GetLuxCoreMaterialProperties();
AZ::Data::InstanceId GetMaterialId();
private:
static constexpr const char* s_pbrColorGroup = "baseColor";
static constexpr const char* s_pbrMetallicGroup = "metallic";
static constexpr const char* s_pbrRoughnessGroup = "roughness";
static constexpr const char* s_pbrSpecularGroup = "specularF0";
static constexpr const char* s_pbrNormalGroup = "normal";
static constexpr const char* s_pbrOpacityGroup = "opacity";
static constexpr const char* s_pbrColorProperty = "color";
static constexpr const char* s_pbrFactorProperty = "factor";
static constexpr const char* s_pbrUseTextureProperty = "useTexture";
static constexpr const char* s_pbrTextureProperty = "textureMap";
void ParseProperty(const char* group, AZStd::string propertyName);
bool ParseTexture(const char* group, AZStd::string propertyName);
AZ::Name MakePbrPropertyName(const char* groupName, const char* propertyName) const;
void Init(const AZ::Data::Instance<AZ::RPI::Material>& material);
AZStd::string m_luxCoreMaterialName;
luxrays::Properties m_luxCoreMaterial;
AZ::Data::Instance<AZ::RPI::Material> m_material = nullptr;
};
}
}
#endif
@@ -1,135 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include "LuxCoreMesh.h"
#include <luxcore/luxcore.h>
namespace AZ
{
namespace Render
{
LuxCoreMesh::LuxCoreMesh(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset)
{
Init(modelAsset);
}
LuxCoreMesh::LuxCoreMesh(const LuxCoreMesh &model)
{
Init(model.m_modelAsset);
}
LuxCoreMesh::~LuxCoreMesh()
{
if (m_position)
{
delete m_position;
m_position = nullptr;
}
if (m_normal)
{
delete m_normal;
m_normal = nullptr;
}
if (m_uv)
{
delete m_uv;
m_uv = nullptr;
}
if (m_index)
{
delete m_index;
m_index = nullptr;
}
if (m_modelAsset)
{
m_modelAsset.Reset();
}
}
void LuxCoreMesh::Init(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset)
{
m_modelAsset = modelAsset;
// [TODO ATOM-3547] Multiple meshes handling
AZ::RPI::ModelLodAsset::Mesh mesh = m_modelAsset->GetLodAssets()[0]->GetMeshes()[0];
// index data
AZStd::array_view<uint8_t> indexBuffer = mesh.GetIndexBufferAssetView().GetBufferAsset()->GetBuffer();
m_index = luxcore::Scene::AllocTrianglesBuffer(mesh.GetIndexCount() / 3);
memcpy(m_index, indexBuffer.data(), indexBuffer.size());
// vertices data
for (AZ::RPI::ModelLodAsset::Mesh::StreamBufferInfo streamBufferInfo : mesh.GetStreamBufferInfoList())
{
AZStd::array_view<uint8_t> dataBuffer = streamBufferInfo.m_bufferAssetView.GetBufferAsset()->GetBuffer();
if (streamBufferInfo.m_semantic == RHI::ShaderSemantic{ "POSITION" })
{
m_position = luxcore::Scene::AllocVerticesBuffer(mesh.GetVertexCount());
memcpy(m_position, dataBuffer.data(), dataBuffer.size());
}
else if (streamBufferInfo.m_semantic == RHI::ShaderSemantic{ "NORMAL" })
{
m_normal = new float[mesh.GetVertexCount() * 3];
memcpy(m_normal, dataBuffer.data(), dataBuffer.size());
}
else if (streamBufferInfo.m_semantic == RHI::ShaderSemantic{ "UV", 0 })
{
m_uv = new float[mesh.GetVertexCount() * 2];
memcpy(m_uv, dataBuffer.data(), dataBuffer.size());
}
}
}
uint32_t LuxCoreMesh::GetVertexCount()
{
// [TODO ATOM-3547] Multiple meshes handling
return m_modelAsset->GetLodAssets()[0]->GetMeshes()[0].GetVertexCount();
}
uint32_t LuxCoreMesh::GetTriangleCount()
{
// [TODO ATOM-3547] Multiple meshes handling
return (m_modelAsset->GetLodAssets()[0]->GetMeshes()[0].GetIndexCount() / 3);
}
AZ::Data::AssetId LuxCoreMesh::GetMeshId()
{
return m_modelAsset->GetId();
}
const float* LuxCoreMesh::GetPositionData()
{
return m_position;
}
const float* LuxCoreMesh::GetNormalData()
{
return m_normal;
}
const float* LuxCoreMesh::GetUVData()
{
return m_uv;
}
const unsigned int* LuxCoreMesh::GetIndexData()
{
return m_index;
}
}
}
#endif
@@ -1,49 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
namespace AZ
{
namespace Render
{
// Extract vertex and index data from source model
class LuxCoreMesh final
{
public:
LuxCoreMesh() = default;
LuxCoreMesh(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset);
LuxCoreMesh(const LuxCoreMesh &mesh);
~LuxCoreMesh();
AZ::Data::AssetId GetMeshId();
const float* GetPositionData();
const float* GetNormalData();
const float* GetUVData();
const unsigned int* GetIndexData();
uint32_t GetVertexCount();
uint32_t GetTriangleCount();
private:
void Init(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset);
float* m_position = nullptr;
float* m_normal = nullptr;
float* m_uv = nullptr;
unsigned int* m_index = nullptr;
AZ::Data::Asset<AZ::RPI::ModelAsset> m_modelAsset;
};
}
}
#endif
@@ -1,57 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include "LuxCoreObject.h"
#include <AzCore/std/string/conversions.h>
namespace AZ
{
namespace Render
{
LuxCoreObject::LuxCoreObject(AZStd::string modelAssetId, AZStd::string materialInstanceId)
{
Init(modelAssetId, materialInstanceId);
}
LuxCoreObject::LuxCoreObject(const LuxCoreObject &object)
{
Init(object.m_modelAssetId, object.m_materialInstanceId);
}
LuxCoreObject::~LuxCoreObject()
{
}
luxrays::Properties LuxCoreObject::GetLuxCoreObjectProperties()
{
return m_luxCoreObject;
}
void LuxCoreObject::Init(AZStd::string modelAssetId, AZStd::string materialInstanceId)
{
m_modelAssetId = modelAssetId;
m_materialInstanceId = materialInstanceId;
static std::atomic_int ObjectId { 0 };
const int localObjectId = ObjectId++;
m_luxCoreObjectName = "scene.objects." + AZStd::to_string(localObjectId);
AZStd::string shapePropertyName = m_luxCoreObjectName + ".shape";
AZStd::string materialPropertyName = m_luxCoreObjectName + ".material";
m_luxCoreObject = m_luxCoreObject << luxrays::Property(std::string(shapePropertyName.data()))(std::string(modelAssetId.data()));
m_luxCoreObject = m_luxCoreObject << luxrays::Property(std::string(materialPropertyName.data()))(std::string(materialInstanceId.data()));
}
};
};
#endif
@@ -1,41 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include <AzCore/std/string/string.h>
#include <luxcore/luxcore.h>
namespace AZ
{
namespace Render
{
// Object holds mesh and material in LuxCore
class LuxCoreObject final
{
public:
LuxCoreObject(AZStd::string modelAssetId, AZStd::string materialInstanceId);
LuxCoreObject(const LuxCoreObject &object);
~LuxCoreObject();
luxrays::Properties GetLuxCoreObjectProperties();
private:
void Init(AZStd::string modelAssetId, AZStd::string materialInstanceId);
AZStd::string m_luxCoreObjectName;
luxrays::Properties m_luxCoreObject;
AZStd::string m_modelAssetId;
AZStd::string m_materialInstanceId;
};
};
};
#endif
@@ -1,308 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include "LuxCoreRenderer.h"
#include <AzCore/Component/TransformBus.h>
#include <AzFramework/Components/CameraBus.h>
#include <AzCore/std/containers/compressed_pair.h>
#include <AzCore/Utils/Utils.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <luxcore/luxcore.h>
namespace LuxCoreUI
{
void LaunchLuxCoreUI(const AZStd::string& luxCoreExeFullPath, const AZStd::string& commandLine);
}
namespace AZ
{
namespace Render
{
LuxCoreRenderer::LuxCoreRenderer()
{
LuxCoreRequestsBus::Handler::BusConnect();
}
LuxCoreRenderer::~LuxCoreRenderer()
{
LuxCoreRequestsBus::Handler::BusDisconnect();
ClearLuxCore();
}
void LuxCoreRenderer::SetCameraEntityID(AZ::EntityId id)
{
m_cameraEntityId = id;
}
void LuxCoreRenderer::AddMesh(Data::Asset<RPI::ModelAsset> modelAsset)
{
AZStd::string meshId = modelAsset->GetId().ToString<AZStd::string>();
m_meshs.emplace(AZStd::piecewise_construct_t{},
AZStd::forward_as_tuple(meshId),
AZStd::forward_as_tuple(modelAsset));
}
void LuxCoreRenderer::AddMaterial(Data::Instance<RPI::Material> material)
{
AZStd::string materialId = material->GetId().ToString<AZStd::string>();
m_materials.emplace(AZStd::piecewise_construct_t{},
AZStd::forward_as_tuple(materialId),
AZStd::forward_as_tuple(material));
}
void LuxCoreRenderer::AddTexture(Data::Instance<RPI::Image> image, LuxCoreTextureType type)
{
AZStd::string textureId = image->GetAssetId().ToString<AZStd::string>();
m_textures.emplace(AZStd::piecewise_construct_t{},
AZStd::forward_as_tuple(textureId),
AZStd::forward_as_tuple(image, type));
}
void LuxCoreRenderer::AddObject(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset, AZ::Data::InstanceId materialInstanceId)
{
m_objects.emplace_back(modelAsset->GetId().ToString<AZStd::string>(), materialInstanceId.ToString<AZStd::string>());
}
bool LuxCoreRenderer::CheckTextureStatus()
{
for (auto it = m_textures.begin(); it != m_textures.end(); ++it)
{
if (!it->second.IsTextureReady())
{
return false;
}
}
return true;
}
void LuxCoreRenderer::ClearLuxCore()
{
m_meshs.clear();
m_materials.clear();
m_textures.clear();
m_objects.clear();
}
void LuxCoreRenderer::ClearObject()
{
m_objects.clear();
}
void LuxCoreRenderer::RenderInLuxCore()
{
luxcore::Init();
luxcore::Scene *luxCoreScene = luxcore::Scene::Create();
const char* folderName = "luxcoredata";
if (!AZ::IO::FileIOBase::GetInstance()->Exists(folderName))
{
AZ::IO::FileIOBase::GetInstance()->CreatePath(folderName);
}
char resolvedPath[1024];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(folderName, resolvedPath, 1024);
// Camera transform
if (!m_cameraEntityId.IsValid())
{
AZ_Assert(false, "Please set camera entity id");
return;
}
AZ::Transform cameraTransform = AZ::Transform::CreateIdentity();
AZ::Vector4 cameraUp, cameraFwd, cameraOrig, cameraTarget;
AZ::TransformBus::EventResult(cameraTransform, m_cameraEntityId, &AZ::TransformBus::Events::GetWorldTM);
const AZ::Matrix4x4 rotationMatrix = AZ::Matrix4x4::CreateFromTransform(cameraTransform);
cameraFwd = rotationMatrix.GetColumn(1);
cameraUp = rotationMatrix.GetColumn(2);
cameraOrig = rotationMatrix.GetColumn(3);
cameraTarget = cameraOrig + cameraFwd;
// Camera parameter
float nearClip, farClip, fieldOfView;
Camera::CameraRequestBus::EventResult(fieldOfView, m_cameraEntityId, &Camera::CameraRequestBus::Events::GetFovDegrees);
Camera::CameraRequestBus::EventResult(nearClip, m_cameraEntityId, &Camera::CameraRequestBus::Events::GetNearClipDistance);
Camera::CameraRequestBus::EventResult(farClip, m_cameraEntityId, &Camera::CameraRequestBus::Events::GetFarClipDistance);
// Set Camera
luxCoreScene->Parse(
luxrays::Property("scene.camera.lookat.orig")((float)cameraOrig.GetX(), (float)cameraOrig.GetY(), (float)cameraOrig.GetZ()) <<
luxrays::Property("scene.camera.lookat.target")((float)cameraTarget.GetX(), (float)cameraTarget.GetY(), (float)cameraTarget.GetZ()) <<
luxrays::Property("scene.camera.up")((float)cameraUp.GetX(), (float)cameraUp.GetY(), (float)cameraUp.GetZ()) <<
luxrays::Property("scene.camera.fieldofview")(fieldOfView) <<
luxrays::Property("scene.camera.cliphither")(nearClip) <<
luxrays::Property("scene.camera.clipyon")(farClip) <<
luxrays::Property("scene.camera.type")("perspective"));
// Set Texture
try {
for (auto it = m_textures.begin(); it != m_textures.end(); ++it)
{
if (it->second.GetRawDataPointer() != nullptr)
{
if (it->second.IsIBLTexture())
{
luxCoreScene->DefineImageMap<float>(std::string(it->first.data()), static_cast<float*>(it->second.GetRawDataPointer()), 1.f, it->second.GetTextureChannels(), it->second.GetTextureWidth(), it->second.GetTextureHeight());
}
else
{
luxCoreScene->DefineImageMap<uint8_t>(std::string(it->first.data()), static_cast<uint8_t*>(it->second.GetRawDataPointer()), 1.f, it->second.GetTextureChannels(), it->second.GetTextureWidth(), it->second.GetTextureHeight());
}
luxCoreScene->Parse(
it->second.GetLuxCoreTextureProperties()
);
}
else
{
AZ_Assert(false, "texture data is nullptr!!!");
return;
}
}
}
catch (const std::runtime_error& e)
{
(void)e;
AZ_Assert(false, "%s", e.what());
return;
}
catch (const std::exception& e)
{
(void)e;
AZ_Assert(false, "%s", e.what());
return;
}
// Set Material
try {
for (auto it = m_materials.begin(); it != m_materials.end(); ++it)
{
luxCoreScene->Parse(
it->second.GetLuxCoreMaterialProperties()
);
}
}
catch (const std::exception& e)
{
(void)e;
AZ_Assert(false, "%s", e.what());
return;
}
// Set Model
try {
for (auto it = m_meshs.begin(); it != m_meshs.end(); ++it)
{
luxCoreScene->DefineMesh(std::string(it->second.GetMeshId().ToString<AZStd::string>().data()),
it->second.GetVertexCount(),
it->second.GetTriangleCount(),
const_cast<float*>(it->second.GetPositionData()),
const_cast<unsigned int*>(it->second.GetIndexData()),
const_cast<float*>(it->second.GetNormalData()),
const_cast<float*>(it->second.GetUVData()),
NULL,
NULL);
}
}
catch (const std::exception& e)
{
(void)e;
AZ_Assert(false, "%s", e.what());
return;
}
// Objects
try {
for (auto it = m_objects.begin(); it != m_objects.end(); ++it)
{
luxCoreScene->Parse(
it->GetLuxCoreObjectProperties()
);
}
}
catch (const std::exception& e)
{
(void)e;
AZ_Assert(false, "%s", e.what());
return;
}
// RenderConfig
luxcore::RenderConfig *config = luxcore::RenderConfig::Create(
luxrays::Property("path.pathdepth.total")(7) <<
luxrays::Property("path.pathdepth.diffuse")(5) <<
luxrays::Property("path.pathdepth.glossy")(5) <<
luxrays::Property("path.pathdepth.specular")(6) <<
luxrays::Property("path.hybridbackforward.enable")(0) <<
luxrays::Property("path.hybridbackforward.partition")(0) <<
luxrays::Property("path.hybridbackforward.glossinessthreshold ")(0.05) <<
luxrays::Property("path.forceblackbackground.enable")(0) <<
luxrays::Property("film.noiseestimation.warmup")(8) <<
luxrays::Property("film.noiseestimation.step")(32) <<
luxrays::Property("film.width")(1920) <<
luxrays::Property("film.height")(1080) <<
luxrays::Property("film.filter.type")("BLACKMANHARRIS") <<
luxrays::Property("film.filter.width")(1.5) <<
luxrays::Property("film.imagepipelines.0.0.type")("NOP") <<
luxrays::Property("film.imagepipelines.0.1.type")("GAMMA_CORRECTION") <<
luxrays::Property("film.imagepipelines.0.1.value")(2.2f) <<
luxrays::Property("film.imagepipelines.0.radiancescales.0.enabled")(1) <<
luxrays::Property("film.imagepipelines.0.radiancescales.0.globalscale")(1) <<
luxrays::Property("film.imagepipelines.0.radiancescales.0.rgbscale")(1, 1, 1) <<
luxrays::Property("film.outputs.0.type")("RGB_IMAGEPIPELINE") <<
luxrays::Property("film.outputs.0.index")(0) <<
luxrays::Property("film.outputs.0.filename")("RGB_IMAGEPIPELINE_0.png") <<
luxrays::Property("sampler.type")("SOBOL") <<
luxrays::Property("renderengine.type")("PATHCPU") <<
luxrays::Property("renderengine.seed")(1) <<
luxrays::Property("lightstrategy.type")("LOG_POWER") <<
luxrays::Property("scene.epsilon.min")(9.9999997473787516e-06f) <<
luxrays::Property("scene.epsilon.max")(0.10000000149011612f) <<
luxrays::Property("scene.epsilon.max")(0.10000000149011612f) <<
luxrays::Property("batch.haltthreshold")(0.01953125f) <<
luxrays::Property("batch.haltthreshold.warmup")(64) <<
luxrays::Property("batch.haltthreshold.step")(64) <<
luxrays::Property("batch.haltthreshold.filter.enable")(1) <<
luxrays::Property("batch.haltthreshold.stoprendering.enable")(1) <<
luxrays::Property("batch.haltspp")(0) <<
luxrays::Property("batch.halttime")(0) <<
luxrays::Property("filesaver.renderengine.type")("PATHCPU") <<
luxrays::Property("filesaver.format")("TXT"),
luxCoreScene);
// Export
try {
config->Export(resolvedPath);
}
catch (const std::runtime_error& e)
{
(void)e;
AZ_Assert(false, "%s", e.what());
return;
}
// Run luxcoreui.exe
AZ::IO::FixedMaxPath luxCoreExeFullPath = AZ::Utils::GetEnginePath();
luxCoreExeFullPath /= AZ_TRAIT_LUXCORE_EXEPATH;
AZStd::string commandLine = "-o " + AZStd::string(resolvedPath) + "/render.cfg";
LuxCoreUI::LaunchLuxCoreUI(luxCoreExeFullPath.String(), commandLine);
}
}
}
#endif
@@ -1,56 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
#include "LuxCoreMaterial.h"
#include "LuxCoreMesh.h"
#include "LuxCoreObject.h"
#include "LuxCoreTexture.h"
namespace AZ
{
namespace Render
{
// Hold all converted data, write scene and render file to disk when command received
// Can be extend to do real-time rendering in the future
class LuxCoreRenderer
: public LuxCoreRequestsBus::Handler
{
public:
LuxCoreRenderer();
~LuxCoreRenderer();
////////////////////////////////////////////////////////////////////////
// LuxCoreRequestsBus
void SetCameraEntityID(AZ::EntityId id);
void AddMesh( Data::Asset<RPI::ModelAsset> modelAsset);
void AddMaterial(Data::Instance<RPI::Material> material);
void AddTexture(Data::Instance<RPI::Image> image, LuxCoreTextureType type);
void AddObject(AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset, AZ::Data::InstanceId materialInstanceId);
bool CheckTextureStatus();
void RenderInLuxCore();
void ClearLuxCore();
void ClearObject();
/////////////////////////////////////////////////////////////////////////
private:
AZ::EntityId m_cameraEntityId;
AZ::Transform m_cameraTransform;
AZStd::unordered_map<AZStd::string, LuxCoreMesh> m_meshs;
AZStd::unordered_map<AZStd::string, LuxCoreMaterial> m_materials;
AZStd::unordered_map<AZStd::string, LuxCoreTexture> m_textures;
AZStd::vector<LuxCoreObject> m_objects;
};
}
}
#endif
@@ -1,158 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include "LuxCoreTexture.h"
#include <Atom/Feature/LuxCore/LuxCoreTexturePass.h>
#include <Atom/RPI.Public/Scene.h>
namespace AZ
{
namespace Render
{
LuxCoreTexture::LuxCoreTexture(AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type)
{
Init(image, type);
}
LuxCoreTexture::LuxCoreTexture(const LuxCoreTexture &texture)
{
Init(texture.m_texture, texture.m_type);
}
LuxCoreTexture::~LuxCoreTexture()
{
if (m_rtPipeline)
{
m_rtPipeline->RemoveFromScene();
m_rtPipeline = nullptr;
}
if (m_texture)
{
m_texture = nullptr;
}
}
void LuxCoreTexture::Init(AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type)
{
m_textureAssetId = image->GetAssetId();
m_texture = image;
m_type = type;
if (m_type == LuxCoreTextureType::IBL)
{
m_luxCoreTextureName = "scene.lights." + m_textureAssetId.ToString<AZStd::string>();
m_luxCoreTexture = m_luxCoreTexture << luxrays::Property(std::string(m_luxCoreTextureName.data()) + ".type")("infinite");
}
else
{
m_luxCoreTextureName = "scene.textures." + m_textureAssetId.ToString<AZStd::string>();
m_luxCoreTexture = m_luxCoreTexture << luxrays::Property(std::string(m_luxCoreTextureName.data()) + ".type")("imagemap");
}
m_luxCoreTexture = m_luxCoreTexture << luxrays::Property(std::string(m_luxCoreTextureName.data()) + ".file")(std::string(m_textureAssetId.ToString<AZStd::string>().data()));
m_textureChannels = 4;
AddRenderTargetPipeline();
}
void LuxCoreTexture::AddRenderTargetPipeline()
{
// Render Texture pipeline
AZ::RPI::RenderPipelineDescriptor pipelineDesc;
pipelineDesc.m_name = m_textureAssetId.ToString<AZStd::string>();
pipelineDesc.m_rootPassTemplate = "LuxCoreTexturePassTemplate";
m_rtPipeline = AZ::RPI::RenderPipeline::CreateRenderPipeline(pipelineDesc);
// Set source texture
AZ::RPI::Pass* rootPass = m_rtPipeline->GetRootPass().get();
AZ_Assert(rootPass != nullptr, "Failed to get root pass for render target pipeline");
LuxCoreTexturePass* parentPass = static_cast<LuxCoreTexturePass*>(rootPass);
// Setup call back to save read back data to m_textureData
RPI::AttachmentReadback::CallbackFunction callback =
[this](const AZ::RPI::AttachmentReadback::ReadbackResult& readbackResult)
{
RHI::ImageSubresourceLayout imageLayout = RHI::GetImageSubresourceLayout(readbackResult.m_imageDescriptor.m_size,
readbackResult.m_imageDescriptor.m_format);
m_textureData.resize_no_construct(imageLayout.m_bytesPerImage);
memcpy(m_textureData.data(), readbackResult.m_dataBuffer->data(), imageLayout.m_bytesPerImage);
m_textureReadbackComplete = true;
};
parentPass->SetReadbackCallback(callback);
switch (m_type)
{
case LuxCoreTextureType::Default:
// assume a 8 bits linear texture
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM);
break;
case LuxCoreTextureType::IBL:
// assume its a float image if its an IBL source
parentPass->SetSourceTexture(m_texture, RHI::Format::R32G32B32A32_FLOAT);
break;
case LuxCoreTextureType::Albedo:
// albedo texture is in sRGB space
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM_SRGB);
break;
case LuxCoreTextureType::Normal:
// Normal texture needs special handling
parentPass->SetIsNormalTexture(true);
parentPass->SetSourceTexture(m_texture, RHI::Format::R8G8B8A8_UNORM);
break;
}
const auto mainScene = AZ::RPI::RPISystemInterface::Get()->GetSceneByName(AZ::Name("RPI"));
if (mainScene)
{
mainScene->AddRenderPipeline(m_rtPipeline);
}
}
bool LuxCoreTexture::IsIBLTexture()
{
return m_type == LuxCoreTextureType::IBL;
}
void* LuxCoreTexture::GetRawDataPointer()
{
return (void*)m_textureData.data();
}
unsigned int LuxCoreTexture::GetTextureWidth()
{
return m_texture->GetRHIImage()->GetDescriptor().m_size.m_width;
}
unsigned int LuxCoreTexture::GetTextureHeight()
{
return m_texture->GetRHIImage()->GetDescriptor().m_size.m_height;
}
unsigned int LuxCoreTexture::GetTextureChannels()
{
return m_textureChannels;
}
luxrays::Properties LuxCoreTexture::GetLuxCoreTextureProperties()
{
return m_luxCoreTexture;
}
bool LuxCoreTexture::IsTextureReady()
{
return m_textureReadbackComplete;
}
}
}
#endif
@@ -1,62 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom_Feature_Traits_Platform.h>
#if AZ_TRAIT_LUXCORE_SUPPORTED
#include <Atom/RPI.Public/RenderPipeline.h>
#include <Atom/RPI.Reflect/Image/Image.h>
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
#include <luxcore/luxcore.h>
namespace AZ
{
namespace Render
{
// Build a pipeline to get raw data from runtime texture
class LuxCoreTexture final
{
public:
LuxCoreTexture() = default;
LuxCoreTexture( AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type);
LuxCoreTexture(const LuxCoreTexture &texture);
~LuxCoreTexture();
void* GetRawDataPointer();
unsigned int GetTextureWidth();
unsigned int GetTextureHeight();
unsigned int GetTextureChannels();
void Init(AZ::Data::Instance<AZ::RPI::Image> image, LuxCoreTextureType type);
void AddRenderTargetPipeline();
luxrays::Properties GetLuxCoreTextureProperties();
bool IsIBLTexture();
bool IsTextureReady();
private:
AZStd::string m_luxCoreTextureName;
luxrays::Properties m_luxCoreTexture;
AZ::RPI::RenderPipelinePtr m_rtPipeline = nullptr;
AZStd::vector<uint8_t> m_textureData;
AZ::Data::Instance<AZ::RPI::Image> m_texture;
unsigned int m_textureChannels = 4;
Data::AssetId m_textureAssetId;
LuxCoreTextureType m_type = LuxCoreTextureType::Default;
bool m_textureReadbackComplete = false;
};
}
}
#endif
@@ -1,90 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/Feature/LuxCore/LuxCoreTexturePass.h>
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
#include <Atom/RHI/RHISystemInterface.h>
namespace AZ
{
namespace Render
{
RPI::Ptr<LuxCoreTexturePass> LuxCoreTexturePass::Create(const RPI::PassDescriptor& descriptor)
{
RPI::Ptr<LuxCoreTexturePass> pass = aznew LuxCoreTexturePass(descriptor);
return pass;
}
LuxCoreTexturePass::LuxCoreTexturePass(const RPI::PassDescriptor& descriptor)
: ParentPass(descriptor)
{
RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get();
// Create render target pass
RPI::PassRequest request;
request.m_templateName = "RenderTextureTemplate";
request.m_passName = "RenderTarget";
m_renderTargetPass = passSystem->CreatePassFromRequest(&request);
AZ_Assert(m_renderTargetPass, "render target pass is invalid");
// Create readback
m_readback = AZStd::make_shared<AZ::RPI::AttachmentReadback>(AZ::RHI::ScopeId{ Uuid::CreateRandom().ToString<AZStd::string>() });
}
LuxCoreTexturePass::~LuxCoreTexturePass()
{
m_renderTargetPass = nullptr;
m_readback = nullptr;
}
void LuxCoreTexturePass::SetSourceTexture(AZ::Data::Instance<AZ::RPI::Image> image, RHI::Format format)
{
static_cast<RenderTexturePass*>(m_renderTargetPass.get())->SetPassSrgImage(image, format);
}
void LuxCoreTexturePass::CreateChildPassesInternal()
{
AddChild(m_renderTargetPass);
}
void LuxCoreTexturePass::BuildInternal()
{
ParentPass::BuildInternal();
}
void LuxCoreTexturePass::FrameBeginInternal(FramePrepareParams params)
{
if (!m_attachmentReadbackComplete && m_readback != nullptr)
{
// Set up read back attachment before children prepare
if (m_readback->IsReady())
{
if (m_renderTargetPass)
{
m_attachmentReadbackComplete = m_renderTargetPass->ReadbackAttachment(m_readback, AZ::Name("RenderTargetOutput"));
}
}
}
ParentPass::FrameBeginInternal(params);
}
void LuxCoreTexturePass::SetIsNormalTexture(bool isNormal)
{
static_cast<RenderTexturePass*>(m_renderTargetPass.get())->InitShaderVariant(isNormal);
}
void LuxCoreTexturePass::SetReadbackCallback(RPI::AttachmentReadback::CallbackFunction callbackFunciton)
{
if (m_readback != nullptr)
{
m_readback->SetCallback(callbackFunciton);
}
}
}
}
@@ -1,90 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/Feature/LuxCore/RenderTexturePass.h>
#include <Atom/Feature/LuxCore/LuxCoreBus.h>
namespace AZ
{
namespace Render
{
RPI::Ptr<RenderTexturePass> RenderTexturePass::Create(const RPI::PassDescriptor& descriptor)
{
RPI::Ptr<RenderTexturePass> pass = aznew RenderTexturePass(descriptor);
return pass;
}
RenderTexturePass::RenderTexturePass(const RPI::PassDescriptor& descriptor)
: FullscreenTrianglePass(descriptor)
{
m_textureIndex = m_shaderResourceGroup->FindShaderInputImageIndex(Name("m_sourceTexture"));
}
RenderTexturePass::~RenderTexturePass()
{
}
void RenderTexturePass::SetPassSrgImage(AZ::Data::Instance<AZ::RPI::Image> image, RHI::Format format)
{
m_attachmentSize = image->GetRHIImage()->GetDescriptor().m_size;
m_attachmentFormat = format;
m_shaderResourceGroup->SetImage(m_textureIndex, image);
QueueForBuildAndInitialization();
}
void RenderTexturePass::BuildInternal()
{
UpdataAttachment();
FullscreenTrianglePass::BuildInternal();
}
void RenderTexturePass::FrameBeginInternal(FramePrepareParams params)
{
FullscreenTrianglePass::FrameBeginInternal(params);
}
void RenderTexturePass::UpdataAttachment()
{
// [GFX TODO][ATOM-2470] stop caring about attachment
RPI::Ptr<RPI::PassAttachment> attachment = m_ownedAttachments.front();
if (!attachment)
{
AZ_Assert(false, "[RenderTexturePass %s] Cannot find any image attachment.", GetPathName().GetCStr());
return;
}
AZ_Assert(attachment->m_descriptor.m_type == RHI::AttachmentType::Image, "[RenderTexturePass %s] requires an image attachment", GetPathName().GetCStr());
RPI::PassAttachmentBinding& binding = GetOutputBinding(0);
binding.m_attachment = attachment;
RHI::ImageDescriptor& imageDescriptor = attachment->m_descriptor.m_image;
imageDescriptor.m_size = m_attachmentSize;
imageDescriptor.m_format = m_attachmentFormat;
}
RHI::AttachmentId RenderTexturePass::GetRenderTargetId()
{
return m_ownedAttachments.front()->GetAttachmentId();
}
void RenderTexturePass::InitShaderVariant(bool isNormal)
{
auto shaderOption = m_shader->CreateShaderOptionGroup();
RPI::ShaderOptionValue isNormalOption{ isNormal };
shaderOption.SetValue(AZ::Name("o_isNormal"), isNormalOption);
RPI::ShaderVariantSearchResult result = m_shader->FindVariantStableId(shaderOption.GetShaderVariantId());
m_shaderVariantStableId = result.GetStableId();
if (!result.IsFullyBaked() && m_drawShaderResourceGroup->HasShaderVariantKeyFallbackEntry())
{
m_drawShaderResourceGroup->SetShaderVariantKeyFallbackValue(shaderOption.GetShaderVariantId().m_key);
}
}
}
}
@@ -7,6 +7,5 @@
*/
#pragma once
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
@@ -5,9 +5,3 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set_source_files_properties(
Source/LuxCore/LuxCoreRenderer.cpp
PROPERTIES
COMPILE_OPTIONS -fexceptions
)
@@ -5,9 +5,3 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
set_source_files_properties(
Source/LuxCore/LuxCoreRenderer.cpp
PROPERTIES
COMPILE_OPTIONS /EHsc
)
@@ -7,6 +7,5 @@
*/
#pragma once
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
@@ -7,6 +7,5 @@
*/
#pragma once
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
@@ -7,6 +7,5 @@
*/
#pragma once
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
#define AZ_TRAIT_LUXCORE_EXEPATH "Gems/Atom/Feature/Common/External/LuxCore2.2/win64/dll/luxcoreui.exe"
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
@@ -1,45 +0,0 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/std/string/string.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/PlatformIncl.h>
namespace LuxCoreUI
{
void LaunchLuxCoreUI(const AZStd::string& luxCoreExeFullPath, const AZStd::string& commandLine)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
AZStd::wstring luxCoreExeFullPathW;
AZStd::to_wstring(luxCoreExeFullPathW, luxCoreExeFullPath.c_str());
AZStd::wstring commandLineW;
AZStd::to_wstring(commandLineW, commandLine.c_str());
// start the program up
CreateProcessW(luxCoreExeFullPathW.c_str(), // the path
commandLineW.data(), // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi // Pointer to PROCESS_INFORMATION structure (removed extra parentheses)
);
// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
}
@@ -9,5 +9,4 @@
set(FILES
Atom_Feature_Traits_Platform.h
Atom_Feature_Traits_Windows.h
LaunchLuxCoreUI_Windows.cpp
)
@@ -7,6 +7,5 @@
*/
#pragma once
#define AZ_TRAIT_LUXCORE_SUPPORTED 0
#define AZ_TRAIT_LUXCORE_EXEPATH UNUSED_TRAIT
#define AZ_TRAIT_DIFFUSE_GI_PASSES_SUPPORTED 1
@@ -46,9 +46,6 @@ set(FILES
Include/Atom/Feature/Utils/MultiSparseVector.h
Include/Atom/Feature/Utils/ProfilingCaptureBus.h
Include/Atom/Feature/Utils/SparseVector.h
Include/Atom/Feature/LuxCore/LuxCoreBus.h
Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h
Include/Atom/Feature/LuxCore/RenderTexturePass.h
Source/CommonModule.cpp
Source/CommonSystemComponent.cpp
Source/FrameCaptureSystemComponent.cpp
@@ -317,18 +314,6 @@ set(FILES
Source/SkyBox/SkyBoxFogSettings.cpp
Source/TransformService/TransformServiceFeatureProcessor.cpp
Source/Utils/GpuBufferHandler.cpp
Source/LuxCore/LuxCoreTexturePass.cpp
Source/LuxCore/RenderTexturePass.cpp
Source/LuxCore/LuxCoreMaterial.cpp
Source/LuxCore/LuxCoreMaterial.h
Source/LuxCore/LuxCoreMesh.cpp
Source/LuxCore/LuxCoreMesh.h
Source/LuxCore/LuxCoreObject.cpp
Source/LuxCore/LuxCoreObject.h
Source/LuxCore/LuxCoreRenderer.cpp
Source/LuxCore/LuxCoreRenderer.h
Source/LuxCore/LuxCoreTexture.cpp
Source/LuxCore/LuxCoreTexture.h
)
set(SKIP_UNITY_BUILD_INCLUSION_FILES
@@ -14,7 +14,7 @@ ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cit
ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform TARGETS expat PACKAGE_HASH 452256acd1fd699cef24162575b3524fccfb712f5321c83f1df1ce878de5b418)
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
# platform-specific:
ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev4-android TARGETS TIFF PACKAGE_HASH 2c62cdf34a8ee6c7eb091d05d98f60b4da7634c74054d4dbb8736886182f4589)
ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-android TARGETS freetype PACKAGE_HASH df9e4d559ea0f03b0666b48c79813b1cd4d9624429148a249865de9f5c2c11cd)
@@ -18,7 +18,6 @@ ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform TARGETS SQLite PACKAGE_HASH dd4d3de6cbb4ce3d15fc504ba0ae0587e515dc89a25228037035fc0aef4831f4)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e)
# platform-specific:
-1
View File
@@ -18,7 +18,6 @@ ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform TARGETS SQLite PACKAGE_HASH dd4d3de6cbb4ce3d15fc504ba0ae0587e515dc89a25228037035fc0aef4831f4)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e)
# platform-specific:
@@ -18,7 +18,6 @@ ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME SQLite-3.32.2-rev3-multiplatform TARGETS SQLite PACKAGE_HASH dd4d3de6cbb4ce3d15fc504ba0ae0587e515dc89a25228037035fc0aef4831f4)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
ly_associate_package(PACKAGE_NAME xxhash-0.7.4-rev1-multiplatform TARGETS xxhash PACKAGE_HASH e81f3e6c4065975833996dd1fcffe46c3cf0f9e3a4207ec5f4a1b564ba75861e)
# platform-specific:
-1
View File
@@ -14,7 +14,6 @@ ly_associate_package(PACKAGE_NAME cityhash-1.1-multiplatform TARGETS cit
ly_associate_package(PACKAGE_NAME expat-2.1.0-multiplatform TARGETS expat PACKAGE_HASH 452256acd1fd699cef24162575b3524fccfb712f5321c83f1df1ce878de5b418)
ly_associate_package(PACKAGE_NAME zstd-1.35-multiplatform TARGETS zstd PACKAGE_HASH 45d466c435f1095898578eedde85acf1fd27190e7ea99aeaa9acfd2f09e12665)
ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS glad PACKAGE_HASH ff97ee9664e97d0854b52a3734c2289329d9f2b4cd69478df6d0ca1f1c9392ee)
ly_associate_package(PACKAGE_NAME lux_core-2.2-rev5-multiplatform TARGETS lux_core PACKAGE_HASH c8c13cf7bc351643e1abd294d0841b24dee60e51647dff13db7aec396ad1e0b5)
# platform-specific:
ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-ios TARGETS TIFF PACKAGE_HASH e9067e88649fb6e93a926d9ed38621a9fae360a2e6f6eb24ebca63c1bc7761ea)