123456789101112131415161718192021222324252627282930313233343536 |
- // Copyright 2023 ZSttt, Inc. All Rights Reserved.
- #include "/Engine/Public/Platform.ush"
- #include "/Engine/Private/Common.ush"
- #ifndef FLOWFIELD2D_USE_COMPUTE
- #define FLOWFIELD2D_USE_COMPUTE true
- #endif
- float2 QuadSize;
- #if FLOWFIELD2D_USE_COMPUTE
- StructuredBuffer<float2> Particles;
- #else
- Texture2D<float4> Particles;
- uint2 ParticlesResolution;
- #endif
- void DrawParticles
- (
- in float4 Vertex : ATTRIBUTE0,
- uint IId : SV_InstanceID,
- out float2 OutParticle : TEXCOORD0,
- out float4 Output : SV_POSITION
- )
- {
- #if FLOWFIELD2D_USE_COMPUTE
- OutParticle = Particles[IId];
- #else
- uint2 Pos = uint2(IId / ParticlesResolution.x, IId % ParticlesResolution.x);
- float4 color = Particles.Load(uint3(Pos, 0));
- OutParticle = float2(color.r / 255.0 + color.b, color.g / 255.0 + color.a);
- #endif
- float2 UV = OutParticle.xy + (QuadSize * Vertex.xy);
- UV = 2.0 * UV - 1.0;
- Output = float4(UV.r, UV.g, 0.0, 1.0);
- }
|