/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Data/Plugins/ParticlePlugin/Shaders/Particles/DefaultTrailParticle.ezShader
85 строк
2 KB
Jan Krassnigg
Particle System Improvements (#1995)
21 июл 2026, 16:50
Не верифицирован
21 июл 2026, 16:50
5e8aa52
Код
Авторство
О чём код?
[PLATFORMS] ALL [PERMUTATIONS] RENDER_PASS PARTICLE_RENDER_MODE PARTICLE_TRAIL_POINTS PARTICLE_LIGHTING_MODE SHADING_QUALITY CAMERA_MODE [MATERIALPARAMETER] // The default particle shader isn't used through a material, so it doesn't define material parameters. [RENDERSTATE] #include <Shaders/Particles/ParticleRenderState.h> [SHADER] #define CUSTOM_INTERPOLATOR float FogAmount : FOG; float Life : TEXCOORD1; float Variation : TEXCOORD2; float2 ParticleUV : TEXCOORD3; #define USE_TEXCOORD0 #define USE_COLOR0 [VERTEXSHADER] #include <Shaders/Particles/TrailParticleVertexShader.h> [PIXELSHADER] #include <Shaders/Particles/ParticlePixelShader.h> // The default shader has to use BG_DRAW_CALL, but custom materials must use BG_MATERIAL. Texture2D ParticleTexture BIND_GROUP(BG_DRAW_CALL); SamplerState ParticleTexture_AutoSampler BIND_GROUP(BG_DRAW_CALL); // Global values use the 'static' keyword so that they can be shared between functions static float4 g_BaseColor = float4(0.0, 0.0, 0.0, 0.0); /* === Available input data === G.Input looks like this: struct PS_IN { float4 Position : SV_Position; float2 TexCoord0 : TEXCOORD0; float4 Color0 : COLOR0; float FogAmount : FOG; float Life : TEXCOORD1; float Variation : TEXCOORD2; float2 ParticleUV : TEXCOORD3; }; Prefer the UV accessors over touching these fields directly: GetParticleQuadUV() - raw [0-1] across the trail, ignores the flipbook / variation atlas .x runs across the trail, .y along it GetParticleFlipbookUV() - the atlas transformed coordinate, i.e. what ParticleTexture uses below Particle System constants can be accessed through the ezParticleSystemConstants buffer, see Data/Plugins/ParticlePlugin/Shaders/Particles/ParticleSystemConstants.h */ void FillCustomGlobals() { #if PARTICLE_RENDER_MODE == PARTICLE_RENDER_MODE_NONE // this code path isn't really necessary, but if someone tries to use the default shader in a material // this makes sure it at least shows something visible g_BaseColor = float4(G.Input.TexCoord0.xy, 1.0, 1.0); #else g_BaseColor = ParticleTexture.Sample(ParticleTexture_AutoSampler, G.Input.TexCoord0.xy); #endif } float GetParticleOpacity() { return g_BaseColor.a * G.Input.Color0.a; } float3 GetParticleColor() { return g_BaseColor.rgb * G.Input.Color0.rgb; }