Files
UnrealEngineUWP/Engine/Source/Developer/MeshUtilities/Public/MeshUtilities.h
Daniel Wright 1464dcf2c3 Distance field AO using a surface cache
* Provides mid-range stable AO for dynamic rigid meshes
* Movable sky lights are now supported, and distance field AO is used for shadowing Movable sky lighting from dynamic scenes
* Static meshes are preprocessed into signed distance field volumes at mesh build time when the r.AllowMeshDistanceFieldRepresentations project setting is enabled
* Non-uniform scaling does not work with this method (mirroring is fine), animating through world position offset also causes artifacts as the two representations diverge
* Occlusion is computed along cones to reduce over-shadowing, object distance fields are operated on directly (no hierarchy) to obtain enough resolution to prevent leaking, visibility traces are done with cone stepping to allow better parallelization, and shading is done adaptively in space and time using the surface cache.

[CL 2093556 by Daniel Wright in Main branch]
2014-06-03 15:53:13 -04:00

264 lines
8.0 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "ModuleInterface.h"
/** The maximum index for a material in a mesh */
#define MAX_MESH_MATERIAL_INDEX 64
/**
* Mesh reduction interface.
*/
class IMeshReduction
{
public:
/**
* Reduces the raw mesh using the provided reduction settings.
* @param OutReducedMesh - Upon return contains the reduced mesh.
* @param OutMaxDeviation - Upon return contains the maximum distance by which the reduced mesh deviates from the original.
* @param InMesh - The mesh to reduce.
* @param ReductionSettings - Setting with which to reduce the mesh.
*/
virtual void Reduce(
struct FRawMesh& OutReducedMesh,
float& OutMaxDeviation,
const struct FRawMesh& InMesh,
const struct FMeshReductionSettings& ReductionSettings
) = 0;
/**
* Reduces the provided skeletal mesh.
* @returns true if reduction was successful.
*/
virtual bool ReduceSkeletalMesh(
class USkeletalMesh* SkeletalMesh,
int32 LODIndex,
const struct FSkeletalMeshOptimizationSettings& Settings,
bool bCalcLODDistance
) = 0;
/**
* Returns a unique string identifying both the reduction plugin itself and the version of the plugin.
*/
virtual const FString& GetVersionString() const = 0;
/**
* Returns true if mesh reduction is supported
*/
virtual bool IsSupported() const = 0;
};
//
namespace MaterialExportUtils
{
struct FFlattenMaterial;
};
/**
* Mesh merging interface.
*/
class IMeshMerging
{
public:
virtual void BuildProxy(
const TArray<FRawMesh>& InputMeshes,
const TArray<MaterialExportUtils::FFlattenMaterial>& InputMaterials,
const struct FMeshProxySettings& InProxySettings,
FRawMesh& OutProxyMesh,
MaterialExportUtils::FFlattenMaterial& OutMaterial
) = 0;
};
/**
* Mesh merging settings
*/
struct FMeshMergingSettings
{
/** */
bool bGnerateAtlasedLightmapUV;
/** */
bool bImportVertexColors;
/** */
bool bImportAllUVChannels;
/** */
int32 TargetLightmapUVChannel;
/** */
bool bPivotPointAtZero;
/** Default settings. */
FMeshMergingSettings()
: bGnerateAtlasedLightmapUV(true)
, bImportVertexColors(false)
, bImportAllUVChannels(false)
, TargetLightmapUVChannel(1)
, bPivotPointAtZero(false)
{
}
};
/**
* Mesh reduction module interface.
*/
class IMeshReductionModule : public IModuleInterface
{
public:
/**
* Retrieve the mesh reduction interface.
*/
virtual class IMeshReduction* GetMeshReductionInterface() = 0;
/**
* Retrieve the mesh merging interface.
*/
virtual class IMeshMerging* GetMeshMergingInterface() = 0;
};
class IMeshUtilities : public IModuleInterface
{
public:
/** Returns a string uniquely identifying this version of mesh utilities. */
virtual const FString& GetVersionString() const = 0;
/**
* Builds a renderable static mesh using the provided source models and the LOD groups settings.
* @returns true if the renderable mesh was built successfully.
*/
virtual bool BuildStaticMesh(
class FStaticMeshRenderData& OutRenderData,
TArray<struct FStaticMeshSourceModel>& SourceModels,
const TArray<UMaterialInterface*>& Materials,
const class FStaticMeshLODGroup& LODGroup
) = 0;
/**
* Create all render specific data for a skeletal mesh LOD model
* @returns true if the mesh was built successfully.
*/
virtual bool BuildSkeletalMesh(
FStaticLODModel& LODModel,
const FReferenceSkeleton& RefSkeleton,
const TArray<FVertInfluence>& Influences,
const TArray<FMeshWedge>& Wedges,
const TArray<FMeshFace>& Faces,
const TArray<FVector>& Points,
const TArray<int32>& PointToOriginalMap,
bool bKeepOverlappingVertices = false,
bool bComputeNormals = true,
bool bComputeTangents = true
) = 0;
/**
* Generates a unique UV layout for a static mesh
* @param RawMesh - The input/output mesh
* @param TexCoordIndex - Index of the uv channel to overwrite or create
* @param bKeepExistingCoordinates - True to preserve the existing charts when packing
* @param MinChartSpacingPercent - Minimum distance between two packed charts (0.0-100.0)
* @param BorderSpacingPercent - Spacing between UV border and charts (0.0-100.0)
* @param bUseMaxStretch - True if "MaxDesiredStretch" should be used; otherwise "MaxCharts" is used
* @param InFalseEdgeIndices - Optional list of raw face edge indices to be ignored when creating UV seams
* @param MaxCharts - In: Max number of charts to allow; Out:Number of charts generated by the uv unwrap algorithm.
* @param MaxDesiredStretch - The amount of stretching allowed. 0 means no stretching is allowed, 1 means any amount of stretching can be used.
* @param OutError - if unsuccessful, contains the error that occurred.
* @return true if successful
*/
virtual bool GenerateUVs(
struct FRawMesh& RawMesh,
uint32 TexCoordIndex,
float MinChartSpacingPercent,
float BorderSpacingPercent,
bool bUseMaxStretch,
const TArray< int32 >* InFalseEdgeIndices,
uint32& MaxCharts,
float& MaxDesiredStretch,
FText& OutError
) = 0;
/**
* For quick generating lightmap uvs.
* It copies charts from 0 uv channel and layouts them without making new charts (keeps edge splits). Additionally separates folded triangles automatically
* Use when DXD generates ugly cuts and degenerates charts
* @param RawMesh - The input/output mesh
* @param TexCoordIndex - Index of the uv channel to overwrite or create
* @param OutError - if unsuccessful, contains the error that occurred.
* @return true if successful
*/
virtual bool LayoutUVs(
struct FRawMesh& RawMesh,
uint32 TextureResolution,
uint32 TexCoordIndex,
FText& OutError
) = 0;
/** Returns the mesh reduction plugin if available. */
virtual IMeshReduction* GetMeshReductionInterface() = 0;
/** Returns the mesh merging plugin if available. */
virtual IMeshMerging* GetMeshMergingInterface() = 0;
/** Cache optimize the index buffer. */
virtual void CacheOptimizeIndexBuffer(TArray<uint16>& Indices) = 0;
/** Cache optimize the index buffer. */
virtual void CacheOptimizeIndexBuffer(TArray<uint32>& Indices) = 0;
/** Build adjacency information for the skeletal mesh used for tessellation. */
virtual void BuildSkeletalAdjacencyIndexBuffer(
const TArray<struct FSoftSkinVertex>& VertexBuffer,
const uint32 TexCoordCount,
const TArray<uint32>& Indices,
TArray<uint32>& OutPnAenIndices
) = 0;
/**
* Calculate the verts associated weighted to each bone of the skeleton.
* The vertices returned are in the local space of the bone.
*
* @param SkeletalMesh The target skeletal mesh.
* @param Infos The output array of vertices associated with each bone.
* @param bOnlyDominant Controls whether a vertex is added to the info for a bone if it is most controlled by that bone, or if that bone has ANY influence on that vert.
*/
virtual void CalcBoneVertInfos( USkeletalMesh* SkeletalMesh, TArray<FBoneVertInfo>& Infos, bool bOnlyDominant) = 0;
/**
* Harvest static mesh components from input actors
* and merge into signle mesh grouping them by unique materials
*
* @param SourceActors List of actors to merge
* @param InSettings Settings to use
* @param PackageName Destination package name for a generated assets
* @param OutAssetsToSync Merged mesh assets
* @param OutMergedActorLocation World position of merged mesh
*/
virtual void MergeActors(
const TArray<AActor*>& SourceActors,
const FMeshMergingSettings& InSettings,
const FString& PackageName,
TArray<UObject*>& OutAssetsToSync,
FVector& OutMergedActorLocation) const = 0;
/**
* Merges list of actors into single proxy mesh
*
* @param Actors List of Actors to merge
* @param InProxySettings Merge settings
* @param ProxyPackageName Destination package name for a generated assets
* @param OutAssetsToSync Result assets - mesh, material
* @param OutProxyLocation Proxy mesh location in the world (bounding box origin of merged actors)
*/
virtual void CreateProxyMesh(
const TArray<AActor*>& Actors,
const struct FMeshProxySettings& InProxySettings,
const FString& ProxyPackageName,
TArray<UObject*>& OutAssetsToSync,
FVector& OutProxyLocation
) = 0;
};