Added support for transparent colors.

This commit is contained in:
Michel Fedde 2023-05-21 14:13:00 +02:00
parent 1dc60741c3
commit 9729f1c5c8
3 changed files with 4 additions and 3 deletions

View file

@ -82,7 +82,7 @@ public sealed class Explosion : ParticleEmitter, IParticleHandler
public void Draw(ref ParticleDrawContext context) public void Draw(ref ParticleDrawContext context)
{ {
context.Effect.Parameters["view_projection"].SetValue(context.View * context.Projection); context.Effect.Parameters["view_projection"].SetValue(context.View * context.Projection);
context.Effect.Parameters["color"].SetValue(this.Color.ToVector3()); context.Effect.Parameters["color"].SetValue(this.Color.ToVector4());

View file

@ -15,7 +15,7 @@ int pixelSize;
float timing; float timing;
float2 noiseOffset; float2 noiseOffset;
float3 color; float4 color;
#define BLUR_KERNEL_X_MIN -0.5 #define BLUR_KERNEL_X_MIN -0.5
#define BLUR_KERNEL_X_MAX 0.5 #define BLUR_KERNEL_X_MAX 0.5
@ -108,7 +108,8 @@ float4 SpritePixelShader(PixelInput p) : SV_TARGET {
val = val + calculateAlpha(relPos, noiseCoord); val = val + calculateAlpha(relPos, noiseCoord);
float noiseResult = getNoise(noiseCoord).r; float noiseResult = getNoise(noiseCoord).r;
float3 resultColor = color * lerp(0.5, 1, noiseResult); float3 resultColor = color.rgb * lerp(0.5, 1, noiseResult);
val *= color.a;
return float4(resultColor,val); return float4(resultColor,val);
} }