Singularity Fixes, Part 3 (#4105)

* Hopefully make singularity shader warping resolution-invariant

This may or may not fix intensity issues

* Fix singularity 'zero velocity' check

It got stuck in a corner. Twice. I really thought I'd fixed that.

* Make it easier to move around various power stuff by shrinking their AABBs a little and making singulo generator a circle

* Changes to some machine prototypes to reduce duplication of collision changes (#1)

* Changes to some machine prototypes to reduce duplication of collision changes

* BaseMachine.BaseMachineUnpowered -> BaseMachine.BaseMachinePowered
This commit is contained in:
20kdc
2021-06-03 08:55:50 +01:00
committed by GitHub
parent 74eb2bd283
commit 6a78c401bf
9 changed files with 28 additions and 59 deletions

View File

@@ -43,10 +43,8 @@ namespace Content.Client.Graphics.Overlays
SingularityQuery(args.Viewport.Eye);
var viewportWB = args.WorldBounds;
// This is a blatant cheat.
// The correct way of doing this would be if the singularity shader performed the matrix transforms.
// I don't need to explain why I'm not doing that.
var resolution = Math.Max(0.125f, Math.Min(args.Viewport.RenderScale.X, args.Viewport.RenderScale.Y));
// Has to be correctly handled because of the way intensity/falloff transform works so just do it.
_shader?.SetParameter("renderScale", args.Viewport.RenderScale);
foreach (SingularityShaderInstance instance in _singularities.Values)
{
// To be clear, this needs to use "inside-viewport" pixels.
@@ -56,8 +54,8 @@ namespace Content.Client.Graphics.Overlays
_shader?.SetParameter("positionInput", tempCoords);
if (ScreenTexture != null)
_shader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
_shader?.SetParameter("intensity", instance.Intensity / resolution);
_shader?.SetParameter("falloff", instance.Falloff / resolution);
_shader?.SetParameter("intensity", instance.Intensity);
_shader?.SetParameter("falloff", instance.Falloff);
var worldHandle = args.WorldHandle;
worldHandle.UseShader(_shader);

View File

@@ -61,12 +61,12 @@ namespace Content.Server.GameObjects.Components.Singularity
if (value < 0) value = 0;
if (value > 6) value = 6;
_level = value;
if ((_level > 1) && (value <= 1))
{
// Prevents it getting stuck (see SingularityController.MoveSingulo)
if (_collidableComponent != null) _collidableComponent.LinearVelocity = Vector2.Zero;
}
_level = value;
if(_radiationPulseComponent != null) _radiationPulseComponent.RadsPerSecond = 10 * value;

View File

@@ -15,8 +15,9 @@
bodyType: Static
fixtures:
- shape:
!type:PhysShapeAabb
bounds: "-0.5, -0.5, 0.5, 0.5"
# Using a circle here makes it a lot easier to pull it all the way from Cargo
!type:PhysShapeCircle
radius: 0.45
mass: 25
# Keep an eye on ParticlesProjectile when adjusting these
layer:

View File

@@ -1,30 +1,12 @@
- type: entity
abstract: true
id: BaseSmes
parent: BaseMachine
name: SMES
description: A high-capacity superconducting magnetic energy storage (SMES) unit.
placement:
mode: SnapgridCenter
components:
- type: Clickable
- type: InteractionOutline
- type: Physics
bodyType: Static
fixtures:
- shape:
!type:PhysShapeAabb {}
mass: 25
mask:
- Impassable
- MobImpassable
- VaultImpassable
- SmallImpassable
layer:
- Opaque
- MobImpassable
- VaultImpassable
- SmallImpassable
- type: SnapGrid
- type: Sprite
netsync: false
sprite: Constructible/Power/smes.rsi
@@ -52,8 +34,6 @@
- type: PowerSupplier
- type: BatteryDischarger
activeSupplyRate: 1000
- type: Anchorable
- type: Pullable
- type: ClientEntitySpawner
prototypes:
- HVDummyWire
@@ -61,30 +41,12 @@
- type: entity
abstract: true
id: BaseSubstation
parent: BaseMachine
name: substation
description: Reduces the voltage of electricity put into it.
placement:
mode: SnapgridCenter
components:
- type: Clickable
- type: InteractionOutline
- type: Physics
bodyType: Static
fixtures:
- shape:
!type:PhysShapeAabb {}
mass: 25
mask:
- Impassable
- MobImpassable
- VaultImpassable
- SmallImpassable
layer:
- Opaque
- MobImpassable
- VaultImpassable
- SmallImpassable
- type: SnapGrid
- type: Sprite
sprite: Constructible/Power/substation.rsi
layers:
@@ -113,8 +75,6 @@
voltage: Medium
- type: BatteryDischarger
activeSupplyRate: 1000
- type: Anchorable
- type: Pullable
- type: ClientEntitySpawner
prototypes:
- HVDummyWire

View File

@@ -1,6 +1,6 @@
- type: entity
id: CloningPod
parent: BaseMachine
parent: BaseMachinePowered
name: cloning pod
description: A Cloning Pod. 50% reliable.
components:

View File

@@ -1,6 +1,6 @@
- type: entity
id: MedicalScanner
parent: BaseMachine
parent: BaseMachinePowered
name: medical scanner
description: A bulky medical scanner.
components:

View File

@@ -10,7 +10,8 @@
bodyType: Static
fixtures:
- shape:
!type:PhysShapeAabb {}
!type:PhysShapeAabb
bounds: "-0.45, -0.45, 0.45, 0.45"
mass: 50
layer:
- SmallImpassable
@@ -34,7 +35,8 @@
bodyType: Dynamic
fixtures:
- shape:
!type:PhysShapeAabb {}
!type:PhysShapeAabb
bounds: "-0.45, -0.45, 0.45, 0.45"
mass: 50
layer:
- SmallImpassable

View File

@@ -5,13 +5,12 @@
components:
- type: InteractionOutline
- type: Anchorable
- type: Pullable
- type: PowerReceiver
- type: Physics
bodyType: Static
fixtures:
- shape:
!type:PhysShapeAabb {}
!type:PhysShapeAabb
bounds: "-0.45, -0.45, 0.45, 0.45"
mass: 25
layer:
- MobMask
@@ -28,3 +27,11 @@
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]
- type: entity
abstract: true
parent: BaseMachine
id: BaseMachinePowered
components:
- type: PowerReceiver

View File

@@ -2,13 +2,14 @@
uniform sampler2D SCREEN_TEXTURE;
uniform highp vec2 positionInput;
uniform highp vec2 renderScale;
uniform highp float falloff;
uniform highp float intensity;
void fragment() {
highp float distanceToCenter = length(FRAGCOORD.xy-positionInput);
highp float distanceToCenter = length((FRAGCOORD.xy - positionInput) / renderScale);
highp vec2 finalCoords = FRAGCOORD.xy - positionInput;
highp float deformation = (pow(intensity, 2.0)*500.0) / pow(distanceToCenter, pow(falloff, 0.5));