Skip to content

Commit

Permalink
Get the plugin working in UE 5.5 Preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Nov 6, 2024
1 parent a279754 commit 751575f
Show file tree
Hide file tree
Showing 33 changed files with 332 additions and 153 deletions.
32 changes: 21 additions & 11 deletions Shaders/Private/CesiumPointAttenuationVertexFactory.ush
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct FVertexFactoryInput
#endif
};

/**
/**
* Per-vertex inputs. Used by passes with a trimmed down position-only shader.
*/
struct FPositionOnlyVertexFactoryInput
Expand All @@ -54,7 +54,7 @@ struct FPositionOnlyVertexFactoryInput
#endif
};

/**
/**
* Per-vertex inputs. Used by passes with a trimmed down position-and-normal-only shader.
*/
struct FPositionAndNormalOnlyVertexFactoryInput
Expand Down Expand Up @@ -83,7 +83,7 @@ struct FVertexFactoryIntermediates
half TangentToWorldSign;

half4 Color;

/** Cached primitive and instance data */
FSceneDataIntermediates SceneData;
};
Expand Down Expand Up @@ -119,15 +119,15 @@ half3x3 CalculateTangentToLocal(uint PointIndex, out float TangentSign)
{
half3 TangentInputX = PackedTangentsBuffer[2 * PointIndex + 0].xyz;
half4 TangentInputZ = PackedTangentsBuffer[2 * PointIndex + 1].xyzw;

half3 TangentX = TangentBias(TangentInputX);
half4 TangentZ = TangentBias(TangentInputZ);

TangentSign = TangentZ.w;

// Derive the binormal by getting the cross product of the normal and tangent
half3 TangentY = cross(TangentZ.xyz, TangentX) * TangentZ.w;

// Recalculate TangentX off of the other two vectors
// This corrects quantization errors since TangentX was passed in as a quantized vertex input
half3x3 Result;
Expand Down Expand Up @@ -158,7 +158,7 @@ FVertexFactoryIntermediates GetVertexFactoryIntermediates(FVertexFactoryInput In
{
FVertexFactoryIntermediates Intermediates = (FVertexFactoryIntermediates)0;
Intermediates.SceneData = VF_GPUSCENE_GET_INTERMEDIATES(Input);

uint PointIndex = Input.VertexId / 4;
uint CornerIndex = Input.VertexId - (PointIndex * 4);

Expand Down Expand Up @@ -213,19 +213,19 @@ FVertexFactoryInterpolantsVSToPS VertexFactoryGetInterpolantsVSToPS(
Interpolants.TangentToWorld0 = float4(Intermediates.TangentToWorld[0], 0);
Interpolants.TangentToWorld2 = float4(Intermediates.TangentToWorld[2], Intermediates.TangentToWorldSign);
Interpolants.Color = Intermediates.Color;

#if NUM_TEX_COORD_INTERPOLATORS
float2 CustomizedUVs[NUM_TEX_COORD_INTERPOLATORS];
GetMaterialCustomizedUVs(VertexParameters, CustomizedUVs);
GetCustomInterpolators(VertexParameters, CustomizedUVs);

UNROLL
for (int CoordinateIndex = 0; CoordinateIndex < NUM_TEX_COORD_INTERPOLATORS; CoordinateIndex++)
{
SetUV(Interpolants, CoordinateIndex, CustomizedUVs[CoordinateIndex]);
}
#endif

#if INSTANCED_STEREO
Interpolants.EyeIndex = 0;
#endif
Expand Down Expand Up @@ -336,7 +336,7 @@ FMaterialVertexParameters GetMaterialVertexParameters(
half3x3 TangentToLocal)
{
FMaterialVertexParameters Result = (FMaterialVertexParameters)0;

Result.SceneData = Intermediates.SceneData;
Result.WorldPosition = WorldPosition;
Result.TangentToWorld = Intermediates.TangentToWorld;
Expand All @@ -357,6 +357,16 @@ FMaterialVertexParameters GetMaterialVertexParameters(
return Result;
}

FMaterialVertexParameters GetMaterialVertexParameters(
FVertexFactoryInput Input,
FVertexFactoryIntermediates Intermediates,
float3 WorldPosition,
half3x3 TangentToLocal,
bool noIdeaWhatThisIs)
{
return GetMaterialVertexParameters(Input, Intermediates, WorldPosition, TangentToLocal);
}

FMaterialPixelParameters GetMaterialPixelParameters(FVertexFactoryInterpolantsVSToPS Interpolants, float4 SvPosition)
{
FMaterialPixelParameters Result = MakeInitializedMaterialPixelParameters();
Expand Down Expand Up @@ -439,7 +449,7 @@ FVertexFactoryRayTracingInterpolants VertexFactoryInterpolate(
float bInterp)
{
FVertexFactoryRayTracingInterpolants O;

INTERPOLATE_MEMBER(InterpolantsVSToPS.TangentToWorld0.xyz);
INTERPOLATE_MEMBER(InterpolantsVSToPS.TangentToWorld2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,13 +524,13 @@ EncodedPropertyTable encodePropertyTableAnyThreadPart(
CesiumEncodedMetadataParseColorFromString::encode(
*pDescription,
property,
gsl::span(pImage->pixelData),
std::span(pImage->pixelData),
encodedFormat.bytesPerChannel * encodedFormat.channels);
} else /* info.Conversion == ECesiumEncodedMetadataConversion::Coerce */ {
CesiumEncodedMetadataCoerce::encode(
*pDescription,
property,
gsl::span(pImage->pixelData),
std::span(pImage->pixelData),
encodedFormat.bytesPerChannel * encodedFormat.channels);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ template <typename T>
void coerceAndEncodeArrays(
const FCesiumPropertyTablePropertyDescription& propertyDescription,
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
int64 propertySize =
UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize(property);
Expand Down Expand Up @@ -180,7 +180,7 @@ void coerceAndEncodeArrays(
template <typename T>
void coerceAndEncodeScalars(
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData) {
const std::span<std::byte>& textureData) {
int64 propertySize =
UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize(property);
if (textureData.size() < propertySize * sizeof(T)) {
Expand Down Expand Up @@ -208,7 +208,7 @@ void coerceAndEncodeScalars(
template <typename T>
void coerceAndEncodeVec2s(
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
int64 propertySize =
UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize(property);
Expand Down Expand Up @@ -254,7 +254,7 @@ void coerceAndEncodeVec2s(
template <typename T>
void coerceAndEncodeVec3s(
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
int64 propertySize =
UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize(property);
Expand Down Expand Up @@ -298,7 +298,7 @@ void coerceAndEncodeVec3s(
template <typename T>
void coerceAndEncodeVec4s(
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
int64 propertySize =
UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize(property);
Expand Down Expand Up @@ -383,7 +383,7 @@ bool CesiumEncodedMetadataCoerce::canEncode(
void CesiumEncodedMetadataCoerce::encode(
const FCesiumPropertyTablePropertyDescription& propertyDescription,
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
if (propertyDescription.PropertyDetails.bIsArray) {
if (propertyDescription.EncodingDetails.ComponentType ==
Expand Down Expand Up @@ -497,7 +497,7 @@ glm::u8vec3 getRgbColorFromString(const FString& rgbString) {
template <typename T>
void parseAndEncodeColors(
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
int64 propertySize =
UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize(property);
Expand Down Expand Up @@ -555,7 +555,7 @@ bool CesiumEncodedMetadataParseColorFromString::canEncode(
void CesiumEncodedMetadataParseColorFromString::encode(
const FCesiumPropertyTablePropertyDescription& propertyDescription,
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize) {
if (propertyDescription.EncodingDetails.ComponentType ==
ECesiumEncodedMetadataComponentType::Uint8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include "HAL/Platform.h"
#include <gsl/span>
#include <span>

enum class ECesiumMetadataType : uint8;
enum class ECesiumEncodedMetadataType : uint8;
Expand Down Expand Up @@ -80,7 +80,7 @@ struct CesiumEncodedMetadataCoerce {
static void encode(
const FCesiumPropertyTablePropertyDescription& propertyDescription,
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& pTextureData,
const std::span<std::byte>& pTextureData,
size_t pixelSize);
};

Expand Down Expand Up @@ -113,6 +113,6 @@ struct CesiumEncodedMetadataParseColorFromString {
static void encode(
const FCesiumPropertyTablePropertyDescription& propertyDescription,
const FCesiumPropertyTableProperty& property,
const gsl::span<std::byte>& textureData,
const std::span<std::byte>& textureData,
size_t pixelSize);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
BEGIN_DEFINE_SPEC(
FCesiumCameraManagerSpec,
"Cesium.Unit.CameraManager",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
END_DEFINE_SPEC(FCesiumCameraManagerSpec)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
BEGIN_DEFINE_SPEC(
FCesiumFeatureIdAttributeSpec,
"Cesium.Unit.FeatureIdAttribute",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
CesiumGltf::Model model;
CesiumGltf::MeshPrimitive* pPrimitive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
BEGIN_DEFINE_SPEC(
FCesiumFeatureIdSetSpec,
"Cesium.Unit.FeatureIdSet",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
CesiumGltf::Model model;
CesiumGltf::MeshPrimitive* pPrimitive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
BEGIN_DEFINE_SPEC(
FCesiumFeatureIdTextureSpec,
"Cesium.Unit.FeatureIdTexture",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
CesiumGltf::Model model;
CesiumGltf::MeshPrimitive* pPrimitive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ using namespace CesiumUtility;
BEGIN_DEFINE_SPEC(
FCesiumGeoreferenceSpec,
"Cesium.Unit.Georeference",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)

TObjectPtr<ACesiumGeoreference> pGeoreferenceNullIsland;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
BEGIN_DEFINE_SPEC(
FCesiumGlobeAnchorSpec,
"Cesium.Unit.GlobeAnchor",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)

TObjectPtr<AActor> pActor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
BEGIN_DEFINE_SPEC(
FCesiumMetadataPickingSpec,
"Cesium.Unit.MetadataPicking",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
CesiumGltf::Model model;
CesiumGltf::MeshPrimitive* pPrimitive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
BEGIN_DEFINE_SPEC(
FCesiumMetadataValueSpec,
"Cesium.Unit.MetadataValue",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
END_DEFINE_SPEC(FCesiumMetadataValueSpec)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
BEGIN_DEFINE_SPEC(
FCesiumOriginShiftComponentSpec,
"Cesium.Unit.OriginShiftComponent",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)

TObjectPtr<UWorld> pWorld;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
BEGIN_DEFINE_SPEC(
FCesiumPrimitiveFeaturesSpec,
"Cesium.Unit.PrimitiveFeatures",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
CesiumGltf::Model model;
CesiumGltf::MeshPrimitive* pPrimitive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
BEGIN_DEFINE_SPEC(
FCesiumPropertyArraySpec,
"Cesium.Unit.PropertyArray",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
END_DEFINE_SPEC(FCesiumPropertyArraySpec)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
BEGIN_DEFINE_SPEC(
FCesiumPropertyTableSpec,
"Cesium.Unit.PropertyTable",
EAutomationTestFlags::ApplicationContextMask |
EAutomationTestFlags::EditorContext | EAutomationTestFlags::ClientContext |
EAutomationTestFlags::ServerContext |
EAutomationTestFlags::CommandletContext |
EAutomationTestFlags::ProductFilter)
CesiumGltf::Model model;
CesiumGltf::ExtensionModelExtStructuralMetadata* pExtension;
Expand Down
Loading

0 comments on commit 751575f

Please sign in to comment.