Hello everyone,
I just started modding with Forge and am currently working on custom particles. The particles themselves work perfectly, however, transparent particles make other particles behind them invisible.
I know this issue is also present in Vanilla Minecraft and I was hoping that it could be eliminated with Forge since it makes particles with a lot of semi-transparent pixels ugly (as you can see in the attachment).
This is the code I use for all my particles:
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
RenderSystem.defaultAlphaFunc();
Vector3d vector3d = renderInfo.getProjectedView();
float f = (float)(MathHelper.lerp((double)partialTicks, this.prevPosX, this.posX) - vector3d.getX());
float g = (float)(MathHelper.lerp((double)partialTicks, this.prevPosY, this.posY) - vector3d.getY());
float h = (float)(MathHelper.lerp((double)partialTicks, this.prevPosZ, this.posZ) - vector3d.getZ());
Quaternion quaternion;
if(this.particleAngle == 0.0F){
quaternion = renderInfo.getRotation();
}
else{
quaternion = new Quaternion(renderInfo.getRotation());
float f3 = MathHelper.lerp(partialTicks, this.prevParticleAngle, this.particleAngle);
quaternion.multiply(Vector3f.ZP.rotation(f3));
}
Vector3f vector3f1 = new Vector3f(-1.0F, -1.0F, 0.0F);
vector3f1.transform(quaternion);
Vector3f[] avector3f = new Vector3f[]{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 f4 = this.getScale(partialTicks);
for(int i = 0; i < 4; ++i) {
Vector3f vector3f = avector3f[i];
vector3f.transform(quaternion);
vector3f.mul(f4);
vector3f.add(f, g, h);
}
float f7 = this.getMinU();
float f8 = this.getMaxU();
float f5 = this.getMinV();
float f6 = this.getMaxV();
int j = this.getBrightnessForRender(partialTicks);
buffer.pos((double)avector3f[0].getX(), (double)avector3f[0].getY(), (double)avector3f[0].getZ()).tex(f8, f6).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos((double)avector3f[1].getX(), (double)avector3f[1].getY(), (double)avector3f[1].getZ()).tex(f8, f5).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos((double)avector3f[2].getX(), (double)avector3f[2].getY(), (double)avector3f[2].getZ()).tex(f7, f5).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos((double)avector3f[3].getX(), (double)avector3f[3].getY(), (double)avector3f[3].getZ()).tex(f7, f6).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
RenderSystem.enableDepthTest();
RenderSystem.depthMask(true);
}
I tried the disableDepthTest() and depthMask(false) methods because they appearantly worked for an older version of Minecraft, but they have no effect in 1.16.5. The defaultAlphaFunc() method makes the texture look a bit smoother, but that's about it.
I also played around with other methods of RenderSystem, but I just kept making it worse that it already is.
Does anyone have a solution for this?
Thanks in advance!