2021-04-29 18:12:32 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "GeometryProcessing/ApproximateActorsImpl.h"
# include "Scene/MeshSceneAdapter.h"
2021-06-13 00:36:02 -04:00
# include "DynamicMesh/DynamicMesh3.h"
# include "DynamicMesh/MeshNormals.h"
# include "DynamicMesh/MeshTangents.h"
2022-02-04 10:25:59 -05:00
# include "DynamicMesh/ColliderMesh.h"
2021-04-29 18:12:32 -04:00
# include "MeshSimplification.h"
# include "MeshConstraintsUtil.h"
# include "Implicit/Solidify.h"
# include "Implicit/Morphology.h"
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
# include "Operations/RemoveOccludedTriangles.h"
2021-07-22 18:56:41 -04:00
# include "Operations/MeshPlaneCut.h"
# include "ConstrainedDelaunay2.h"
2021-04-29 18:12:32 -04:00
# include "ParameterizationOps/ParameterizeMeshOp.h"
# include "Parameterization/MeshUVPacking.h"
# include "MeshQueries.h"
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
# include "ProjectionTargets.h"
# include "Selections/MeshFaceSelection.h"
2021-07-22 18:56:41 -04:00
# include "Generators/RectangleMeshGenerator.h"
# include "Parameterization/DynamicMeshUVEditor.h"
2021-04-29 18:12:32 -04:00
# include "AssetUtils/CreateStaticMeshUtil.h"
# include "AssetUtils/CreateTexture2DUtil.h"
# include "AssetUtils/CreateMaterialUtil.h"
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
# include "AssetUtils/Texture2DUtil.h"
2021-04-29 18:12:32 -04:00
# include "UObject/UObjectGlobals.h" // for CreatePackage
# include "ImageUtils.h"
# include "Image/ImageInfilling.h"
# include "Sampling/MeshGenericWorldPositionBaker.h"
# include "Scene/SceneCapturePhotoSet.h"
# include "AssetUtils/Texture2DBuilder.h"
# include "Materials/Material.h"
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
# include "Materials/MaterialInstanceConstant.h"
2021-04-29 18:12:32 -04:00
2021-06-02 16:08:31 -04:00
# include "Engine/MeshMerging.h"
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
# include "Async/Async.h"
2021-04-29 18:12:32 -04:00
# include "Misc/ScopedSlowTask.h"
2021-05-20 20:54:29 -04:00
# include "RenderCaptureInterface.h"
2021-04-29 18:12:32 -04:00
using namespace UE : : Geometry ;
using namespace UE : : AssetUtils ;
2021-06-04 12:43:35 -04:00
DEFINE_LOG_CATEGORY_STATIC ( LogApproximateActors , Log , All ) ;
2021-04-29 18:12:32 -04:00
# define LOCTEXT_NAMESPACE "ApproximateActorsImpl"
2021-05-20 20:54:29 -04:00
static TAutoConsoleVariable < int32 > CVarApproximateActorsRDOCCapture (
TEXT ( " ApproximateActors.RenderCapture " ) ,
0 ,
TEXT ( " Determines whether or not to trigger a render capture. \n " )
TEXT ( " 0: Turned Off \n " )
TEXT ( " 1: Turned On " ) ,
ECVF_Default ) ;
2021-04-29 18:12:32 -04:00
struct FGeneratedResultTextures
{
2021-05-26 03:37:14 -04:00
UTexture2D * BaseColorMap = nullptr ;
UTexture2D * RoughnessMap = nullptr ;
UTexture2D * MetallicMap = nullptr ;
UTexture2D * SpecularMap = nullptr ;
UTexture2D * PackedMRSMap = nullptr ;
UTexture2D * EmissiveMap = nullptr ;
UTexture2D * NormalMap = nullptr ;
2021-04-29 18:12:32 -04:00
} ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
static TUniquePtr < FSceneCapturePhotoSet > CapturePhotoSet (
const TArray < AActor * > & Actors ,
const IGeometryProcessing_ApproximateActors : : FOptions & Options
)
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Captures ) ;
double FieldOfView = Options . FieldOfViewDegrees ;
double NearPlaneDist = Options . NearPlaneDist ;
FImageDimensions CaptureDimensions ( Options . RenderCaptureImageSize , Options . RenderCaptureImageSize ) ;
TUniquePtr < FSceneCapturePhotoSet > SceneCapture = MakeUnique < FSceneCapturePhotoSet > ( ) ;
2021-05-26 03:37:14 -04:00
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : BaseColor , Options . bBakeBaseColor ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : WorldNormal , Options . bBakeNormalMap ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Emissive , Options . bBakeEmissive ) ;
bool bMetallic = Options . bBakeMetallic ;
bool bRoughness = Options . bBakeRoughness ;
bool bSpecular = Options . bBakeSpecular ;
if ( Options . bUsePackedMRS & & ( bMetallic | | bRoughness | | bSpecular ) )
{
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : CombinedMRS , true ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Roughness , false ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Metallic , false ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Specular , false ) ;
}
else
{
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : CombinedMRS , false ) ;
2021-08-16 09:36:40 -04:00
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Roughness , bRoughness ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Metallic , bMetallic ) ;
SceneCapture - > SetCaptureTypeEnabled ( ERenderCaptureType : : Specular , bSpecular ) ;
2021-05-26 03:37:14 -04:00
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
SceneCapture - > SetCaptureSceneActors ( Actors [ 0 ] - > GetWorld ( ) , Actors ) ;
SceneCapture - > AddStandardExteriorCapturesFromBoundingBox (
CaptureDimensions , FieldOfView , NearPlaneDist ,
true , true , true ) ;
return SceneCapture ;
}
2021-04-29 18:12:32 -04:00
static void BakeTexturesFromPhotoCapture (
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TUniquePtr < FSceneCapturePhotoSet > & SceneCapture ,
2021-04-29 18:12:32 -04:00
const IGeometryProcessing_ApproximateActors : : FOptions & Options ,
FGeneratedResultTextures & GeneratedTextures ,
const FDynamicMesh3 * WorldTargetMesh ,
const FMeshTangentsd * MeshTangents
)
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures ) ;
2021-04-29 18:12:32 -04:00
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
int32 UVLayer = 0 ;
2021-05-04 19:08:26 -04:00
int32 Supersample = FMath : : Max ( 1 , Options . AntiAliasMultiSampling ) ;
if ( ( Options . TextureImageSize * Supersample ) > 16384 )
{
2021-06-04 12:43:35 -04:00
UE_LOG ( LogApproximateActors , Warning , TEXT ( " Ignoring requested supersampling rate %d because it would require image buffers with resolution %d, please try lower value. " ) , Supersample , Options . TextureImageSize * Supersample ) ;
2021-05-04 19:08:26 -04:00
Supersample = 1 ;
}
FImageDimensions OutputDimensions ( Options . TextureImageSize * Supersample , Options . TextureImageSize * Supersample ) ;
2021-04-29 18:12:32 -04:00
FScopedSlowTask Progress ( 8.f , LOCTEXT ( " BakingTextures " , " Baking Textures... " ) ) ;
Progress . MakeDialog ( true ) ;
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " BakingSetup " , " Setup... " ) ) ;
FDynamicMeshAABBTree3 Spatial ( WorldTargetMesh , true ) ;
FMeshImageBakingCache TempBakeCache ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_MakeCache ) ;
TempBakeCache . SetDetailMesh ( WorldTargetMesh , & Spatial ) ;
TempBakeCache . SetBakeTargetMesh ( WorldTargetMesh ) ;
TempBakeCache . SetDimensions ( OutputDimensions ) ;
TempBakeCache . SetUVLayer ( UVLayer ) ;
TempBakeCache . SetThickness ( 0.1 ) ;
TempBakeCache . SetCorrespondenceStrategy ( FMeshImageBakingCache : : ECorrespondenceStrategy : : Identity ) ;
TempBakeCache . ValidateCache ( ) ;
}
2021-04-29 18:12:32 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " BakingBaseColor " , " Baking Base Color... " ) ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FAxisAlignedBox3d TargetBounds = WorldTargetMesh - > GetBounds ( ) ;
double RayOffsetHackDist = ( double ) ( 100.0f * FMathf : : ZeroTolerance * TargetBounds . MinDim ( ) ) ;
2021-04-29 18:12:32 -04:00
auto VisibilityFunction = [ & Spatial , RayOffsetHackDist ] ( const FVector3d & SurfPos , const FVector3d & ImagePosWorld )
{
FVector3d RayDir = ImagePosWorld - SurfPos ;
double Dist = Normalize ( RayDir ) ;
FVector3d RayOrigin = SurfPos + RayOffsetHackDist * RayDir ;
2021-11-17 21:06:46 -05:00
int32 HitTID = Spatial . FindNearestHitTriangle ( FRay3d ( RayOrigin , RayDir ) , IMeshSpatial : : FQueryOptions ( Dist ) ) ;
2021-04-29 18:12:32 -04:00
return ( HitTID = = IndexConstants : : InvalidID ) ;
} ;
FSceneCapturePhotoSet : : FSceneSample DefaultSample ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FVector4f InvalidColor ( 0 , - 1 , 0 , 1 ) ;
DefaultSample . BaseColor = FVector3f ( InvalidColor . X , InvalidColor . Y , InvalidColor . Z ) ;
2021-04-29 18:12:32 -04:00
FMeshGenericWorldPositionColorBaker BaseColorBaker ;
BaseColorBaker . SetCache ( & TempBakeCache ) ;
BaseColorBaker . ColorSampleFunction = [ & ] ( FVector3d Position , FVector3d Normal ) {
FSceneCapturePhotoSet : : FSceneSample Sample = DefaultSample ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
SceneCapture - > ComputeSample ( FRenderCaptureTypeFlags : : BaseColor ( ) ,
2021-04-29 18:12:32 -04:00
Position , Normal , VisibilityFunction , Sample ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
return Sample . GetValue4f ( ERenderCaptureType : : BaseColor ) ;
2021-04-29 18:12:32 -04:00
} ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_BakeColor ) ;
BaseColorBaker . Bake ( ) ;
}
2021-04-29 18:12:32 -04:00
// find "hole" pixels
TArray < FVector2i > MissingPixels ;
TUniquePtr < TImageBuilder < FVector4f > > ColorImage = BaseColorBaker . TakeResult ( ) ;
TMarchingPixelInfill < FVector4f > Infill ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_ComputeInfill ) ;
TempBakeCache . FindSamplingHoles ( [ & ] ( const FVector2i & Coords )
{
return ColorImage - > GetPixel ( Coords ) = = InvalidColor ;
} , MissingPixels ) ;
// solve infill for the holes while also caching infill information
Infill . ComputeInfill ( * ColorImage , MissingPixels , InvalidColor ,
[ ] ( FVector4f SumValue , int32 Count ) {
float InvSum = ( Count = = 0 ) ? 1.0f : ( 1.0f / Count ) ;
return FVector4f ( SumValue . X * InvSum , SumValue . Y * InvSum , SumValue . Z * InvSum , 1.0f ) ;
} ) ;
}
2021-04-29 18:12:32 -04:00
2021-05-04 19:08:26 -04:00
// downsample the image if necessary
if ( Supersample > 1 )
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_Downsample ) ;
2021-05-04 19:08:26 -04:00
TImageBuilder < FVector4f > Downsampled = ColorImage - > FastDownsample ( Supersample , FVector4f : : Zero ( ) , [ ] ( FVector4f V , int N ) { return V / ( float ) N ; } ) ;
* ColorImage = MoveTemp ( Downsampled ) ;
}
2021-04-29 18:12:32 -04:00
2021-05-04 19:08:26 -04:00
// this lambda is used to process the per-channel images. It does the bake, applies infill, and downsamples if necessary
2021-04-29 18:12:32 -04:00
auto ProcessChannelFunc = [ & ] ( ERenderCaptureType CaptureType )
{
FVector4f DefaultValue ( 0 , 0 , 0 , 0 ) ;
FMeshGenericWorldPositionColorBaker ChannelBaker ;
ChannelBaker . SetCache ( & TempBakeCache ) ;
ChannelBaker . ColorSampleFunction = [ & ] ( FVector3d Position , FVector3d Normal ) {
FSceneCapturePhotoSet : : FSceneSample Sample = DefaultSample ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
SceneCapture - > ComputeSample ( FRenderCaptureTypeFlags : : Single ( CaptureType ) , Position , Normal , VisibilityFunction , Sample ) ;
return Sample . GetValue4f ( CaptureType ) ;
2021-04-29 18:12:32 -04:00
} ;
ChannelBaker . Bake ( ) ;
TUniquePtr < TImageBuilder < FVector4f > > Image = ChannelBaker . TakeResult ( ) ;
Infill . ApplyInfill ( * Image ,
[ ] ( FVector4f SumValue , int32 Count ) {
float InvSum = ( Count = = 0 ) ? 1.0f : ( 1.0f / Count ) ;
return FVector4f ( SumValue . X * InvSum , SumValue . Y * InvSum , SumValue . Z * InvSum , 1.0f ) ;
} ) ;
2021-05-04 19:08:26 -04:00
if ( Supersample > 1 )
{
TImageBuilder < FVector4f > Downsampled = Image - > FastDownsample ( Supersample , FVector4f : : Zero ( ) , [ ] ( FVector4f V , int N ) { return V / ( float ) N ; } ) ;
* Image = MoveTemp ( Downsampled ) ;
}
2021-04-29 18:12:32 -04:00
return MoveTemp ( Image ) ;
} ;
2021-05-26 03:37:14 -04:00
bool bMetallic = Options . bBakeMetallic ;
bool bRoughness = Options . bBakeRoughness ;
bool bSpecular = Options . bBakeSpecular ;
TUniquePtr < TImageBuilder < FVector4f > > RoughnessImage , MetallicImage , SpecularImage , PackedMRSImage , EmissiveImage ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_OtherChannels ) ;
2021-05-26 03:37:14 -04:00
if ( Options . bUsePackedMRS & & ( bMetallic | | bRoughness | | bSpecular ) )
{
PackedMRSImage = ProcessChannelFunc ( ERenderCaptureType : : CombinedMRS ) ;
}
else
{
if ( bRoughness )
{
RoughnessImage = ProcessChannelFunc ( ERenderCaptureType : : Roughness ) ;
}
if ( bMetallic )
{
MetallicImage = ProcessChannelFunc ( ERenderCaptureType : : Metallic ) ;
}
if ( bSpecular )
{
SpecularImage = ProcessChannelFunc ( ERenderCaptureType : : Specular ) ;
}
}
if ( Options . bBakeEmissive )
{
EmissiveImage = ProcessChannelFunc ( ERenderCaptureType : : Emissive ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2021-04-29 18:12:32 -04:00
2021-05-26 03:37:14 -04:00
2021-04-29 18:12:32 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " BakingNormals " , " Baking Normals... " ) ) ;
2021-05-26 03:37:14 -04:00
TUniquePtr < TImageBuilder < FVector3f > > NormalImage ;
if ( Options . bBakeNormalMap )
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_NormalMapBake ) ;
2021-04-29 18:12:32 -04:00
2021-05-26 03:37:14 -04:00
// no infill on normal map for now, doesn't make sense to do after mapping to tangent space!
// (should we build baked normal map in world space, and then resample to tangent space??)
FVector4f DefaultNormalValue ( 0 , 0 , 1 , 1 ) ;
FMeshGenericWorldPositionNormalBaker NormalMapBaker ;
NormalMapBaker . SetCache ( & TempBakeCache ) ;
NormalMapBaker . BaseMeshTangents = MeshTangents ;
NormalMapBaker . NormalSampleFunction = [ & ] ( FVector3d Position , FVector3d Normal ) {
FSceneCapturePhotoSet : : FSceneSample Sample = DefaultSample ;
SceneCapture - > ComputeSample ( FRenderCaptureTypeFlags : : WorldNormal ( ) ,
Position , Normal , VisibilityFunction , Sample ) ;
FVector3f NormalColor = Sample . WorldNormal ;
float x = ( NormalColor . X - 0.5f ) * 2.0f ;
float y = ( NormalColor . Y - 0.5f ) * 2.0f ;
float z = ( NormalColor . Z - 0.5f ) * 2.0f ;
return FVector3f ( x , y , z ) ;
} ;
NormalMapBaker . Bake ( ) ;
NormalImage = NormalMapBaker . TakeResult ( ) ;
if ( Supersample > 1 )
{
TImageBuilder < FVector3f > Downsampled = NormalImage - > FastDownsample ( Supersample , FVector3f : : Zero ( ) , [ ] ( FVector3f V , int N ) { return V / ( float ) N ; } ) ;
* NormalImage = MoveTemp ( Downsampled ) ;
}
2021-05-04 19:08:26 -04:00
}
2021-04-29 18:12:32 -04:00
// build textures
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " BuildingTextures " , " Building Textures... " ) ) ;
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Textures_BuildTextures ) ;
2021-04-29 18:12:32 -04:00
FScopedSlowTask BuildTexProgress ( 6.f , LOCTEXT ( " BuildingTextures " , " Building Textures... " ) ) ;
BuildTexProgress . MakeDialog ( true ) ;
2021-05-26 03:37:14 -04:00
if ( Options . bBakeBaseColor & & ColorImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
GeneratedTextures . BaseColorMap = FTexture2DBuilder : : BuildTextureFromImage ( * ColorImage , FTexture2DBuilder : : ETextureType : : Color , true , false ) ;
}
if ( Options . bBakeEmissive & & EmissiveImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
2021-05-27 21:27:15 -04:00
GeneratedTextures . EmissiveMap = FTexture2DBuilder : : BuildTextureFromImage ( * EmissiveImage , FTexture2DBuilder : : ETextureType : : EmissiveHDR , false , false ) ;
2021-07-14 15:28:55 -04:00
GeneratedTextures . EmissiveMap - > CompressionSettings = TC_HDR_Compressed ;
2021-05-26 03:37:14 -04:00
}
if ( Options . bBakeNormalMap & & NormalImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
GeneratedTextures . NormalMap = FTexture2DBuilder : : BuildTextureFromImage ( * NormalImage , FTexture2DBuilder : : ETextureType : : NormalMap , false , false ) ;
}
if ( ( bRoughness | | bMetallic | | bSpecular ) & & PackedMRSImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
GeneratedTextures . PackedMRSMap = FTexture2DBuilder : : BuildTextureFromImage ( * PackedMRSImage , FTexture2DBuilder : : ETextureType : : ColorLinear , false , false ) ;
}
else
{
if ( bRoughness & & RoughnessImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
GeneratedTextures . RoughnessMap = FTexture2DBuilder : : BuildTextureFromImage ( * RoughnessImage , FTexture2DBuilder : : ETextureType : : Roughness , false , false ) ;
}
if ( bMetallic & & MetallicImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
GeneratedTextures . MetallicMap = FTexture2DBuilder : : BuildTextureFromImage ( * MetallicImage , FTexture2DBuilder : : ETextureType : : Metallic , false , false ) ;
}
if ( bSpecular & & SpecularImage . IsValid ( ) )
{
BuildTexProgress . EnterProgressFrame ( 1.f ) ;
GeneratedTextures . SpecularMap = FTexture2DBuilder : : BuildTextureFromImage ( * SpecularImage , FTexture2DBuilder : : ETextureType : : Specular , false , false ) ;
}
}
2021-04-29 18:12:32 -04:00
}
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
struct FApproximationMeshData
2021-04-29 18:12:32 -04:00
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
IGeometryProcessing_ApproximateActors : : EResultCode ResultCode = IGeometryProcessing_ApproximateActors : : EResultCode : : UnknownError ;
bool bHaveMesh = false ;
FDynamicMesh3 Mesh ;
bool bHaveTangents = false ;
FMeshTangentsd Tangents ;
} ;
2021-04-29 18:12:32 -04:00
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
static TSharedPtr < FApproximationMeshData > GenerateApproximationMesh (
2022-02-04 10:25:59 -05:00
TUniquePtr < FMeshSceneAdapter > Scene ,
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
const IGeometryProcessing_ApproximateActors : : FOptions & Options ,
double ApproxAccuracy
)
2021-04-29 18:12:32 -04:00
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FScopedSlowTask Progress ( 8.f , LOCTEXT ( " Generating Mesh " , " Generating Mesh.. " ) ) ;
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Collect Seed Points " ) ) ;
2021-04-29 18:12:32 -04:00
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TSharedPtr < FApproximationMeshData > Result = MakeShared < FApproximationMeshData > ( ) ;
2021-04-29 18:12:32 -04:00
2021-05-20 19:35:43 -04:00
// collect seed points
2021-04-29 18:12:32 -04:00
TArray < FVector3d > SeedPoints ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_SeedPoints ) ;
2022-02-04 10:25:59 -05:00
Scene - > CollectMeshSeedPoints ( SeedPoints ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2022-02-04 10:25:59 -05:00
FAxisAlignedBox3d SceneBounds = Scene - > GetBoundingBox ( ) ;
2021-04-29 18:12:32 -04:00
// calculate a voxel size based on target world-space approximation accuracy
float WorldBoundsSize = SceneBounds . DiagonalLength ( ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
int32 VoxelDimTarget = ( int ) ( WorldBoundsSize / ApproxAccuracy ) + 1 ;
2021-04-29 18:12:32 -04:00
if ( VoxelDimTarget < 64 )
{
VoxelDimTarget = 64 ; // use a sane minimum in case the parameter is super-wrong
}
// avoid insane memory usage
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( VoxelDimTarget > Options . ClampVoxelDimension )
2021-04-29 18:12:32 -04:00
{
2021-07-22 18:56:41 -04:00
UE_LOG ( LogApproximateActors , Warning , TEXT ( " very large voxel size %d clamped to %d " ) , VoxelDimTarget , Options . ClampVoxelDimension ) ;
2021-04-29 18:12:32 -04:00
VoxelDimTarget = Options . ClampVoxelDimension ;
}
2021-07-22 18:56:41 -04:00
// make ground plane
FVector3d GroundPlaneOrigin ;
FPlane3d GroundClipPlane ;
bool bHaveGroundClipPlane = false ;
if ( Options . GroundPlanePolicy = = IGeometryProcessing_ApproximateActors : : EGroundPlanePolicy : : FixedZHeightGroundPlane )
{
GroundPlaneOrigin = FVector3d ( SceneBounds . Center ( ) . X , SceneBounds . Center ( ) . Y , Options . GroundPlaneZHeight ) ;
GroundClipPlane = FPlane3d ( FVector3d : : UnitZ ( ) , GroundPlaneOrigin ) ;
bHaveGroundClipPlane = true ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " SolidifyMesh " , " Approximating Mesh... " ) ) ;
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Solidify " ) ) ;
2021-04-29 18:12:32 -04:00
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FDynamicMesh3 SolidMesh ;
{
2022-02-04 10:25:59 -05:00
// Do in local scope so that memory allocated in Solidify is released after SolidMesh is available
// TODO: SolidMesh could be replaced with a FColliderMesh if TImplicitMorphology would allow it
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Solidify ) ;
2022-02-04 10:25:59 -05:00
FWindingNumberBasedSolidify Solidify (
[ & Scene ] ( const FVector3d & Position ) { return Scene - > FastWindingNumber ( Position , true ) ; } ,
SceneBounds , SeedPoints ) ;
Solidify . SetCellSizeAndExtendBounds ( SceneBounds , 2.0 * ApproxAccuracy , VoxelDimTarget ) ;
Solidify . WindingThreshold = Options . WindingThreshold ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
SolidMesh = FDynamicMesh3 ( & Solidify . Generate ( ) ) ;
2022-02-04 10:25:59 -05:00
SolidMesh . DiscardAttributes ( ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2022-02-04 10:25:59 -05:00
// CurResultMesh will point to the "current" result and we will update this pointer as we
// step through various stages of the generation process
FDynamicMesh3 * CurResultMesh = & SolidMesh ;
2021-04-29 18:12:32 -04:00
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Options . bVerbose )
{
2021-12-14 13:08:31 -05:00
UE_LOG ( LogApproximateActors , Log , TEXT ( " Solidify mesh has %d triangles " ) , CurResultMesh - > TriangleCount ( ) ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2022-02-04 10:25:59 -05:00
// we are done w/ the FMeshSceneAdapter now and can free it's memory
Scene . Reset ( ) ;
SeedPoints . Empty ( ) ;
2021-04-29 18:12:32 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " ClosingMesh " , " Topological Operations... " ) ) ;
// do topological closure to fix small gaps/etc
FDynamicMesh3 MorphologyMesh ;
if ( Options . bApplyMorphology )
{
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Morphology " ) ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Morphology ) ;
2021-04-29 18:12:32 -04:00
double MorphologyDistance = Options . MorphologyDistanceMeters * 100.0 ; // convert to cm
FAxisAlignedBox3d MorphologyBounds = CurResultMesh - > GetBounds ( ) ;
FDynamicMeshAABBTree3 MorphologyBVTree ( CurResultMesh ) ;
TImplicitMorphology < FDynamicMesh3 > ImplicitMorphology ;
ImplicitMorphology . MorphologyOp = TImplicitMorphology < FDynamicMesh3 > : : EMorphologyOp : : Close ;
ImplicitMorphology . Source = CurResultMesh ;
ImplicitMorphology . SourceSpatial = & MorphologyBVTree ;
ImplicitMorphology . SetCellSizesAndDistance ( MorphologyBounds , MorphologyDistance , VoxelDimTarget , VoxelDimTarget ) ;
MorphologyMesh = FDynamicMesh3 ( & ImplicitMorphology . Generate ( ) ) ;
MorphologyMesh . DiscardAttributes ( ) ;
2022-02-04 10:25:59 -05:00
2021-04-29 18:12:32 -04:00
CurResultMesh = & MorphologyMesh ;
2022-02-04 10:25:59 -05:00
SolidMesh = FDynamicMesh3 ( ) ; // we are done with SolidMesh now, release it's memory
2021-05-20 19:35:43 -04:00
if ( Options . bVerbose )
{
2021-12-14 13:08:31 -05:00
UE_LOG ( LogApproximateActors , Log , TEXT ( " Morphology mesh has %d triangles " ) , CurResultMesh - > TriangleCount ( ) ) ;
2021-05-20 19:35:43 -04:00
}
2021-04-29 18:12:32 -04:00
}
2021-07-22 18:56:41 -04:00
// TODO: try doing base clipping here to speed up simplification? slight risk of introducing border issues...
2021-04-29 18:12:32 -04:00
// if mesh has no triangles, something has gone wrong
if ( CurResultMesh = = nullptr | | CurResultMesh - > TriangleCount ( ) = = 0 )
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Result - > ResultCode = IGeometryProcessing_ApproximateActors : : EResultCode : : MeshGenerationFailed ;
return Result ;
2021-04-29 18:12:32 -04:00
}
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " SimplifyingMesh " , " Simplifying Mesh... " ) ) ;
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Simplify " ) ) ;
2021-04-29 18:12:32 -04:00
FVolPresMeshSimplification Simplifier ( CurResultMesh ) ;
Simplifier . ProjectionMode = FVolPresMeshSimplification : : ETargetProjectionMode : : NoProjection ;
Simplifier . DEBUG_CHECK_LEVEL = 0 ;
Simplifier . bAllowSeamCollapse = false ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
int32 BaseTargeTriCount = Options . FixedTriangleCount ;
{
int32 BeforeCount = CurResultMesh - > TriangleCount ( ) ;
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification ) ;
if ( Options . MeshSimplificationPolicy = = IGeometryProcessing_ApproximateActors : : ESimplificationPolicy : : TrianglesPerUnitSqMeter )
{
FVector2d VolArea = TMeshQueries < FDynamicMesh3 > : : GetVolumeArea ( * CurResultMesh ) ;
double MeshAreaMeterSqr = VolArea . Y * 0.0001 ;
int32 AreaBaseTargetTriCount = MeshAreaMeterSqr * Options . SimplificationTargetMetric ;
2022-02-24 23:46:55 -05:00
// do initial fast-collapse pass if enabled
if ( Options . bEnableFastSimplifyPrePass & & CurResultMesh - > TriangleCount ( ) > 10 * AreaBaseTargetTriCount )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification_PrePass ) ;
Simplifier . FastCollapsePass ( ApproxAccuracy , 10 , false , 5 * AreaBaseTargetTriCount ) ;
}
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification_Pass1 ) ;
Simplifier . SimplifyToTriangleCount ( AreaBaseTargetTriCount ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
else if ( Options . MeshSimplificationPolicy = = IGeometryProcessing_ApproximateActors : : ESimplificationPolicy : : GeometricTolerance )
{
double UseTargetTolerance = Options . SimplificationTargetMetric * 100.0 ; // convert to cm (UE Units)
2022-02-24 23:46:55 -05:00
// do initial fast-collapse pass if enabled
if ( Options . bEnableFastSimplifyPrePass & & CurResultMesh - > TriangleCount ( ) > 1000000 )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification_PrePass ) ;
Simplifier . FastCollapsePass ( ApproxAccuracy , 10 , false , 1000000 ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
2022-02-24 23:46:55 -05:00
// simplify down to a reasonable tri count, as geometric metric is (relatively) expensive
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
// (still, this is all incredibly cheap compared to the cost of the rest of this method in practice)
2021-05-20 19:35:43 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification_Pass1 ) ;
Simplifier . SimplifyToTriangleCount ( 50000 ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
2022-02-04 10:25:59 -05:00
// make copy of mesh geometry to use for geometric error measurement
FColliderMesh Collider ;
Collider . Initialize ( * CurResultMesh ) ;
FColliderMeshProjectionTarget ColliderTarget ( & Collider ) ;
Simplifier . SetProjectionTarget ( & ColliderTarget ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Simplifier . GeometricErrorConstraint = FVolPresMeshSimplification : : EGeometricErrorCriteria : : PredictedPointToProjectionTarget ;
Simplifier . GeometricErrorTolerance = UseTargetTolerance ;
2021-05-20 19:35:43 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification_Pass2 ) ;
Simplifier . SimplifyToTriangleCount ( 8 ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
else
{
2022-02-24 23:46:55 -05:00
// do initial fast-collapse pass if enabled
int32 FastCollapseThresh = FMath : : Max ( 1000000 , 2 * BaseTargeTriCount ) ;
if ( Options . bEnableFastSimplifyPrePass & & CurResultMesh - > TriangleCount ( ) > FastCollapseThresh )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Simplification_PrePass ) ;
Simplifier . FastCollapsePass ( ApproxAccuracy , 10 , false , FastCollapseThresh ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Simplifier . SimplifyToTriangleCount ( BaseTargeTriCount ) ;
}
int32 AfterCount = CurResultMesh - > TriangleCount ( ) ;
if ( Options . bVerbose )
{
2021-12-14 13:08:31 -05:00
UE_LOG ( LogApproximateActors , Log , TEXT ( " Simplified mesh from %d to %d triangles " ) , BeforeCount , AfterCount ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
}
2021-04-29 18:12:32 -04:00
2021-06-15 00:29:21 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " RemoveHidden " , " Removing Hidden Geometry... " ) ) ;
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Remove Hidden " ) ) ;
2021-06-15 00:29:21 -04:00
if ( Options . OcclusionPolicy = = IGeometryProcessing_ApproximateActors : : EOcclusionPolicy : : VisibilityBased )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Occlusion ) ;
TRemoveOccludedTriangles < FDynamicMesh3 > Remover ( CurResultMesh ) ;
Remover . InsideMode = EOcclusionCalculationMode : : SimpleOcclusionTest ;
Remover . TriangleSamplingMethod = EOcclusionTriangleSampling : : VerticesAndCentroids ;
Remover . AddTriangleSamples = 50 ;
Remover . AddRandomRays = 50 ;
FDynamicMeshAABBTree3 CurResultMeshSpatial ( CurResultMesh , false ) ;
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Occlusion_Spatial ) ;
CurResultMeshSpatial . Build ( ) ;
}
2022-01-29 14:37:53 -05:00
TArray < FTransformSRT3d > NoTransforms ;
NoTransforms . Add ( FTransformSRT3d : : Identity ( ) ) ;
2021-06-15 00:29:21 -04:00
TArray < FDynamicMeshAABBTree3 * > Spatials ;
Spatials . Add ( & CurResultMeshSpatial ) ;
2021-07-22 18:56:41 -04:00
FAxisAlignedBox3d Bounds = CurResultMesh - > GetBounds ( ) ;
FDynamicMesh3 BasePlaneOccluderMesh ;
FDynamicMeshAABBTree3 BasePlaneOccluderSpatial ;
if ( Options . bAddDownwardFacesOccluder )
{
FRectangleMeshGenerator RectGen ;
RectGen . Origin = Bounds . Center ( ) ;
RectGen . Origin . Z = Bounds . Min . Z - 1.0 ;
RectGen . Normal = FVector3f : : UnitZ ( ) ;
RectGen . Width = RectGen . Height = 10.0 * Bounds . MaxDim ( ) ;
BasePlaneOccluderMesh . Copy ( & RectGen . Generate ( ) ) ;
BasePlaneOccluderSpatial . SetMesh ( & BasePlaneOccluderMesh , true ) ;
2022-01-29 14:37:53 -05:00
NoTransforms . Add ( FTransformSRT3d : : Identity ( ) ) ;
2021-07-22 18:56:41 -04:00
Spatials . Add ( & BasePlaneOccluderSpatial ) ;
}
2021-06-15 00:29:21 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Occlusion_Compute ) ;
Remover . Select ( NoTransforms , Spatials , { } , NoTransforms ) ;
}
2021-07-22 18:56:41 -04:00
int32 NumRemoved = 0 ;
2021-06-15 00:29:21 -04:00
if ( Remover . RemovedT . Num ( ) > 0 )
{
FMeshFaceSelection Selection ( CurResultMesh ) ;
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Occlusion_Clean ) ;
Selection . Select ( Remover . RemovedT ) ;
Selection . ExpandToOneRingNeighbours ( 1 ) ;
Selection . ContractBorderByOneRingNeighbours ( 2 ) ;
2021-07-22 18:56:41 -04:00
// select any tris w/ all verts below clip plane
if ( Options . GroundPlaneClippingPolicy = = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : DiscardFullyHiddenFaces )
{
if ( bHaveGroundClipPlane )
{
for ( int32 tid : CurResultMesh - > TriangleIndicesItr ( ) )
{
FVector3d A , B , C ;
CurResultMesh - > GetTriVertices ( tid , A , B , C ) ;
if ( GroundClipPlane . WhichSide ( A ) < = 0 & & GroundClipPlane . WhichSide ( B ) < = 0 & & GroundClipPlane . WhichSide ( C ) < = 0 )
{
Selection . Select ( tid ) ;
}
}
}
else
{
UE_LOG ( LogApproximateActors , Warning , TEXT ( " DiscardFullyHiddenFaces Ground Plane Clipping Policy ignored because no Ground Clip Plane is set " ) ) ;
}
}
2021-06-15 00:29:21 -04:00
}
FDynamicMeshEditor Editor ( CurResultMesh ) ;
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Occlusion_Delete ) ;
2021-07-22 18:56:41 -04:00
TArray SelectionArray ( Selection . AsArray ( ) ) ;
NumRemoved = SelectionArray . Num ( ) ;
Editor . RemoveTriangles ( SelectionArray , true ) ;
2021-06-15 00:29:21 -04:00
}
}
if ( Options . bVerbose )
{
2021-12-14 13:08:31 -05:00
UE_LOG ( LogApproximateActors , Log , TEXT ( " Occlusion-Filtered mesh has %d triangles (removed %d) " ) , CurResultMesh - > TriangleCount ( ) , NumRemoved ) ;
2021-06-15 00:29:21 -04:00
}
}
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Clip Ground " ) ) ;
2021-07-22 18:56:41 -04:00
if ( Options . GroundPlaneClippingPolicy = = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : CutFaces | |
Options . GroundPlaneClippingPolicy = = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : CutFacesAndFill )
{
if ( bHaveGroundClipPlane )
{
FMeshPlaneCut PlaneCut ( CurResultMesh , GroundPlaneOrigin , - GroundClipPlane . Normal ) ;
PlaneCut . Cut ( ) ;
if ( Options . GroundPlaneClippingPolicy = = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : CutFacesAndFill )
{
PlaneCut . HoleFill ( ConstrainedDelaunayTriangulate < double > , true ) ;
}
}
else
{
UE_LOG ( LogApproximateActors , Warning , TEXT ( " Ground Plane Cut/Fill Policy ignored because no Ground Clip Plane is set " ) ) ;
}
}
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Normals and UVs " ) ) ;
2021-06-15 00:29:21 -04:00
2021-04-29 18:12:32 -04:00
// re-enable attributes
CurResultMesh - > EnableAttributes ( ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
// TODO: clip hidden triangles against occluder geo like landscape
2021-04-29 18:12:32 -04:00
// compute normals
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Normals ) ;
2021-05-20 19:35:43 -04:00
if ( Options . bCalculateHardNormals )
{
FMeshNormals : : InitializeOverlayTopologyFromOpeningAngle ( CurResultMesh , CurResultMesh - > Attributes ( ) - > PrimaryNormals ( ) , Options . HardNormalsAngleDeg ) ;
FMeshNormals : : QuickRecomputeOverlayNormals ( * CurResultMesh ) ;
}
else
{
FMeshNormals : : InitializeOverlayToPerVertexNormals ( CurResultMesh - > Attributes ( ) - > PrimaryNormals ( ) ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2021-04-29 18:12:32 -04:00
// exit here if we are just generating a merged collision mesh
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Options . BasePolicy = = IGeometryProcessing_ApproximateActors : : EApproximationPolicy : : CollisionMesh )
2021-04-29 18:12:32 -04:00
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Result - > ResultCode = IGeometryProcessing_ApproximateActors : : EResultCode : : Success ;
Result - > bHaveMesh = true ;
Result - > Mesh = MoveTemp ( * CurResultMesh ) ;
return Result ;
2021-04-29 18:12:32 -04:00
}
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " ComputingUVs " , " Computing UVs... " ) ) ;
// compute UVs
2021-07-22 18:56:41 -04:00
bool bHaveValidUVs = true ;
2021-04-29 18:12:32 -04:00
TSharedPtr < FDynamicMesh3 , ESPMode : : ThreadSafe > UVInputMesh = MakeShared < FDynamicMesh3 , ESPMode : : ThreadSafe > ( ) ;
2021-12-14 13:08:31 -05:00
// PatchBuilder AutoUV currently requires compact input mesh. TODO: fix that, then we can just re-use CurResultMesh here.
UVInputMesh - > CompactCopy ( * CurResultMesh ) ;
//*UVInputMesh = MoveTemp(*CurResultMesh);
2021-04-29 18:12:32 -04:00
FParameterizeMeshOp ParameterizeMeshOp ;
2021-07-22 18:56:41 -04:00
ParameterizeMeshOp . Stretch = Options . UVAtlasStretchTarget ;
2021-12-14 13:08:31 -05:00
// UVAtlas parameters
2021-04-29 18:12:32 -04:00
ParameterizeMeshOp . NumCharts = 0 ;
2021-12-14 13:08:31 -05:00
// PatchBuilder generation parameters
ParameterizeMeshOp . InitialPatchCount = Options . PatchBuilderInitialPatchCount ;
ParameterizeMeshOp . bRespectInputGroups = false ;
ParameterizeMeshOp . PatchCurvatureAlignmentWeight = Options . PatchBuilderCurvatureAlignment ;
ParameterizeMeshOp . PatchMergingMetricThresh = Options . PatchBuilderMergingThreshold ;
ParameterizeMeshOp . PatchMergingAngleThresh = Options . PatchBuilderMaxNormalDeviationDeg ;
ParameterizeMeshOp . ExpMapNormalSmoothingSteps = 5 ;
ParameterizeMeshOp . ExpMapNormalSmoothingAlpha = 0.25 ;
2021-04-29 18:12:32 -04:00
ParameterizeMeshOp . InputMesh = UVInputMesh ;
2021-07-22 18:56:41 -04:00
ParameterizeMeshOp . Method = UE : : Geometry : : EParamOpBackend : : XAtlas ;
if ( Options . UVPolicy = = IGeometryProcessing_ApproximateActors : : EUVGenerationPolicy : : PreferUVAtlas )
{
ParameterizeMeshOp . Method = UE : : Geometry : : EParamOpBackend : : UVAtlas ;
}
2021-12-14 13:08:31 -05:00
else if ( Options . UVPolicy = = IGeometryProcessing_ApproximateActors : : EUVGenerationPolicy : : PreferPatchBuilder )
{
ParameterizeMeshOp . Method = UE : : Geometry : : EParamOpBackend : : PatchBuilder ;
}
2021-04-29 18:12:32 -04:00
FProgressCancel UVProgressCancel ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_GenerateUVs ) ;
ParameterizeMeshOp . CalculateResult ( & UVProgressCancel ) ;
}
2021-04-29 18:12:32 -04:00
2021-07-22 18:56:41 -04:00
TUniquePtr < FDynamicMesh3 > FinalMesh ;
FGeometryResult UVResultInfo = ParameterizeMeshOp . GetResultInfo ( ) ;
if ( ! UVResultInfo . HasResult ( ) )
{
UE_LOG ( LogApproximateActors , Warning , TEXT ( " UV Auto-Generation Failed for target path %s " ) , * Options . BasePackagePath ) ;
bHaveValidUVs = false ;
FinalMesh = MakeUnique < FDynamicMesh3 > ( MoveTemp ( * UVInputMesh ) ) ;
}
else
{
FinalMesh = ParameterizeMeshOp . ExtractResult ( ) ;
}
// if UVs failed, fall back to box projection
if ( ! bHaveValidUVs )
{
FDynamicMeshUVEditor UVEditor ( FinalMesh . Get ( ) , 0 , true ) ;
TArray < int32 > AllTriangles ;
for ( int32 tid : FinalMesh - > TriangleIndicesItr ( ) )
{
AllTriangles . Add ( tid ) ;
}
UVEditor . SetTriangleUVsFromBoxProjection ( AllTriangles , [ & ] ( const FVector3d & P ) { return P ; } ,
FFrame3d ( FinalMesh - > GetBounds ( ) . Center ( ) ) , FVector3d : : One ( ) ) ;
bHaveValidUVs = true ;
}
2021-04-29 18:12:32 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " PackingUVs " , " Packing UVs... " ) ) ;
// repack UVs
2021-07-22 18:56:41 -04:00
if ( bHaveValidUVs )
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
2021-07-22 18:56:41 -04:00
FDynamicMeshUVOverlay * RepackUVLayer = FinalMesh - > Attributes ( ) - > PrimaryUV ( ) ;
RepackUVLayer - > SplitBowties ( ) ;
FDynamicMeshUVPacker Packer ( RepackUVLayer ) ;
Packer . TextureResolution = Options . TextureImageSize / 4 ; // maybe too conservative? We don't have gutter control currently.
Packer . GutterSize = 1.0 ; // not clear this works
Packer . bAllowFlips = false ;
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_PackUVs ) ;
bool bPackingOK = Packer . StandardPack ( ) ;
if ( ! bPackingOK )
{
UE_LOG ( LogApproximateActors , Warning , TEXT ( " UV Packing Failed for target path %s " ) , * Options . BasePackagePath ) ;
}
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2021-04-29 18:12:32 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " ComputingTangents " , " Computing Tangents... " ) ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Result - > ResultCode = IGeometryProcessing_ApproximateActors : : EResultCode : : Success ;
Result - > bHaveMesh = true ;
Result - > Mesh = MoveTemp ( * FinalMesh ) ;
2021-04-29 18:12:32 -04:00
// compute tangents
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Result - > bHaveTangents = true ;
Result - > Tangents . SetMesh ( & Result - > Mesh ) ;
2021-04-29 18:12:32 -04:00
FComputeTangentsOptions TangentsOptions ;
TangentsOptions . bAveraged = true ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Tangents ) ;
Result - > Tangents . ComputeTriVertexTangents (
Result - > Mesh . Attributes ( ) - > PrimaryNormals ( ) ,
Result - > Mesh . Attributes ( ) - > PrimaryUV ( ) ,
TangentsOptions ) ;
}
return Result ;
}
2021-06-10 21:50:21 -04:00
static int32 GetMeshTextureSizeFromTargetTexelDensity ( const FDynamicMesh3 & Mesh , float TargetTexelDensity )
{
const FDynamicMeshUVOverlay * UVOverlay = Mesh . Attributes ( ) - > PrimaryUV ( ) ;
double Mesh3DArea = 0 ;
double MeshUVArea = 0 ;
for ( int TriangleID : Mesh . TriangleIndicesItr ( ) )
{
// World space area
Mesh3DArea + = Mesh . GetTriArea ( TriangleID ) ;
FIndex3i UVVertices = UVOverlay - > GetTriangle ( TriangleID ) ;
FTriangle2d TriangleUV = FTriangle2d (
( FVector2d ) UVOverlay - > GetElement ( UVVertices . A ) ,
( FVector2d ) UVOverlay - > GetElement ( UVVertices . B ) ,
( FVector2d ) UVOverlay - > GetElement ( UVVertices . C ) ) ;
// UV space area
MeshUVArea + = TriangleUV . Area ( ) ;
}
double TexelRatio = FMath : : Sqrt ( MeshUVArea / Mesh3DArea ) * 100 ;
// Compute the perfect texture size that would get us to our texture density
// Also compute the nearest power of two sizes (below and above our target)
const int32 SizePerfect = FMath : : CeilToInt ( TargetTexelDensity / TexelRatio ) ;
const int32 SizeHi = FMath : : RoundUpToPowerOfTwo ( SizePerfect ) ;
const int32 SizeLo = SizeHi > > 1 ;
// Compute the texel density we achieve with these two texture sizes
const double TexelDensityLo = SizeLo * TexelRatio ;
const double TexelDensityHi = SizeHi * TexelRatio ;
// Select best match between low & high res textures.
const double TexelDensityLoDiff = TargetTexelDensity - TexelDensityLo ;
const double TexelDensityHiDiff = TexelDensityHi - TargetTexelDensity ;
const int32 BestTextureSize = TexelDensityLoDiff < TexelDensityHiDiff ? SizeLo : SizeHi ;
return BestTextureSize ;
}
2021-06-02 16:08:31 -04:00
IGeometryProcessing_ApproximateActors : : FOptions FApproximateActorsImpl : : ConstructOptions ( const FMeshApproximationSettings & UseSettings )
{
//
// Construct options for ApproximateActors operation
//
FOptions Options ;
Options . BasePolicy = ( UseSettings . OutputType = = EMeshApproximationType : : MeshShapeOnly ) ?
IGeometryProcessing_ApproximateActors : : EApproximationPolicy : : CollisionMesh :
IGeometryProcessing_ApproximateActors : : EApproximationPolicy : : MeshAndGeneratedMaterial ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
Options . MeshDataLODPolicy = ( UseSettings . bUseRenderLODMeshes ) ?
EMeshDataSourceLODPolicy : : LOD0RenderMeshes : EMeshDataSourceLODPolicy : : LOD0SourceMeshes ;
2021-06-02 16:08:31 -04:00
Options . WorldSpaceApproximationAccuracyMeters = UseSettings . ApproximationAccuracy ;
Options . bAutoThickenThinParts = UseSettings . bAttemptAutoThickening ;
Options . AutoThickenThicknessMeters = UseSettings . TargetMinThicknessMultiplier * UseSettings . ApproximationAccuracy ;
2021-07-22 18:56:41 -04:00
Options . bIgnoreTinyParts = UseSettings . bIgnoreTinyParts ;
Options . TinyPartMaxDimensionMeters = UseSettings . TinyPartSizeMultiplier * UseSettings . ApproximationAccuracy ;
2021-06-02 16:08:31 -04:00
Options . BaseCappingPolicy = IGeometryProcessing_ApproximateActors : : EBaseCappingPolicy : : NoBaseCapping ;
if ( UseSettings . BaseCapping = = EMeshApproximationBaseCappingType : : ConvexPolygon )
{
Options . BaseCappingPolicy = IGeometryProcessing_ApproximateActors : : EBaseCappingPolicy : : ConvexPolygon ;
}
else if ( UseSettings . BaseCapping = = EMeshApproximationBaseCappingType : : ConvexSolid )
{
Options . BaseCappingPolicy = IGeometryProcessing_ApproximateActors : : EBaseCappingPolicy : : ConvexSolid ;
}
Options . ClampVoxelDimension = UseSettings . ClampVoxelDimension ;
Options . WindingThreshold = UseSettings . WindingThreshold ;
Options . bApplyMorphology = UseSettings . bFillGaps ;
Options . MorphologyDistanceMeters = UseSettings . GapDistance ;
2021-07-22 18:56:41 -04:00
if ( UseSettings . GroundClipping = = EMeshApproximationGroundPlaneClippingPolicy : : NoGroundClipping )
{
Options . GroundPlanePolicy = EGroundPlanePolicy : : NoGroundPlane ;
Options . GroundPlaneClippingPolicy = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : NoClipping ;
}
else if ( UseSettings . GroundClipping = = EMeshApproximationGroundPlaneClippingPolicy : : DiscardWithZPlane )
{
Options . GroundPlanePolicy = EGroundPlanePolicy : : FixedZHeightGroundPlane ;
Options . GroundPlaneZHeight = UseSettings . GroundClippingZHeight ;
Options . GroundPlaneClippingPolicy = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : DiscardFullyHiddenFaces ;
}
else if ( UseSettings . GroundClipping = = EMeshApproximationGroundPlaneClippingPolicy : : CutWithZPlane )
{
Options . GroundPlanePolicy = EGroundPlanePolicy : : FixedZHeightGroundPlane ;
Options . GroundPlaneZHeight = UseSettings . GroundClippingZHeight ;
Options . GroundPlaneClippingPolicy = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : CutFaces ;
}
else if ( UseSettings . GroundClipping = = EMeshApproximationGroundPlaneClippingPolicy : : CutAndFillWithZPlane )
{
Options . GroundPlanePolicy = EGroundPlanePolicy : : FixedZHeightGroundPlane ;
Options . GroundPlaneZHeight = UseSettings . GroundClippingZHeight ;
Options . GroundPlaneClippingPolicy = IGeometryProcessing_ApproximateActors : : EGroundPlaneClippingPolicy : : CutFacesAndFill ;
}
2021-06-02 16:08:31 -04:00
Options . OcclusionPolicy = ( UseSettings . OcclusionMethod = = EOccludedGeometryFilteringPolicy : : VisibilityBasedFiltering ) ?
IGeometryProcessing_ApproximateActors : : EOcclusionPolicy : : VisibilityBased : IGeometryProcessing_ApproximateActors : : EOcclusionPolicy : : None ;
2021-07-22 18:56:41 -04:00
Options . bAddDownwardFacesOccluder = UseSettings . bOccludeFromBottom ;
2021-06-02 16:08:31 -04:00
Options . FixedTriangleCount = UseSettings . TargetTriCount ;
if ( UseSettings . SimplifyMethod = = EMeshApproximationSimplificationPolicy : : TrianglesPerArea )
{
Options . MeshSimplificationPolicy = IGeometryProcessing_ApproximateActors : : ESimplificationPolicy : : TrianglesPerUnitSqMeter ;
Options . SimplificationTargetMetric = UseSettings . TrianglesPerM ;
}
else if ( UseSettings . SimplifyMethod = = EMeshApproximationSimplificationPolicy : : GeometricTolerance )
{
Options . MeshSimplificationPolicy = IGeometryProcessing_ApproximateActors : : ESimplificationPolicy : : GeometricTolerance ;
Options . SimplificationTargetMetric = UseSettings . GeometricDeviation ;
}
else
{
Options . MeshSimplificationPolicy = IGeometryProcessing_ApproximateActors : : ESimplificationPolicy : : FixedTriangleCount ;
}
2022-02-24 23:46:55 -05:00
Options . bEnableFastSimplifyPrePass = UseSettings . bEnableSimplifyPrePass ;
2021-06-02 16:08:31 -04:00
2021-12-14 13:08:31 -05:00
Options . UVPolicy = IGeometryProcessing_ApproximateActors : : EUVGenerationPolicy : : PreferXAtlas ;
if ( UseSettings . UVGenerationMethod = = EMeshApproximationUVGenerationPolicy : : PreferUVAtlas )
{
Options . UVPolicy = IGeometryProcessing_ApproximateActors : : EUVGenerationPolicy : : PreferUVAtlas ;
}
else if ( UseSettings . UVGenerationMethod = = EMeshApproximationUVGenerationPolicy : : PreferPatchBuilder )
{
Options . UVPolicy = IGeometryProcessing_ApproximateActors : : EUVGenerationPolicy : : PreferPatchBuilder ;
}
Options . PatchBuilderInitialPatchCount = FMath : : Clamp ( UseSettings . InitialPatchCount , 1 , 99999 ) ;
Options . PatchBuilderCurvatureAlignment = FMath : : Clamp ( UseSettings . CurvatureAlignment , 0.001 , 1000.0 ) ;
Options . PatchBuilderMergingThreshold = FMath : : Clamp ( UseSettings . MergingThreshold , 1.0 , 9999.0 ) ;
Options . PatchBuilderMaxNormalDeviationDeg = FMath : : Clamp ( UseSettings . MaxAngleDeviation , 0.0 , 180 ) ;
2021-07-22 18:56:41 -04:00
2021-06-15 00:29:21 -04:00
Options . bCalculateHardNormals = UseSettings . bEstimateHardNormals ;
Options . HardNormalsAngleDeg = FMath : : Clamp ( UseSettings . HardNormalAngle , 0.001f , 89.99f ) ;
2021-06-02 16:08:31 -04:00
Options . TextureImageSize = UseSettings . MaterialSettings . TextureSize . X ;
Options . AntiAliasMultiSampling = FMath : : Max ( 1 , UseSettings . MultiSamplingAA ) ;
Options . RenderCaptureImageSize = ( UseSettings . RenderCaptureResolution = = 0 ) ?
Options . TextureImageSize : UseSettings . RenderCaptureResolution ;
Options . FieldOfViewDegrees = UseSettings . CaptureFieldOfView ;
Options . NearPlaneDist = UseSettings . NearPlaneDist ;
2022-02-24 23:46:55 -05:00
Options . bMaximizeBakeParallelism = UseSettings . bEnableParallelBaking ;
2021-06-02 16:08:31 -04:00
Options . bVerbose = UseSettings . bPrintDebugMessages ;
Options . bWriteDebugMesh = UseSettings . bEmitFullDebugMesh ;
// Nanite settings
Options . bGenerateNaniteEnabledMesh = UseSettings . bGenerateNaniteEnabledMesh ;
Options . NaniteProxyTrianglePercent = UseSettings . NaniteProxyTrianglePercent ;
// Distance field
Options . bAllowDistanceField = UseSettings . bAllowDistanceField ;
// Ray tracing
Options . bSupportRayTracing = UseSettings . bSupportRayTracing ;
return Options ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
void FApproximateActorsImpl : : ApproximateActors ( const TArray < AActor * > & Actors , const FOptions & Options , FResults & ResultsOut )
{
int32 ActorClusters = 1 ;
FScopedSlowTask Progress ( 1.f , LOCTEXT ( " ApproximatingActors " , " Generating Actor Approximation... " ) ) ;
Progress . MakeDialog ( true ) ;
Progress . EnterProgressFrame ( 1.f ) ;
GenerateApproximationForActorSet ( Actors , Options , ResultsOut ) ;
}
void FApproximateActorsImpl : : GenerateApproximationForActorSet ( const TArray < AActor * > & Actors , const FOptions & Options , FResults & ResultsOut )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate ) ;
2021-05-20 20:54:29 -04:00
RenderCaptureInterface : : FScopedCapture RenderCapture ( CVarApproximateActorsRDOCCapture . GetValueOnAnyThread ( ) = = 1 , TEXT ( " ApproximateActors " ) ) ;
2021-06-04 12:43:35 -04:00
if ( Options . BasePolicy = = IGeometryProcessing_ApproximateActors : : EApproximationPolicy : : MeshAndGeneratedMaterial )
{
// The scene capture photoset part of this process relies on debug view modes being available.
// If it ain't the case, fail immediatelly
if ( ! AllowDebugViewmodes ( ) )
{
UE_LOG ( LogApproximateActors , Error , TEXT ( " Debug view modes not are available - unable to generate material " ) ) ;
ResultsOut . ResultCode = EResultCode : : MaterialGenerationFailed ;
return ;
}
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
2022-02-04 10:25:59 -05:00
//
// extract all visible meshes from the list of Actors and build up a "mesh scene" that represents the
// assembly of geometry, taking advantage of instancing where possible, but also pulling those meshes
// apart and processing them if necessary to (eg) thicken them, etc, so that later processing works better.
// FMeshSceneAdapter does all the heavy lifting, here it is just being configured and built
//
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FScopedSlowTask Progress ( 11.f , LOCTEXT ( " ApproximatingActors " , " Generating Actor Approximation... " ) ) ;
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " BuildingScene " , " Building Scene... " ) ) ;
float ApproxAccuracy = Options . WorldSpaceApproximationAccuracyMeters * 100.0 ; // convert to cm (UE Units)
2022-02-04 10:25:59 -05:00
TUniquePtr < FMeshSceneAdapter > Scene = MakeUnique < FMeshSceneAdapter > ( ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FMeshSceneAdapterBuildOptions SceneBuildOptions ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
SceneBuildOptions . bIgnoreStaticMeshSourceData = ( Options . MeshDataLODPolicy = = EMeshDataSourceLODPolicy : : LOD0RenderMeshes ) ; // default is false
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
SceneBuildOptions . bThickenThinMeshes = Options . bAutoThickenThinParts ;
SceneBuildOptions . DesiredMinThickness = Options . AutoThickenThicknessMeters * 100.0 ; // convert to cm (UE Units)
2021-06-15 02:47:39 -04:00
// filter out objects smaller than 10% of voxel size
2021-07-22 18:56:41 -04:00
SceneBuildOptions . bFilterTinyObjects = Options . bIgnoreTinyParts ;
SceneBuildOptions . TinyObjectBoxMaxDimension = Options . TinyPartMaxDimensionMeters ;
ApproximateActors: reduce memory footprint by using compressed or lower-resolution LOD0 meshes
- add FStaticMeshLODResourcesAdapter in MeshConversions module, wrapper that presents StaticMesh LODResources mesh (ie Section buffers) with an API compatible with GeometryCore mesh templates
- add TMeshWrapperAdapterd in GeometryCore, this is a shim for getting any template-API-compatible mesh into a FTriangleMeshAdapterd specifically (required to call some non-template mesh processing functions)
- add support for using StaticMesh LODResources meshes in FMeshSceneAdapter instead of source meshes, controlled by build options flag
- add FMeshSceneAdapter build options flags specifying whether UV/Normal queries are required (default true)
- when not required, the loaded MeshDescriptions and created DynamicMeshes are packed into FColliderMesh which has a smaller memory footprint, allowing the larger meshes to be freed
- to support above, the SpatialWrappers in MeshSceneAdapter.cpp have been refactored extensively
- added FCompressedMeshSpatialWrapper which Builds from a temporary FDynamicMesh3 into a FColliderMesh, supports all the same options as FDynamicMeshSpatialWrapper (so a drop-in replacement with less memory usage, but no UV/Normal queries)
- added FBaseMeshSpatialWrapper, base class for existing FDynamicMeshSpatialWrapper and new FCompressedMeshSpatialWrapper that has shared config settings (can more more here in the future)
- added FStaticMeshLODResourcesMeshSurfaceAdapter, similar toFMeshDescriptionTriangleMeshSurfaceAdapter, a mesh adapter that filters out any geo that doesn't have a Surface-domain material
- refactored TStaticMeshSpatialWrapper into TStaticMeshSpatialWrapperBase and subclasses FStaticMeshSourceDataSpatialWrapper and FStaticMeshRenderDataSpatialWrapper, for source mesh vs render mesh
- added FCompressedStaticMeshSpatialWrapper, variant of FStaticMeshSourceDataSpatialWrapper that stores to a FColliderMesh and releases the source MeshDescription
- SpatialWrapperFactory() now has logic to build from render mesh vs source mesh vs compressed source mesh
- moved initial SpatialWrapper construction from AddActors() phase to Build() phase, because now it depends on build settings
- add EMeshDataSourceLODPolicy to IGeometryProcessing::FOptions, with LOD0 Source and LOD0 RenderMesh options
- ApproximateActorsImpl now provides/handles this policy setting, and configures FMeshSceneAdapter to not need UV/Normal queries (not required in this context)
- add bUseRenderLODMeshes option in FMeshApproximationSettings to expose render vs source mesh control at user level
#rb sebastien.lussier, rinat.abdrashitov
#jira UE-141256
#preflight 6206db44054c2e38c473be5d
#rnx
#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18963126 in //UE5/Release-5.0/... via CL 18963829 via CL 18964587
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)
[CL 18964607 by ryan schmidt in ue5-main branch]
2022-02-11 18:11:49 -05:00
SceneBuildOptions . bOnlySurfaceMaterials = true ; // don't include decal geometry in 3D mesh scene (will be included in renderings)
SceneBuildOptions . bEnableUVQueries = SceneBuildOptions . bEnableNormalsQueries = false ; // not required in this context, will reduce memory usage
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
SceneBuildOptions . bPrintDebugMessages = Options . bVerbose ;
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_BuildScene ) ;
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Adding Actors " ) ) ;
Scene - > AddActors ( Actors ) ;
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Building Scene " ) ) ;
Scene - > Build ( SceneBuildOptions ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
if ( Options . bVerbose )
{
FMeshSceneAdapter : : FStatistics Stats ;
2022-02-04 10:25:59 -05:00
Scene - > GetGeometryStatistics ( Stats ) ;
2021-12-14 13:08:31 -05:00
UE_LOG ( LogApproximateActors , Log , TEXT ( " %lld triangles in %lld unique meshes, total %lld triangles in %lld instances " ) ,
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
Stats . UniqueMeshTriangleCount , Stats . UniqueMeshCount , Stats . InstanceMeshTriangleCount , Stats . InstanceMeshCount ) ;
}
2022-02-04 10:25:59 -05:00
// add a "base cap" if desired, this helps with (eg) large meshes with no base like a 3D scan of a mountain, etc
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Options . BaseCappingPolicy ! = EBaseCappingPolicy : : NoBaseCapping )
{
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Capping " ) ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_Capping ) ;
2022-01-18 16:38:06 -05:00
double UseThickness = 0.0 ;
if ( Options . BaseCappingPolicy = = EBaseCappingPolicy : : ConvexSolid )
{
UseThickness = ( Options . BaseThicknessOverrideMeters ! = 0 ) ? ( Options . BaseThicknessOverrideMeters * 100.0 ) :
( Options . bAutoThickenThinParts ? SceneBuildOptions . DesiredMinThickness : 1.25 * ApproxAccuracy ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
double UseHeight = ( Options . BaseHeightOverrideMeters ! = 0 ) ? ( Options . BaseHeightOverrideMeters * 100.0 ) : ( 2.0 * ApproxAccuracy ) ;
2022-02-04 10:25:59 -05:00
Scene - > GenerateBaseClosingMesh ( UseHeight , UseThickness ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
FDynamicMesh3 DebugMesh ;
FDynamicMesh3 * WriteDebugMesh = nullptr ;
if ( Options . bWriteDebugMesh )
{
TRACE_CPUPROFILER_EVENT_SCOPE ( ApproximateActorsImpl_Generate_DebugMesh ) ;
DebugMesh . EnableAttributes ( ) ;
2022-02-04 10:25:59 -05:00
Scene - > GetAccumulatedMesh ( DebugMesh ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FMeshNormals : : InitializeMeshToPerTriangleNormals ( & DebugMesh ) ;
WriteDebugMesh = & DebugMesh ;
}
2022-02-04 10:25:59 -05:00
// build spatial evaluation cache in the FMeshSceneAdapter, necessary for the mesh build below
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Building Cache " ) ) ;
Scene - > BuildSpatialEvaluationCache ( ) ;
2021-05-20 19:35:43 -04:00
2022-02-04 10:25:59 -05:00
//
// Generate a new mesh that approximates the entire scene represented by FMeshSceneAdapter.
//
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Building Approx Mesh " ) ) ;
// Pass ownership of the Scene to GenerateApproximationMesh() so that it can delete it as soon
// as possible (because it is often very large, memory-wise)
2022-02-24 23:46:55 -05:00
TFuture < TSharedPtr < FApproximationMeshData > > GenerateMeshFuture = Async ( EAsyncExecution : : ThreadPool , [ & Scene , Options , ApproxAccuracy ] ( )
{
return GenerateApproximationMesh ( MoveTemp ( Scene ) , Options , ApproxAccuracy ) ;
} ) ;
FDynamicMesh3 FinalMesh ;
FMeshTangentsd FinalMeshTangents ;
auto WaitForMeshAvailable = [ & ] ( )
{
TSharedPtr < FApproximationMeshData > ApproximationMeshData = GenerateMeshFuture . Get ( ) ;
ResultsOut . ResultCode = ApproximationMeshData - > ResultCode ;
FinalMesh = MoveTemp ( ApproximationMeshData - > Mesh ) ;
FinalMeshTangents = MoveTemp ( ApproximationMeshData - > Tangents ) ;
} ;
2022-02-04 10:25:59 -05:00
// if we are only generating collision mesh, we are done now
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Options . BasePolicy = = IGeometryProcessing_ApproximateActors : : EApproximationPolicy : : CollisionMesh )
{
2022-02-24 23:46:55 -05:00
WaitForMeshAvailable ( ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( ResultsOut . ResultCode = = EResultCode : : Success )
{
2022-02-24 23:46:55 -05:00
EmitGeneratedMeshAsset ( Actors , Options , ResultsOut , & FinalMesh , nullptr , WriteDebugMesh ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
return ;
}
2022-02-24 23:46:55 -05:00
// if parallel capture is not allowed, force mesh computation to finish now
if ( Options . bMaximizeBakeParallelism = = false )
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
{
2022-02-24 23:46:55 -05:00
WaitForMeshAvailable ( ) ;
if ( ResultsOut . ResultCode ! = EResultCode : : Success )
{
return ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
}
2022-02-04 10:25:59 -05:00
//
// create a set of spatially located render captures of the scene ("photo set").
//
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " CapturingScene " , " Capturing Scene... " ) ) ;
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Capture Photos " ) ) ;
TUniquePtr < FSceneCapturePhotoSet > SceneCapture = CapturePhotoSet ( Actors , Options ) ;
2022-02-24 23:46:55 -05:00
// if parallel capture was allowed, need to force the mesh compute to finish now to be able to proceed
if ( Options . bMaximizeBakeParallelism = = true )
{
WaitForMeshAvailable ( ) ;
if ( ResultsOut . ResultCode ! = EResultCode : : Success )
{
return ;
}
}
2022-02-04 10:25:59 -05:00
//
// bake textures onto the generated approximation mesh by projecting/sampling
// the set of captured photos
//
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " BakingTextures " , " Baking Textures... " ) ) ;
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Bake Textures " ) ) ;
2021-06-10 21:50:21 -04:00
FOptions OverridenOptions = Options ;
// evaluate required texture size if needed
if ( Options . TextureSizePolicy = = ETextureSizePolicy : : TexelDensity )
{
const int32 MaxTextureSize = 8192 ;
const int32 BestTextureSize = GetMeshTextureSizeFromTargetTexelDensity ( FinalMesh , Options . MeshTexelDensity ) ;
if ( BestTextureSize > MaxTextureSize )
{
UE_LOG ( LogApproximateActors , Warning , TEXT ( " Mesh would require %dx%d textures, clamping down to maximum (%dx%d) " ) , BestTextureSize , BestTextureSize , MaxTextureSize , MaxTextureSize ) ;
OverridenOptions . TextureImageSize = MaxTextureSize ;
}
else
{
OverridenOptions . TextureImageSize = BestTextureSize ;
}
}
2022-02-04 10:25:59 -05:00
2021-04-29 18:12:32 -04:00
// bake textures for Actor
FGeneratedResultTextures GeneratedTextures ;
2021-06-10 21:50:21 -04:00
BakeTexturesFromPhotoCapture ( SceneCapture , OverridenOptions ,
2021-04-29 18:12:32 -04:00
GeneratedTextures ,
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
& FinalMesh , & FinalMeshTangents ) ;
2021-04-29 18:12:32 -04:00
Progress . EnterProgressFrame ( 1.f , LOCTEXT ( " Writing Assets " , " Writing Assets... " ) ) ;
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Create Material " ) ) ;
2021-04-29 18:12:32 -04:00
2021-05-26 03:37:14 -04:00
// Make material for textures by creating MIC of input material, or fall back to known material
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
UMaterialInterface * UseBaseMaterial = ( Options . BakeMaterial ! = nullptr ) ?
2021-07-29 20:08:48 -04:00
Options . BakeMaterial : LoadObject < UMaterial > ( nullptr , TEXT ( " /MeshModelingToolsetExp/Materials/FullMaterialBakePreviewMaterial_PackedMRS " ) ) ;
2021-04-29 18:12:32 -04:00
FMaterialAssetOptions MatOptions ;
MatOptions . NewAssetPath = Options . BasePackagePath + TEXT ( " _Material " ) ;
FMaterialAssetResults MatResults ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
ECreateMaterialResult MatResult = UE : : AssetUtils : : CreateDerivedMaterialInstance ( UseBaseMaterial , MatOptions , MatResults ) ;
UMaterialInstanceConstant * NewMaterial = nullptr ;
2021-04-29 18:12:32 -04:00
if ( ensure ( MatResult = = ECreateMaterialResult : : Ok ) )
{
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
NewMaterial = MatResults . NewMaterialInstance ;
2021-04-29 18:12:32 -04:00
ResultsOut . NewMaterials . Add ( NewMaterial ) ;
}
// this lambda converts a generated texture to an Asset, and then assigns it to a parameter of the Material
FString BaseTexturePath = MatOptions . NewAssetPath ;
auto WriteTextureLambda = [ BaseTexturePath , NewMaterial , & ResultsOut ] (
UTexture2D * Texture ,
FString TextureTypeSuffix ,
FTexture2DBuilder : : ETextureType Type ,
FName MaterialParamName )
{
if ( ensure ( Texture ! = nullptr ) = = false ) return ;
FTexture2DBuilder : : CopyPlatformDataToSourceData ( Texture , Type ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Type = = FTexture2DBuilder : : ETextureType : : Roughness
| | Type = = FTexture2DBuilder : : ETextureType : : Metallic
| | Type = = FTexture2DBuilder : : ETextureType : : Specular )
{
UE : : AssetUtils : : ConvertToSingleChannel ( Texture ) ;
}
2021-05-28 02:46:59 -04:00
// Make sure the texture is a VT if required by the material sampler
if ( NewMaterial ! = nullptr )
{
UTexture * DefaultTexture = nullptr ;
NewMaterial - > GetTextureParameterValue ( MaterialParamName , DefaultTexture ) ;
if ( ensure ( DefaultTexture ) )
{
Texture - > VirtualTextureStreaming = DefaultTexture - > VirtualTextureStreaming ;
}
}
2021-04-29 18:12:32 -04:00
FTexture2DAssetOptions TexOptions ;
TexOptions . NewAssetPath = BaseTexturePath + TextureTypeSuffix ;
FTexture2DAssetResults Results ;
ECreateTexture2DResult TexResult = UE : : AssetUtils : : SaveGeneratedTexture2DAsset ( Texture , TexOptions , Results ) ;
if ( ensure ( TexResult = = ECreateTexture2DResult : : Ok ) )
{
ResultsOut . NewTextures . Add ( Texture ) ;
if ( NewMaterial ! = nullptr )
{
NewMaterial - > SetTextureParameterValueEditorOnly ( MaterialParamName , Texture ) ;
}
}
} ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
2022-02-04 10:25:59 -05:00
TRACE_BOOKMARK ( TEXT ( " ApproximateActors-Write Textures " ) ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
2021-04-29 18:12:32 -04:00
// process the generated textures
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Options . bBakeBaseColor & & GeneratedTextures . BaseColorMap )
{
WriteTextureLambda ( GeneratedTextures . BaseColorMap , TEXT ( " _BaseColor " ) , FTexture2DBuilder : : ETextureType : : Color , Options . BaseColorTexParamName ) ;
}
2021-05-26 03:37:14 -04:00
if ( Options . bBakeEmissive & & GeneratedTextures . EmissiveMap )
{
2021-05-27 21:27:15 -04:00
WriteTextureLambda ( GeneratedTextures . EmissiveMap , TEXT ( " _Emissive " ) , FTexture2DBuilder : : ETextureType : : EmissiveHDR , Options . EmissiveTexParamName ) ;
2021-05-26 03:37:14 -04:00
}
if ( Options . bBakeNormalMap & & GeneratedTextures . NormalMap )
{
WriteTextureLambda ( GeneratedTextures . NormalMap , TEXT ( " _Normal " ) , FTexture2DBuilder : : ETextureType : : NormalMap , Options . NormalTexParamName ) ;
}
if ( ( Options . bBakeRoughness | | Options . bBakeMetallic | | Options . bBakeSpecular ) & & Options . bUsePackedMRS & & GeneratedTextures . PackedMRSMap )
{
WriteTextureLambda ( GeneratedTextures . PackedMRSMap , TEXT ( " _PackedMRS " ) , FTexture2DBuilder : : ETextureType : : ColorLinear , Options . PackedMRSTexParamName ) ;
}
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( Options . bBakeRoughness & & GeneratedTextures . RoughnessMap )
{
WriteTextureLambda ( GeneratedTextures . RoughnessMap , TEXT ( " _Roughness " ) , FTexture2DBuilder : : ETextureType : : Roughness , Options . RoughnessTexParamName ) ;
}
if ( Options . bBakeMetallic & & GeneratedTextures . MetallicMap )
{
WriteTextureLambda ( GeneratedTextures . MetallicMap , TEXT ( " _Metallic " ) , FTexture2DBuilder : : ETextureType : : Metallic , Options . MetallicTexParamName ) ;
}
if ( Options . bBakeSpecular & & GeneratedTextures . SpecularMap )
{
WriteTextureLambda ( GeneratedTextures . SpecularMap , TEXT ( " _Specular " ) , FTexture2DBuilder : : ETextureType : : Specular , Options . SpecularTexParamName ) ;
}
2021-05-26 03:37:14 -04:00
2021-04-29 18:12:32 -04:00
// force material update now that we have updated texture parameters
// (does this do that? Let calling code do it?)
NewMaterial - > PostEditChange ( ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
EmitGeneratedMeshAsset ( Actors , Options , ResultsOut , & FinalMesh , NewMaterial , WriteDebugMesh ) ;
2021-04-29 18:12:32 -04:00
ResultsOut . ResultCode = EResultCode : : Success ;
}
UStaticMesh * FApproximateActorsImpl : : EmitGeneratedMeshAsset (
const TArray < AActor * > & Actors ,
const FOptions & Options ,
FResults & ResultsOut ,
FDynamicMesh3 * FinalMesh ,
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
UMaterialInterface * Material ,
FDynamicMesh3 * DebugMesh )
2021-04-29 18:12:32 -04:00
{
FStaticMeshAssetOptions MeshAssetOptions ;
2021-05-20 19:35:43 -04:00
MeshAssetOptions . CollisionType = ECollisionTraceFlag : : CTF_UseSimpleAsComplex ;
MeshAssetOptions . bEnableRecomputeTangents = false ;
2021-04-29 18:12:32 -04:00
MeshAssetOptions . NewAssetPath = Options . BasePackagePath ;
MeshAssetOptions . SourceMeshes . DynamicMeshes . Add ( FinalMesh ) ;
2021-05-28 02:46:59 -04:00
MeshAssetOptions . bGenerateNaniteEnabledMesh = Options . bGenerateNaniteEnabledMesh ;
MeshAssetOptions . NaniteProxyTrianglePercent = Options . NaniteProxyTrianglePercent ;
2021-06-02 16:08:31 -04:00
MeshAssetOptions . bSupportRayTracing = Options . bSupportRayTracing ;
MeshAssetOptions . bAllowDistanceField = Options . bAllowDistanceField ;
MeshAssetOptions . bGenerateLightmapUVs = Options . bGenerateLightmapUVs ;
MeshAssetOptions . bCreatePhysicsBody = Options . bCreatePhysicsBody ;
2021-04-29 18:12:32 -04:00
if ( Material )
{
MeshAssetOptions . AssetMaterials . Add ( Material ) ;
}
2021-07-22 18:56:41 -04:00
else
{
MeshAssetOptions . AssetMaterials . Add ( UMaterial : : GetDefaultMaterial ( MD_Surface ) ) ;
}
2021-04-29 18:12:32 -04:00
FStaticMeshResults MeshAssetOutputs ;
ECreateStaticMeshResult ResultCode = UE : : AssetUtils : : CreateStaticMeshAsset ( MeshAssetOptions , MeshAssetOutputs ) ;
ensure ( ResultCode = = ECreateStaticMeshResult : : Ok ) ;
ResultsOut . NewMeshAssets . Add ( MeshAssetOutputs . StaticMesh ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
if ( DebugMesh ! = nullptr )
{
2021-05-28 02:46:59 -04:00
FStaticMeshAssetOptions DebugMeshAssetOptions = MeshAssetOptions ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
DebugMeshAssetOptions . NewAssetPath = Options . BasePackagePath + TEXT ( " _DEBUG " ) ;
2021-05-28 02:46:59 -04:00
DebugMeshAssetOptions . SourceMeshes . DynamicMeshes . Reset ( 1 ) ;
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
DebugMeshAssetOptions . SourceMeshes . DynamicMeshes . Add ( DebugMesh ) ;
2021-05-28 02:46:59 -04:00
GeometryProcessing:
- Add FImageAdapter, wraps TImageBuilder of different types and provides a consistent interface, so that other code doesn't need specializations for each image type
- FMeshSceneAdapter now supports the ability to detect and thicken "thin" meshes, by flattening the instances into unique mesh copies (generally necessary due to scaling). Can also now return statistics about the mesh scene, return a full flattened mesh (for debugging), and automatically generate a "closing mesh" that can help to cap off the base of mesh assemblies when trying to generate a solid/etc.
ModelingComponents:
- FWorldRenderCapture now writes via FImageAdapter instead of an Image4f
- FSceneCapturePhotoSet now stores less data for photo sets. BaseColor/Emissive/WorldNormal are 3f, Roughness/Specular/Metallic are 1f
- IApproximateActors and implementation now support optional base-capping, occluded mesh removal, geometric-tolerance simplification, thin mesh auth-thickening. Now creates MICs based on an input Material, instead of new Material. Added ability to emit a flattened debug mesh, and print debug info.
MergeActors:
- Expose above improvements to IApproximateActors
#rb none
#rnx
#jira none
#preflight 609ef005f6c6e3000144c5e2
[CL 16338550 by Ryan Schmidt in ue5-main branch]
2021-05-14 21:11:51 -04:00
FStaticMeshResults DebugMeshAssetOutputs ;
UE : : AssetUtils : : CreateStaticMeshAsset ( DebugMeshAssetOptions , DebugMeshAssetOutputs ) ;
}
2021-04-29 18:12:32 -04:00
return MeshAssetOutputs . StaticMesh ;
}
# undef LOCTEXT_NAMESPACE