This commit is contained in:
LZX committed 2026-08-25 22:02:11 +08:00
1 parent 0cbaf4c3af
commit 0a00e06d9c
40 files changed
+1170 -189

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ mod_name=Lzxnone Terraria
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=1.8.0
mod_version=1.8.1
## The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -64,6 +64,9 @@ public class LzxnoneTerrariaClient {
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.CIRCLE_PARTICLE.get(), CircleParticle.Provider::new);
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpecial(ModParticles.STARLIGHT_PARTICLE.get(), new StarlightParticle.Provider());
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.STAR_PARTICLE.get(), StarParticle.Provider::new);
});
@@ -77,19 +80,19 @@ public class LzxnoneTerrariaClient {
event.registerSpriteSet(ModParticles.INFLUX_WAVER_DROP_PARTICLE.get(), InfluxWaverDropParticle.Provider::new);
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), TerraBeamHitParticle.Provider::new);
event.registerSpecial(ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), new TerraBeamHitParticle.Provider());
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.EXCALIBUR_HIT_PARTICLE.get(), ExcaliburHitParticle.Provider::new);
event.registerSpecial(ModParticles.EXCALIBUR_HIT_PARTICLE.get(), new ExcaliburHitParticle.Provider());
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.TRUE_EXCALIBUR_HIT_PARTICLE.get(), TrueExcaliburHitParticle.Provider::new);
event.registerSpecial(ModParticles.TRUE_EXCALIBUR_HIT_PARTICLE.get(), new TrueExcaliburHitParticle.Provider());
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(), NightsEdgeHitParticle.Provider::new);
event.registerSpecial(ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(), new NightsEdgeHitParticle.Provider());
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.TRUE_NIGHTS_EDGE_HIT_PARTICLE.get(), TrueNightsEdgeHitParticle.Provider::new);
event.registerSpecial(ModParticles.TRUE_NIGHTS_EDGE_HIT_PARTICLE.get(), new TrueNightsEdgeHitParticle.Provider());
});
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.BLOOD_BUTCHERED_PARTICLE.get(), BloodButcheredParticle.Provider::new);
@@ -10,6 +10,21 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
public class RenderConfigs {
public static final ConfigBoolean ENABLE_DYNAMIC_LIGHTS = new ConfigBoolean(
"render.effects.dynamic_lights",
"render_effects_dynamic_lights",
true
);
public static final ConfigBoolean ENABLE_OUTLINE = new ConfigBoolean(
"render.effects.outline",
"render_effects_outline",
true
);
public static final ConfigBoolean ENABLE_BLOOM = new ConfigBoolean(
"render.effects.bloom",
"render_effects_bloom",
true
);
public static final ConfigBoolean ENABLE_RENDER_HAND = new ConfigBoolean(
"render.mixin.render_hand",
"render_mixin_render_hand",
@@ -49,6 +64,9 @@ public class RenderConfigs {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(
ENABLE_DYNAMIC_LIGHTS,
ENABLE_OUTLINE,
ENABLE_BLOOM,
ENABLE_RENDER_HAND,
ENABLE_RENDER_ITEM,
ENABLE_SETUP_ANIM,
@@ -20,6 +20,8 @@ public class ShaderRegistry {
private static ShaderInstance particleBloom;
private static ShaderInstance ironSparkParticle;
private static ShaderInstance circleParticle;
private static ShaderInstance superellipseParticle;
private static ShaderInstance nightsEdgeHitParticle;
private static ShaderInstance devilsDevastationEnergy;
public static ShaderInstance getBlur() {
@@ -50,6 +52,14 @@ public class ShaderRegistry {
return circleParticle;
}
public static ShaderInstance getSuperellipseParticle() {
return superellipseParticle;
}
public static ShaderInstance getNightsEdgeHitParticle() {
return nightsEdgeHitParticle;
}
public static ShaderInstance getDevilsDevastationEnergy() {
return devilsDevastationEnergy;
}
@@ -113,6 +123,22 @@ public class ShaderRegistry {
),
shader -> circleParticle = shader
);
event.registerShader(
new ShaderInstance(
event.getResourceProvider(),
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "superellipse_particle"),
DefaultVertexFormat.PARTICLE
),
shader -> superellipseParticle = shader
);
event.registerShader(
new ShaderInstance(
event.getResourceProvider(),
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "nights_edge_hit_particle"),
DefaultVertexFormat.PARTICLE
),
shader -> nightsEdgeHitParticle = shader
);
event.registerShader(
new ShaderInstance(
event.getResourceProvider(),
@@ -169,13 +169,14 @@ public class ClientDevilsDevastation {
Vector3f tipDir = dir.toVector3f().rotate(rotationUp);
poseStack.translate(-tipDir.x * 2, -tipDir.y * 2, -tipDir.z * 2);
poseStack.translate(-up.x * 0.5, -up.y * 0.5, -up.z * 0.5);
poseStack.translate(-up.x * 0, -up.y * 0, -up.z * 0);
poseStack.mulPose(rotationUp2);
poseStack.mulPose(rotationDir);
poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1]));
poseStack.mulPose(Axis.XP.rotationDegrees(xyRot[0]));
poseStack.mulPose(Axis.XP.rotationDegrees(-90));
poseStack.mulPose(Axis.ZP.rotationDegrees(-135));
poseStack.mulPose(Axis.YP.rotationDegrees(90));
renderEnergyWave(bufferSource, poseStack, projectile);
poseStack.popPose();
@@ -481,6 +482,9 @@ public class ClientDevilsDevastation {
poseStack.translate(0.0, 1.4, 0.2);
Matrix4f modelMatrix = new Matrix4f(poseStack.last().pose());
float partialTick = Minecraft.getInstance().getTimer()
.getGameTimeDeltaPartialTick(false);
float renderTime = entity.tickCount + partialTick;
//注入 uniform
Uniform modelMat = shader.getUniform("ModelMat");
@@ -508,9 +512,7 @@ public class ClientDevilsDevastation {
}
Uniform flowTimeUniform = shader.getUniform("FlowTime");
if (flowTimeUniform != null) {
float flowTime = entity.tickCount
+ Minecraft.getInstance().getTimer().getGameTimeDeltaPartialTick(false);
flowTimeUniform.set(flowTime);
flowTimeUniform.set(renderTime);
}
Uniform edgeColor0Uniform = shader.getUniform("EdgeColor0");
if (edgeColor0Uniform != null) {
@@ -1,6 +1,7 @@
package com.lzxnone.terraria.client.renderer;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.client.config.RenderConfigs;
import com.lzxnone.terraria.entity.IrisCompat;
import com.lzxnone.terraria.entity.beam.SwordBeam;
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
@@ -51,7 +52,7 @@ public class BloomRenderer {
public static void onRenderStage(RenderLevelStageEvent event) {
if(event.getStage() != RenderLevelStageEvent.Stage.AFTER_LEVEL) return;
//开启光影禁用
if(IrisCompat.isShaderPackInUse()) return;
if(!RenderConfigs.ENABLE_BLOOM.get() || IrisCompat.isShaderPackInUse()) return;
if(ShaderRegistry.getBlur() == null || ShaderRegistry.getComposite() == null) return;
if(!hasAnyGlow()) return;
@@ -1,9 +1,11 @@
package com.lzxnone.terraria.client.renderer;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.client.config.RenderConfigs;
import com.lzxnone.terraria.client.entity.projectile.ClientStaticProjectileRenderBehaviors;
import com.lzxnone.terraria.client.entity.summon.ClientStaticSummonRenderBehaviors;
import com.lzxnone.terraria.entity.IrisCompat;
import com.lzxnone.terraria.entity.beam.SwordBeam;
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.client.event.ShaderRegistry;
@@ -49,7 +51,7 @@ public class OutlineRenderer {
@SubscribeEvent
public static void onRenderStage(RenderLevelStageEvent event) {
if(event.getStage() != RenderLevelStageEvent.Stage.AFTER_LEVEL) return;
if(IrisCompat.isShaderPackInUse()) return;
if(!RenderConfigs.ENABLE_OUTLINE.get()) return;
if(ShaderRegistry.getOutline() == null
|| ShaderRegistry.getOutlineMask() == null) return;
if(!hasAnyOutline()) return;
@@ -113,10 +115,6 @@ public class OutlineRenderer {
if(texelSize != null) {
texelSize.set(1.0f / outlineTarget.viewWidth, 1.0f / outlineTarget.viewHeight);
}
Uniform outlineColor = shader.getUniform("OutlineColor");
if(outlineColor != null) {
outlineColor.set(0.8f, 0.176f, 0.78f, 1.0f);
}
Uniform radius = shader.getUniform("Radius");
if(radius != null) {
radius.set(OUTLINE_RADIUS);
@@ -181,12 +179,13 @@ public class OutlineRenderer {
poseStack.pushPose();
try {
poseStack.translate(camX, camY, camZ);
setMaskColor(entity);
renderEntityMask(entity, entityYaw, partialTick, poseStack, bufferSource);
maskBuffers.endBatch();
}finally {
poseStack.popPose();
}
}
maskBuffers.endBatch();
}finally {
RenderSystem.setProjectionMatrix(previousProjection, previousSorting);
modelViewStack.popMatrix();
@@ -211,6 +210,34 @@ public class OutlineRenderer {
return false;
}
private static void setMaskColor(Entity entity) {
Uniform color = ShaderRegistry.getOutlineMask().getUniform("MaskColor");
if(color == null) return;
if(entity instanceof StaticProjectile projectile) {
color.set(
projectile.getEntityData().get(StaticProjectile.OUTLINE_COLOR_R),
projectile.getEntityData().get(StaticProjectile.OUTLINE_COLOR_G),
projectile.getEntityData().get(StaticProjectile.OUTLINE_COLOR_B),
projectile.getEntityData().get(StaticProjectile.OUTLINE_COLOR_A)
);
}else if(entity instanceof StaticSummon summon) {
color.set(
summon.getEntityData().get(StaticSummon.OUTLINE_COLOR_R),
summon.getEntityData().get(StaticSummon.OUTLINE_COLOR_G),
summon.getEntityData().get(StaticSummon.OUTLINE_COLOR_B),
summon.getEntityData().get(StaticSummon.OUTLINE_COLOR_A)
);
}else if(entity instanceof SwordBeam beam) {
color.set(
beam.getEntityData().get(SwordBeam.OUTLINE_COLOR_R),
beam.getEntityData().get(SwordBeam.OUTLINE_COLOR_G),
beam.getEntityData().get(SwordBeam.OUTLINE_COLOR_B),
beam.getEntityData().get(SwordBeam.OUTLINE_COLOR_A)
);
}
}
private static void renderEntityMask(Entity entity, float entityYaw, float partialTick,
PoseStack poseStack, MultiBufferSource bufferSource) {
if(entity instanceof StaticProjectile projectile) {
@@ -1,6 +1,7 @@
package com.lzxnone.terraria.dynamic_lights;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.client.config.RenderConfigs;
import com.lzxnone.terraria.entity.beam.SwordBeam;
import com.lzxnone.terraria.entity.beam.SwordBeamBehaviors;
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
@@ -25,6 +26,7 @@ public class MEntityLuminance implements EntityLuminance {
@Override
public @Range(from = 0, to = 15) int getLuminance(@NonNull ItemLightSourceManager itemLightSourceManager, @NonNull Entity entity) {
if(!RenderConfigs.ENABLE_DYNAMIC_LIGHTS.get()) return 0;
if(entity instanceof StaticProjectile projectile) {
switch(projectile.getEntityData().get(StaticProjectile.BEHAVIOR)) {
case StaticProjectileBehaviors.ENCHANTED_SWORD_BEAM,
@@ -50,6 +50,14 @@ public class SwordBeam extends Entity {
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Boolean> OUTLINE =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_R =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_G =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_B =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_A =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Integer> AGE =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> LIFETIME =
@@ -250,6 +258,10 @@ public class SwordBeam extends Entity {
builder.define(RIGHT_HAND, true);
builder.define(INFLATE, 0.0f);
builder.define(OUTLINE, false);
builder.define(OUTLINE_COLOR_R, 1.0f);
builder.define(OUTLINE_COLOR_G, 1.0f);
builder.define(OUTLINE_COLOR_B, 1.0f);
builder.define(OUTLINE_COLOR_A, 1.0f);
builder.define(COLOR0, new Vector3f(1.0f, 1.0f, 1.0f));
builder.define(COLOR1, new Vector3f(1.0f, 1.0f, 1.0f));
builder.define(COLOR2, new Vector3f(1.0f, 1.0f, 1.0f));
@@ -269,6 +281,10 @@ public class SwordBeam extends Entity {
tag.putBoolean("rightHand", this.entityData.get(RIGHT_HAND));
tag.putFloat("inflate", this.entityData.get(INFLATE));
tag.putBoolean("outline", this.entityData.get(OUTLINE));
tag.putFloat("outlineColorR", this.entityData.get(OUTLINE_COLOR_R));
tag.putFloat("outlineColorG", this.entityData.get(OUTLINE_COLOR_G));
tag.putFloat("outlineColorB", this.entityData.get(OUTLINE_COLOR_B));
tag.putFloat("outlineColorA", this.entityData.get(OUTLINE_COLOR_A));
Vector3f c0 = this.entityData.get(COLOR0);
tag.putFloat("color0R", c0.x);
tag.putFloat("color0G", c0.y);
@@ -301,6 +317,10 @@ public class SwordBeam extends Entity {
if(tag.contains("rightHand")) this.entityData.set(RIGHT_HAND, tag.getBoolean("rightHand"));
if(tag.contains("inflate")) this.entityData.set(INFLATE, tag.getFloat("inflate"));
if(tag.contains("outline")) this.entityData.set(OUTLINE, tag.getBoolean("outline"));
if(tag.contains("outlineColorR")) this.entityData.set(OUTLINE_COLOR_R, tag.getFloat("outlineColorR"));
if(tag.contains("outlineColorG")) this.entityData.set(OUTLINE_COLOR_G, tag.getFloat("outlineColorG"));
if(tag.contains("outlineColorB")) this.entityData.set(OUTLINE_COLOR_B, tag.getFloat("outlineColorB"));
if(tag.contains("outlineColorA")) this.entityData.set(OUTLINE_COLOR_A, tag.getFloat("outlineColorA"));
if(tag.contains("color0R")) {
this.entityData.set(COLOR0, new Vector3f(
tag.getFloat("color0R"), tag.getFloat("color0G"), tag.getFloat("color0B")
@@ -71,6 +71,14 @@ public class StaticProjectile extends Projectile {
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Boolean> OUTLINE =
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_R =
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_G =
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_B =
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_A =
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Integer> AGE =
SynchedEntityData.defineId(StaticProjectile.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> LIFETIME =
@@ -133,6 +141,10 @@ public class StaticProjectile extends Projectile {
builder.define(COLOR_A, 1.0f);
builder.define(GLOW, false);
builder.define(OUTLINE, false);
builder.define(OUTLINE_COLOR_R, 1.0f);
builder.define(OUTLINE_COLOR_G, 1.0f);
builder.define(OUTLINE_COLOR_B, 1.0f);
builder.define(OUTLINE_COLOR_A, 1.0f);
builder.define(AGE, 0);
builder.define(LIFETIME, 60);
builder.define(EXPRESSION_X, "0");
@@ -235,6 +247,10 @@ public class StaticProjectile extends Projectile {
tag.putFloat("colorA", this.entityData.get(COLOR_A));
tag.putBoolean("glow", this.entityData.get(GLOW));
tag.putBoolean("outline", this.entityData.get(OUTLINE));
tag.putFloat("outlineColorR", this.entityData.get(OUTLINE_COLOR_R));
tag.putFloat("outlineColorG", this.entityData.get(OUTLINE_COLOR_G));
tag.putFloat("outlineColorB", this.entityData.get(OUTLINE_COLOR_B));
tag.putFloat("outlineColorA", this.entityData.get(OUTLINE_COLOR_A));
tag.putInt("age", this.entityData.get(AGE));
tag.putInt("lifetime", this.entityData.get(LIFETIME));
tag.putString("expressionX", this.entityData.get(EXPRESSION_X));
@@ -297,6 +313,10 @@ public class StaticProjectile extends Projectile {
if(tag.contains("colorA")) this.entityData.set(COLOR_A, tag.getFloat("colorA"));
if(tag.contains("glow")) this.entityData.set(GLOW, tag.getBoolean("glow"));
if(tag.contains("outline")) this.entityData.set(OUTLINE, tag.getBoolean("outline"));
if(tag.contains("outlineColorR")) this.entityData.set(OUTLINE_COLOR_R, tag.getFloat("outlineColorR"));
if(tag.contains("outlineColorG")) this.entityData.set(OUTLINE_COLOR_G, tag.getFloat("outlineColorG"));
if(tag.contains("outlineColorB")) this.entityData.set(OUTLINE_COLOR_B, tag.getFloat("outlineColorB"));
if(tag.contains("outlineColorA")) this.entityData.set(OUTLINE_COLOR_A, tag.getFloat("outlineColorA"));
if(tag.contains("age")) this.entityData.set(AGE, tag.getInt("age"));
if(tag.contains("lifetime")) this.entityData.set(LIFETIME, tag.getInt("lifetime"));
if(tag.contains("expressionX")) this.entityData.set(EXPRESSION_X, tag.getString("expressionX"));
@@ -64,6 +64,14 @@ public class StaticSummon extends Entity {
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Boolean> OUTLINE =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_R =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_G =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_B =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Float> OUTLINE_COLOR_A =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Integer> AGE =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> LIFETIME =
@@ -134,6 +142,10 @@ public class StaticSummon extends Entity {
builder.define(COLOR_A, 1.0f);
builder.define(GLOW, false);
builder.define(OUTLINE, false);
builder.define(OUTLINE_COLOR_R, 1.0f);
builder.define(OUTLINE_COLOR_G, 1.0f);
builder.define(OUTLINE_COLOR_B, 1.0f);
builder.define(OUTLINE_COLOR_A, 1.0f);
builder.define(AGE, 0);
builder.define(LIFETIME, 100);
builder.define(OWNER, Optional.empty());
@@ -188,6 +200,10 @@ public class StaticSummon extends Entity {
tag.putFloat("colorA", this.entityData.get(COLOR_A));
tag.putBoolean("glow", this.entityData.get(GLOW));
tag.putBoolean("outline", this.entityData.get(OUTLINE));
tag.putFloat("outlineColorR", this.entityData.get(OUTLINE_COLOR_R));
tag.putFloat("outlineColorG", this.entityData.get(OUTLINE_COLOR_G));
tag.putFloat("outlineColorB", this.entityData.get(OUTLINE_COLOR_B));
tag.putFloat("outlineColorA", this.entityData.get(OUTLINE_COLOR_A));
tag.putInt("age", this.entityData.get(AGE));
tag.putInt("lifetime", this.entityData.get(LIFETIME));
if(getOwner() != null) tag.putUUID("owner", getOwner().getUUID());
@@ -228,6 +244,10 @@ public class StaticSummon extends Entity {
if(tag.contains("colorA")) this.entityData.set(COLOR_A, tag.getFloat("colorA"));
if(tag.contains("glow")) this.entityData.set(GLOW, tag.getBoolean("glow"));
if(tag.contains("outline")) this.entityData.set(OUTLINE, tag.getBoolean("outline"));
if(tag.contains("outlineColorR")) this.entityData.set(OUTLINE_COLOR_R, tag.getFloat("outlineColorR"));
if(tag.contains("outlineColorG")) this.entityData.set(OUTLINE_COLOR_G, tag.getFloat("outlineColorG"));
if(tag.contains("outlineColorB")) this.entityData.set(OUTLINE_COLOR_B, tag.getFloat("outlineColorB"));
if(tag.contains("outlineColorA")) this.entityData.set(OUTLINE_COLOR_A, tag.getFloat("outlineColorA"));
if(tag.contains("age")) this.entityData.set(AGE, tag.getInt("age"));
if(tag.contains("lifetime")) this.entityData.set(LIFETIME, tag.getInt("lifetime"));
if(tag.contains("owner")) {
@@ -9,6 +9,7 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.weapon.MagicWeapon;
import com.lzxnone.terraria.particle.ModParticles;
import com.lzxnone.terraria.particle.StarlightParticleOptions;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
@@ -51,6 +52,16 @@ public class StellarTune extends MagicWeapon {
public static final ConfigDouble TARGET_RANGE = new ConfigDouble("weapon.stellar_tune.target_range", "stellar_tune_target_range", 32.0D, 0.0D, 128.0D);
public static final ConfigInt ARRIVAL_TIME = new ConfigInt("weapon.stellar_tune.arrival_time", "stellar_tune_arrival_time", 10, 1, 72000);
public static final Vector3f OFFSET = new Vector3f(-0.3F, -0.1F, 1.5F);
public static final StarlightParticleOptions PARTICLE = new StarlightParticleOptions(
1.0f,
0.35f,
40,
new Vector3f[]{
new Vector3f(1.00f, 0.55f, 0.76f), // 粉红
new Vector3f(0.56f, 0.76f, 1.00f), // 粉蓝
new Vector3f(1.00f, 0.87f, 0.54f) // 粉黄
}
);
private static final double WAVE_AMPLITUDE = 2.0D;
private static final double HITBOX_INFLATE = 1.0D;
@@ -96,6 +107,15 @@ public class StellarTune extends MagicWeapon {
public void onDied(StaticProjectile projectile) {
if(projectile.level() instanceof ServerLevel serverLevel) {
ParticleUtil.addParticles(serverLevel, ModParticles.STAR_PARTICLE.get(), projectile.position(), new Vec3(0.5D, 0.5D, 0.5D), 0.25D, 25);
int count = 4 + projectile.getRandom().nextInt(5);
ParticleUtil.addParticles(
serverLevel,
PARTICLE,
projectile.position(),
new Vec3(0.35D, 0.35D, 0.35D),
0.16D,
count
);
}
projectile.discard();
}
@@ -357,6 +357,10 @@ public class DevilsDevastation extends MeleeWeapon {
summon.getEntityData().set(StaticSummon.LIFETIME, STUCK_LIFETIME.get());
summon.getEntityData().set(StaticSummon.GLOW, true);
summon.getEntityData().set(StaticSummon.OUTLINE, true);
summon.getEntityData().set(StaticSummon.OUTLINE_COLOR_R, 0.8f);
summon.getEntityData().set(StaticSummon.OUTLINE_COLOR_G, 0.176f);
summon.getEntityData().set(StaticSummon.OUTLINE_COLOR_B, 0.78f);
summon.getEntityData().set(StaticSummon.OUTLINE_COLOR_A, 1.0f);
CompoundTag customData = new CompoundTag();
Vec3 deltaPos = pos.subtract(target.position());
@@ -413,14 +417,14 @@ public class DevilsDevastation extends MeleeWeapon {
CircleParticleOptions circleParticleOptions;
if(projectile.getRandom().nextInt(2) == 0) {
ironSparkParticleOptions = new IronSparkParticleOptions(
0.1f, 40, 4.0f, new Vector3f(0.729f, 0.396f, 0.345f), dirs[0].mul(0.2f), dirs[2]
0.15f, 40, 10.0f, new Vector3f(0.729f, 0.396f, 0.345f), dirs[0].mul(0.6f), dirs[2]
);
circleParticleOptions = new CircleParticleOptions(
0.1f, 40, new Vector3f(0.729f, 0.396f, 0.345f)
);
}else {
ironSparkParticleOptions = new IronSparkParticleOptions(
0.1f, 40, 4.0f, new Vector3f(0.8f, 0.176f, 0.78f), dirs[0].mul(0.2f), dirs[2]
0.15f, 40, 10.0f, new Vector3f(0.8f, 0.176f, 0.78f), dirs[0].mul(0.6f), dirs[2]
);
circleParticleOptions = new CircleParticleOptions(
0.1f, 40, new Vector3f(0.8f, 0.176f, 0.78f)
@@ -1,15 +1,20 @@
package com.lzxnone.terraria.particle;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class ExcaliburHitParticle extends TextureSheetParticle {
private final float baseSize;
protected ExcaliburHitParticle(ClientLevel level, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) {
double xSpeed, double ySpeed, double zSpeed) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.hasPhysics = false;
@@ -25,21 +30,51 @@ public class ExcaliburHitParticle extends TextureSheetParticle {
this.alpha = 1.0f;
this.lifetime = 10;
this.pickSprite(spriteSet);
}
@Override
public void tick() {
super.tick();
}
float lifeRatio = (float) this.age / (float) this.lifetime;
if(lifeRatio <= 0.25f) {
this.quadSize = (lifeRatio / 0.25f) * this.baseSize;
}else if(lifeRatio >= 0.75f) {
this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize;
}else {
this.quadSize = this.baseSize;
@Override
public void render(VertexConsumer buffer, Camera camera, float partialTick) {
float lifeRatio = Mth.clamp((this.age + partialTick) / (float) this.lifetime, 0.0f, 1.0f);
float grow = (float) Mth.smoothstep(Mth.clamp(lifeRatio / 0.20f, 0.0f, 1.0f));
float shrink = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.60f) / 0.40f, 0.0f, 1.0f)
);
float fade = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.50f) / 0.50f, 0.0f, 1.0f)
);
float size = this.baseSize * grow * shrink;
if(size <= 0.001f || fade <= 0.001f) {
return;
}
float cx = (float) (Mth.lerp(partialTick, this.xo, this.x) - camera.getPosition().x);
float cy = (float) (Mth.lerp(partialTick, this.yo, this.y) - camera.getPosition().y);
float cz = (float) (Mth.lerp(partialTick, this.zo, this.z) - camera.getPosition().z);
Quaternionf rotation = new Quaternionf(camera.rotation());
Vector3f[] corners = {
new Vector3f(1.0f, -1.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, -1.0f, 0.0f)
};
float[][] uvs = {
{1.0f, 1.0f},
{1.0f, 0.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
};
for(int i = 0; i < corners.length; i++) {
Vector3f corner = corners[i].rotate(rotation).mul(size).add(cx, cy, cz);
buffer.addVertex(corner.x, corner.y, corner.z)
.setUv(uvs[i][0], uvs[i][1])
.setColor(1.0f, 1.0f, 1.0f, fade)
.setLight(LightTexture.FULL_BRIGHT);
}
}
@@ -50,21 +85,15 @@ public class ExcaliburHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
return ModParticleRenderTypes.EXCALIBUR_HIT_PARTICLE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet spriteSet;
public Provider(SpriteSet spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel level,
double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new ExcaliburHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
return new ExcaliburHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
}
}
}
@@ -33,12 +33,13 @@ public class IronSparkParticle extends TextureSheetParticle {
this.lifetime = options.initLifetime + this.random.nextInt(options.initLifetime / 2);
this.dir = new Vector3f(options.dir).normalize();
Vector3f velocity = new Vector3f(options.dir);
this.dir = new Vector3f(velocity).normalize();
this.right = new Vector3f(options.right).normalize();
this.xd = dir.x;
this.yd = dir.y;
this.zd = dir.z;
this.xd = velocity.x;
this.yd = velocity.y;
this.zd = velocity.z;
this.pickSprite(spriteSet);
}
@@ -1,19 +1,172 @@
package com.lzxnone.terraria.particle;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.shaders.Uniform;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.lzxnone.terraria.client.event.ShaderRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureManager;
import org.joml.Vector3f;
public final class ModParticleRenderTypes {
private static final float QUARTER_TURN = (float) Math.PI / 4.0f;
private static final SuperellipseStyle STARLIGHT_STYLE = new SuperellipseStyle(
0.25f, 0.90f, 0.90f, 0.0f,
new Vector3f(1.0f), new Vector3f(1.0f), new Vector3f(0.38f), 0.68f,
0.08f, 0.68f, 0.66f, 1.0f,
0.10f, 1.0f,
2.15f, 1.18f, 1.14f, 0.48f, 0.34f
);
private static final SuperellipseStyle TERRA_STYLE = new SuperellipseStyle(
0.80f, 0.82f, 0.62f, 0.0f,
new Vector3f(1.00f, 1.00f, 0.96f),
new Vector3f(0.30f, 1.00f, 0.50f),
new Vector3f(0.01f, 0.82f, 0.20f), 0.0f,
0.16f, 0.58f, 0.56f, 0.96f,
0.42f, 0.98f,
2.45f, 1.30f, 1.14f, 0.38f, 0.34f
);
private static final SuperellipseStyle TRUE_NIGHTS_EDGE_STYLE = new SuperellipseStyle(
1.0f / 3.0f, 0.64f, 0.64f, QUARTER_TURN,
new Vector3f(0.46f, 0.96f, 0.25f),
new Vector3f(0.08f, 0.62f, 0.13f),
new Vector3f(0.01f, 0.25f, 0.045f), 0.0f,
0.16f, 0.68f, 0.66f, 1.0f,
0.18f, 1.0f,
1.55f, 1.12f, 1.14f, 0.48f, 0.34f
);
private static final SuperellipseStyle TRUE_EXCALIBUR_STYLE = new SuperellipseStyle(
0.50f, 0.58f, 0.58f, QUARTER_TURN,
new Vector3f(1.00f, 0.56f, 0.79f),
new Vector3f(0.96f, 0.11f, 0.52f),
new Vector3f(0.40f, 0.018f, 0.19f), 0.0f,
0.15f, 0.67f, 0.65f, 1.0f,
0.16f, 1.0f,
1.48f, 1.12f, 1.14f, 0.50f, 0.35f
);
private static final SuperellipseStyle EXCALIBUR_STYLE = new SuperellipseStyle(
0.80f, 0.43f, 0.82f, 0.0f,
new Vector3f(1.00f, 0.94f, 0.36f),
new Vector3f(1.00f, 0.62f, 0.025f),
new Vector3f(0.50f, 0.20f, 0.005f), 0.0f,
0.15f, 0.68f, 0.66f, 1.0f,
0.16f, 1.0f,
1.52f, 1.12f, 1.14f, 0.50f, 0.35f
);
public static final ParticleRenderType STARLIGHT_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
return beginSuperellipse(tesselator, STARLIGHT_STYLE);
}
@Override
public String toString() {
return "lzxnoneterraria:starlight_particle";
}
@Override
public boolean isTranslucent() {
return false;
}
};
public static final ParticleRenderType TERRA_BEAM_HIT_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
return beginSuperellipse(tesselator, TERRA_STYLE);
}
@Override
public String toString() {
return "lzxnoneterraria:terra_beam_hit_particle";
}
@Override
public boolean isTranslucent() {
return false;
}
};
public static final ParticleRenderType TRUE_NIGHTS_EDGE_HIT_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
return beginSuperellipse(tesselator, TRUE_NIGHTS_EDGE_STYLE);
}
@Override
public String toString() {
return "lzxnoneterraria:true_nights_edge_hit_particle";
}
@Override
public boolean isTranslucent() {
return false;
}
};
public static final ParticleRenderType TRUE_EXCALIBUR_HIT_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
return beginSuperellipse(tesselator, TRUE_EXCALIBUR_STYLE);
}
@Override
public String toString() {
return "lzxnoneterraria:true_excalibur_hit_particle";
}
@Override
public boolean isTranslucent() {
return false;
}
};
public static final ParticleRenderType EXCALIBUR_HIT_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
return beginSuperellipse(tesselator, EXCALIBUR_STYLE);
}
@Override
public String toString() {
return "lzxnoneterraria:excalibur_hit_particle";
}
@Override
public boolean isTranslucent() {
return false;
}
};
public static final ParticleRenderType NIGHTS_EDGE_HIT_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
RenderSystem.enableBlend();
RenderSystem.depthMask(true);
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
RenderSystem.setShader(ShaderRegistry::getNightsEdgeHitParticle);
return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
}
@Override
public String toString() {
return "lzxnoneterraria:nights_edge_hit_particle";
}
@Override
public boolean isTranslucent() {
return false;
}
};
public static final ParticleRenderType IRON_SPARK_PARTICLE = new ParticleRenderType() {
@Override
public BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) {
@@ -78,5 +231,66 @@ public final class ModParticleRenderTypes {
}
};
private static BufferBuilder beginSuperellipse(Tesselator tesselator, SuperellipseStyle style) {
RenderSystem.enableBlend();
RenderSystem.depthMask(true);
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
ShaderInstance shader = ShaderRegistry.getSuperellipseParticle();
RenderSystem.setShader(() -> shader);
set(shader, "ShapePower", style.power);
set(shader, "ShapeRadius", style.radiusX, style.radiusY);
set(shader, "ShapeRotation", style.rotation);
set(shader, "CoreColor", style.coreColor);
set(shader, "MiddleColor", style.middleColor);
set(shader, "EdgeColor", style.edgeColor);
set(shader, "CoreWhiteMix", style.coreWhiteMix);
set(shader, "FirstGradient", style.firstGradientStart, style.firstGradientEnd);
set(shader, "SecondGradient", style.secondGradientStart, style.secondGradientEnd);
set(shader, "BrightnessGradient", style.brightnessGradientStart, style.brightnessGradientEnd);
set(shader, "Brightness", style.coreBrightness, style.edgeBrightness);
set(shader, "AuraScale", style.auraScale);
set(shader, "AuraBrightness", style.auraBrightness);
set(shader, "AuraAlpha", style.auraAlpha);
return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
}
private static void set(ShaderInstance shader, String name, float value) {
Uniform uniform = shader.getUniform(name);
if(uniform != null) uniform.set(value);
}
private static void set(ShaderInstance shader, String name, float x, float y) {
Uniform uniform = shader.getUniform(name);
if(uniform != null) uniform.set(x, y);
}
private static void set(ShaderInstance shader, String name, Vector3f value) {
Uniform uniform = shader.getUniform(name);
if(uniform != null) uniform.set(value.x, value.y, value.z);
}
private record SuperellipseStyle(
float power,
float radiusX,
float radiusY,
float rotation,
Vector3f coreColor,
Vector3f middleColor,
Vector3f edgeColor,
float coreWhiteMix,
float firstGradientStart,
float firstGradientEnd,
float secondGradientStart,
float secondGradientEnd,
float brightnessGradientStart,
float brightnessGradientEnd,
float coreBrightness,
float edgeBrightness,
float auraScale,
float auraBrightness,
float auraAlpha
) {}
private ModParticleRenderTypes() {}
}
@@ -82,6 +82,17 @@ public class ModParticles {
return CircleParticleOptions.STREAM_CODEC;
}
});
public static final Supplier<ParticleType<StarlightParticleOptions>> STARLIGHT_PARTICLE =
PARTICLE_TYPES.register("starlight_particle", () -> new ParticleType<>(false) {
@Override
public MapCodec<StarlightParticleOptions> codec() {
return StarlightParticleOptions.CODEC;
}
@Override
public StreamCodec<? super RegistryFriendlyByteBuf, StarlightParticleOptions> streamCodec() {
return StarlightParticleOptions.STREAM_CODEC;
}
});
public static final Supplier<SimpleParticleType> STAR_PARTICLE =
PARTICLE_TYPES.register("star_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> EXPLODE_PARTICLE =
@@ -1,16 +1,20 @@
package com.lzxnone.terraria.particle;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class NightsEdgeHitParticle extends TextureSheetParticle {
private final float baseSize;
private final SpriteSet spriteSet;
protected NightsEdgeHitParticle(ClientLevel level, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) {
double xSpeed, double ySpeed, double zSpeed) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.hasPhysics = false;
@@ -26,25 +30,52 @@ public class NightsEdgeHitParticle extends TextureSheetParticle {
this.alpha = 1.0f;
this.lifetime = 10;
this.spriteSet = spriteSet;
this.setSpriteFromAge(spriteSet);
}
@Override
public void tick() {
super.tick();
float lifeRatio = (float) this.age / (float) this.lifetime;
if(lifeRatio <= 0.25f) {
this.quadSize = (lifeRatio / 0.25f) * this.baseSize;
}else if(lifeRatio >= 0.75f) {
this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize;
}else {
this.quadSize = this.baseSize;
}
this.setSpriteFromAge(this.spriteSet);
@Override
public void render(VertexConsumer buffer, Camera camera, float partialTick) {
float lifeRatio = Mth.clamp((this.age + partialTick) / (float) this.lifetime, 0.0f, 1.0f);
float grow = (float) Mth.smoothstep(Mth.clamp(lifeRatio / 0.22f, 0.0f, 1.0f));
float shrink = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.70f) / 0.30f, 0.0f, 1.0f)
);
float fade = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.55f) / 0.45f, 0.0f, 1.0f)
);
float size = this.baseSize * grow * shrink;
if(size <= 0.001f || fade <= 0.001f) {
return;
}
float cx = (float) (Mth.lerp(partialTick, this.xo, this.x) - camera.getPosition().x);
float cy = (float) (Mth.lerp(partialTick, this.yo, this.y) - camera.getPosition().y);
float cz = (float) (Mth.lerp(partialTick, this.zo, this.z) - camera.getPosition().z);
Quaternionf rotation = new Quaternionf(camera.rotation());
Vector3f[] corners = {
new Vector3f(1.0f, -1.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, -1.0f, 0.0f)
};
float[][] uvs = {
{1.0f, 1.0f},
{1.0f, 0.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
};
for(int i = 0; i < corners.length; i++) {
Vector3f corner = corners[i].rotate(rotation).mul(size).add(cx, cy, cz);
buffer.addVertex(corner.x, corner.y, corner.z)
.setUv(uvs[i][0], uvs[i][1])
.setColor(1.0f, 1.0f, 1.0f, fade)
.setLight(LightTexture.FULL_BRIGHT);
}
}
@Override
@@ -54,21 +85,15 @@ public class NightsEdgeHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
return ModParticleRenderTypes.NIGHTS_EDGE_HIT_PARTICLE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet spriteSet;
public Provider(SpriteSet spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel level,
double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new NightsEdgeHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
return new NightsEdgeHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
}
}
}
@@ -0,0 +1,115 @@
package com.lzxnone.terraria.particle;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.TextureSheetParticle;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class StarlightParticle extends TextureSheetParticle {
private static final Vector3f DEFAULT_COLOR = new Vector3f(1.0f, 1.0f, 1.0f);
private final float baseSize;
private final float rotSpeed;
protected StarlightParticle(ClientLevel level, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed,
StarlightParticleOptions options) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.hasPhysics = false;
this.friction = 0.9f;
this.gravity = 0.0f;
this.xd = xSpeed;
this.yd = ySpeed;
this.zd = zSpeed;
float initSize = Math.max(0.0f, options.initSize);
this.baseSize = initSize + this.random.nextFloat() * initSize;
this.quadSize = this.baseSize;
this.roll = this.random.nextFloat() * Mth.TWO_PI;
this.oRoll = this.roll;
this.rotSpeed = (this.random.nextFloat() - 0.5f) * options.initRotSpeed;
int initLifetime = Math.max(1, options.initLifetime);
this.lifetime = initLifetime + this.random.nextInt(Math.max(1, initLifetime / 2));
Vector3f[] palette = options.colors;
Vector3f color = palette != null && palette.length > 0
? palette[this.random.nextInt(palette.length)]
: DEFAULT_COLOR;
this.rCol = color.x;
this.gCol = color.y;
this.bCol = color.z;
}
@Override
public void tick() {
super.tick();
this.oRoll = this.roll;
this.roll += this.rotSpeed;
float lifeRatio = Mth.clamp(this.age / (float) this.lifetime, 0.0f, 1.0f);
this.quadSize = this.baseSize * (1.0f - lifeRatio);
this.alpha = 1.0f - lifeRatio;
}
@Override
public void render(VertexConsumer buffer, Camera camera, float partialTick) {
float size = this.getQuadSize(partialTick);
float alpha = Mth.lerp(partialTick, Math.min(1.0f, this.alpha + 1.0f / this.lifetime), this.alpha);
if(size <= 0.001f || alpha <= 0.001f) {
return;
}
float cx = (float) (Mth.lerp(partialTick, this.xo, this.x) - camera.getPosition().x);
float cy = (float) (Mth.lerp(partialTick, this.yo, this.y) - camera.getPosition().y);
float cz = (float) (Mth.lerp(partialTick, this.zo, this.z) - camera.getPosition().z);
Quaternionf rotation = new Quaternionf(camera.rotation());
rotation.rotateZ(Mth.lerp(partialTick, this.oRoll, this.roll));
Vector3f[] corners = {
new Vector3f(1.0f, -1.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, -1.0f, 0.0f)
};
float[][] uvs = {
{1.0f, 1.0f},
{1.0f, 0.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
};
for(int i = 0; i < corners.length; i++) {
Vector3f corner = corners[i].rotate(rotation).mul(size).add(cx, cy, cz);
buffer.addVertex(corner.x, corner.y, corner.z)
.setUv(uvs[i][0], uvs[i][1])
.setColor(this.rCol, this.gCol, this.bCol, alpha)
.setLight(LightTexture.FULL_BRIGHT);
}
}
@Override
public int getLightColor(float partialTick) {
return LightTexture.FULL_BRIGHT;
}
@Override
public ParticleRenderType getRenderType() {
return ModParticleRenderTypes.STARLIGHT_PARTICLE;
}
public static class Provider implements ParticleProvider<StarlightParticleOptions> {
@Override
public Particle createParticle(StarlightParticleOptions options, ClientLevel level,
double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new StarlightParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, options);
}
}
}
@@ -0,0 +1,86 @@
package com.lzxnone.terraria.particle;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import org.joml.Vector3f;
import java.util.Arrays;
public class StarlightParticleOptions implements ParticleOptions {
public final float initSize;
public final float initRotSpeed;
public final int initLifetime;
public final Vector3f[] colors;
public StarlightParticleOptions(float initSize, float initRotSpeed, int initLifetime,
Vector3f[] colors) {
this.initSize = initSize;
this.initRotSpeed = initRotSpeed;
this.initLifetime = initLifetime;
this.colors = colors;
}
public StarlightParticleOptions() {
this(0.05f, 0.5f, 40, null);
}
@Override
public ParticleType<?> getType() {
return ModParticles.STARLIGHT_PARTICLE.get();
}
private static final Codec<Vector3f[]> COLORS_CODEC =
Codec.FLOAT.listOf().listOf().xmap(
lists -> lists.stream()
.map(l -> new Vector3f(l.get(0), l.get(1), l.get(2)))
.toArray(Vector3f[]::new),
arr -> Arrays.stream(arr).map(c -> java.util.List.of(c.x, c.y, c.z)).toList()
);
public static final MapCodec<StarlightParticleOptions> CODEC = RecordCodecBuilder.mapCodec(instance ->
instance.group(
Codec.FLOAT.optionalFieldOf("initSize", 0.05f).forGetter(o -> o.initSize),
Codec.FLOAT.optionalFieldOf("initRotSpeed", 0.5f).forGetter(o -> o.initRotSpeed),
Codec.INT.optionalFieldOf("initLifetime", 40).forGetter(o -> o.initLifetime),
COLORS_CODEC.optionalFieldOf("colors", null).forGetter(o -> o.colors)
).apply(instance, StarlightParticleOptions::new)
);
public static final StreamCodec<RegistryFriendlyByteBuf, StarlightParticleOptions> STREAM_CODEC =
new StreamCodec<>() {
@Override
public StarlightParticleOptions decode(RegistryFriendlyByteBuf buf) {
float size = buf.readFloat();
float rotSpeed = buf.readFloat();
int lifetime = buf.readInt();
int colorCount = buf.readVarInt();
Vector3f[] colors = colorCount > 0 ? new Vector3f[colorCount] : null;
for(int i = 0; i < colorCount; i++) {
colors[i] = new Vector3f(buf.readFloat(), buf.readFloat(), buf.readFloat());
}
return new StarlightParticleOptions(size, rotSpeed, lifetime, colors);
}
@Override
public void encode(RegistryFriendlyByteBuf buf, StarlightParticleOptions options) {
buf.writeFloat(options.initSize);
buf.writeFloat(options.initRotSpeed);
buf.writeInt(options.initLifetime);
if(options.colors != null) {
buf.writeVarInt(options.colors.length);
for(Vector3f color : options.colors) {
buf.writeFloat(color.x);
buf.writeFloat(color.y);
buf.writeFloat(color.z);
}
}else {
buf.writeVarInt(0);
}
}
};
}
@@ -6,17 +6,22 @@ import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class TerraBeamHitParticle extends TextureSheetParticle {
private final float rotSpeed;
private final float baseSize;
private final SpriteSet spriteSet;
private final Float INCREASE = 0.5f;
private final Float MUL = 5.0f;
private static final float QUAD_SIZE_MULTIPLIER = 2.5f;
private static final float OFFSET_X_MULTIPLIER = 1.35f;
private static final float OFFSET_Y_MULTIPLIER = 1.05f;
private static final float QUAD_OPACITY = 0.55f;
private static final float GROW_END = 0.15f;
private static final float SHRINK_START = 0.22f;
private static final float FADE_START = 0.35f;
protected TerraBeamHitParticle(ClientLevel level, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) {
double xSpeed, double ySpeed, double zSpeed) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.hasPhysics = false;
@@ -26,49 +31,81 @@ public class TerraBeamHitParticle extends TextureSheetParticle {
this.yd = ySpeed;
this.zd = zSpeed;
this.baseSize = 0.2f + (this.random.nextFloat() * 0.2f);
this.baseSize = 0.18f;
this.quadSize = baseSize;
this.roll = this.random.nextFloat() * ((float)Math.PI * 2F);
this.roll = 0;
this.oRoll = this.roll;
this.rotSpeed = 0;
this.lifetime = 15;
this.spriteSet = spriteSet;
this.setSpriteFromAge(spriteSet);
}
@Override
public void tick() {
super.tick();
this.oRoll = this.roll;
this.roll += this.rotSpeed;
this.setSpriteFromAge(this.spriteSet);
float lifeRatio = (float) this.age / (float) this.lifetime;
if(lifeRatio <= INCREASE) {
// [0, INCREASE] 从 0 线性增长到 baseSize * MUL
this.quadSize = this.baseSize * MUL * (lifeRatio / INCREASE);
this.alpha = 1.0F;
}else {
// [INCREASE, 1] 从 baseSize * MUL 线性缩小到 0
this.quadSize = this.baseSize * MUL * (1.0f - lifeRatio) / (1.0f - INCREASE);
this.alpha = 1.0f - (lifeRatio - 0.5f) / 0.5f;
}
}
@Override
public void render(VertexConsumer buffer, Camera camera, float partialTick) {
if(this.alpha <= 0.01F) return;
float lifeRatio = Mth.clamp((this.age + partialTick) / (float) this.lifetime, 0.0f, 1.0f);
float growProgress = Mth.clamp(lifeRatio / GROW_END, 0.0f, 1.0f);
float grow = 1.0f - (float) Math.pow(1.0f - growProgress, 3.0);
float shrink = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - SHRINK_START) / (1.0f - SHRINK_START), 0.0f, 1.0f)
);
float size = this.baseSize * QUAD_SIZE_MULTIPLIER * grow * shrink;
float fade = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - FADE_START) / (1.0f - FADE_START), 0.0f, 1.0f)
);
if(size <= 0.001f || fade <= 0.001f) return;
float lifeRatio = (float) this.age / (float) this.lifetime - 0.5f;
float cx = (float) (Mth.lerp(partialTick, this.xo, this.x) - camera.getPosition().x);
float cy = (float) (Mth.lerp(partialTick, this.yo, this.y) - camera.getPosition().y);
float cz = (float) (Mth.lerp(partialTick, this.zo, this.z) - camera.getPosition().z);
for(int i = 0;i < 10 + (int) lifeRatio * 5;i++) {
super.render(buffer, camera, partialTick);
Quaternionf rotation = new Quaternionf(camera.rotation());
rotation.rotateZ(Mth.lerp(partialTick, this.oRoll, this.roll));
// 五个 quad 的中心位置固定,生命周期缩放只影响各自的半尺寸。
// 这样每个超椭圆都会围绕自己的中心放大、缩小,而不是整组一起缩向原点。
float offsetX = this.baseSize * OFFSET_X_MULTIPLIER;
float offsetY = this.baseSize * OFFSET_Y_MULTIPLIER;
float[][] localCenters = {
{0.0f, 0.0f},
{-offsetX, 0.0f},
{offsetX, 0.0f},
{0.0f, -offsetY},
{0.0f, offsetY}
};
// 与 SingleQuadParticle 保持相同的正面绕序:右下 -> 右上 -> 左上 -> 左下。
// 自定义 ParticleRenderType 不会关闭背面剔除,反向绕序会让整张 billboard 被裁掉。
Vector3f[] corners = {
new Vector3f(1.0f, -1.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, -1.0f, 0.0f)
};
float[][] uvs = {
{1.0f, 1.0f},
{1.0f, 0.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
};
for(float[] localCenter : localCenters) {
Vector3f quadCenter = new Vector3f(localCenter[0], localCenter[1], 0.0f)
.rotate(rotation)
.add(cx, cy, cz);
for(int i = 0; i < corners.length; i++) {
Vector3f corner = new Vector3f(corners[i])
.rotate(rotation)
.mul(size)
.add(quadCenter);
buffer.addVertex(corner.x, corner.y, corner.z)
.setUv(uvs[i][0], uvs[i][1])
.setColor(1.0f, 1.0f, 1.0f, fade * QUAD_OPACITY)
.setLight(LightTexture.FULL_BRIGHT);
}
}
}
@@ -79,21 +116,15 @@ public class TerraBeamHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
return ModParticleRenderTypes.TERRA_BEAM_HIT_PARTICLE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet spriteSet;
public Provider(SpriteSet spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel level,
double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new TerraBeamHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
return new TerraBeamHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
}
}
}
@@ -1,15 +1,20 @@
package com.lzxnone.terraria.particle;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class TrueExcaliburHitParticle extends TextureSheetParticle {
private final float baseSize;
protected TrueExcaliburHitParticle(ClientLevel level, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) {
double xSpeed, double ySpeed, double zSpeed) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.hasPhysics = false;
@@ -19,31 +24,62 @@ public class TrueExcaliburHitParticle extends TextureSheetParticle {
this.yd = ySpeed;
this.zd = zSpeed;
this.baseSize = 0.8F;
this.baseSize = 1.2F;
this.quadSize = baseSize;
this.alpha = 1.0f;
this.lifetime = 20;
this.pickSprite(spriteSet);
}
@Override
public void tick() {
super.tick();
if(this.age <= 10) {
this.quadSize = 0;
}
@Override
public void render(VertexConsumer buffer, Camera camera, float partialTick) {
float activeAge = this.age + partialTick - 10.0f;
if(activeAge <= 0.0f) {
return;
}
float lifeRatio = (float) this.age / (float) this.lifetime;
if(lifeRatio <= 0.25f) {
this.quadSize = (lifeRatio / 0.25f) * this.baseSize;
}else if(lifeRatio >= 0.75f) {
this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize;
}else {
this.quadSize = this.baseSize;
float lifeRatio = Mth.clamp(activeAge / (this.lifetime - 10.0f), 0.0f, 1.0f);
float grow = (float) Mth.smoothstep(Mth.clamp(lifeRatio / 0.20f, 0.0f, 1.0f));
float shrink = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.58f) / 0.42f, 0.0f, 1.0f)
);
float fade = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.48f) / 0.52f, 0.0f, 1.0f)
);
float size = this.baseSize * grow * shrink;
if(size <= 0.001f || fade <= 0.001f) {
return;
}
float cx = (float) (Mth.lerp(partialTick, this.xo, this.x) - camera.getPosition().x);
float cy = (float) (Mth.lerp(partialTick, this.yo, this.y) - camera.getPosition().y);
float cz = (float) (Mth.lerp(partialTick, this.zo, this.z) - camera.getPosition().z);
Quaternionf rotation = new Quaternionf(camera.rotation());
Vector3f[] corners = {
new Vector3f(1.0f, -1.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, -1.0f, 0.0f)
};
float[][] uvs = {
{1.0f, 1.0f},
{1.0f, 0.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
};
for(int i = 0; i < corners.length; i++) {
Vector3f corner = corners[i].rotate(rotation).mul(size).add(cx, cy, cz);
buffer.addVertex(corner.x, corner.y, corner.z)
.setUv(uvs[i][0], uvs[i][1])
.setColor(1.0f, 1.0f, 1.0f, fade)
.setLight(LightTexture.FULL_BRIGHT);
}
}
@@ -54,21 +90,15 @@ public class TrueExcaliburHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
return ModParticleRenderTypes.TRUE_EXCALIBUR_HIT_PARTICLE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet spriteSet;
public Provider(SpriteSet spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel level,
double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new TrueExcaliburHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
return new TrueExcaliburHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
}
}
}
@@ -1,16 +1,20 @@
package com.lzxnone.terraria.particle;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.Mth;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class TrueNightsEdgeHitParticle extends TextureSheetParticle {
private final float baseSize;
private final SpriteSet spriteSet;
protected TrueNightsEdgeHitParticle(ClientLevel level, double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) {
double xSpeed, double ySpeed, double zSpeed) {
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
this.hasPhysics = false;
@@ -20,31 +24,58 @@ public class TrueNightsEdgeHitParticle extends TextureSheetParticle {
this.yd = ySpeed;
this.zd = zSpeed;
this.baseSize = 0.8F;
this.baseSize = 2.0F;
this.quadSize = baseSize;
this.alpha = 1.0f;
this.lifetime = 10;
this.spriteSet = spriteSet;
this.setSpriteFromAge(spriteSet);
}
@Override
public void tick() {
super.tick();
float lifeRatio = (float) this.age / (float) this.lifetime;
if(lifeRatio <= 0.25f) {
this.quadSize = (lifeRatio / 0.25f) * this.baseSize;
}else if(lifeRatio >= 0.75f) {
this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize;
}else {
this.quadSize = this.baseSize;
}
this.setSpriteFromAge(this.spriteSet);
@Override
public void render(VertexConsumer buffer, Camera camera, float partialTick) {
float lifeRatio = Mth.clamp((this.age + partialTick) / (float) this.lifetime, 0.0f, 1.0f);
float grow = (float) Mth.smoothstep(Mth.clamp(lifeRatio / 0.22f, 0.0f, 1.0f));
float shrink = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.70f) / 0.30f, 0.0f, 1.0f)
);
float fade = 1.0f - (float) Mth.smoothstep(
Mth.clamp((lifeRatio - 0.55f) / 0.45f, 0.0f, 1.0f)
);
float size = this.baseSize * grow * shrink;
if(size <= 0.001f || fade <= 0.001f) {
return;
}
float cx = (float) (Mth.lerp(partialTick, this.xo, this.x) - camera.getPosition().x);
float cy = (float) (Mth.lerp(partialTick, this.yo, this.y) - camera.getPosition().y);
float cz = (float) (Mth.lerp(partialTick, this.zo, this.z) - camera.getPosition().z);
Quaternionf rotation = new Quaternionf(camera.rotation());
Vector3f[] corners = {
new Vector3f(1.0f, -1.0f, 0.0f),
new Vector3f(1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, 1.0f, 0.0f),
new Vector3f(-1.0f, -1.0f, 0.0f)
};
float[][] uvs = {
{1.0f, 1.0f},
{1.0f, 0.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
};
for(int i = 0; i < corners.length; i++) {
Vector3f corner = corners[i].rotate(rotation).mul(size).add(cx, cy, cz);
buffer.addVertex(corner.x, corner.y, corner.z)
.setUv(uvs[i][0], uvs[i][1])
.setColor(1.0f, 1.0f, 1.0f, fade)
.setLight(LightTexture.FULL_BRIGHT);
}
}
@Override
@@ -54,21 +85,15 @@ public class TrueNightsEdgeHitParticle extends TextureSheetParticle {
@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
return ModParticleRenderTypes.TRUE_NIGHTS_EDGE_HIT_PARTICLE;
}
public static class Provider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet spriteSet;
public Provider(SpriteSet spriteSet) {
this.spriteSet = spriteSet;
}
@Override
public Particle createParticle(SimpleParticleType type, ClientLevel level,
double x, double y, double z,
double xSpeed, double ySpeed, double zSpeed) {
return new TrueNightsEdgeHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
return new TrueNightsEdgeHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
}
}
}
@@ -502,6 +502,12 @@
"lzxnoneterraria.configuration.steady_breath_spread_multiplier": "Spread Multiplier",
"lzxnoneterraria.configuration.steady_breath_spread_multiplier.tooltip": "Ranged weapon spread multiplier per Steady Breath level",
"lzxnoneterraria.configuration.render_settings": "Render Settings",
"lzxnoneterraria.configuration.render_effects_dynamic_lights": "Enable Dynamic Lights",
"lzxnoneterraria.configuration.render_effects_dynamic_lights.tooltip": "Controls dynamic lights emitted by this mod's entities",
"lzxnoneterraria.configuration.render_effects_outline": "Enable Outlines",
"lzxnoneterraria.configuration.render_effects_outline.tooltip": "Controls this mod's entity outline post-processing",
"lzxnoneterraria.configuration.render_effects_bloom": "Enable Bloom",
"lzxnoneterraria.configuration.render_effects_bloom.tooltip": "Controls this mod's bloom post-processing; always disabled while a shader pack is active",
"lzxnoneterraria.configuration.render_mixin_render_hand": "Enable renderHand",
"lzxnoneterraria.configuration.render_mixin_render_hand.tooltip": "Enables the first-person hand rendering mixin",
"lzxnoneterraria.configuration.render_mixin_render_item": "Enable renderItem",
@@ -502,6 +502,12 @@
"lzxnoneterraria.configuration.steady_breath_spread_multiplier": "散射倍率",
"lzxnoneterraria.configuration.steady_breath_spread_multiplier.tooltip": "每级屏息对远程武器散射幅度的倍率",
"lzxnoneterraria.configuration.render_settings": "渲染 设置",
"lzxnoneterraria.configuration.render_effects_dynamic_lights": "启用动态光源",
"lzxnoneterraria.configuration.render_effects_dynamic_lights.tooltip": "控制本模组实体产生的动态光源",
"lzxnoneterraria.configuration.render_effects_outline": "启用描边",
"lzxnoneterraria.configuration.render_effects_outline.tooltip": "控制本模组的实体描边后处理",
"lzxnoneterraria.configuration.render_effects_bloom": "启用泛光",
"lzxnoneterraria.configuration.render_effects_bloom.tooltip": "控制本模组的泛光后处理;启用光影包时始终关闭",
"lzxnoneterraria.configuration.render_mixin_render_hand": "启用 renderHand",
"lzxnoneterraria.configuration.render_mixin_render_hand.tooltip": "启用第一人称手部渲染相关 mixin",
"lzxnoneterraria.configuration.render_mixin_render_item": "启用 renderItem",
@@ -1,5 +0,0 @@
{
"textures": [
"lzxnoneterraria:excalibur_hit_particle"
]
}
@@ -1,7 +0,0 @@
{
"textures": [
"lzxnoneterraria:nights_edge_hit_particle0",
"lzxnoneterraria:nights_edge_hit_particle1",
"lzxnoneterraria:nights_edge_hit_particle2"
]
}
@@ -1,8 +0,0 @@
{
"textures": [
"lzxnoneterraria:terra_beam_hit_particle0",
"lzxnoneterraria:terra_beam_hit_particle1",
"lzxnoneterraria:terra_beam_hit_particle2",
"lzxnoneterraria:terra_beam_hit_particle3"
]
}
@@ -1,5 +0,0 @@
{
"textures": [
"lzxnoneterraria:true_excalibur_hit_particle"
]
}
@@ -1,7 +0,0 @@
{
"textures": [
"lzxnoneterraria:true_nights_edge_hit_particle0",
"lzxnoneterraria:true_nights_edge_hit_particle1",
"lzxnoneterraria:true_nights_edge_hit_particle2"
]
}
@@ -0,0 +1,86 @@
#version 150
#moj_import <fog.glsl>
uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
in float vertexDistance;
in vec2 localUv;
in vec4 vertexColor;
out vec4 fragColor;
const vec3 CORE_PURPLE = vec3(0.82, 0.48, 1.00);
const vec3 VIVID_PURPLE = vec3(0.48, 0.10, 0.88);
const vec3 DEEP_PURPLE = vec3(0.16, 0.015, 0.34);
float superellipseMetric(vec2 position, vec2 radius) {
const float POWER = 4.0;
vec2 q = abs(position) / radius;
return pow(pow(q.x, POWER) + pow(q.y, POWER), 1.0 / POWER);
}
float boundaryCoverage(float metric, float boundary) {
float antialiasWidth = max(fwidth(metric) * 0.90, 0.0015);
return 1.0 - smoothstep(
boundary - antialiasWidth,
boundary + antialiasWidth,
metric
);
}
void main() {
vec2 position = localUv * 2.0 - 1.0;
const float DIAGONAL = 0.70710678;
vec2 diagonalA = vec2(
(position.x + position.y) * DIAGONAL,
(position.y - position.x) * DIAGONAL
);
vec2 diagonalB = vec2(
(position.x - position.y) * DIAGONAL,
(position.x + position.y) * DIAGONAL
);
vec2 vertical = vec2(position.y, position.x);
// 两条对角线加一条竖线,形成六个放射端点。
float metricA = superellipseMetric(diagonalA, vec2(0.83, 0.070));
float metricB = superellipseMetric(diagonalB, vec2(0.83, 0.070));
float metricVertical = superellipseMetric(vertical, vec2(0.82, 0.065));
float shapeMetric = min(metricVertical, min(metricA, metricB));
float bodyMask = boundaryCoverage(shapeMetric, 1.0);
float auraA = boundaryCoverage(superellipseMetric(diagonalA, vec2(0.86, 0.105)), 1.0);
float auraB = boundaryCoverage(superellipseMetric(diagonalB, vec2(0.86, 0.105)), 1.0);
float auraVertical = boundaryCoverage(superellipseMetric(vertical, vec2(0.85, 0.098)), 1.0);
float auraMask = max(auraVertical, max(auraA, auraB));
if(auraMask < 0.001) {
discard;
}
vec3 bodyColor = mix(
CORE_PURPLE,
VIVID_PURPLE,
smoothstep(0.14, 0.66, shapeMetric)
);
bodyColor = mix(
bodyColor,
DEEP_PURPLE,
smoothstep(0.64, 1.0, shapeMetric)
);
float brightness = mix(1.65, 1.15, smoothstep(0.16, 1.0, shapeMetric));
float outerAuraMask = max(auraMask - bodyMask, 0.0);
vec4 particleColor = vertexColor * ColorModulator;
vec3 weightedEmission =
bodyColor * bodyMask * brightness
+ DEEP_PURPLE * outerAuraMask * 0.52;
float shapeAlpha = max(bodyMask, outerAuraMask * 0.36);
vec3 sourceColor = weightedEmission * particleColor.rgb
/ max(shapeAlpha, 0.0001);
float fogFade = linear_fog_fade(vertexDistance, FogStart, FogEnd);
float alpha = shapeAlpha * particleColor.a * fogFade;
fragColor = vec4(sourceColor, alpha);
}
@@ -0,0 +1,15 @@
{
"blend": { "func": "add", "srcrgb": "srcalpha", "dstrgb": "1" },
"vertex": "lzxnoneterraria:nights_edge_hit_particle",
"fragment": "lzxnoneterraria:nights_edge_hit_particle",
"attributes": ["Position", "UV0", "Color", "UV2"],
"samplers": [],
"uniforms": [
{ "name": "ModelViewMat", "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": "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": "ColorModulator", "type": "float", "count": 4, "values": [1.0, 1.0, 1.0, 1.0] },
{ "name": "FogStart", "type": "float", "count": 1, "values": [0.0] },
{ "name": "FogEnd", "type": "float", "count": 1, "values": [1.0] },
{ "name": "FogShape", "type": "int", "count": 1, "values": [0] }
]
}
@@ -0,0 +1,23 @@
#version 150
#moj_import <fog.glsl>
in vec3 Position;
in vec2 UV0;
in vec4 Color;
in ivec2 UV2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;
out float vertexDistance;
out vec2 localUv;
out vec4 vertexColor;
void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
vertexDistance = fog_distance(Position, FogShape);
localUv = UV0;
vertexColor = Color;
}
@@ -6,15 +6,16 @@ uniform sampler2D Sampler0;
uniform sampler2D Sampler1;
uniform sampler2D Sampler2;
uniform vec2 TexelSize;
uniform vec4 OutlineColor;
uniform float Radius;
uniform float DepthBias;
out vec4 fragColor;
void main() {
float center = texture(Sampler0, texCoord0).a;
vec4 centerSample = texture(Sampler0, texCoord0);
float center = centerSample.a;
float dilated = center;
vec3 outlineColor = centerSample.rgb;
float outlineDepth = texture(Sampler1, texCoord0).r;
int radius = int(clamp(Radius, 1.0, 4.0));
int radiusSquared = radius * radius;
@@ -24,12 +25,14 @@ void main() {
if(x * x + y * y > radiusSquared) continue;
vec2 sampleUv = texCoord0 + vec2(float(x), float(y)) * TexelSize;
float sampleMask = texture(Sampler0, sampleUv).a;
vec4 maskSample = texture(Sampler0, sampleUv);
float sampleMask = maskSample.a;
if(sampleMask <= 0.0) continue;
float sampleDepth = texture(Sampler1, sampleUv).r;
if(sampleMask > dilated || (sampleMask == dilated && sampleDepth < outlineDepth)) {
dilated = sampleMask;
outlineColor = maskSample.rgb;
outlineDepth = sampleDepth;
}
}
@@ -39,5 +42,5 @@ void main() {
float sceneDepth = texture(Sampler2, texCoord0).r;
if(outline <= 0.0 || outlineDepth > sceneDepth + DepthBias) discard;
fragColor = vec4(OutlineColor.rgb, outline * OutlineColor.a);
fragColor = vec4(outlineColor, outline);
}
@@ -12,7 +12,6 @@
],
"uniforms": [
{ "name": "TexelSize", "type": "float", "count": 2, "values": [ 0.001, 0.001 ] },
{ "name": "OutlineColor", "type": "float", "count": 4, "values": [ 0.8, 0.176, 0.78, 1.0 ] },
{ "name": "Radius", "type": "float", "count": 1, "values": [ 2.0 ] },
{ "name": "DepthBias", "type": "float", "count": 1, "values": [ 0.00005 ] }
]
@@ -4,10 +4,11 @@ in vec2 texCoord0;
uniform sampler2D Sampler0;
uniform float AlphaCutoff;
uniform vec4 MaskColor;
out vec4 fragColor;
void main() {
if(texture(Sampler0, texCoord0).a <= AlphaCutoff) discard;
fragColor = vec4(1.0);
fragColor = MaskColor;
}
@@ -11,6 +11,7 @@
"uniforms": [
{ "name": "ModelViewMat", "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": "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": "AlphaCutoff", "type": "float", "count": 1, "values": [0.05] }
{ "name": "AlphaCutoff", "type": "float", "count": 1, "values": [0.05] },
{ "name": "MaskColor", "type": "float", "count": 4, "values": [1.0, 1.0, 1.0, 1.0] }
]
}
@@ -0,0 +1,91 @@
#version 150
#moj_import <fog.glsl>
uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform float ShapePower;
uniform vec2 ShapeRadius;
uniform float ShapeRotation;
uniform vec3 CoreColor;
uniform vec3 MiddleColor;
uniform vec3 EdgeColor;
uniform float CoreWhiteMix;
uniform vec2 FirstGradient;
uniform vec2 SecondGradient;
uniform vec2 BrightnessGradient;
uniform vec2 Brightness;
uniform float AuraScale;
uniform float AuraBrightness;
uniform float AuraAlpha;
in float vertexDistance;
in vec2 localUv;
in vec4 vertexColor;
out vec4 fragColor;
float superellipseMetric(vec2 position) {
float cosine = cos(ShapeRotation);
float sine = sin(ShapeRotation);
vec2 rotatedPosition = vec2(
position.x * cosine + position.y * sine,
position.y * cosine - position.x * sine
);
vec2 q = abs(rotatedPosition) / ShapeRadius;
float power = max(ShapePower, 0.001);
return pow(pow(q.x, power) + pow(q.y, power), 1.0 / power);
}
float boundaryCoverage(float metric, float boundary) {
float antialiasWidth = max(fwidth(metric) * 0.90, 0.0015);
return 1.0 - smoothstep(
boundary - antialiasWidth,
boundary + antialiasWidth,
metric
);
}
void main() {
vec2 position = localUv * 2.0 - 1.0;
float shapeMetric = superellipseMetric(position);
float bodyMask = boundaryCoverage(shapeMetric, 1.0);
float auraMask = boundaryCoverage(shapeMetric, AuraScale);
if(auraMask < 0.001) {
discard;
}
vec4 particleColor = vertexColor * ColorModulator;
vec3 coreColor = CoreColor * particleColor.rgb;
coreColor = mix(coreColor, vec3(1.0), CoreWhiteMix);
vec3 middleColor = MiddleColor * particleColor.rgb;
vec3 edgeColor = EdgeColor * particleColor.rgb;
vec3 bodyColor = mix(
coreColor,
middleColor,
smoothstep(FirstGradient.x, FirstGradient.y, shapeMetric)
);
bodyColor = mix(
bodyColor,
edgeColor,
smoothstep(SecondGradient.x, SecondGradient.y, shapeMetric)
);
float brightness = mix(
Brightness.x,
Brightness.y,
smoothstep(BrightnessGradient.x, BrightnessGradient.y, shapeMetric)
);
float outerAuraMask = max(auraMask - bodyMask, 0.0);
vec3 weightedEmission =
bodyColor * bodyMask * brightness
+ edgeColor * outerAuraMask * AuraBrightness;
float shapeAlpha = max(bodyMask, outerAuraMask * AuraAlpha);
vec3 sourceColor = weightedEmission / max(shapeAlpha, 0.0001);
float fogFade = linear_fog_fade(vertexDistance, FogStart, FogEnd);
float alpha = shapeAlpha * particleColor.a * fogFade;
fragColor = vec4(sourceColor, alpha);
}
@@ -0,0 +1,29 @@
{
"blend": { "func": "add", "srcrgb": "srcalpha", "dstrgb": "1" },
"vertex": "lzxnoneterraria:superellipse_particle",
"fragment": "lzxnoneterraria:superellipse_particle",
"attributes": ["Position", "UV0", "Color", "UV2"],
"samplers": [],
"uniforms": [
{ "name": "ModelViewMat", "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": "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": "ColorModulator", "type": "float", "count": 4, "values": [1.0, 1.0, 1.0, 1.0] },
{ "name": "FogStart", "type": "float", "count": 1, "values": [0.0] },
{ "name": "FogEnd", "type": "float", "count": 1, "values": [1.0] },
{ "name": "FogShape", "type": "int", "count": 1, "values": [0] },
{ "name": "ShapePower", "type": "float", "count": 1, "values": [1.0] },
{ "name": "ShapeRadius", "type": "float", "count": 2, "values": [0.8, 0.8] },
{ "name": "ShapeRotation", "type": "float", "count": 1, "values": [0.0] },
{ "name": "CoreColor", "type": "float", "count": 3, "values": [1.0, 1.0, 1.0] },
{ "name": "MiddleColor", "type": "float", "count": 3, "values": [1.0, 1.0, 1.0] },
{ "name": "EdgeColor", "type": "float", "count": 3, "values": [1.0, 1.0, 1.0] },
{ "name": "CoreWhiteMix", "type": "float", "count": 1, "values": [0.0] },
{ "name": "FirstGradient", "type": "float", "count": 2, "values": [0.15, 0.68] },
{ "name": "SecondGradient", "type": "float", "count": 2, "values": [0.66, 1.0] },
{ "name": "BrightnessGradient", "type": "float", "count": 2, "values": [0.16, 1.0] },
{ "name": "Brightness", "type": "float", "count": 2, "values": [1.5, 1.1] },
{ "name": "AuraScale", "type": "float", "count": 1, "values": [1.14] },
{ "name": "AuraBrightness", "type": "float", "count": 1, "values": [0.5] },
{ "name": "AuraAlpha", "type": "float", "count": 1, "values": [0.35] }
]
}
@@ -0,0 +1,23 @@
#version 150
#moj_import <fog.glsl>
in vec3 Position;
in vec2 UV0;
in vec4 Color;
in ivec2 UV2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;
out float vertexDistance;
out vec2 localUv;
out vec4 vertexColor;
void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
vertexDistance = fog_distance(Position, FogShape);
localUv = UV0;
vertexColor = Color;
}