You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#author ola.olsson #rb graham.wihlidal #fyi brian.karis, rune.stubbe [CL 15105946 by graham wihlidal in ue5-main branch]
153 lines
4.4 KiB
Plaintext
153 lines
4.4 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
LocalVertexFactoryCommon.usf: Local vertex factory common functionality
|
|
=============================================================================*/
|
|
|
|
struct FVertexFactoryInterpolantsVSToPS
|
|
{
|
|
TANGENTTOWORLD_INTERPOLATOR_BLOCK
|
|
|
|
#if INTERPOLATE_VERTEX_COLOR
|
|
half4 Color : COLOR0;
|
|
#endif
|
|
|
|
#if USE_INSTANCING || USE_INSTANCE_CULLING
|
|
// x = per-instance random, y = per-instance fade out amount, z = hide/show flag, w dither fade cutoff
|
|
float4 PerInstanceParams : COLOR1;
|
|
#endif
|
|
|
|
#if NUM_TEX_COORD_INTERPOLATORS
|
|
float4 TexCoords[(NUM_TEX_COORD_INTERPOLATORS+1)/2] : TEXCOORD0;
|
|
#elif USE_PARTICLE_SUBUVS
|
|
float4 TexCoords[1] : TEXCOORD0;
|
|
#endif
|
|
|
|
#if NEEDS_LIGHTMAP_COORDINATE
|
|
float4 LightMapCoordinate : TEXCOORD4;
|
|
#endif
|
|
|
|
#if INSTANCED_STEREO
|
|
nointerpolation uint EyeIndex : PACKED_EYE_INDEX;
|
|
#endif
|
|
#if VF_USE_PRIMITIVE_SCENE_DATA
|
|
nointerpolation uint PrimitiveId : PRIMITIVE_ID;
|
|
#if NEEDS_LIGHTMAP_COORDINATE
|
|
nointerpolation uint LightmapDataIndex : LIGHTMAP_ID;
|
|
#endif
|
|
#endif
|
|
#if HAIR_STRAND_MESH_FACTORY || HAIR_CARD_MESH_FACTORY
|
|
nointerpolation uint HairPrimitiveId : HAIR_PRIMITIVE_ID; // Control point ID
|
|
float2 HairPrimitiveUV : HAIR_PRIMITIVE_UV; // U: parameteric distance between the two surrounding control points. V: parametric distance along the width.
|
|
#endif
|
|
};
|
|
|
|
#if NUM_TEX_COORD_INTERPOLATORS || USE_PARTICLE_SUBUVS
|
|
float2 GetUV(FVertexFactoryInterpolantsVSToPS Interpolants, int UVIndex)
|
|
{
|
|
float4 UVVector = Interpolants.TexCoords[UVIndex / 2];
|
|
return UVIndex % 2 ? UVVector.zw : UVVector.xy;
|
|
}
|
|
|
|
void SetUV(inout FVertexFactoryInterpolantsVSToPS Interpolants, int UVIndex, float2 InValue)
|
|
{
|
|
FLATTEN
|
|
if (UVIndex % 2)
|
|
{
|
|
Interpolants.TexCoords[UVIndex / 2].zw = InValue;
|
|
}
|
|
else
|
|
{
|
|
Interpolants.TexCoords[UVIndex / 2].xy = InValue;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
float4 GetColor(FVertexFactoryInterpolantsVSToPS Interpolants)
|
|
{
|
|
#if INTERPOLATE_VERTEX_COLOR
|
|
return Interpolants.Color;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
void SetColor(inout FVertexFactoryInterpolantsVSToPS Interpolants, float4 InValue)
|
|
{
|
|
#if INTERPOLATE_VERTEX_COLOR
|
|
Interpolants.Color = InValue;
|
|
#endif
|
|
}
|
|
|
|
#if NEEDS_LIGHTMAP_COORDINATE
|
|
void GetLightMapCoordinates(FVertexFactoryInterpolantsVSToPS Interpolants, out float2 LightmapUV0, out float2 LightmapUV1, out uint LightmapDataIndex)
|
|
{
|
|
LightmapUV0 = Interpolants.LightMapCoordinate.xy * float2( 1, 0.5 );
|
|
LightmapUV1 = LightmapUV0 + float2( 0, 0.5 );
|
|
|
|
#if VF_USE_PRIMITIVE_SCENE_DATA && NEEDS_LIGHTMAP_COORDINATE
|
|
LightmapDataIndex = Interpolants.LightmapDataIndex;
|
|
#else
|
|
LightmapDataIndex = 0;
|
|
#endif
|
|
}
|
|
|
|
void GetShadowMapCoordinate(FVertexFactoryInterpolantsVSToPS Interpolants, out float2 ShadowMapCoordinate, out uint LightmapDataIndex)
|
|
{
|
|
#if VF_USE_PRIMITIVE_SCENE_DATA && NEEDS_LIGHTMAP_COORDINATE
|
|
LightmapDataIndex = Interpolants.LightmapDataIndex;
|
|
#else
|
|
LightmapDataIndex = 0;
|
|
#endif
|
|
ShadowMapCoordinate = Interpolants.LightMapCoordinate.zw;
|
|
}
|
|
|
|
void SetLightMapCoordinate(inout FVertexFactoryInterpolantsVSToPS Interpolants, float2 InLightMapCoordinate, float2 InShadowMapCoordinate)
|
|
{
|
|
Interpolants.LightMapCoordinate.xy = InLightMapCoordinate;
|
|
Interpolants.LightMapCoordinate.zw = InShadowMapCoordinate;
|
|
}
|
|
#endif
|
|
|
|
float4 GetTangentToWorld2(FVertexFactoryInterpolantsVSToPS Interpolants)
|
|
{
|
|
return Interpolants.TangentToWorld2;
|
|
}
|
|
|
|
float4 GetTangentToWorld0(FVertexFactoryInterpolantsVSToPS Interpolants)
|
|
{
|
|
return Interpolants.TangentToWorld0;
|
|
}
|
|
|
|
void SetTangents(inout FVertexFactoryInterpolantsVSToPS Interpolants, float3 InTangentToWorld0, float3 InTangentToWorld2, float InTangentToWorldSign)
|
|
{
|
|
Interpolants.TangentToWorld0 = float4(InTangentToWorld0,0);
|
|
Interpolants.TangentToWorld2 = float4(InTangentToWorld2,InTangentToWorldSign);
|
|
#if USE_WORLDVERTEXNORMAL_CENTER_INTERPOLATION
|
|
Interpolants.TangentToWorld2_Center = Interpolants.TangentToWorld2;
|
|
#endif
|
|
}
|
|
|
|
uint GetPrimitiveId(FVertexFactoryInterpolantsVSToPS Interpolants)
|
|
{
|
|
#if VF_USE_PRIMITIVE_SCENE_DATA
|
|
return Interpolants.PrimitiveId;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
void SetPrimitiveId(inout FVertexFactoryInterpolantsVSToPS Interpolants, uint PrimitiveId)
|
|
{
|
|
#if VF_USE_PRIMITIVE_SCENE_DATA
|
|
Interpolants.PrimitiveId = PrimitiveId;
|
|
#endif
|
|
}
|
|
|
|
void SetLightmapDataIndex(inout FVertexFactoryInterpolantsVSToPS Interpolants, uint LightmapDataIndex)
|
|
{
|
|
#if VF_USE_PRIMITIVE_SCENE_DATA && NEEDS_LIGHTMAP_COORDINATE
|
|
Interpolants.LightmapDataIndex = LightmapDataIndex;
|
|
#endif
|
|
}
|