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 bool RequestScreenTexture => true;
|
||||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||||
private readonly ShaderInstance _blurryVisionXShader;
|
private readonly ShaderInstance _dim;
|
||||||
private readonly ShaderInstance _blurryVisionYShader;
|
|
||||||
private BlurryVisionComponent _blurryVisionComponent = default!;
|
private BlurryVisionComponent _blurryVisionComponent = default!;
|
||||||
|
|
||||||
public BlurryVisionOverlay()
|
public BlurryVisionOverlay()
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
_blurryVisionXShader = _prototypeManager.Index<ShaderPrototype>("BlurryVisionX").InstanceUnique();
|
_dim = _prototypeManager.Index<ShaderPrototype>("Dim").InstanceUnique();
|
||||||
_blurryVisionYShader = _prototypeManager.Index<ShaderPrototype>("BlurryVisionY").InstanceUnique();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||||
@@ -51,18 +49,17 @@ namespace Content.Client.Eye.Blinding
|
|||||||
if (ScreenTexture == null)
|
if (ScreenTexture == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_blurryVisionXShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
var opacity = -(_blurryVisionComponent.Magnitude / 15) + 0.9f;
|
||||||
_blurryVisionXShader?.SetParameter("BLUR_AMOUNT", (_blurryVisionComponent.Magnitude / 10));
|
|
||||||
_blurryVisionYShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
_dim.SetParameter("DAMAGE_AMOUNT", opacity);
|
||||||
_blurryVisionYShader?.SetParameter("BLUR_AMOUNT", (_blurryVisionComponent.Magnitude / 10));
|
|
||||||
|
|
||||||
var worldHandle = args.WorldHandle;
|
var worldHandle = args.WorldHandle;
|
||||||
var viewport = args.WorldBounds;
|
var viewport = args.WorldBounds;
|
||||||
|
|
||||||
|
worldHandle.UseShader(_dim);
|
||||||
worldHandle.SetTransform(Matrix3.Identity);
|
worldHandle.SetTransform(Matrix3.Identity);
|
||||||
worldHandle.UseShader(_blurryVisionXShader);
|
worldHandle.DrawRect(viewport, Color.Black);
|
||||||
worldHandle.DrawRect(viewport, Color.White);
|
worldHandle.UseShader(null);
|
||||||
worldHandle.UseShader(_blurryVisionYShader);
|
|
||||||
worldHandle.DrawRect(viewport, Color.White);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,3 +65,8 @@
|
|||||||
id: BlurryVisionY
|
id: BlurryVisionY
|
||||||
kind: source
|
kind: source
|
||||||
path: "/Textures/Shaders/blurryy.swsl"
|
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