This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add custom uniforms to Nvidium's scene data using the render pi…
…peline
- Loading branch information
1 parent
628c46a
commit bed48a8
Showing
19 changed files
with
193 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/io/github/steveplays28/blendium/mixin/iris/IrisMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../steveplays28/blendium/mixin/nvidium/NvidiumPrimaryAndTemporalTerrainRasterizerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.steveplays28.blendium.mixin.nvidium; | ||
|
||
import com.mojang.blaze3d.platform.GlStateManager; | ||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import me.cortex.nvidium.renderers.PrimaryTerrainRasterizer; | ||
import me.cortex.nvidium.renderers.TemporalTerrainRasterizer; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(value = {PrimaryTerrainRasterizer.class, TemporalTerrainRasterizer.class}, remap = false) | ||
public class NvidiumPrimaryAndTemporalTerrainRasterizerMixin { | ||
@Inject(method = "raster", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/NVMeshShader;glMultiDrawMeshTasksIndirectNV(JII)V")) | ||
private void blendium$rasterBlendFuncInject(int regionCount, long commandAddr, CallbackInfo ci) { | ||
RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA.value, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA.value, | ||
GlStateManager.SrcFactor.ONE.value, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA.value | ||
); | ||
RenderSystem.enableBlend(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/io/github/steveplays28/blendium/mixin/nvidium/NvidiumRenderPipelineMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.github.steveplays28.blendium.mixin.nvidium; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalLongRef; | ||
import me.cortex.nvidium.RenderPipeline; | ||
import me.cortex.nvidium.gl.RenderDevice; | ||
import me.cortex.nvidium.managers.SectionManager; | ||
import me.cortex.nvidium.util.DownloadTaskStream; | ||
import me.cortex.nvidium.util.UploadingBufferStream; | ||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderMatrices; | ||
import me.jellysquid.mods.sodium.client.render.viewport.Viewport; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.MinecraftClient; | ||
import org.lwjgl.system.MemoryUtil; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import static io.github.steveplays28.blendium.client.BlendiumClient.config; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(value = RenderPipeline.class, remap = false) | ||
public class NvidiumRenderPipelineMixin { | ||
@Mutable | ||
@Shadow | ||
@Final | ||
private static int SCENE_SIZE; | ||
|
||
@Unique | ||
private static final int INT_UNIFORM_SIZE_BYTES = 4; | ||
@Unique | ||
private static final int FLOAT_UNIFORM_SIZE_BYTES = 4; | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void blendium$constructorInject(RenderDevice device, UploadingBufferStream uploadStream, DownloadTaskStream downloadStream, SectionManager sectionManager, CallbackInfo ci) { | ||
SCENE_SIZE += INT_UNIFORM_SIZE_BYTES * FLOAT_UNIFORM_SIZE_BYTES; | ||
} | ||
|
||
@Inject(method = "renderFrame", at = @At(value = "INVOKE", target = "Lorg/lwjgl/system/MemoryUtil;memPutByte(JB)V", ordinal = 0, shift = At.Shift.BEFORE)) | ||
private void blendium$renderFrameSetUniformsInject(Viewport frustum, ChunkRenderMatrices crm, double px, double py, double pz, CallbackInfo ci, @Local(ordinal = 1) LocalLongRef addr) { | ||
// u_Far | ||
MemoryUtil.memPutInt(addr.get(), MinecraftClient.getInstance().options.getClampedViewDistance()); | ||
addr.set(addr.get() + INT_UNIFORM_SIZE_BYTES); | ||
|
||
// u_ViewDistanceFactor | ||
MemoryUtil.memPutFloat(addr.get(), config.viewDistanceFactor); | ||
addr.set(addr.get() + FLOAT_UNIFORM_SIZE_BYTES); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.