use of net.coderbot.iris.vendored.joml.Vector3d in project Iris by IrisShaders.
the class DeferredWorldRenderingPipeline method prepareRenderTargets.
private void prepareRenderTargets() {
// Make sure we're using texture unit 0 for this.
RenderSystem.activeTexture(GL15C.GL_TEXTURE0);
RenderTarget main = Minecraft.getInstance().getMainRenderTarget();
renderTargets.resizeIfNeeded(main.width, main.height);
final ImmutableList<ClearPass> passes;
if (renderTargets.isFullClearRequired()) {
renderTargets.onFullClear();
passes = clearPassesFull;
} else {
passes = clearPasses;
}
Vector3d fogColor3 = CapturedRenderingState.INSTANCE.getFogColor();
// NB: The alpha value must be 1.0 here, or else you will get a bunch of bugs. Sildur's Vibrant Shaders
// will give you pink reflections and other weirdness if this is zero.
Vector4f fogColor = new Vector4f((float) fogColor3.x, (float) fogColor3.y, (float) fogColor3.z, 1.0F);
for (ClearPass clearPass : passes) {
clearPass.execute(fogColor);
}
}
use of net.coderbot.iris.vendored.joml.Vector3d in project Iris by IrisShaders.
the class ShadowRenderer method renderShadows.
@Override
public void renderShadows(LevelRendererAccessor levelRenderer, Camera playerCamera) {
// vanilla ShaderInstances.
if (blendModeOverride != null) {
blendModeOverride.apply();
} else {
BlendModeOverride.restore();
}
Minecraft client = Minecraft.getInstance();
profiler.popPush("shadows");
ACTIVE = true;
// NB: We store the previous player buffers in order to be able to allow mods rendering entities in the shadow pass (Flywheel) to use the shadow buffers instead.
RenderBuffers playerBuffers = levelRenderer.getRenderBuffers();
levelRenderer.setRenderBuffers(buffers);
visibleBlockEntities = new ArrayList<>();
// Create our camera
PoseStack modelView = createShadowModelView(this.sunPathRotation, this.intervalSize);
MODELVIEW = modelView.last().pose().copy();
float[] projMatrix;
if (this.fov != null) {
// If FOV is not null, the pack wants a perspective based projection matrix. (This is to support legacy packs)
projMatrix = ShadowMatrices.createPerspectiveMatrix(this.fov);
} else {
projMatrix = ShadowMatrices.createOrthoMatrix(halfPlaneLength);
}
PROJECTION = new Matrix4f();
((Matrix4fAccess) (Object) PROJECTION).copyFromArray(projMatrix);
profiler.push("terrain_setup");
if (levelRenderer instanceof CullingDataCache) {
((CullingDataCache) levelRenderer).saveState();
}
profiler.push("initialize frustum");
terrainFrustumHolder = createShadowFrustum(renderDistanceMultiplier, terrainFrustumHolder);
// Determine the player camera position
Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
double cameraX = cameraPos.x();
double cameraY = cameraPos.y();
double cameraZ = cameraPos.z();
// Center the frustum on the player camera position
terrainFrustumHolder.getFrustum().prepare(cameraX, cameraY, cameraZ);
profiler.pop();
// Disable chunk occlusion culling - it's a bit complex to get this properly working with shadow rendering
// as-is, however in the future it will be good to work on restoring it for a nice performance boost.
//
// TODO: Get chunk occlusion working with shadows
boolean wasChunkCullingEnabled = client.smartCull;
client.smartCull = false;
// Always schedule a terrain update
// TODO: Only schedule a terrain update if the sun / moon is moving, or the shadow map camera moved.
((LevelRenderer) levelRenderer).needsUpdate();
// Execute the vanilla terrain setup / culling routines using our shadow frustum.
levelRenderer.invokeSetupRender(playerCamera, terrainFrustumHolder.getFrustum(), false, levelRenderer.getFrameId(), false);
// Don't forget to increment the frame counter! This variable is arbitrary and only used in terrain setup,
// and if it's not incremented, the vanilla culling code will get confused and think that it's already seen
// chunks during traversal, and break rendering in concerning ways.
levelRenderer.setFrameId(levelRenderer.getFrameId() + 1);
client.smartCull = wasChunkCullingEnabled;
profiler.popPush("terrain");
pipeline.pushProgram(GbufferProgram.NONE);
pipeline.beginShadowRender();
setupGlState(projMatrix);
// Render all opaque terrain unless pack requests not to
if (shouldRenderTerrain) {
levelRenderer.invokeRenderChunkLayer(RenderType.solid(), modelView, cameraX, cameraY, cameraZ);
levelRenderer.invokeRenderChunkLayer(RenderType.cutout(), modelView, cameraX, cameraY, cameraZ);
levelRenderer.invokeRenderChunkLayer(RenderType.cutoutMipped(), modelView, cameraX, cameraY, cameraZ);
}
// Reset our shader program in case Sodium overrode it.
//
// If we forget to do this entities will be very small on most shaderpacks since they're being rendered
// without shaders, which doesn't integrate with their shadow distortion code.
setupShadowProgram();
profiler.popPush("entities");
// Get the current tick delta. Normally this is the same as client.getTickDelta(), but when the game is paused,
// it is set to a fixed value.
final float tickDelta = CapturedRenderingState.INSTANCE.getTickDelta();
// Create a constrained shadow frustum for entities to avoid rendering faraway entities in the shadow pass
// TODO: Make this configurable and disable-able
boolean hasEntityFrustum = false;
if (entityShadowDistanceMultiplier == 1.0F || entityShadowDistanceMultiplier < 0.0F) {
entityFrustumHolder.setInfo(terrainFrustumHolder.getFrustum(), terrainFrustumHolder.getDistanceInfo(), terrainFrustumHolder.getCullingInfo());
} else {
hasEntityFrustum = true;
entityFrustumHolder = createShadowFrustum(renderDistanceMultiplier * entityShadowDistanceMultiplier, entityFrustumHolder);
}
Frustum entityShadowFrustum = entityFrustumHolder.getFrustum();
entityShadowFrustum.prepare(cameraX, cameraY, cameraZ);
// rendering.
if (renderBuffersExt != null) {
renderBuffersExt.beginLevelRendering();
}
if (buffers instanceof DrawCallTrackingRenderBuffers) {
((DrawCallTrackingRenderBuffers) buffers).resetDrawCounts();
}
MultiBufferSource.BufferSource bufferSource = buffers.bufferSource();
if (shouldRenderEntities) {
renderEntities(levelRenderer, entityShadowFrustum, bufferSource, modelView, cameraX, cameraY, cameraZ, tickDelta);
}
if (shouldRenderBlockEntities) {
renderBlockEntities(bufferSource, modelView, cameraX, cameraY, cameraZ, tickDelta, hasEntityFrustum);
}
profiler.popPush("draw entities");
// NB: Don't try to draw the translucent parts of entities afterwards. It'll cause problems since some
// shader packs assume that everything drawn afterwards is actually translucent and should cast a colored
// shadow...
bufferSource.endBatch();
copyPreTranslucentDepth();
profiler.popPush("translucent terrain");
// Just something to watch out for, however...
if (shouldRenderTranslucent) {
levelRenderer.invokeRenderChunkLayer(RenderType.translucent(), modelView, cameraX, cameraY, cameraZ);
}
if (renderBuffersExt != null) {
renderBuffersExt.endLevelRendering();
}
debugStringTerrain = ((LevelRenderer) levelRenderer).getChunkStatistics();
profiler.popPush("generate mipmaps");
generateMipmaps();
profiler.popPush("restore gl state");
restoreGlState(client);
pipeline.endShadowRender();
// Note: This MUST happen before popProgram, otherwise we'll mess up the blend mode override of the program that
// is being restored.
BlendModeOverride.restore();
// Note: This unbinds the shadow framebuffer
pipeline.popProgram(GbufferProgram.NONE);
if (levelRenderer instanceof CullingDataCache) {
((CullingDataCache) levelRenderer).restoreState();
}
levelRenderer.setRenderBuffers(playerBuffers);
ACTIVE = false;
profiler.popPush("updatechunks");
}
use of net.coderbot.iris.vendored.joml.Vector3d in project Iris by IrisShaders.
the class MixinLevelRenderer method iris$renderSky$drawHorizon.
@Inject(method = "renderSky", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/FogRenderer;levelFogColor()V"))
private void iris$renderSky$drawHorizon(PoseStack poseStack, float tickDelta, CallbackInfo callback) {
RenderSystem.depthMask(false);
Vector3d fogColor = CapturedRenderingState.INSTANCE.getFogColor();
RenderSystem.color3f((float) fogColor.x, (float) fogColor.y, (float) fogColor.z);
new HorizonRenderer().renderHorizon(poseStack);
RenderSystem.depthMask(true);
}
use of net.coderbot.iris.vendored.joml.Vector3d in project Iris by IrisShaders.
the class ShadowRenderer method createShadowModelView.
public static PoseStack createShadowModelView(float sunPathRotation, float intervalSize) {
// Determine the camera position
Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
double cameraX = cameraPos.x;
double cameraY = cameraPos.y;
double cameraZ = cameraPos.z;
// Set up our modelview matrix stack
PoseStack modelView = new PoseStack();
ShadowMatrices.createModelViewMatrix(modelView.last().pose(), getShadowAngle(), intervalSize, sunPathRotation, cameraX, cameraY, cameraZ);
return modelView;
}
use of net.coderbot.iris.vendored.joml.Vector3d in project Iris by IrisShaders.
the class Vector3Uniform method converted.
static Vector3Uniform converted(int location, Supplier<Vector3d> value) {
Vector3f held = new Vector3f();
return new Vector3Uniform(location, () -> {
Vector3d updated = value.get();
held.set((float) updated.x, (float) updated.y, (float) updated.z);
return held;
});
}
Aggregations