2021-04-27 21:11:58 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "Scene/SceneCapturePhotoSet.h"
|
2021-05-18 11:54:40 -04:00
|
|
|
#include "EngineUtils.h"
|
2021-04-27 21:11:58 -04:00
|
|
|
|
|
|
|
|
using namespace UE::Geometry;
|
|
|
|
|
|
|
|
|
|
void FSceneCapturePhotoSet::SetCaptureSceneActors(UWorld* World, const TArray<AActor*>& Actors)
|
|
|
|
|
{
|
|
|
|
|
this->TargetWorld = World;
|
|
|
|
|
this->VisibleActors = Actors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FSceneCapturePhotoSet::SetCaptureTypeEnabled(ERenderCaptureType CaptureType, bool bEnabled)
|
|
|
|
|
{
|
|
|
|
|
switch (CaptureType)
|
|
|
|
|
{
|
|
|
|
|
case ERenderCaptureType::BaseColor:
|
|
|
|
|
bEnableBaseColor = bEnabled;
|
|
|
|
|
break;
|
|
|
|
|
case ERenderCaptureType::WorldNormal:
|
|
|
|
|
bEnableWorldNormal = bEnabled;
|
|
|
|
|
break;
|
|
|
|
|
case ERenderCaptureType::Roughness:
|
|
|
|
|
bEnableRoughness = bEnabled;
|
|
|
|
|
break;
|
|
|
|
|
case ERenderCaptureType::Metallic:
|
|
|
|
|
bEnableMetallic = bEnabled;
|
|
|
|
|
break;
|
|
|
|
|
case ERenderCaptureType::Specular:
|
|
|
|
|
bEnableSpecular = bEnabled;
|
|
|
|
|
break;
|
|
|
|
|
case ERenderCaptureType::Emissive:
|
|
|
|
|
bEnableEmissive = bEnabled;
|
|
|
|
|
break;
|
2021-05-26 03:02:11 -04:00
|
|
|
case ERenderCaptureType::CombinedMRS:
|
|
|
|
|
bEnablePackedMRS = bEnabled;
|
|
|
|
|
break;
|
2021-04-27 21:11:58 -04:00
|
|
|
default:
|
|
|
|
|
check(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FSceneCapturePhotoSet::AddStandardExteriorCapturesFromBoundingBox(
|
|
|
|
|
FImageDimensions PhotoDimensions,
|
|
|
|
|
double HorizontalFOVDegrees,
|
|
|
|
|
double NearPlaneDist,
|
|
|
|
|
bool bFaces,
|
|
|
|
|
bool bUpperCorners,
|
|
|
|
|
bool bLowerCorners)
|
|
|
|
|
{
|
|
|
|
|
TArray<FVector3d> Directions;
|
|
|
|
|
|
|
|
|
|
if (bFaces)
|
|
|
|
|
{
|
|
|
|
|
Directions.Add(FVector3d::UnitX());
|
|
|
|
|
Directions.Add(-FVector3d::UnitX());
|
|
|
|
|
Directions.Add(FVector3d::UnitY());
|
|
|
|
|
Directions.Add(-FVector3d::UnitY());
|
|
|
|
|
Directions.Add(FVector3d::UnitZ());
|
|
|
|
|
Directions.Add(-FVector3d::UnitZ());
|
|
|
|
|
}
|
|
|
|
|
if (bUpperCorners)
|
|
|
|
|
{
|
|
|
|
|
Directions.Add(Normalized(FVector3d(1, 1, -1)));
|
|
|
|
|
Directions.Add(Normalized(FVector3d(-1, 1, -1)));
|
|
|
|
|
Directions.Add(Normalized(FVector3d(1, -1, -1)));
|
|
|
|
|
Directions.Add(Normalized(FVector3d(-1, -1, -1)));
|
|
|
|
|
}
|
|
|
|
|
if (bLowerCorners)
|
|
|
|
|
{
|
|
|
|
|
Directions.Add(Normalized(FVector3d(1, 1, 1)));
|
|
|
|
|
Directions.Add(Normalized(FVector3d(-1, 1, 1)));
|
|
|
|
|
Directions.Add(Normalized(FVector3d(1, -1, 1)));
|
|
|
|
|
Directions.Add(Normalized(FVector3d(-1, -1, 1)));
|
|
|
|
|
}
|
|
|
|
|
AddExteriorCaptures(PhotoDimensions, HorizontalFOVDegrees, NearPlaneDist, Directions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FSceneCapturePhotoSet::AddExteriorCaptures(
|
|
|
|
|
FImageDimensions PhotoDimensions,
|
|
|
|
|
double HorizontalFOVDegrees,
|
|
|
|
|
double NearPlaneDist,
|
|
|
|
|
const TArray<FVector3d>& Directions)
|
|
|
|
|
{
|
|
|
|
|
check(this->TargetWorld != nullptr);
|
|
|
|
|
|
2021-05-18 11:54:40 -04:00
|
|
|
// Workaround for Nanite scene proxies visibility
|
|
|
|
|
// Unregister all components to remove unwanted proxies from the scene. This is currently the only way to "hide" nanite meshes.
|
|
|
|
|
TSet<AActor*> VisibleActorsSet(VisibleActors);
|
|
|
|
|
TArray<AActor*> ActorsToRegister;
|
|
|
|
|
for (TActorIterator<AActor> Actor(TargetWorld); Actor; ++Actor)
|
|
|
|
|
{
|
|
|
|
|
if (!VisibleActorsSet.Contains(*Actor))
|
|
|
|
|
{
|
|
|
|
|
Actor->UnregisterAllComponents();
|
|
|
|
|
ActorsToRegister.Add(*Actor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-27 21:11:58 -04:00
|
|
|
FWorldRenderCapture RenderCapture;
|
|
|
|
|
RenderCapture.SetWorld(TargetWorld);
|
|
|
|
|
RenderCapture.SetVisibleActors(VisibleActors);
|
|
|
|
|
RenderCapture.SetDimensions(PhotoDimensions);
|
2021-05-28 02:46:59 -04:00
|
|
|
if (bWriteDebugImages)
|
|
|
|
|
{
|
|
|
|
|
RenderCapture.SetEnableWriteDebugImage(true, 0, DebugImagesFolderName);
|
|
|
|
|
}
|
2021-04-27 21:11:58 -04:00
|
|
|
|
|
|
|
|
// this tells us origin and radius - could be view-dependent...
|
|
|
|
|
FSphere RenderSphere = RenderCapture.ComputeContainingRenderSphere(HorizontalFOVDegrees);
|
|
|
|
|
|
|
|
|
|
int32 NumDirections = Directions.Num();
|
|
|
|
|
for (int32 di = 0; di < NumDirections; ++di)
|
|
|
|
|
{
|
|
|
|
|
FVector3d ViewDirection = Directions[di];
|
|
|
|
|
ViewDirection.Normalize();
|
|
|
|
|
|
|
|
|
|
FFrame3d ViewFrame;
|
|
|
|
|
ViewFrame.AlignAxis(0, ViewDirection);
|
|
|
|
|
ViewFrame.ConstrainedAlignAxis(2, FVector3d::UnitZ(), ViewFrame.X());
|
|
|
|
|
ViewFrame.Origin = (FVector3d)RenderSphere.Center;
|
|
|
|
|
ViewFrame.Origin -= (double)RenderSphere.W * ViewFrame.X();
|
|
|
|
|
|
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
|
|
|
FSpatialPhoto3f BasePhoto3f;
|
|
|
|
|
BasePhoto3f.Frame = ViewFrame;
|
|
|
|
|
BasePhoto3f.NearPlaneDist = NearPlaneDist;
|
|
|
|
|
BasePhoto3f.HorzFOVDegrees = HorizontalFOVDegrees;
|
|
|
|
|
BasePhoto3f.Dimensions = PhotoDimensions;
|
2021-04-27 21:11:58 -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
|
|
|
auto CaptureImageTypeFunc_3f = [&BasePhoto3f, &RenderCapture](ERenderCaptureType CaptureType, FSpatialPhotoSet3f& PhotoSet)
|
2021-04-27 21:11:58 -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
|
|
|
FSpatialPhoto3f NewPhoto = BasePhoto3f;
|
|
|
|
|
FImageAdapter Image(&NewPhoto.Image);
|
|
|
|
|
RenderCapture.CaptureFromPosition(CaptureType, NewPhoto.Frame, NewPhoto.HorzFOVDegrees, NewPhoto.NearPlaneDist, Image);
|
|
|
|
|
PhotoSet.Add(MoveTemp(NewPhoto));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FSpatialPhoto1f BasePhoto1f;
|
|
|
|
|
BasePhoto1f.Frame = ViewFrame;
|
|
|
|
|
BasePhoto1f.NearPlaneDist = NearPlaneDist;
|
|
|
|
|
BasePhoto1f.HorzFOVDegrees = HorizontalFOVDegrees;
|
|
|
|
|
BasePhoto1f.Dimensions = PhotoDimensions;
|
|
|
|
|
|
|
|
|
|
auto CaptureImageTypeFunc_1f = [&BasePhoto1f, &RenderCapture](ERenderCaptureType CaptureType, FSpatialPhotoSet1f& PhotoSet)
|
|
|
|
|
{
|
|
|
|
|
FSpatialPhoto1f NewPhoto = BasePhoto1f;
|
|
|
|
|
FImageAdapter Image(&NewPhoto.Image);
|
|
|
|
|
RenderCapture.CaptureFromPosition(CaptureType, NewPhoto.Frame, NewPhoto.HorzFOVDegrees, NewPhoto.NearPlaneDist, Image);
|
2021-04-27 21:11:58 -04:00
|
|
|
PhotoSet.Add(MoveTemp(NewPhoto));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (bEnableBaseColor)
|
|
|
|
|
{
|
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
|
|
|
CaptureImageTypeFunc_3f(ERenderCaptureType::BaseColor, BaseColorPhotoSet);
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
|
|
|
|
if (bEnableRoughness)
|
|
|
|
|
{
|
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
|
|
|
CaptureImageTypeFunc_1f(ERenderCaptureType::Roughness, RoughnessPhotoSet);
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
|
|
|
|
if (bEnableSpecular)
|
|
|
|
|
{
|
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
|
|
|
CaptureImageTypeFunc_1f(ERenderCaptureType::Specular, SpecularPhotoSet);
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
|
|
|
|
if (bEnableMetallic)
|
|
|
|
|
{
|
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
|
|
|
CaptureImageTypeFunc_1f(ERenderCaptureType::Metallic, MetallicPhotoSet);
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
2021-05-26 03:02:11 -04:00
|
|
|
if (bEnablePackedMRS)
|
|
|
|
|
{
|
|
|
|
|
CaptureImageTypeFunc_3f(ERenderCaptureType::CombinedMRS, PackedMRSPhotoSet);
|
|
|
|
|
}
|
2021-04-27 21:11:58 -04:00
|
|
|
if (bEnableWorldNormal)
|
|
|
|
|
{
|
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
|
|
|
CaptureImageTypeFunc_3f(ERenderCaptureType::WorldNormal, WorldNormalPhotoSet);
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
|
|
|
|
if (bEnableEmissive)
|
|
|
|
|
{
|
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
|
|
|
CaptureImageTypeFunc_3f(ERenderCaptureType::Emissive, EmissivePhotoSet);
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-18 11:54:40 -04:00
|
|
|
// Workaround for Nanite scene proxies visibility
|
|
|
|
|
// Reregister all components we previously unregistered
|
|
|
|
|
for (AActor* Actor : ActorsToRegister)
|
|
|
|
|
{
|
|
|
|
|
Actor->RegisterAllComponents();
|
|
|
|
|
}
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FSceneCapturePhotoSet::OptimizePhotoSets()
|
|
|
|
|
{
|
|
|
|
|
// todo:
|
|
|
|
|
// 1) crop photos to regions with actual pixels
|
|
|
|
|
// 2) pack into fewer photos (eg pack spec/rough/metallic)
|
|
|
|
|
// 3) RLE encoding or other compression
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FSceneCapturePhotoSet::FSceneSample::FSceneSample()
|
|
|
|
|
{
|
|
|
|
|
HaveValues = FRenderCaptureTypeFlags::None();
|
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
|
|
|
BaseColor = FVector3f(0, 0, 0);
|
|
|
|
|
Roughness = 0.0f;
|
|
|
|
|
Specular = 0.0f;
|
|
|
|
|
Metallic = 0.0f;
|
|
|
|
|
Emissive = FVector3f(0, 0, 0);
|
|
|
|
|
WorldNormal = FVector3f(0, 0, 1);
|
2021-04-27 21:11:58 -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
|
|
|
FVector3f FSceneCapturePhotoSet::FSceneSample::GetValue3f(ERenderCaptureType CaptureType) const
|
2021-04-27 21:11:58 -04:00
|
|
|
{
|
|
|
|
|
switch (CaptureType)
|
|
|
|
|
{
|
|
|
|
|
case ERenderCaptureType::BaseColor:
|
|
|
|
|
return BaseColor;
|
|
|
|
|
case ERenderCaptureType::WorldNormal:
|
|
|
|
|
return WorldNormal;
|
|
|
|
|
case ERenderCaptureType::Roughness:
|
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 Roughness * FVector3f::One();
|
2021-04-27 21:11:58 -04:00
|
|
|
case ERenderCaptureType::Metallic:
|
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 Metallic * FVector3f::One();
|
2021-04-27 21:11:58 -04:00
|
|
|
case ERenderCaptureType::Specular:
|
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 Specular * FVector3f::One();
|
2021-04-27 21:11:58 -04:00
|
|
|
case ERenderCaptureType::Emissive:
|
|
|
|
|
return Emissive;
|
|
|
|
|
default:
|
|
|
|
|
check(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
|
|
|
return FVector3f::Zero();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FVector4f FSceneCapturePhotoSet::FSceneSample::GetValue4f(ERenderCaptureType CaptureType) const
|
|
|
|
|
{
|
|
|
|
|
switch (CaptureType)
|
|
|
|
|
{
|
|
|
|
|
case ERenderCaptureType::BaseColor:
|
|
|
|
|
return FVector4f(BaseColor.X, BaseColor.Y, BaseColor.Z, 1.0f);
|
|
|
|
|
case ERenderCaptureType::WorldNormal:
|
|
|
|
|
return FVector4f(WorldNormal.X, WorldNormal.Y, WorldNormal.Z, 1.0f);
|
|
|
|
|
case ERenderCaptureType::Roughness:
|
|
|
|
|
return FVector4f(Roughness, Roughness, Roughness, 1.0f);
|
|
|
|
|
case ERenderCaptureType::Metallic:
|
|
|
|
|
return FVector4f(Metallic, Metallic, Metallic, 1.0f);
|
|
|
|
|
case ERenderCaptureType::Specular:
|
|
|
|
|
return FVector4f(Specular, Specular, Specular, 1.0f);
|
2021-05-26 03:02:11 -04:00
|
|
|
case ERenderCaptureType::CombinedMRS:
|
|
|
|
|
return FVector4f(Metallic, Roughness, Specular, 1.0f);
|
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
|
|
|
case ERenderCaptureType::Emissive:
|
|
|
|
|
return FVector4f(Emissive.X, Emissive.Y, Emissive.Z, 1.0f);
|
|
|
|
|
default:
|
|
|
|
|
check(false);
|
|
|
|
|
}
|
2021-04-27 21:11:58 -04:00
|
|
|
return FVector4f::Zero();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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-27 21:11:58 -04:00
|
|
|
bool FSceneCapturePhotoSet::ComputeSample(
|
|
|
|
|
const FRenderCaptureTypeFlags& SampleChannels,
|
|
|
|
|
const FVector3d& Position,
|
|
|
|
|
const FVector3d& Normal,
|
|
|
|
|
TFunctionRef<bool(const FVector3d&, const FVector3d&)> VisibilityFunction,
|
|
|
|
|
FSceneSample& DefaultsInResultsOut) const
|
|
|
|
|
{
|
|
|
|
|
// This could be much more efficient if (eg) we knew that all the photo sets have
|
|
|
|
|
// the same captures, then the query only has to be done once and can be used to sample each specific photo
|
|
|
|
|
|
|
|
|
|
if (SampleChannels.bBaseColor)
|
|
|
|
|
{
|
|
|
|
|
DefaultsInResultsOut.BaseColor =
|
|
|
|
|
BaseColorPhotoSet.ComputeSample(Position, Normal, VisibilityFunction, DefaultsInResultsOut.BaseColor);
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bBaseColor = true;
|
|
|
|
|
}
|
|
|
|
|
if (SampleChannels.bRoughness)
|
|
|
|
|
{
|
|
|
|
|
DefaultsInResultsOut.Roughness =
|
|
|
|
|
RoughnessPhotoSet.ComputeSample(Position, Normal, VisibilityFunction, DefaultsInResultsOut.Roughness);
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bRoughness = true;
|
|
|
|
|
}
|
|
|
|
|
if (SampleChannels.bSpecular)
|
|
|
|
|
{
|
|
|
|
|
DefaultsInResultsOut.Specular =
|
|
|
|
|
SpecularPhotoSet.ComputeSample(Position, Normal, VisibilityFunction, DefaultsInResultsOut.Specular);
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bSpecular = true;
|
|
|
|
|
}
|
|
|
|
|
if (SampleChannels.bMetallic)
|
|
|
|
|
{
|
|
|
|
|
DefaultsInResultsOut.Metallic =
|
|
|
|
|
MetallicPhotoSet.ComputeSample(Position, Normal, VisibilityFunction, DefaultsInResultsOut.Metallic);
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bMetallic = true;
|
|
|
|
|
}
|
2021-05-26 03:02:11 -04:00
|
|
|
if (SampleChannels.bCombinedMRS)
|
|
|
|
|
{
|
|
|
|
|
FVector3f MRSValue(DefaultsInResultsOut.Metallic, DefaultsInResultsOut.Roughness, DefaultsInResultsOut.Specular);
|
|
|
|
|
MRSValue = PackedMRSPhotoSet.ComputeSample(Position, Normal, VisibilityFunction, MRSValue);
|
|
|
|
|
DefaultsInResultsOut.Metallic = MRSValue.X;
|
|
|
|
|
DefaultsInResultsOut.Roughness = MRSValue.Y;
|
|
|
|
|
DefaultsInResultsOut.Specular = MRSValue.Z;
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bMetallic = true;
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bRoughness = true;
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bSpecular = true;
|
|
|
|
|
}
|
2021-04-27 21:11:58 -04:00
|
|
|
if (SampleChannels.bEmissive)
|
|
|
|
|
{
|
|
|
|
|
DefaultsInResultsOut.Emissive =
|
|
|
|
|
EmissivePhotoSet.ComputeSample(Position, Normal, VisibilityFunction, DefaultsInResultsOut.Emissive);
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bEmissive = true;
|
|
|
|
|
}
|
|
|
|
|
if (SampleChannels.bWorldNormal)
|
|
|
|
|
{
|
|
|
|
|
DefaultsInResultsOut.WorldNormal =
|
|
|
|
|
WorldNormalPhotoSet.ComputeSample(Position, Normal, VisibilityFunction, DefaultsInResultsOut.WorldNormal);
|
|
|
|
|
DefaultsInResultsOut.HaveValues.bWorldNormal = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2021-05-28 02:46:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSceneCapturePhotoSet::SetEnableWriteDebugImages(bool bEnable, FString FolderName)
|
|
|
|
|
{
|
|
|
|
|
bWriteDebugImages = bEnable;
|
|
|
|
|
if (FolderName.Len() > 0)
|
|
|
|
|
{
|
|
|
|
|
DebugImagesFolderName = FolderName;
|
|
|
|
|
}
|
2021-04-27 21:11:58 -04:00
|
|
|
}
|