Files
UnrealEngineUWP/Engine/Shaders/OneColorShader.usf
Joe Tidmarsh c489d646df #ttp 316639 - UE4: RENDERING: DrawDenormalizedQuad should reuse static index and vertexbuffer
#summary UV offsets are now correctly calculated. This was previously blocking shadow game

[CL 2039548 by Joe Tidmarsh in Main branch]
2014-04-23 17:26:59 -04:00

135 lines
2.9 KiB
Plaintext

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
OneColorShader.usf: 2D shader for drawing a single constant color.
=============================================================================*/
#include "Common.usf"
/*=============================================================================
* Vertex shader
=============================================================================*/
struct FOneColorVertexOutput
{
float4 Position : SV_POSITION;
};
#ifndef USING_NDC_POSITIONS
#define USING_NDC_POSITIONS 1
#endif
void MainVertexShader(
in float4 InPosition : ATTRIBUTE0,
out FOneColorVertexOutput Output
)
{
Output.Position = InPosition;
#if !USING_NDC_POSITIONS
DrawRectangle( InPosition, Output.Position);
#endif
}
/*=============================================================================
* Pixel shader
=============================================================================*/
float4 DrawColorMRT[8];
#ifndef NUM_OUTPUTS
#define NUM_OUTPUTS 1
#endif
void MainPixelShaderMRT(
out float4 OutColor[NUM_OUTPUTS] : SV_Target0)
{
for (int i = 0; i < NUM_OUTPUTS; i++)
{
OutColor[i] = DrawColorMRT[i];
}
}
void MainPixelShader(
out float4 OutColor : SV_Target0)
{
OutColor = DrawColorMRT[0];
}
/**
* Designed to take about 100ms of GPU time (depending on resolution and GPU),
* To make sure that we're not CPU bound when profiling the GPU, as we can't isolate GPU idle time on PC.
*/
void MainLongGPUTask(out float4 OutColor : SV_Target0)
{
OutColor = 0;
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM4
for (int i = 0; i < 4000; i++)
{
OutColor += .0001f * cos(i * .0001f) * sin(i * i * .00001f);
}
#else
for (int i = 0; i < 255; i++)
{
OutColor += .0001f * cos(i * .0001f) * sin(i * i * .00001f);
}
#endif
OutColor *= .000001f;
}
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5
float4 FillValue;
RWTexture2D<float4> FillTexture;
float4 Params0; // Texture Width,Height (.xy); Use Exclude Rect 1 : 0 (.z)
float4 Params1; // Include X0,Y0 (.xy) - X1,Y1 (.zw)
float4 Params2; // ExcludeRect X0,Y0 (.xy) - X1,Y1 (.zw)
[numthreads(8,8,1)]
void MainFillTextureCS(uint2 XY : SV_DispatchThreadID)
{
float Width = Params0.x;
float Height = Params0.y;
bool bUseExcludeRect = (Params0.z != 0);
float X = XY.x;
float Y = XY.y;
float IncludeX0 = Params1.x;
float IncludeY0 = Params1.y;
float IncludeX1 = Params1.z;
float IncludeY1 = Params1.w;
if (X < Width && Y < Height)
{
if (X >= IncludeX0 && X <= IncludeX1 && Y >= IncludeY0 && Y <= IncludeY1)
{
bool bDoWrite = true;
/*
if (bUseExcludeRect)
{
float ExcludeX0 = Params2.x;
float ExcludeY0 = Params2.y;
float ExcludeX1 = Params2.z;
float ExcludeY1 = Params2.w;
if (X >= ExcludeX0 && X <= ExcludeX1 && Y >= ExcludeY0 && Y <= ExcludeY1)
{
bDoWrite = false;
}
}
*/
if (bDoWrite)
{
FillTexture[XY] = FillValue;
}
}
}
}
#endif