平滑火炮转角
This commit is contained in:
parent
317e336a6c
commit
1f3de84507
7 changed files with 144 additions and 20 deletions
|
@ -39,7 +39,7 @@ public class CannonHudOverlay {
|
|||
float yRotOffset = Mth.lerp(event.getPartialTick(), player.yRotO, player.getYRot());
|
||||
float xRotOffset = Mth.lerp(event.getPartialTick(), player.xRotO, player.getXRot());
|
||||
float diffY = 13 * (Objects.requireNonNull(player.getVehicle()).getViewYRot(event.getPartialTick()) - yRotOffset);
|
||||
float diffX = 13 * (Objects.requireNonNull(player.getVehicle()).getViewXRot(event.getPartialTick()) - xRotOffset + 1.3f);
|
||||
float diffX = 17 * (Objects.requireNonNull(player.getVehicle()).getViewXRot(event.getPartialTick()) - xRotOffset + 1.3f);
|
||||
if (diffY > 180.0f) {
|
||||
diffY -= 360.0f;
|
||||
} else if (diffY < -180.0f) {
|
||||
|
|
|
@ -50,6 +50,11 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
|
||||
public String animationprocedure = "empty";
|
||||
|
||||
protected int interpolationSteps;
|
||||
|
||||
protected double serverYRot;
|
||||
protected double serverXRot;
|
||||
|
||||
public Mk42Entity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.MK_42.get(), world);
|
||||
}
|
||||
|
@ -186,7 +191,6 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
capability.syncPlayerVariables(gunner);
|
||||
});
|
||||
}
|
||||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
|
@ -302,6 +306,13 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) {
|
||||
serverYRot = yaw;
|
||||
serverXRot = pitch;
|
||||
this.interpolationSteps = 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void travel(@NotNull Vec3 dir) {
|
||||
Player entity = this.getPassengers().isEmpty() ? null : (Player) this.getPassengers().get(0);
|
||||
|
@ -320,14 +331,11 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity, ICannonEntit
|
|||
diffY = diffY * 0.15f;
|
||||
diffX = diffX * 0.15f;
|
||||
|
||||
if (Math.abs(diffY) < 60f && Math.abs(diffX) < 60f) {
|
||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f));
|
||||
this.yRotO = this.getYRot();
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 15));
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f);
|
||||
this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f);
|
||||
}
|
||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f));
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 15));
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
this.yBodyRot = this.getYRot();
|
||||
this.yHeadRot = this.getYRot();
|
||||
return;
|
||||
}
|
||||
super.travel(dir);
|
||||
|
|
|
@ -52,6 +52,11 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
|
||||
public String animationprocedure = "empty";
|
||||
|
||||
protected int interpolationSteps;
|
||||
|
||||
protected double serverYRot;
|
||||
protected double serverXRot;
|
||||
|
||||
public Mle1934Entity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.MLE_1934.get(), world);
|
||||
}
|
||||
|
@ -332,6 +337,13 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) {
|
||||
serverYRot = yaw;
|
||||
serverXRot = pitch;
|
||||
this.interpolationSteps = 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void travel(@NotNull Vec3 dir) {
|
||||
Player entity = this.getPassengers().isEmpty() ? null : (Player) this.getPassengers().get(0);
|
||||
|
@ -349,14 +361,12 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
}
|
||||
diffY = diffY * 0.15f;
|
||||
diffX = diffX * 0.15f;
|
||||
if (Math.abs(diffY) < 60f && Math.abs(diffX) < 60f) {
|
||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f));
|
||||
this.yRotO = this.getYRot();
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4));
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f);
|
||||
this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f);
|
||||
}
|
||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f));
|
||||
this.yRotO = this.getYRot();
|
||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4));
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
this.yBodyRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f);
|
||||
this.yHeadRot = this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f);
|
||||
return;
|
||||
}
|
||||
super.travel(dir);
|
||||
|
@ -383,6 +393,7 @@ public class Mle1934Entity extends PathfinderMob implements GeoEntity, ICannonEn
|
|||
entity.setXRot(entity.getXRot() + f1 - f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPassengerTurned(Entity entity) {
|
||||
this.clampRotation(entity);
|
||||
|
|
|
@ -67,7 +67,11 @@ public class ClientEventHandler {
|
|||
&& living.getMainHandItem().getOrCreateTag().getBoolean("Linked")) {
|
||||
handleDroneCamera(event, living);
|
||||
} else {
|
||||
Minecraft.getInstance().gameRenderer.shutdownEffect();
|
||||
if (Minecraft.getInstance().gameRenderer.currentEffect() != null && Minecraft.getInstance().gameRenderer.currentEffect().getName().equals("superbwarfare:shaders/post/scan_pincushion.json")) {
|
||||
Minecraft.getInstance().gameRenderer.shutdownEffect();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (level != null && entity instanceof LivingEntity living && living.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||
handleWeaponCrossHair(living);
|
||||
|
@ -111,7 +115,7 @@ public class ClientEventHandler {
|
|||
|
||||
if (drone != null && stack.getOrCreateTag().getBoolean("Using")) {
|
||||
if (Minecraft.getInstance().gameRenderer.currentEffect() == null) {
|
||||
Minecraft.getInstance().gameRenderer.loadEffect(new ResourceLocation("minecraft:shaders/post/scan_pincushion.json"));
|
||||
Minecraft.getInstance().gameRenderer.loadEffect(new ResourceLocation("superbwarfare:shaders/post/scan_pincushion.json"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"targets": [
|
||||
"swap"
|
||||
],
|
||||
"passes": [
|
||||
{
|
||||
"name": "scan_pincushion",
|
||||
"intarget": "minecraft:main",
|
||||
"outtarget": "swap"
|
||||
},
|
||||
{
|
||||
"name": "blit",
|
||||
"intarget": "swap",
|
||||
"outtarget": "minecraft:main"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
#version 150
|
||||
|
||||
uniform sampler2D DiffuseSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 oneTexel;
|
||||
|
||||
uniform vec2 InSize;
|
||||
|
||||
const vec4 Zero = vec4(0.0);
|
||||
const vec4 Half = vec4(0.5);
|
||||
const vec4 One = vec4(1.0);
|
||||
const vec4 Two = vec4(2.0);
|
||||
|
||||
const float Pi = 3.1415926535;
|
||||
const float PincushionAmount = 0.02;
|
||||
const float CurvatureAmount = 0.02;
|
||||
const float ScanlineAmount = 0.8;
|
||||
const float ScanlineScale = 1.0;
|
||||
const float ScanlineHeight = 1.0;
|
||||
const float ScanlineBrightScale = 1.0;
|
||||
const float ScanlineBrightOffset = 0.0;
|
||||
const float ScanlineOffset = 0.0;
|
||||
const vec3 Floor = vec3(0.05, 0.05, 0.05);
|
||||
const vec3 Power = vec3(0.8, 0.8, 0.8);
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 InTexel = texture(DiffuseSampler, texCoord);
|
||||
|
||||
vec2 PinUnitCoord = texCoord * Two.xy - One.xy;
|
||||
float PincushionR2 = pow(length(PinUnitCoord), 2.0);
|
||||
vec2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2;
|
||||
vec2 ScanCoord = texCoord;
|
||||
|
||||
ScanCoord *= One.xy - PincushionAmount * 0.2;
|
||||
ScanCoord += PincushionAmount * 0.1;
|
||||
ScanCoord += PincushionCurve;
|
||||
|
||||
vec2 CurvatureClipCurve = PinUnitCoord * CurvatureAmount * PincushionR2;
|
||||
vec2 ScreenClipCoord = texCoord;
|
||||
ScreenClipCoord -= Half.xy;
|
||||
ScreenClipCoord *= One.xy - CurvatureAmount * 0.2;
|
||||
ScreenClipCoord += Half.xy;
|
||||
ScreenClipCoord += CurvatureClipCurve;
|
||||
|
||||
// -- Alpha Clipping --
|
||||
if (ScanCoord.x < 0.0) discard;
|
||||
if (ScanCoord.y < 0.0) discard;
|
||||
if (ScanCoord.x > 1.0) discard;
|
||||
if (ScanCoord.y > 1.0) discard;
|
||||
|
||||
// -- Scanline Simulation --
|
||||
float InnerSine = ScanCoord.y * InSize.y * ScanlineScale * 0.25;
|
||||
float ScanBrightMod = sin(InnerSine * Pi + ScanlineOffset * InSize.y * 0.25);
|
||||
float ScanBrightness = mix(1.0, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0) * 0.5, ScanlineAmount);
|
||||
vec3 ScanlineTexel = InTexel.rgb * ScanBrightness;
|
||||
|
||||
// -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
|
||||
ScanlineTexel = Floor + (One.xyz - Floor) * ScanlineTexel;
|
||||
|
||||
ScanlineTexel.rgb = pow(ScanlineTexel.rgb, Power);
|
||||
|
||||
fragColor = vec4(ScanlineTexel.rgb, 1.0);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "one",
|
||||
"dstrgb": "zero"
|
||||
},
|
||||
"vertex": "sobel",
|
||||
"fragment": "scan_pincushion",
|
||||
"attributes": [ "Position" ],
|
||||
"samplers": [
|
||||
{ "name": "DiffuseSampler" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }
|
||||
]
|
||||
}
|
Loading…
Add table
Reference in a new issue