Avaritia:Reforged

Avaritia:Reforged

45.5k Downloads

[Enhancement/功能请求] Strange border lines appear in Cosmic Render

NOBTG opened this issue · 4 comments

commented

Checks/检查

  • I confirm that I have searched for existing issues / pull requests before reporting to avoid duplicate reporting./我确认在报告之前我已经搜索了现有的问题或者拉取请求,以避免重复报告。
  • I confirm that I noted that if I don't follow the instructions, the issue may be closed directly./我确认我已经检查,如果我不按照说明进行操作,该问题可能会被直接关闭。

Description/描述

This is a suggestion and doesn't have to be done, but I hope it can be fixed.
這是一個建議,並不一定要做,但我希望能修復。

commented

提個建議:
RenderStateShard不用at,直接
`private static class RenderStateShardAccess extends RenderStateShard {
private static final RenderStateShard.DepthTestStateShard EQUAL_DEPTH_TEST = RenderStateShard.EQUAL_DEPTH_TEST;
private static final RenderStateShard.LightmapStateShard LIGHT_MAP = RenderStateShard.LIGHTMAP;
private static final RenderStateShard.TransparencyStateShard TRANSLUCENT_TRANSPARENCY = RenderStateShard.TRANSLUCENT_TRANSPARENCY;
private static final RenderStateShard.TextureStateShard BLOCK_SHEET_MIPPED = RenderStateShard.BLOCK_SHEET_MIPPED;

    private RenderStateShardAccess(String pName, Runnable pSetupState, Runnable pClearState) {
        super(pName, pSetupState, pClearState);
    }
}`

**即可訪問,用at會導致兼容性降低,能不用則不用。**
所以看起來像這樣

`package committee.nova.mods.avaritia.client.shader;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import committee.nova.mods.avaritia.Avaritia;
import committee.nova.mods.avaritia.api.client.shader.CCShaderInstance;
import committee.nova.mods.avaritia.api.client.shader.CCUniform;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RegisterShadersEvent;
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.lang.reflect.Field;
import java.util.Objects;

@Mod.EventBusSubscriber(modid = Avaritia.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.FORGE)
public final class AvaritiaShaders {
private static class RenderStateShardAccess extends RenderStateShard {
private static final RenderStateShard.DepthTestStateShard EQUAL_DEPTH_TEST = RenderStateShard.EQUAL_DEPTH_TEST;
private static final RenderStateShard.LightmapStateShard LIGHT_MAP = RenderStateShard.LIGHTMAP;
private static final RenderStateShard.TransparencyStateShard TRANSLUCENT_TRANSPARENCY = RenderStateShard.TRANSLUCENT_TRANSPARENCY;
private static final RenderStateShard.TextureStateShard BLOCK_SHEET_MIPPED = RenderStateShard.BLOCK_SHEET_MIPPED;

    private RenderStateShardAccess(String pName, Runnable pSetupState, Runnable pClearState) {
        super(pName, pSetupState, pClearState);
    }
}

public static final float[] COSMIC_UVS = new float[40];
public static boolean inventoryRender = false;
public static int renderTime;
public static float renderFrame;
public static CCShaderInstance cosmicShader;
public static CCUniform cosmicTime;
public static CCUniform cosmicYaw;
public static CCUniform cosmicPitch;
public static CCUniform cosmicExternalScale;
public static CCUniform cosmicOpacity;
public static CCUniform cosmicUVs;
public static final RenderType COSMIC_RENDER_TYPE = RenderType.create(Avaritia.MOD_ID + ":cosmic", DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS, 2097152, true, false, RenderType.CompositeState.builder().setShaderState(new RenderStateShard.ShaderStateShard(() -> cosmicShader)).setDepthTestState(RenderStateShardAccess.EQUAL_DEPTH_TEST).setLightmapState(RenderStateShardAccess.LIGHT_MAP).setTransparencyState(RenderStateShardAccess.TRANSLUCENT_TRANSPARENCY).setTextureState(RenderStateShardAccess.BLOCK_SHEET_MIPPED).createCompositeState(true));

public static void onRegisterShaders(RegisterShadersEvent event) {
    event.registerShader(CCShaderInstance.create(event.getResourceProvider(), new ResourceLocation(Avaritia.MOD_ID, "cosmic"), DefaultVertexFormat.BLOCK), e -> {
        cosmicShader = (CCShaderInstance) e;
        cosmicTime = Objects.requireNonNull(cosmicShader.getUniform("time"));
        cosmicYaw = Objects.requireNonNull(cosmicShader.getUniform("yaw"));
        cosmicPitch = Objects.requireNonNull(cosmicShader.getUniform("pitch"));
        cosmicExternalScale = Objects.requireNonNull(cosmicShader.getUniform("externalScale"));
        cosmicOpacity = Objects.requireNonNull(cosmicShader.getUniform("opacity"));
        cosmicUVs = Objects.requireNonNull(cosmicShader.getUniform("cosmicuvs"));
        cosmicTime.set((float) renderTime + renderFrame);
        cosmicShader.onApply(() -> cosmicTime.set((float) renderTime + renderFrame));
    });
}

@SubscribeEvent
public static void renderTick(TickEvent.RenderTickEvent event) {
    if (!Minecraft.getInstance().isPaused() && event.phase == TickEvent.Phase.START) {
        renderFrame = event.renderTickTime;
    }
}

@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void drawScreenPre(final ScreenEvent.Render.Pre e) {
    AvaritiaShaders.inventoryRender = true;
}

@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void drawScreenPost(final ScreenEvent.Render.Post e) {
    AvaritiaShaders.inventoryRender = false;
}

}`

commented
commented

當前版本有此狀況
image

1.18.2的原版也有
image

1.12.2的似乎沒有
image

commented

这是shader不一样的原因,1.18.2以上cosmic shader改变了