Files
UnrealEngineUWP/Engine/Shaders/LocalVertexFactoryCommon.usf
Marcus Wassmer e09c81f59e Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3304653)
#lockdown Nick.Penwarden
#rb none

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3288774 on 2017/02/06 by Ben.Salem

	Added in min/max/avg values to table. Allow us to also set which stat groups we use explicitly to massively cut down on plugin overhead.
	#tests Several tests passes taken on ShooterGame.

Change 3289887 on 2017/02/07 by David.Hill

	Eye Adaptation:  Fix basic mode.
	The last step of the basic eye adaptation needs to know the correct down-sampled viewport size
	#jira: UE-29491

Change 3290281 on 2017/02/07 by Chris.Bunner

	Account for LogToLin approximation value offseting.

Change 3290282 on 2017/02/07 by Chris.Bunner

	Fixed missing 2000 nit branch in tonemapper.

Change 3290331 on 2017/02/07 by Chris.Bunner

	Minor optimization for BlendMaterialAttributes node compilation.

Change 3291140 on 2017/02/07 by Daniel.Wright

	Fixed distance field temporal filter using Point filtering
	* Fixed the manual bilinear filter in the high quality reprojection path, still doesn't solve the streaking artifacts though

Change 3292060 on 2017/02/08 by Rolando.Caloca

	DR - Some enums for max/num bits on RHI definitions

Change 3292213 on 2017/02/08 by Benjamin.Hyder

	Updating TM-DistanceFields map in QAGame

Change 3292291 on 2017/02/08 by Benjamin.Hyder

	small tweaks to TM-DistanceFields

Change 3292399 on 2017/02/08 by Chris.Bunner

	Minor fix to HDR format type check.

Change 3293560 on 2017/02/08 by Rolando.Caloca

	DR - vk - Events

Change 3293562 on 2017/02/08 by Rolando.Caloca

	DR - vk - Disambiguate class name

Change 3295346 on 2017/02/09 by Rolando.Caloca

	DR - Duplicate fix from 3295320

Change 3296930 on 2017/02/10 by Chris.Bunner

	Search keywords for pre-skinned position/normal nodes.

Change 3297162 on 2017/02/10 by Daniel.Wright

	Distance field temporal filter stores a confidence value, which is used to track leaking of occlusion during the upsample, and flush those leaked values through the history faster.  Reduces DFAO ghosting when the camera is moving.

Change 3297345 on 2017/02/10 by Daniel.Wright

	Added 'r.CompressMeshDistanceFields' to rendering project settings, defaults to off to prevent hitches when streaming in levels

Change 3297371 on 2017/02/10 by Chris.Bunner

	Custom vertex interpolator in/out node with auto-packing - Function support. Unified UV/CVI interpolator arrays for mixed custom UV support.

Change 3298013 on 2017/02/10 by Daniel.Wright

	Ray Traced Distance Field shadowing is overlapped with the shadow depth pass, controlled by r.DFShadowAsyncCompute.
	* Didn't save any GPU time on PS4, so currently disabled until further investigation.
	* This change breaks RTDF shadows in splitscreen / stereo

Change 3300028 on 2017/02/13 by Ben.Salem

	Adding GPU/Render/Game thread timers by default. Remove pointless flavor whitelisting on the plugin. Add sample usage in ShooterGame.ini config.
	#tests Ran half a dozen perf passes, and preflighted my changes in EC

Change 3301571 on 2017/02/14 by Joe.Graf

	Deleted this plugin since it is no longer needed as an example

Change 3301882 on 2017/02/14 by Daniel.Wright

	Fixed DistanceFieldAOConfidenceHistoryRT not getting released on RT

Change 3304283 on 2017/02/15 by Daniel.Wright

	Variable shadowing fix

Change 3304653 on 2017/02/15 by Ben.Salem

	Fix thread safety issues in Performance Monitor - deal with floating point bug in determining when to record frames.
	#tests Preflighted changes several times, ran several runs on Showdown

[CL 3307957 by Marcus Wassmer in Main branch]
2017-02-16 17:52:21 -05:00

252 lines
7.0 KiB
Plaintext

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
LocalVertexFactoryCommon.usf: Local vertex factory common functionality
=============================================================================*/
// FVertexFactoryInterpolantsVSToPS is split into a PC and ES2 version, since the ES2 version has more restrictions on packing
// Then accessors are provided for each property which try to encapsulate the packing differences
#if FEATURE_LEVEL >= FEATURE_LEVEL_ES3_1
struct FVertexFactoryInterpolantsVSToPS
{
TANGENTTOWORLD_INTERPOLATOR_BLOCK
#if INTERPOLATE_VERTEX_COLOR
half4 Color : COLOR0;
#endif
#if USE_INSTANCING
// 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 PackedEyeIndex : PACKED_EYE_INDEX;
#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)
{
LightmapUV0 = Interpolants.LightMapCoordinate.xy * float2( 1, 0.5 );
LightmapUV1 = LightmapUV0 + float2( 0, 0.5 );
}
float2 GetShadowMapCoordinate(FVertexFactoryInterpolantsVSToPS Interpolants)
{
return 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);
}
#else // #if FEATURE_LEVEL >= FEATURE_LEVEL_ES3_1
#define NUM_PACKED_UVS (NUM_TEX_COORD_INTERPOLATORS > 1 ? 3 : 1)
#define USE_INTERPOLATOR_345 ((!MATERIAL_SHADINGMODEL_UNLIT) || USES_TRANSFORM_VECTOR || USES_DISTORTION)
/** Interpolants packed for ES2. All UVs are in the xy to ensure independent texture fetches. */
struct FVertexFactoryInterpolantsVSToPS
{
// Save one interpolator if the material is only using one UV
#if NUM_PACKED_UVS == 1
// UV0, normal xy
float4 PackedUVs[1] : TEXCOORD0;
#if INTERPOLATE_VERTEX_COLOR
// Only interpolate vertex color if needed by the material pixel shader
float4 Color : TEXCOORD1;
#endif
#else
// UV0, normal xy
// UV1, color xy
// UV2, color zw
float4 PackedUVs[3] : TEXCOORD0;
#endif
#if USE_INTERPOLATOR_345
// LightmapUV0, normal zw
float4 PackedInterpolator3 : TEXCOORD3;
// LightmapUV1, tangent xy
float4 PackedInterpolator4 : TEXCOORD4;
// ShadowmapUV, tangent zw
float4 PackedInterpolator5 : TEXCOORD5;
#endif
#if USE_INSTANCING
// x = per-instance random, y = per-instance fade out amount, z = hide/show flag, w dither fade cutoff
float4 PerInstanceParams : COLOR1;
#endif
#if INSTANCED_STEREO
nointerpolation uint PackedEyeIndex : PACKED_EYE_INDEX;
#endif
};
float2 GetUV(FVertexFactoryInterpolantsVSToPS Interpolants, int UVIndex)
{
return Interpolants.PackedUVs[UVIndex].xy;
}
void SetUV(inout FVertexFactoryInterpolantsVSToPS Interpolants, int UVIndex, float2 InValue)
{
Interpolants.PackedUVs[UVIndex].xy = InValue;
}
float4 GetColor(FVertexFactoryInterpolantsVSToPS Interpolants)
{
#if NUM_PACKED_UVS == 1
#if INTERPOLATE_VERTEX_COLOR
return Interpolants.Color;
#else
return 0;
#endif
#else
return float4(Interpolants.PackedUVs[1].zw, Interpolants.PackedUVs[2].zw);
#endif
}
void SetColor(inout FVertexFactoryInterpolantsVSToPS Interpolants, float4 InValue)
{
#if NUM_PACKED_UVS == 1
#if INTERPOLATE_VERTEX_COLOR
Interpolants.Color = InValue;
#endif
#else
Interpolants.PackedUVs[1].zw = InValue.xy;
Interpolants.PackedUVs[2].zw = InValue.zw;
#endif
}
void GetLightMapCoordinates(FVertexFactoryInterpolantsVSToPS Interpolants, out float2 LightmapUV0, out float2 LightmapUV1)
{
#if USE_INTERPOLATOR_345
LightmapUV0 = Interpolants.PackedInterpolator3.xy;
LightmapUV1 = Interpolants.PackedInterpolator4.xy;
#else
LightmapUV0 = LightmapUV1 = 0;
#endif
}
float2 GetShadowMapCoordinate(FVertexFactoryInterpolantsVSToPS Interpolants)
{
#if USE_INTERPOLATOR_345
return Interpolants.PackedInterpolator5.xy;
#else
return float2(0, 0);
#endif
}
void SetLightMapCoordinate(inout FVertexFactoryInterpolantsVSToPS Interpolants, float2 InLightMapCoordinate, float2 InShadowMapCoordinate)
{
#if USE_INTERPOLATOR_345
Interpolants.PackedInterpolator3.xy = InLightMapCoordinate * float2(1, 0.5);
Interpolants.PackedInterpolator4.xy = Interpolants.PackedInterpolator3.xy + float2(0, 0.5);
Interpolants.PackedInterpolator5.xy = InShadowMapCoordinate;
#endif
}
float4 GetTangentToWorld2(FVertexFactoryInterpolantsVSToPS Interpolants)
{
#if USE_INTERPOLATOR_345
return float4(Interpolants.PackedUVs[0].zw, Interpolants.PackedInterpolator3.zw);
#else
return float4(0, 0, 0, 1);
#endif
}
float4 GetTangentToWorld0(FVertexFactoryInterpolantsVSToPS Interpolants)
{
#if USE_INTERPOLATOR_345
return float4(Interpolants.PackedInterpolator4.zw, Interpolants.PackedInterpolator5.zw);
#else
return float4(0, 0, 0, 0);
#endif
}
void SetTangents(inout FVertexFactoryInterpolantsVSToPS Interpolants, float3 InTangentToWorld0, float3 InTangentToWorld2, float InTangentToWorldSign)
{
#if USE_INTERPOLATOR_345
Interpolants.PackedInterpolator4.zw = InTangentToWorld0.xy;
Interpolants.PackedInterpolator5.zw = InTangentToWorld0.zz;
Interpolants.PackedUVs[0].zw = InTangentToWorld2.xy;
Interpolants.PackedInterpolator3.zw = float2(InTangentToWorld2.z,InTangentToWorldSign);
#else
Interpolants.PackedUVs[0].zw = 0;
#endif
}
#endif