Files
UnrealEngineUWP/Engine/Shaders/ParticleCurveInjectionShader.usf
Ben Marsh 149375b14b Update copyright notices to 2015.
[CL 2379638 by Ben Marsh in Main branch]
2014-12-07 19:09:38 -05:00

70 lines
2.0 KiB
Plaintext

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
ParticleCurveInjectionShader.usf: Shaders for uploading curves to the GPU.
=============================================================================*/
#include "Common.usf"
/*-----------------------------------------------------------------------------
Shared declarations and functions.
-----------------------------------------------------------------------------*/
struct FShaderInterpolants
{
/** The curve sample. */
float4 Sample : TEXCOORD0;
};
/*-----------------------------------------------------------------------------
Vertex shader.
-----------------------------------------------------------------------------*/
#if VERTEXSHADER
struct FVertexInput
{
/** The initial position and relative time of the particle. */
float4 Sample : ATTRIBUTE0;
/** The texture coordinate of the corner of the sprite being rendered. */
float2 TexCoord : ATTRIBUTE1;
/** The sample index. */
uint SampleIndex : SV_InstanceID;
};
void VertexMain(
in FVertexInput Input,
out FShaderInterpolants Interpolants,
out float4 OutPosition : SV_POSITION
)
{
float2 TexelCoord = Input.TexCoord.xy * ParticleCurveInjection.PixelScale.xy +
ParticleCurveInjection.CurveOffset.xy;
TexelCoord.x += (float)Input.SampleIndex * ParticleCurveInjection.PixelScale.x;
OutPosition = float4(
TexelCoord.xy * float2(2.0f,-2.0f) + float2(-1.0f,1.0f),
0,
1
);
// Pass sample on to the pixel shader.
Interpolants.Sample = Input.Sample;
}
#endif // #if VERTEXSHADER
/*-----------------------------------------------------------------------------
Pixel shader.
-----------------------------------------------------------------------------*/
#if PIXELSHADER
void PixelMain(
in FShaderInterpolants Interpolants,
out float4 OutSample : SV_Target0
)
{
// Store sample in the texture.
OutSample = Interpolants.Sample;
}
#endif // #if PIXELSHADER