Skip to content

Commit

Permalink
Merge pull request #85 from ferriarnus/Multiloader-1.19
Browse files Browse the repository at this point in the history
stencil fix 1.19.3
  • Loading branch information
fayer3 authored Dec 10, 2022
2 parents dbd757e + 7bb290e commit d2c9e4e
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/src/main/java/org/vivecraft/VRTextureTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public VRTextureTarget(String name, int width, int height, boolean usedepth, boo
((RenderTargetExtension)this).isLinearFilter(linearFilter);
((RenderTargetExtension)this).setUseStencil(useStencil);
this.resize(width, height, onMac);
if (useStencil) {
Xplat.enableRenderTargetStencil(this);
}
this.setClearColor(0, 0, 0, 0);
}
}
6 changes: 6 additions & 0 deletions common/src/main/java/org/vivecraft/Xplat.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vivecraft;

import com.mojang.blaze3d.pipeline.RenderTarget;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.storage.LevelResource;
Expand Down Expand Up @@ -49,4 +50,9 @@ static String getModVersion() {
static boolean isModLoadedSuccess() {
return false;
}

@ExpectPlatform
static boolean enableRenderTargetStencil(RenderTarget renderTarget) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ default void genMipMaps() {

void setUseStencil(boolean useStencil);

boolean getUseStencil();

void isLinearFilter(boolean linearFilter);

void blitFovReduction(ShaderInstance instance, int width, int height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ protected void actionPerformed(AbstractWidget widget)
{
GuiVROptionButton guivroptionbutton = (GuiVROptionButton)widget;

if (guivroptionbutton.id == VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() || guivroptionbutton.id == VRSettings.VrOptions.FSAA.ordinal())
if (guivroptionbutton.id == VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() || guivroptionbutton.id == VRSettings.VrOptions.FSAA.ordinal() || guivroptionbutton.id == VRSettings.VrOptions.STENCIL_ON.ordinal())
{
if (guivroptionbutton.id != VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() && !((Xplat.isModLoaded("iris") || Xplat.isModLoaded("oculus")) && IrisHelper.isShaderActive())) {
if (guivroptionbutton.id != VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() || !((Xplat.isModLoaded("iris") || Xplat.isModLoaded("oculus")) && IrisHelper.isShaderActive())) {
this.dataholder.vrRenderer.reinitFrameBuffers("Render Setting Changed");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public void setUseStencil(boolean useStencil){
this.useStencil = useStencil;
}

@Override
public boolean getUseStencil(){
return useStencil;
}

@Override
public void clearWithColor(float r, float g, float b, float a, boolean isMac) {
RenderSystem.assertOnRenderThreadOrInit();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.vivecraft.mixin.client.renderer;

import com.mojang.blaze3d.pipeline.RenderTarget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.PostChain;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.vivecraft.extensions.RenderTargetExtension;

@Mixin(PostChain.class)
public class PostChainVRMixin {

@Shadow
@Final
private RenderTarget screenTarget;

@ModifyVariable(method = "addTempTarget", at = @At(value = "STORE"), ordinal = 0)
private RenderTarget vrTarget(RenderTarget old) {
if (((RenderTargetExtension)screenTarget).getUseStencil()) {
((RenderTargetExtension) old).setUseStencil(true);
old.resize(old.width, old.height, Minecraft.ON_OSX);
}
return old;
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/vivecraft.vr.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"client.renderer.entity.MobRendererVRMixin",
"client.renderer.item.ItemPropertiesVRMixin",
"client.renderer.NoSodiumLevelRendererVRMixin",
"client.renderer.PostChainVRMixin",

"world.entity.vehicle.BoatMixin",
"world.item.ItemVRMixin",
Expand Down
5 changes: 5 additions & 0 deletions fabric/src/main/java/org/vivecraft/fabric/XplatImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vivecraft.fabric;

import com.mojang.blaze3d.pipeline.RenderTarget;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;

Expand Down Expand Up @@ -32,4 +33,8 @@ public static String getModVersion() {
public static boolean isModLoadedSuccess() {
return FabricLoader.getInstance().isModLoaded("vivecraft");
}

public static boolean enableRenderTargetStencil(RenderTarget renderTarget) {
return false;
}
}
6 changes: 6 additions & 0 deletions forge/src/main/java/org/vivecraft/forge/XplatImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vivecraft.forge;

import com.mojang.blaze3d.pipeline.RenderTarget;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.fml.loading.FMLLoader;
Expand Down Expand Up @@ -34,4 +35,9 @@ public static String getModVersion() {
public static boolean isModLoadedSuccess() {
return FMLLoader.getLoadingModList().getModFileById("vivecraft") != null;
}

public static boolean enableRenderTargetStencil(RenderTarget renderTarget) {
renderTarget.enableStencil();
return true;
}
}

0 comments on commit d2c9e4e

Please sign in to comment.