2022-11-03 07:15:45 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
2022-11-03 09:02:02 -04:00
# pragma once
2022-11-03 07:15:45 -04:00
# include "Scene/SceneCapturePhotoSet.h"
# include "Sampling/MeshBakerCommon.h"
2023-10-12 05:53:39 -04:00
# include "Sampling/MeshMapBaker.h"
2022-11-03 07:15:45 -04:00
# include "Image/ImageInfilling.h"
# include "Baking/BakingTypes.h"
# include "DynamicMesh/MeshTangents.h"
# include "CoreMinimal.h"
class UTexture2D ;
class AActor ;
namespace UE
{
namespace Geometry
{
class MODELINGCOMPONENTS_API FRenderCaptureOcclusionHandler
{
public :
FRenderCaptureOcclusionHandler ( FImageDimensions Dimensions ) ;
void RegisterSample ( const FVector2i & ImageCoords , bool bSampleValid ) ;
void PushInfillRequired ( bool bInfillRequired ) ;
void ComputeAndApplyInfill ( TArray < TUniquePtr < TImageBuilder < FVector4f > > > & Images ) ;
private :
struct FSampleStats {
uint16 NumValid = 0 ;
uint16 NumInvalid = 0 ;
// These are required by the TMarchingPixelInfill implementation
bool operator = = ( const FSampleStats & Other ) const ;
bool operator ! = ( const FSampleStats & Other ) const ;
FSampleStats & operator + = ( const FSampleStats & Other ) ;
static FSampleStats Zero ( ) ;
} ;
void ComputeInfill ( ) ;
void ApplyInfill ( TImageBuilder < FVector4f > & Image ) const ;
// Collect some sample stats per pixel, used to determine if a pixel requires infill or not
TImageBuilder < FSampleStats > SampleStats ;
// InfillRequire[i] indicates if the i-th image passed to ComputeAndApplyInfill needs infill
TArray < bool > InfillRequired ;
TMarchingPixelInfill < FSampleStats > Infill ;
} ;
class MODELINGCOMPONENTS_API FSceneCapturePhotoSetSampler : public FMeshBakerDynamicMeshSampler
{
public :
FSceneCapturePhotoSetSampler (
FSceneCapturePhotoSet * SceneCapture ,
float ValidSampleDepthThreshold ,
const FDynamicMesh3 * Mesh ,
const FDynamicMeshAABBTree3 * Spatial ,
const FMeshTangentsd * Tangents ) ;
2023-04-03 06:14:42 -04:00
UE_NONCOPYABLE ( FSceneCapturePhotoSetSampler ) ;
2022-11-03 07:15:45 -04:00
virtual bool SupportsCustomCorrespondence ( ) const override ;
// Warning: Expects that Sample.BaseSample.SurfacePoint and Sample.BaseNormal are set when the function is called
virtual void * ComputeCustomCorrespondence ( const FMeshUVSampleInfo & SampleInfo , FMeshMapEvaluator : : FCorrespondenceSample & Sample ) const override ;
virtual bool IsValidCorrespondence ( const FMeshMapEvaluator : : FCorrespondenceSample & Sample ) const override ;
private :
FSceneCapturePhotoSet * SceneCapture = nullptr ;
float ValidSampleDepthThreshold = 0 ;
TFunction < bool ( const FVector3d & , const FVector3d & ) > VisibilityFunction ;
} ;
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
struct MODELINGCOMPONENTS_API FSceneCaptureConfig
{
int32 RenderCaptureImageSize = 1024 ;
bool bAntiAliasing = false ;
double FieldOfViewDegrees = 45.0 ;
double NearPlaneDist = 1.0 ;
2022-11-03 07:15:45 -04:00
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
FRenderCaptureTypeFlags Flags = FRenderCaptureTypeFlags : : None ( ) ;
bool operator = = ( const FSceneCaptureConfig & ) const ;
bool operator ! = ( const FSceneCaptureConfig & ) const ;
} ;
MODELINGCOMPONENTS_API
void ConfigureSceneCapture (
2023-10-12 05:53:39 -04:00
FSceneCapturePhotoSet & SceneCapture ,
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
const TArray < TObjectPtr < AActor > > & Actors ,
const FSceneCaptureConfig & Config ,
bool bAllowCancel ) ;
MODELINGCOMPONENTS_API
FRenderCaptureTypeFlags UpdateSceneCapture (
2023-10-12 05:53:39 -04:00
FSceneCapturePhotoSet & SceneCapture ,
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
const TArray < TObjectPtr < AActor > > & Actors ,
const FSceneCaptureConfig & DesiredConfig ,
bool bAllowCancel ) ;
MODELINGCOMPONENTS_API
FSceneCaptureConfig GetSceneCaptureConfig (
2023-10-12 05:53:39 -04:00
const FSceneCapturePhotoSet & SceneCapture ,
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
FSceneCapturePhotoSet : : ECaptureTypeStatus QueryStatus = FSceneCapturePhotoSet : : ECaptureTypeStatus : : Computed ) ;
// Return a render capture baker, note the lifetime of all arguments such match the lifetime of the returned baker
MODELINGCOMPONENTS_API
TUniquePtr < FMeshMapBaker > MakeRenderCaptureBaker (
FDynamicMesh3 * BaseMesh ,
TSharedPtr < FMeshTangentsd , ESPMode : : ThreadSafe > BaseMeshTangents ,
TSharedPtr < TArray < int32 > , ESPMode : : ThreadSafe > BaseMeshUVCharts ,
FSceneCapturePhotoSet * SceneCapture ,
FSceneCapturePhotoSetSampler * Sampler ,
FRenderCaptureTypeFlags PendingBake ,
int32 TargetUVLayer ,
EBakeTextureResolution TextureImageSize ,
EBakeTextureSamplesPerPixel SamplesPerPixel ,
FRenderCaptureOcclusionHandler * OcclusionHandler ) ;
struct MODELINGCOMPONENTS_API FRenderCaptureTextures
{
UTexture2D * BaseColorMap = nullptr ;
UTexture2D * NormalMap = nullptr ;
UTexture2D * PackedMRSMap = nullptr ;
UTexture2D * MetallicMap = nullptr ;
UTexture2D * RoughnessMap = nullptr ;
UTexture2D * SpecularMap = nullptr ;
UTexture2D * EmissiveMap = nullptr ;
UTexture2D * OpacityMap = nullptr ;
UTexture2D * SubsurfaceColorMap = nullptr ;
} ;
// Note: The source data in the textures is *not* updated by this function
MODELINGCOMPONENTS_API
void GetTexturesFromRenderCaptureBaker (
2023-10-12 05:53:39 -04:00
FMeshMapBaker & Baker ,
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
FRenderCaptureTextures & TexturesOut ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2023-10-12 05:53:39 -04:00
// Everything that follows is deprecated
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PRAGMA_DISABLE_DEPRECATION_WARNINGS
2023-10-12 05:53:39 -04:00
UE_DEPRECATED ( 5.4 , " Please use the overload passing SceneCapture by reference. Using smart pointers was an error since ownership semantics were not intended. " )
MODELINGCOMPONENTS_API
void ConfigureSceneCapture (
const TUniquePtr < FSceneCapturePhotoSet > & SceneCapture ,
const TArray < TObjectPtr < AActor > > & Actors ,
const FSceneCaptureConfig & Config ,
bool bAllowCancel ) ;
UE_DEPRECATED ( 5.4 , " Please use the overload passing SceneCapture by reference. Using smart pointers was an error since ownership semantics were not intended. " )
MODELINGCOMPONENTS_API
FRenderCaptureTypeFlags UpdateSceneCapture (
const TUniquePtr < FSceneCapturePhotoSet > & SceneCapture ,
const TArray < TObjectPtr < AActor > > & Actors ,
const FSceneCaptureConfig & DesiredConfig ,
bool bAllowCancel ) ;
UE_DEPRECATED ( 5.4 , " Please use the overload passing SceneCapture by reference. Using smart pointers was an error since ownership semantics were not intended. " )
MODELINGCOMPONENTS_API
FSceneCaptureConfig GetSceneCaptureConfig (
const TUniquePtr < FSceneCapturePhotoSet > & SceneCapture ,
FSceneCapturePhotoSet : : ECaptureTypeStatus QueryStatus = FSceneCapturePhotoSet : : ECaptureTypeStatus : : Computed ) ;
// Note: The source data in the textures is *not* updated by this function
UE_DEPRECATED ( 5.4 , " Please use the overload passing Baker by reference. Using smart pointers was an error since ownership semantics were not intended. " )
MODELINGCOMPONENTS_API
void GetTexturesFromRenderCaptureBaker (
const TUniquePtr < FMeshMapBaker > & Baker ,
FRenderCaptureTextures & TexturesOut ) ;
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
struct UE_DEPRECATED ( 5.3 , " FRenderCaptureOptions is only used by deprecated functions, see those deprecation notes for more info. " ) MODELINGCOMPONENTS_API FRenderCaptureOptions
2022-11-03 07:15:45 -04:00
{
//
// Material approximation settings
//
int32 RenderCaptureImageSize = 1024 ;
bool bAntiAliasing = false ;
// render capture parameters
double FieldOfViewDegrees = 45.0 ;
double NearPlaneDist = 1.0 ;
//
// Material output settings
//
bool bBakeBaseColor = true ;
bool bBakeRoughness = true ;
bool bBakeMetallic = true ;
bool bBakeSpecular = true ;
bool bBakeEmissive = true ;
bool bBakeNormalMap = true ;
2023-01-05 05:19:44 -05:00
bool bBakeOpacity = true ;
bool bBakeSubsurfaceColor = true ;
2022-11-03 07:15:45 -04:00
bool bBakeDeviceDepth = true ;
bool bUsePackedMRS = true ;
} ;
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
struct UE_DEPRECATED ( 5.3 , " FRenderCaptureUpdate is only used by deprecated functions, see those deprecation notes for more info. " ) MODELINGCOMPONENTS_API FRenderCaptureUpdate
2023-01-12 11:09:29 -05:00
{
// Default to true so that we can use the default value to trigger all update code paths
bool bUpdatedBaseColor = true ;
bool bUpdatedRoughness = true ;
bool bUpdatedMetallic = true ;
bool bUpdatedSpecular = true ;
bool bUpdatedEmissive = true ;
bool bUpdatedNormalMap = true ;
bool bUpdatedOpacity = true ;
bool bUpdatedSubsurfaceColor = true ;
bool bUpdatedDeviceDepth = true ;
bool bUpdatedPackedMRS = true ;
} ;
2022-11-03 07:15:45 -04:00
2023-01-31 14:12:46 -05:00
/**
* This function computes the SceneCapture for the first time
*/
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
UE_DEPRECATED ( 5.3 , " Please use ConfigureSceneCapture and FSceneCapturePhotoSet::Compute instead. " )
2022-11-03 07:15:45 -04:00
MODELINGCOMPONENTS_API
TUniquePtr < FSceneCapturePhotoSet > CapturePhotoSet (
const TArray < TObjectPtr < AActor > > & Actors ,
const FRenderCaptureOptions & Options ,
2023-01-12 11:09:29 -05:00
FRenderCaptureUpdate & Update ,
2022-11-03 07:15:45 -04:00
bool bAllowCancel ) ;
2023-01-12 11:09:29 -05:00
/**
* This function efficiently updates the given SceneCapture and returns a struct indicating which channels were updated
*
* - If the requested Options and Actors have already been captured the call is a no - op
* - If the given Options disable existing capture channels then the call just clears the corresponding photo sets
* - If the given Options enable a new capture channel then the new photos set are captured and added to the SceneCapture
* - If the given Actors are different the ones cached in the SceneCapture , or if the given Options changes a parameter
* affecting all photo sets ( e . g . , photo resolution ) , then all the photo sets are cleared and recomputed
*/
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
UE_DEPRECATED ( 5.3 , " Please use UpdateSceneCapture instead. " )
2022-11-14 05:09:53 -05:00
MODELINGCOMPONENTS_API
2023-01-12 11:09:29 -05:00
FRenderCaptureUpdate UpdatePhotoSets (
const TUniquePtr < FSceneCapturePhotoSet > & SceneCapture ,
2022-11-14 05:09:53 -05:00
const TArray < TObjectPtr < AActor > > & Actors ,
const FRenderCaptureOptions & Options ,
bool bAllowCancel ) ;
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
UE_DEPRECATED ( 5.3 , " Please use GetSceneCaptureConfig instead. " )
2023-01-12 11:09:29 -05:00
MODELINGCOMPONENTS_API
FRenderCaptureOptions GetComputedPhotoSetOptions ( const TUniquePtr < FSceneCapturePhotoSet > & SceneCapture ) ;
2022-11-03 07:15:45 -04:00
// Return a render capture baker, note the lifetime of all arguments such match the lifetime of the returned baker
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
UE_DEPRECATED ( 5.3 , " Please use the overload where PendingBake has type FRenderCaptureTypeFlags instead. " )
2022-11-03 07:15:45 -04:00
MODELINGCOMPONENTS_API
TUniquePtr < FMeshMapBaker > MakeRenderCaptureBaker (
FDynamicMesh3 * BaseMesh ,
TSharedPtr < FMeshTangentsd , ESPMode : : ThreadSafe > BaseMeshTangents ,
2023-01-24 05:18:59 -05:00
TSharedPtr < TArray < int32 > , ESPMode : : ThreadSafe > BaseMeshUVCharts ,
2022-11-03 07:15:45 -04:00
FSceneCapturePhotoSet * SceneCapture ,
FSceneCapturePhotoSetSampler * Sampler ,
2023-01-12 11:09:29 -05:00
FRenderCaptureOptions PendingBake ,
int32 TargetUVLayer ,
2022-11-03 07:15:45 -04:00
EBakeTextureResolution TextureImageSize ,
EBakeTextureSamplesPerPixel SamplesPerPixel ,
FRenderCaptureOcclusionHandler * OcclusionHandler ) ;
Fix crashes in BakeRC tool, improved the scene capture progress bar, improved and simplified the scene capture cancellation behavior
* Fixed a crash that occurred in the baking step when cancelling a scene capture which was triggered by changing an option which invalidated all photo sets (i.e., render capture resolution or capture anti aliasing). This was occurring because the baking step proceeded after the scene capture cancellation and the needed photosets were empty.
* Fixed a crash which can happen if you have no channel enabled, change cleanup tolerance from 0 to 1 and then enable the BaseColor channel. This was fixed by changing the behavior of the Cleanup Threshold property, if its positive the DeviceDepth capture is enabled and its disabled otherwise, previously we also required that another channel was enabled which led to the crash in the baking step. The new semantics are easier to understand in the code and and is probably an improvement to the UX as well since the Cleanup Threshold property behavior does not depend on other properties.
* Improved the scene capture cancellation: Users can now cancel the scene capture when the tool is starting up which is better UX since if they picked slow settings they don't intend to reuse, the capture can be cancelled, also, the code is simpler. Changed the behavior of the BakeRC tool properties so that after cancellation the completed captures with the desired settings are enabled. The old behavior where cancellation was documented to restore old results was broken and cannot be made to work unless we store the old results in a separate scene capture but for high capture resolutions that would require a lot of memory. When the SceneCapture is cancelled the channels which were pending and didn't complete are logged in the Output Log in case the user forgets which ones were enabled.
* Simplified the code in various places: Added `operator[](ERenderCaptureType)` to structs with per-capture data, and use it to simplify many places where we previously checked channels individually. Added conversion functions from tool properties/geometry script parameters to the render capture parameters. Removed old confusing logic that determined if a capture had been updated by tracking the number of photos in each photoset with a new system based on a new per-capture pending state. Deprecated a bunch of functions which are no longer useful or which used the wrong types (e.g., `FRenderCaptureUpdate` was added because I hadn't noticed `FRenderCaptureTypeFlags`). Changed the defaults in `FSceneCapturePhotoSet` so that the DeviceDepth capture is off, its an advanced feature and the defaults are intended to make the class friendly to new developers
#rb lonnie.li
[CL 26569987 by matija kecman in ue5-main branch]
2023-07-25 08:46:23 -04:00
PRAGMA_ENABLE_DEPRECATION_WARNINGS
2022-11-03 07:15:45 -04:00
} // end namespace Geometry
} // end namespace UE