Fancy Fog

This commit is contained in:
peytonplayz595 2023-09-02 10:41:18 -05:00
parent 294ae032ec
commit e4962cc8f1
6 changed files with 185 additions and 54 deletions

View File

@ -110,6 +110,22 @@ public class Config {
return Minecraft.getMinecraft().gameSettings.ofBetterGrass == 2;
}
public static boolean isFogFancy() {
return Minecraft.getMinecraft().gameSettings.ofFogType == 2;
}
public static boolean isFogFast() {
return Minecraft.getMinecraft().gameSettings.ofFogType == 1;
}
public static boolean isFogOff() {
return Minecraft.getMinecraft().gameSettings.ofFogType == 3;
}
public static float getFogStart() {
return Minecraft.getMinecraft().gameSettings.ofFogStart;
}
public static int limit(int p_limit_0_, int p_limit_1_, int p_limit_2_) {
return p_limit_0_ < p_limit_1_ ? p_limit_1_ : (p_limit_0_ > p_limit_2_ ? p_limit_2_ : p_limit_0_);
}

View File

@ -54,7 +54,11 @@ public class GuiVideoSettings extends GuiScreen {
GameSettings.Options.AO_LEVEL,
GameSettings.Options.VIEW_BOBBING,
GameSettings.Options.GUI_SCALE,
GameSettings.Options.USE_VBO
GameSettings.Options.USE_VBO,
GameSettings.Options.GAMMA,
GameSettings.Options.BLOCK_ALTERNATIVES,
GameSettings.Options.FOG_FANCY,
GameSettings.Options.FOG_START
};
public GuiVideoSettings(GuiScreen parentScreenIn, GameSettings gameSettingsIn) {

View File

@ -173,6 +173,7 @@ public class EntityRenderer implements IResourceManagerReloadListener {
private int frameCount;
private GameOverlayFramebuffer overlayFramebuffer;
private float eagPartialTicks = 0.0f;
public boolean fogStandard = false;
public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn) {
this.useShader = false;
@ -582,6 +583,15 @@ public class EntityRenderer implements IResourceManagerReloadListener {
*/
private void setupCameraTransform(float partialTicks, int pass) {
this.farPlaneDistance = (float) (this.mc.gameSettings.renderDistanceChunks * 16);
if (Config.isFogFancy()) {
this.farPlaneDistance *= 0.95F;
}
if (Config.isFogFast()) {
this.farPlaneDistance *= 0.83F;
}
GlStateManager.matrixMode(GL_PROJECTION);
GlStateManager.loadIdentity();
float f = 0.07F;
@ -1725,6 +1735,7 @@ public class EntityRenderer implements IResourceManagerReloadListener {
private void setupFog(int partialTicks, float parFloat1) {
Entity entity = this.mc.getRenderViewEntity();
boolean flag = false;
this.fogStandard = false;
if (entity instanceof EntityPlayer) {
flag = ((EntityPlayer) entity).capabilities.isCreativeMode;
}
@ -1735,21 +1746,26 @@ public class EntityRenderer implements IResourceManagerReloadListener {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, parFloat1);
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isPotionActive(Potion.blindness)) {
float f1 = 5.0F;
int i = ((EntityLivingBase) entity).getActivePotionEffect(Potion.blindness).getDuration();
float f2 = 5.0F;
int i = ((EntityLivingBase)entity).getActivePotionEffect(Potion.blindness).getDuration();
if (i < 20) {
f1 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float) i / 20.0F);
f2 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float)i / 20.0F);
}
GlStateManager.setFog(GL_LINEAR);
GlStateManager.setFog(9729);
if (partialTicks == -1) {
GlStateManager.setFogStart(0.0F);
GlStateManager.setFogEnd(f1 * 0.8F);
GlStateManager.setFogEnd(f2 * 0.8F);
} else {
GlStateManager.setFogStart(f1 * 0.25F);
GlStateManager.setFogEnd(f1);
GlStateManager.setFogStart(f2 * 0.25F);
GlStateManager.setFogEnd(f2);
}
if (Config.isFogFancy()) {
EaglercraftGPU.glFogi(34138, 34139);
}
EaglercraftGPU.glFogi('\u855a', '\u855b');
} else if (this.cloudFog) {
GlStateManager.setFog(GL_EXP);
GlStateManager.setFogDensity(0.1F);
@ -1768,22 +1784,26 @@ public class EntityRenderer implements IResourceManagerReloadListener {
} else if (block.getMaterial() == Material.lava) {
GlStateManager.setFog(GL_EXP);
GlStateManager.setFogDensity(2.0F);
} else if (!this.mc.gameSettings.fog) {
GlStateManager.setFog(GL_EXP);
GlStateManager.setFogDensity(0.0F);
} else {
GlStateManager.setFogDensity(0.001F);
float f = this.farPlaneDistance;
this.fogStandard = true;
GlStateManager.setFog(GL_LINEAR);
if (partialTicks == -1) {
GlStateManager.setFogStart(0.0F);
GlStateManager.setFogEnd(f);
} else {
GlStateManager.setFogStart(f * 0.75F);
GlStateManager.setFogStart(f * Config.getFogStart());
GlStateManager.setFogEnd(f);
}
EaglercraftGPU.glFogi('\u855a', '\u855b');
if (Config.isFogFancy()) {
EaglercraftGPU.glFogi(34138, 34139);
}
if (Config.isFogFast()) {
EaglercraftGPU.glFogi(34138, 34140);
}
if (this.mc.theWorld.provider.doesXZShowFog((int) entity.posX, (int) entity.posZ)) {
GlStateManager.setFogStart(f * 0.05F);

View File

@ -184,6 +184,8 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
private double prevRenderSortY;
private double prevRenderSortZ;
private boolean displayListEntitiesDirty = true;
private int renderDistance = 0;
private int renderDistanceSq = 0;
public RenderGlobal(Minecraft mcIn) {
this.mc = mcIn;
@ -394,6 +396,8 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
Blocks.leaves2.setGraphicsLevel(mc.gameSettings.shaders || mc.gameSettings.fancyGraphics);
BlockModelRenderer.updateAoLightValue();
this.renderDistanceChunks = this.mc.gameSettings.renderDistanceChunks;
this.renderDistance = this.renderDistanceChunks * 16;
this.renderDistanceSq = this.renderDistance * this.renderDistance;
if (this.viewFrustum != null) {
this.viewFrustum.deleteGlResources();
@ -514,6 +518,9 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
this.theWorld.theProfiler.endStartSection("global");
List list = this.theWorld.getLoadedEntityList();
this.countEntitiesTotal = list.size();
if (Config.isFogOff() && this.mc.entityRenderer.fogStandard) {
GlStateManager.disableFog();
}
if (!DeferredStateManager.isDeferredRenderer()) {
for (int i = 0; i < this.theWorld.weatherEffects.size(); ++i) {
@ -999,14 +1006,28 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
}
private RenderChunk func_181562_a(BlockPos parBlockPos, RenderChunk parRenderChunk, EnumFacing parEnumFacing) {
BlockPos blockpos = parRenderChunk.func_181701_a(parEnumFacing);
return MathHelper
.abs_int(parBlockPos.getX() - blockpos.getX()) > this.renderDistanceChunks * 16
? null
: (blockpos.getY() >= 0 && blockpos.getY() < 256
? (MathHelper.abs_int(parBlockPos.getZ() - blockpos.getZ()) > this.renderDistanceChunks
* 16 ? null : this.viewFrustum.getRenderChunk(blockpos))
: null);
BlockPos blockpos = parRenderChunk.getPositionOffset16(parEnumFacing);
if (blockpos.getY() >= 0 && blockpos.getY() < 256) {
int i = MathHelper.abs_int(parBlockPos.getX() - blockpos.getX());
int j = MathHelper.abs_int(parBlockPos.getZ() - blockpos.getZ());
if (Config.isFogOff()) {
if (i > this.renderDistance || j > this.renderDistance) {
return null;
}
} else {
int k = i * i + j * j;
if (k > this.renderDistanceSq) {
return null;
}
}
return this.viewFrustum.getRenderChunk(blockpos);
} else {
return null;
}
}
private void fixTerrainFrustum(double x, double y, double z) {
@ -1099,6 +1120,10 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
}
}
if (Config.isFogOff() && this.mc.entityRenderer.fogStandard) {
GlStateManager.disableFog();
}
this.mc.mcProfiler.endStartSection("render_" + blockLayerIn);
this.renderBlockLayer(blockLayerIn);
this.mc.mcProfiler.endSection();

View File

@ -71,7 +71,8 @@ public class RenderChunk {
public ShadowFrustumState shadowLOD0InFrustum = ShadowFrustumState.OUTSIDE;
public ShadowFrustumState shadowLOD1InFrustum = ShadowFrustumState.OUTSIDE;
public ShadowFrustumState shadowLOD2InFrustum = ShadowFrustumState.OUTSIDE;
private EnumMap<EnumFacing, BlockPos> field_181702_p = Maps.newEnumMap(EnumFacing.class);
//private EnumMap<EnumFacing, BlockPos> field_181702_p = Maps.newEnumMap(EnumFacing.class);
private BlockPos[] positionOffsets16 = new BlockPos[EnumFacing.VALUES.length];
public RenderChunk(World worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn) {
this.world = worldIn;
@ -96,12 +97,11 @@ public class RenderChunk {
this.stopCompileTask();
this.position = pos;
this.boundingBox = new AxisAlignedBB(pos, pos.add(16, 16, 16));
for (EnumFacing enumfacing : EnumFacing.values()) {
this.field_181702_p.put(enumfacing, pos.offset(enumfacing, 16));
}
this.initModelviewMatrix();
for (int i = 0; i < this.positionOffsets16.length; ++i) {
this.positionOffsets16[i] = null;
}
}
public void resortTransparency(float x, float y, float z, ChunkCompileTaskGenerator generator) {
@ -306,7 +306,19 @@ public class RenderChunk {
return this.needsUpdate;
}
public BlockPos func_181701_a(EnumFacing parEnumFacing) {
return (BlockPos) this.field_181702_p.get(parEnumFacing);
public BlockPos func_181701_a(EnumFacing p_181701_1_) {
return this.getPositionOffset16(p_181701_1_);
}
public BlockPos getPositionOffset16(EnumFacing p_getPositionOffset16_1_) {
int i = p_getPositionOffset16_1_.getIndex();
BlockPos blockpos = this.positionOffsets16[i];
if (blockpos == null) {
blockpos = this.getPosition().offset(p_getPositionOffset16_1_, 16);
this.positionOffsets16[i] = blockpos;
}
return blockpos;
}
}

View File

@ -190,7 +190,6 @@ public class GameSettings {
public boolean hudStats = false;
public boolean hud24h = false;
public boolean chunkFix = true;
public boolean fog = true;
public int fxaa = 0;
public boolean shaders = false;
public boolean shadersAODisable = false;
@ -200,6 +199,8 @@ public class GameSettings {
//Main Menu Settings
public float ofAoLevel = 1.0F;
public boolean useVbo = false;
public int ofFogType = 1;
public float ofFogStart = 0.8F;
//Quality Settings
public boolean ofCustomSky = true;
@ -463,10 +464,6 @@ public class GameSettings {
this.chunkFix = !this.chunkFix;
}
if (parOptions == GameSettings.Options.FOG) {
this.fog = !this.fog;
}
if (parOptions == GameSettings.Options.FXAA) {
this.fxaa = (this.fxaa + parInt1) % 3;
}
@ -586,6 +583,33 @@ public class GameSettings {
this.mc.renderGlobal.loadRenderers();
}
if (parOptions == GameSettings.Options.FOG_FANCY) {
switch (this.ofFogType) {
case 1:
this.ofFogType = 2;
break;
case 2:
this.ofFogType = 3;
break;
case 3:
this.ofFogType = 1;
break;
default:
this.ofFogType = 1;
}
}
if (parOptions == GameSettings.Options.FOG_START) {
this.ofFogStart += 0.2F;
if (this.ofFogStart > 0.81F) {
this.ofFogStart = 0.2F;
}
}
this.saveOptions();
}
@ -648,8 +672,6 @@ public class GameSettings {
return this.hud24h;
case CHUNK_FIX:
return this.chunkFix;
case FOG:
return this.fog;
case FULLSCREEN:
return this.mc.isFullScreen();
case USE_VBO:
@ -797,6 +819,22 @@ public class GameSettings {
default:
return s + "OFF";
}
} else if (parOptions == GameSettings.Options.FOG_FANCY) {
switch (this.ofFogType) {
case 1:
return s + "Fast";
case 2:
return s + "Fancy";
case 3:
return s + "OFF";
default:
return s + "OFF";
}
} else if (parOptions == GameSettings.Options.FOG_START) {
return s + this.ofFogStart;
} else {
return s;
}
@ -1058,10 +1096,6 @@ public class GameSettings {
this.chunkFix = astring[1].equals("true");
}
if (astring[0].equals("fog")) {
this.fog = astring[1].equals("true");
}
if (astring[0].equals("fxaa")) {
this.fxaa = (astring[1].equals("true") || astring[1].equals("false")) ? 0
: Integer.parseInt(astring[1]);
@ -1170,6 +1204,23 @@ public class GameSettings {
this.ofBetterGrass = Config.limit(this.ofBetterGrass, 1, 3);
}
if (astring[0].equals("ofFogType") && astring.length >= 2) {
this.ofFogType = Integer.valueOf(astring[1]).intValue();
this.ofFogType = Config.limit(this.ofFogType, 1, 3);
}
if (astring[0].equals("ofFogStart") && astring.length >= 2) {
this.ofFogStart = Float.valueOf(astring[1]).floatValue();
if (this.ofFogStart < 0.2F) {
this.ofFogStart = 0.2F;
}
if (this.ofFogStart > 0.81F) {
this.ofFogStart = 0.8F;
}
}
Keyboard.setFunctionKeyModifier(keyBindFunction.getKeyCode());
for (SoundCategory soundcategory : SoundCategory.values()) {
@ -1273,7 +1324,6 @@ public class GameSettings {
printwriter.println("hudStats:" + this.hudStats);
printwriter.println("hud24h:" + this.hud24h);
printwriter.println("chunkFix:" + this.chunkFix);
printwriter.println("fog:" + this.fog);
printwriter.println("fxaa:" + this.fxaa);
printwriter.println("fastMath:" + this.fastMath);
printwriter.println("shaders:" + this.shaders);
@ -1298,6 +1348,8 @@ public class GameSettings {
printwriter.println("ofCustomSky:" + this.ofCustomSky);
printwriter.println("ofClearWater:" + this.ofClearWater);
printwriter.println("ofBetterGrass:" + this.ofBetterGrass);
printwriter.println("ofFogType:" + this.ofFogType);
printwriter.println("ofFogStart:" + this.ofFogStart);
for (KeyBinding keybinding : this.keyBindings) {
printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode());
@ -1440,7 +1492,7 @@ public class GameSettings {
HUD_COORDS("options.hud.coords", false, true), HUD_STATS("options.hud.stats", false, true),
HUD_WORLD("options.hud.world", false, true), HUD_PLAYER("options.hud.player", false, true),
HUD_24H("options.hud.24h", false, true), CHUNK_FIX("options.chunkFix", false, true),
FOG("options.fog", false, true), FXAA("options.fxaa", false, false),
FXAA("options.fxaa", false, false),
FULLSCREEN("options.fullscreen", false, true), FAST_MATH("options.fastMath", false, false),
ANIMATED_WATER("Water Animated", false, false),
ANIMATED_LAVA("Lava Animated", false, false),
@ -1462,7 +1514,9 @@ public class GameSettings {
USE_VBO("Use VBOs", false, false),
CUSTOM_SKY("Custom Sky", false, false),
CLEAR_WATER("Clear Water", false, false),
BETTER_GRASS("Better Grass", false, false);
BETTER_GRASS("Better Grass", false, false),
FOG_FANCY("Fog", false, false),
FOG_START("Fog Start", false, false);
private final boolean enumFloat;
private final boolean enumBoolean;