Files
UnrealEngineUWP/Engine/Shaders/HitProxyVertexShader.usf
Guillaume Abadie 5f8bec9a35 Do not bind the GBuffer in hit proxy rendering, avoiding a check assertion failure at start-up time with r.RenderTargetPoolTest=1
#code_review: Martin.Mittring

[CL 2527529 by Guillaume Abadie in Main branch]
2015-04-27 17:39:25 -04:00

126 lines
3.5 KiB
Plaintext

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
HitProxyVertexShader.hlsl: Vertex shader for rendering hit proxies.
=============================================================================*/
// Some input nodes can't compute their output value at hit proxy rendering time, and so their implementation changes.
#define HIT_PROXY_SHADER 1
#include "Common.usf"
#include "Material.usf"
#include "VertexFactory.usf"
struct FHitProxyVSToPS
{
FVertexFactoryInterpolantsVSToPS FactoryInterpolants;
#if USE_INSTANCING
float4 InstanceHitProxyId : HIT_PROXY_ID;
#endif
float4 PixelPosition : TEXCOORD6;
float4 Position : SV_POSITION;
};
#if USING_TESSELLATION
struct FHitProxyVSToDS
{
FVertexFactoryInterpolantsVSToDS FactoryInterpolants;
#if USE_INSTANCING
float4 InstanceHitProxyId : HIT_PROXY_ID;
#endif
float4 Position : VS_To_DS_Position;
OPTIONAL_VertexID_VS_To_DS
};
#define FHitProxyVSOutput FHitProxyVSToDS
#else
#define FHitProxyVSOutput FHitProxyVSToPS
#endif
#if USING_TESSELLATION
#define FPassSpecificVSToDS FHitProxyVSToDS
#define FPassSpecificVSToPS FHitProxyVSToPS
FHitProxyVSToDS PassInterpolate(FHitProxyVSToDS a, float aInterp, FHitProxyVSToDS b, float bInterp)
{
FHitProxyVSToDS O;
O.FactoryInterpolants = VertexFactoryInterpolate(a.FactoryInterpolants, aInterp, b.FactoryInterpolants, bInterp);
#if USE_INSTANCING
TESSELLATION_INTERPOLATE_MEMBER(InstanceHitProxyId);
#endif
return O;
}
FHitProxyVSToPS PassFinalizeTessellationOutput(FHitProxyVSToDS Interpolants, float4 WorldPosition, FMaterialTessellationParameters MaterialParameters)
{
FHitProxyVSToPS O;
O.FactoryInterpolants = VertexFactoryAssignInterpolants(Interpolants.FactoryInterpolants);
// Calc displacement mapping
float3 WorldDisplacement = GetMaterialWorldDisplacement(MaterialParameters);
WorldPosition.xyz += WorldDisplacement;
#if USE_INSTANCING
O.InstanceHitProxyId = Interpolants.InstanceHitProxyId;
#endif
// Finally, transform position to clip-space
ISOLATE
{
O.Position = mul(WorldPosition, View.TranslatedWorldToClip);
}
O.PixelPosition = WorldPosition;
return O;
}
#include "Tessellation.usf"
#endif
#if VERTEXSHADER
void Main(
FVertexFactoryInput Input,
OPTIONAL_VertexID
out FHitProxyVSOutput Output
)
{
FVertexFactoryIntermediates VFIntermediates = GetVertexFactoryIntermediates(Input);
float4 WorldPosition = VertexFactoryGetWorldPosition(Input, VFIntermediates);
float3x3 TangentToLocal = VertexFactoryGetTangentToLocal(Input, VFIntermediates);
FMaterialVertexParameters VertexParameters = GetMaterialVertexParameters(Input, VFIntermediates, WorldPosition.xyz, TangentToLocal);
WorldPosition.xyz += GetMaterialWorldPositionOffset(VertexParameters);
#if USE_INSTANCING
Output.InstanceHitProxyId = VertexFactoryGetInstanceHitProxyId(Input, VFIntermediates);
#endif
#if USING_TESSELLATION
Output.Position = WorldPosition;
Output.FactoryInterpolants = VertexFactoryGetInterpolantsVSToDS(Input, VFIntermediates, VertexParameters);
#else
ISOLATE
{
float4 RasterizedWorldPosition = VertexFactoryGetRasterizedWorldPosition(Input, VFIntermediates, WorldPosition);
Output.Position = mul(RasterizedWorldPosition, View.TranslatedWorldToClip);
}
Output.FactoryInterpolants = VertexFactoryGetInterpolantsVSToPS(Input, VFIntermediates, VertexParameters);
Output.PixelPosition = WorldPosition;
#endif
OutputVertexID( Output );
}
#endif // VERTEXSHADER