new eye damage effect (#10728)
This commit is contained in:
@@ -14,15 +14,13 @@ namespace Content.Client.Eye.Blinding
|
||||
|
||||
public override bool RequestScreenTexture => true;
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
private readonly ShaderInstance _blurryVisionXShader;
|
||||
private readonly ShaderInstance _blurryVisionYShader;
|
||||
private readonly ShaderInstance _dim;
|
||||
private BlurryVisionComponent _blurryVisionComponent = default!;
|
||||
|
||||
public BlurryVisionOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_blurryVisionXShader = _prototypeManager.Index<ShaderPrototype>("BlurryVisionX").InstanceUnique();
|
||||
_blurryVisionYShader = _prototypeManager.Index<ShaderPrototype>("BlurryVisionY").InstanceUnique();
|
||||
_dim = _prototypeManager.Index<ShaderPrototype>("Dim").InstanceUnique();
|
||||
}
|
||||
|
||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||
@@ -51,18 +49,17 @@ namespace Content.Client.Eye.Blinding
|
||||
if (ScreenTexture == null)
|
||||
return;
|
||||
|
||||
_blurryVisionXShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
||||
_blurryVisionXShader?.SetParameter("BLUR_AMOUNT", (_blurryVisionComponent.Magnitude / 10));
|
||||
_blurryVisionYShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
||||
_blurryVisionYShader?.SetParameter("BLUR_AMOUNT", (_blurryVisionComponent.Magnitude / 10));
|
||||
var opacity = -(_blurryVisionComponent.Magnitude / 15) + 0.9f;
|
||||
|
||||
_dim.SetParameter("DAMAGE_AMOUNT", opacity);
|
||||
|
||||
var worldHandle = args.WorldHandle;
|
||||
var viewport = args.WorldBounds;
|
||||
|
||||
worldHandle.UseShader(_dim);
|
||||
worldHandle.SetTransform(Matrix3.Identity);
|
||||
worldHandle.UseShader(_blurryVisionXShader);
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
worldHandle.UseShader(_blurryVisionYShader);
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
worldHandle.DrawRect(viewport, Color.Black);
|
||||
worldHandle.UseShader(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,3 +65,8 @@
|
||||
id: BlurryVisionY
|
||||
kind: source
|
||||
path: "/Textures/Shaders/blurryy.swsl"
|
||||
|
||||
- type: shader
|
||||
id: Dim
|
||||
kind: source
|
||||
path: "/Textures/Shaders/dim.swsl"
|
||||
|
||||
12
Resources/Textures/Shaders/dim.swsl
Normal file
12
Resources/Textures/Shaders/dim.swsl
Normal file
@@ -0,0 +1,12 @@
|
||||
uniform highp float DAMAGE_AMOUNT;
|
||||
|
||||
void fragment() {
|
||||
|
||||
// Higher exponent -> stronger blinding effect
|
||||
|
||||
// Gradually mixes between the texture mix and a full-white texture, causing the "blinding" effect
|
||||
highp vec4 mixed = mix(vec4(1.0, 1.0, 1.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0), DAMAGE_AMOUNT);
|
||||
|
||||
COLOR = vec4(mixed.rgb, DAMAGE_AMOUNT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user