You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
optimized shaders to use SvPosition where possible, following change could remove some unused interpolator [CL 2697164 by Martin Mittring in Main branch]
131 lines
3.8 KiB
Plaintext
131 lines
3.8 KiB
Plaintext
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
LandscapeGrassWeightVertexShader.usf: Vertex shader to dump the weight map for Landscape Grass
|
|
=============================================================================*/
|
|
|
|
#include "Common.usf"
|
|
#include "Material.usf"
|
|
#include "VertexFactory.usf"
|
|
|
|
struct FLandscapeGrassWeightInterpolantsVSToPS
|
|
{
|
|
FVertexFactoryInterpolantsVSToPS FactoryInterpolants;
|
|
float4 PixelPosition : TEXCOORD8; // xyz = world position, w = clip z
|
|
float2 Height : TEXCOORD9;
|
|
float4 Position : SV_POSITION;
|
|
};
|
|
|
|
#if VERTEXSHADER
|
|
|
|
float2 RenderOffset;
|
|
|
|
/** Vertex Shader */
|
|
void VSMain(
|
|
FVertexFactoryInput Input,
|
|
out FLandscapeGrassWeightInterpolantsVSToPS Output
|
|
)
|
|
{
|
|
FVertexFactoryIntermediates VFIntermediates = GetVertexFactoryIntermediates(Input);
|
|
float4 WorldPositionExcludingWPO = VertexFactoryGetWorldPosition(Input, VFIntermediates);
|
|
float4 WorldPosition = WorldPositionExcludingWPO;
|
|
|
|
half3x3 TangentToLocal = VertexFactoryGetTangentToLocal(Input, VFIntermediates);
|
|
FMaterialVertexParameters VertexParameters = GetMaterialVertexParameters(Input, VFIntermediates, WorldPosition.xyz, TangentToLocal);
|
|
|
|
half3 WorldPositionOffset = GetMaterialWorldPositionOffset(VertexParameters);
|
|
|
|
WorldPosition.xyz += WorldPositionOffset;
|
|
float4 RasterizedWorldPosition = VertexFactoryGetRasterizedWorldPosition(Input, VFIntermediates, WorldPosition);
|
|
Output.PixelPosition = WorldPosition;
|
|
Output.Position = mul(RasterizedWorldPosition, View.TranslatedWorldToClip);
|
|
Output.FactoryInterpolants = VertexFactoryGetInterpolantsVSToPS(Input, VFIntermediates, VertexParameters);
|
|
|
|
Output.Height = LandscapeVertexFactorySampleHeight(Input, VFIntermediates);
|
|
|
|
Output.Position.xy += RenderOffset;
|
|
|
|
Output.PixelPosition.w = Output.Position.w;
|
|
}
|
|
|
|
#elif PIXELSHADER
|
|
|
|
int OutputPass;
|
|
|
|
// Pixel Shader
|
|
void PSMain(
|
|
FLandscapeGrassWeightInterpolantsVSToPS Interpolants,
|
|
in float4 SvPosition : SV_Position
|
|
OPTIONAL_IsFrontFace,
|
|
out half4 OutColor : SV_Target0
|
|
)
|
|
{
|
|
FMaterialPixelParameters MaterialParameters = GetMaterialPixelParameters(Interpolants.FactoryInterpolants, SvPosition);
|
|
|
|
CalcMaterialParameters(MaterialParameters, SvPosition, bIsFrontFace);
|
|
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 2
|
|
switch(OutputPass)
|
|
{
|
|
case 0:
|
|
#endif
|
|
// Height, outputs 1 & 2
|
|
OutColor.xy = Interpolants.Height;
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 0
|
|
OutColor.z = GetGrassWeight0(MaterialParameters);
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 1
|
|
OutColor.w = GetGrassWeight1(MaterialParameters);
|
|
#else
|
|
OutColor.w = 0;
|
|
#endif
|
|
#else
|
|
OutColor.z = 0;
|
|
OutColor.w = 0;
|
|
#endif
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 2
|
|
break;
|
|
case 1:
|
|
OutColor.x = GetGrassWeight2(MaterialParameters);
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 3
|
|
OutColor.y = GetGrassWeight3(MaterialParameters);
|
|
#else
|
|
OutColor.y = 0;
|
|
#endif
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 4
|
|
OutColor.z = GetGrassWeight4(MaterialParameters);
|
|
#else
|
|
OutColor.z = 0;
|
|
#endif
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 5
|
|
OutColor.w = GetGrassWeight5(MaterialParameters);
|
|
#else
|
|
OutColor.w = 0;
|
|
#endif
|
|
break;
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 6
|
|
case 2:
|
|
OutColor.x = GetGrassWeight6(MaterialParameters);
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 7
|
|
OutColor.y = GetGrassWeight7(MaterialParameters);
|
|
#else
|
|
OutColor.y = 0;
|
|
#endif
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 8
|
|
OutColor.z = GetGrassWeight8(MaterialParameters);
|
|
#else
|
|
OutColor.z = 0;
|
|
#endif
|
|
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 9
|
|
OutColor.w = GetGrassWeight9(MaterialParameters);
|
|
#else
|
|
OutColor.w = 0;
|
|
#endif
|
|
break;
|
|
#endif // NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 6
|
|
default:
|
|
OutColor = float4(0,0,0,0);
|
|
break;
|
|
}
|
|
#endif // NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 2
|
|
}
|
|
#endif |