shader faker thing
This commit is contained in:
@@ -21,6 +21,7 @@ import static org.lwjgl.opengl.GL40.glBlendFuncSeparatei;
|
||||
public class IrisShaderPatch {
|
||||
public static final int VERSION = ((IntSupplier)()->1).getAsInt();
|
||||
|
||||
public static final boolean IMPERSONATE_DISTANT_HORIZONS = System.getProperty("voxy.impersonateDHShader", "false").equalsIgnoreCase("true");
|
||||
|
||||
private static final class SSBODeserializer implements JsonDeserializer<Int2ObjectOpenHashMap<String>> {
|
||||
@Override
|
||||
|
||||
@@ -292,8 +292,18 @@ public class IrisVoxyRenderPipelineData {
|
||||
|
||||
CachedUniform[] uniforms = new CachedUniform[patch.getUniformList().length];
|
||||
((CustomUniformsAccessor)cu).getLocationMap().get(patch).object2IntEntrySet().forEach(entry->uniforms[entry.getIntValue()] = entry.getKey());
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
for (var uniform : uniforms) {
|
||||
if (uniform == null) {
|
||||
Logger.error("Unknown uniform at location "+j + " skipping");
|
||||
} else {
|
||||
uniforms[i++] = uniform;//This shuffles the uniforms down till its compacted
|
||||
}
|
||||
j++;
|
||||
}
|
||||
//In _theory_ this should work?
|
||||
return uniforms;
|
||||
return Arrays.copyOf(uniforms, i);
|
||||
}
|
||||
|
||||
private record TextureWSampler(String name, IntSupplier texture, int sampler) { }
|
||||
|
||||
@@ -8,6 +8,14 @@ public class VoxySamplers {
|
||||
public static void addSamplers(IrisRenderingPipeline pipeline, SamplerHolder samplers) {
|
||||
var patchData = ((IGetVoxyPatchData)pipeline).voxy$getPatchData();
|
||||
if (patchData != null) {
|
||||
String[] opaqueNames = new String[]{"vxDepthTexOpaque"};
|
||||
String[] translucentNames = new String[]{"vxDepthTexTrans"};
|
||||
|
||||
if (IrisShaderPatch.IMPERSONATE_DISTANT_HORIZONS) {
|
||||
opaqueNames = new String[]{"vxDepthTexOpaque", "dhDepthTex1"};
|
||||
translucentNames = new String[]{"vxDepthTexTrans", "dhDepthTex", "dhDepthTex0"};
|
||||
}
|
||||
|
||||
//TODO replace ()->0 with the actual depth texture id
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, () -> {
|
||||
var pipeData = ((IGetIrisVoxyPipelineData)pipeline).voxy$getPipelineData();
|
||||
@@ -24,7 +32,8 @@ public class VoxySamplers {
|
||||
return 0;
|
||||
}
|
||||
return dt.id;
|
||||
}, null, "vxDepthTexOpaque");
|
||||
}, null, opaqueNames);
|
||||
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, () -> {
|
||||
var pipeData = ((IGetIrisVoxyPipelineData)pipeline).voxy$getPipelineData();
|
||||
if (pipeData == null) {
|
||||
@@ -39,7 +48,7 @@ public class VoxySamplers {
|
||||
return 0;
|
||||
}
|
||||
return dt.id;
|
||||
}, null, "vxDepthTexTrans");
|
||||
}, null, translucentNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,17 @@ public class VoxyUniforms {
|
||||
.uniformMatrix(PER_FRAME, "vxProj", VoxyUniforms::getProjection)
|
||||
.uniformMatrix(PER_FRAME, "vxProjInv", new Inverted(VoxyUniforms::getProjection))
|
||||
.uniformMatrix(PER_FRAME, "vxProjPrev", new PreviousMat(VoxyUniforms::getProjection));
|
||||
|
||||
if (IrisShaderPatch.IMPERSONATE_DISTANT_HORIZONS) {
|
||||
uniforms
|
||||
.uniform1f(PER_FRAME, "dhNearPlane", ()->16)//Presently hardcoded in voxy
|
||||
.uniform1f(PER_FRAME, "dhFarPlane", ()->16*3000)//Presently hardcoded in voxy
|
||||
|
||||
.uniform1i(PER_FRAME, "dhRenderDistance", ()-> VoxyConfig.loadOrCreate().sectionRenderDistance*32)//In chunks
|
||||
.uniformMatrix(PER_FRAME, "dhProjection", VoxyUniforms::getProjection)
|
||||
.uniformMatrix(PER_FRAME, "dhProjectionInverse", new Inverted(VoxyUniforms::getProjection))
|
||||
.uniformMatrix(PER_FRAME, "dhPreviousProjection", new PreviousMat(VoxyUniforms::getProjection));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = CommonUniforms.class, remap = false)
|
||||
public class MixinMatrixUniforms {
|
||||
@Inject(method = "addNonDynamicUniforms", at = @At("TAIL"))
|
||||
@Inject(method = "addNonDynamicUniforms", at = @At("HEAD"))//Am so angry ims this is what IS REQUIRED TODO, because we need to override the uniforms of dh
|
||||
private static void voxy$InjectMatrixUniforms(UniformHolder uniforms, IdMap idMap, PackDirectives directives, FrameUpdateNotifier updateNotifier, CallbackInfo ci) {
|
||||
if (VoxyConfig.CONFIG.isRenderingEnabled() && IrisUtil.SHADER_SUPPORT) {
|
||||
VoxyUniforms.addUniforms(uniforms);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import me.cortex.voxy.client.config.VoxyConfig;
|
||||
import me.cortex.voxy.client.core.util.IrisUtil;
|
||||
import me.cortex.voxy.client.iris.IrisShaderPatch;
|
||||
import net.irisshaders.iris.gl.shader.StandardMacros;
|
||||
import net.irisshaders.iris.helpers.StringPair;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -23,6 +24,9 @@ public abstract class MixinStandardMacros {
|
||||
private static ImmutableList<StringPair> voxy$injectVoxyDefine(Collection<StringPair> list, Operation<ImmutableList<StringPair>> original) {
|
||||
if (VoxyConfig.CONFIG.isRenderingEnabled() && IrisUtil.SHADER_SUPPORT) {
|
||||
define((List<StringPair>) list, "VOXY");
|
||||
if (IrisShaderPatch.IMPERSONATE_DISTANT_HORIZONS) {
|
||||
define((List<StringPair>) list, "DISTANT_HORIZONS");
|
||||
}
|
||||
}
|
||||
return ImmutableList.copyOf(list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user