add DhApiBeforeFogRenderEvent
This commit is contained in:
+99
@@ -0,0 +1,99 @@
|
||||
package com.seibel.distanthorizons.core.render.renderer;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeFogRenderEvent;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @see DhApiFogRenderParam
|
||||
* @see DhApiBeforeFogRenderEvent.EventParam
|
||||
*/
|
||||
public class FogRenderParamFactory
|
||||
{
|
||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
|
||||
|
||||
|
||||
public static DhApiBeforeFogRenderEvent.EventParam createRenderParam(RenderParams renderParams)
|
||||
{
|
||||
Color fogColor = getFogColor(renderParams.partialTicks);
|
||||
|
||||
// far fog
|
||||
EDhApiFogFalloff farFogFalloff = Config.Client.Advanced.Graphics.Fog.farFogFalloff.get();
|
||||
float farFogStart = Config.Client.Advanced.Graphics.Fog.farFogStart.get();
|
||||
float farFogEnd = Config.Client.Advanced.Graphics.Fog.farFogEnd.get();
|
||||
float farFogMin = Config.Client.Advanced.Graphics.Fog.farFogMin.get();
|
||||
float farFogMax = Config.Client.Advanced.Graphics.Fog.farFogMax.get();
|
||||
float farFogDensity = Config.Client.Advanced.Graphics.Fog.farFogDensity.get();
|
||||
|
||||
|
||||
// height fog
|
||||
EDhApiFogFalloff heightFogFalloff = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogFalloff.get();
|
||||
EDhApiHeightFogMixMode heightFogMixingMode = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMixMode.get();
|
||||
EDhApiHeightFogDirection heightFogCameraDirection = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDirection.get();
|
||||
|
||||
float heightFogBaseHeight = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogBaseHeight.get();
|
||||
float heightFogStart = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogStart.get();
|
||||
float heightFogEnd = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogEnd.get();
|
||||
float heightFogMin = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMin.get();
|
||||
float heightFogMax = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMax.get();
|
||||
float heightFogDensity = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDensity.get();
|
||||
|
||||
// override fog if underwater
|
||||
if (MC_RENDER.isFogStateSpecial())
|
||||
{
|
||||
// hide everything behind fog
|
||||
farFogStart = 0.0f;
|
||||
farFogEnd = 0.0f;
|
||||
}
|
||||
|
||||
DhApiFogRenderParam fogRenderParam = new DhApiFogRenderParam(
|
||||
fogColor,
|
||||
|
||||
// far fog
|
||||
farFogFalloff,
|
||||
farFogStart, farFogEnd,
|
||||
farFogMin, farFogMax,
|
||||
farFogDensity,
|
||||
|
||||
// height fog
|
||||
heightFogFalloff,
|
||||
heightFogMixingMode, heightFogCameraDirection,
|
||||
heightFogBaseHeight,
|
||||
heightFogStart, heightFogEnd,
|
||||
heightFogMin, heightFogMax,
|
||||
heightFogDensity
|
||||
);
|
||||
|
||||
DhApiBeforeFogRenderEvent.EventParam fogRenderEventParam = new DhApiBeforeFogRenderEvent.EventParam(renderParams, fogRenderParam);
|
||||
return fogRenderEventParam;
|
||||
}
|
||||
|
||||
private static Color getFogColor(float partialTicks)
|
||||
{
|
||||
Color fogColor;
|
||||
|
||||
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
|
||||
{
|
||||
fogColor = MC_RENDER.getSkyColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
fogColor = MC_RENDER.getFogColor(partialTicks);
|
||||
}
|
||||
|
||||
return fogColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+12
-5
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.render.renderer;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiTransparency;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
@@ -118,9 +119,9 @@ public class LodRenderer
|
||||
|
||||
private void renderTerrain(RenderParams renderParams, IProfilerWrapper profiler, boolean runningDeferredPass)
|
||||
{
|
||||
//====================//
|
||||
// validate rendering //
|
||||
//====================//
|
||||
//====================//
|
||||
//region
|
||||
|
||||
boolean deferTransparentRendering = DhApiRenderProxy.INSTANCE.getDeferTransparentRendering();
|
||||
@@ -202,6 +203,8 @@ public class LodRenderer
|
||||
renderFog |= renderParams.vanillaFogEnabled;
|
||||
}
|
||||
|
||||
DhApiBeforeFogRenderEvent.EventParam fogRenderEventParam = FogRenderParamFactory.createRenderParam(renderParams);
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -270,11 +273,13 @@ public class LodRenderer
|
||||
|
||||
// fog
|
||||
|
||||
if (renderFog)
|
||||
boolean cancelFogEvent = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeFogRenderEvent.class, fogRenderEventParam);
|
||||
if (renderFog
|
||||
&& !cancelFogEvent)
|
||||
{
|
||||
profiler.popPush("LOD Fog");
|
||||
|
||||
this.fogRenderer.render(renderParams);
|
||||
this.fogRenderer.render(renderParams, fogRenderEventParam.getFogRenderParam());
|
||||
}
|
||||
|
||||
|
||||
@@ -333,11 +338,13 @@ public class LodRenderer
|
||||
this.renderTerrain(this.terrainRenderer, renderBufferHandler, renderParams, /*opaquePass*/ false, profiler);
|
||||
|
||||
|
||||
if (renderFog)
|
||||
boolean cancelFogEvent = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeFogRenderEvent.class, fogRenderEventParam);
|
||||
if (renderFog
|
||||
&& !cancelFogEvent)
|
||||
{
|
||||
profiler.popPush("LOD Fog");
|
||||
|
||||
this.fogRenderer.render(renderParams);
|
||||
this.fogRenderer.render(renderParams, fogRenderEventParam.getFogRenderParam());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -19,12 +19,13 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass;
|
||||
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
|
||||
|
||||
public interface IDhFogRenderer extends IBindable
|
||||
{
|
||||
|
||||
void render(RenderParams renderParams);
|
||||
void render(RenderParams renderParams, DhApiFogRenderParam fogRenderParams);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user