Common Shaders #14
No files matched your search
+41
-2
@@ -12,10 +12,12 @@ import net.irisshaders.iris.gl.blending.AlphaTest;
|
|||||||
import net.irisshaders.iris.gl.buffer.ShaderStorageBufferHolder;
|
import net.irisshaders.iris.gl.buffer.ShaderStorageBufferHolder;
|
||||||
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
||||||
import net.irisshaders.iris.gl.image.GlImage;
|
import net.irisshaders.iris.gl.image.GlImage;
|
||||||
|
import net.irisshaders.iris.gl.image.ImageHolder;
|
||||||
import net.irisshaders.iris.gl.program.ComputeProgram;
|
import net.irisshaders.iris.gl.program.ComputeProgram;
|
||||||
import net.irisshaders.iris.gl.program.ProgramBuilder;
|
import net.irisshaders.iris.gl.program.ProgramBuilder;
|
||||||
import net.irisshaders.iris.gl.program.ProgramImages;
|
import net.irisshaders.iris.gl.program.ProgramImages;
|
||||||
import net.irisshaders.iris.gl.program.ProgramSamplers;
|
import net.irisshaders.iris.gl.program.ProgramSamplers;
|
||||||
|
import net.irisshaders.iris.gl.sampler.SamplerHolder;
|
||||||
import net.irisshaders.iris.gl.sampler.SamplerLimits;
|
import net.irisshaders.iris.gl.sampler.SamplerLimits;
|
||||||
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
import net.irisshaders.iris.gl.shader.ShaderCompileException;
|
||||||
import net.irisshaders.iris.gl.state.FogMode;
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
@@ -600,6 +602,37 @@ public abstract class CommonIrisRenderingPipeline implements WorldRenderingPipel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addGbufferOrShadowSamplers(SamplerHolder samplers, ImageHolder images, Supplier<ImmutableSet<Integer>> flipped,
|
||||||
|
boolean isShadowPass, boolean hasTexture, boolean hasLightmap, boolean hasOverlay) {
|
||||||
|
TextureStage textureStage = TextureStage.GBUFFERS_AND_SHADOW;
|
||||||
|
|
||||||
|
ProgramSamplers.CustomTextureSamplerInterceptor samplerHolder =
|
||||||
|
ProgramSamplers.customTextureSamplerInterceptor(samplers,
|
||||||
|
customTextureManager.getCustomTextureIdMap().getOrDefault(textureStage, Object2ObjectMaps.emptyMap()));
|
||||||
|
|
||||||
|
IrisSamplers.addRenderTargetSamplers(samplerHolder, flipped, renderTargets, false, this);
|
||||||
|
IrisSamplers.addCustomTextures(samplerHolder, customTextureManager.getIrisCustomTextures());
|
||||||
|
IrisImages.addRenderTargetImages(images, flipped, renderTargets);
|
||||||
|
IrisImages.addCustomImages(images, customImages);
|
||||||
|
|
||||||
|
if (!shouldBindPBR) {
|
||||||
|
shouldBindPBR = IrisSamplers.hasPBRSamplers(samplerHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisSamplers.addLevelSamplers(samplers, this, (MCAbstractTexture) getWhitePixel(), hasTexture, hasLightmap, hasOverlay);
|
||||||
|
IrisSamplers.addWorldDepthSamplers(samplerHolder, this.renderTargets);
|
||||||
|
IrisSamplers.addNoiseSampler(samplerHolder, this.customTextureManager.getNoiseTexture());
|
||||||
|
IrisSamplers.addCustomImages(samplerHolder, customImages);
|
||||||
|
|
||||||
|
if (IrisSamplers.hasShadowSamplers(samplerHolder)) {
|
||||||
|
IrisSamplers.addShadowSamplers(samplerHolder, shadowTargetsSupplier.get(), null, separateHardwareSamplers);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShadowPass || IrisImages.hasShadowImages(images)) {
|
||||||
|
IrisImages.addShadowColorImages(images, shadowTargetsSupplier.get(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void renderHorizon();
|
protected abstract void renderHorizon();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1420,8 +1453,14 @@ public abstract class CommonIrisRenderingPipeline implements WorldRenderingPipel
|
|||||||
|
|
||||||
protected abstract MCShaderInstance createFallbackShader(String name, ShaderKey key) throws IOException;
|
protected abstract MCShaderInstance createFallbackShader(String name, ShaderKey key) throws IOException;
|
||||||
|
|
||||||
protected abstract CompletableFuture<MCShaderInstance> createShadowShader(String name, Optional<ProgramSource> source, ShaderKey key, Executor syncExecutor)
|
protected CompletableFuture<MCShaderInstance> createShadowShader(String name, Optional<ProgramSource> source, ShaderKey key, Executor syncExecutor) throws IOException {
|
||||||
throws IOException;
|
if (!source.isPresent()) {
|
||||||
|
return CompletableFuture.completedFuture(createFallbackShadowShader(name, key));
|
||||||
|
}
|
||||||
|
|
||||||
|
return createShadowShader(name, syncExecutor, source.get(), key.getProgram(), key.getAlphaTest(), key.getVertexFormat(),
|
||||||
|
key.isIntensity(), key.shouldIgnoreLightmap(), key.isText());
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract MCShaderInstance createFallbackShadowShader(String name, ShaderKey key) throws IOException;
|
protected abstract MCShaderInstance createFallbackShadowShader(String name, ShaderKey key) throws IOException;
|
||||||
|
|
||||||
|
|||||||
-48
@@ -8,25 +8,18 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
|
||||||
import net.irisshaders.iris.gl.blending.AlphaTest;
|
import net.irisshaders.iris.gl.blending.AlphaTest;
|
||||||
import net.irisshaders.iris.gl.blending.BlendModeOverride;
|
import net.irisshaders.iris.gl.blending.BlendModeOverride;
|
||||||
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
|
||||||
import net.irisshaders.iris.gl.image.ImageHolder;
|
|
||||||
import net.irisshaders.iris.gl.program.ProgramSamplers;
|
|
||||||
import net.irisshaders.iris.gl.sampler.SamplerHolder;
|
|
||||||
import net.irisshaders.iris.gl.state.FogMode;
|
import net.irisshaders.iris.gl.state.FogMode;
|
||||||
import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
|
import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
|
||||||
import net.irisshaders.iris.gl.state.ShaderAttributeInputsBuilder;
|
import net.irisshaders.iris.gl.state.ShaderAttributeInputsBuilder;
|
||||||
import net.irisshaders.iris.pathways.HorizonRenderer;
|
import net.irisshaders.iris.pathways.HorizonRenderer;
|
||||||
import net.irisshaders.iris.pipeline.programs.*;
|
import net.irisshaders.iris.pipeline.programs.*;
|
||||||
import net.irisshaders.iris.samplers.IrisImages;
|
|
||||||
import net.irisshaders.iris.samplers.IrisSamplers;
|
|
||||||
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
import net.irisshaders.iris.shaderpack.loading.ProgramId;
|
||||||
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
|
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
|
||||||
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||||
import net.irisshaders.iris.shaderpack.texture.TextureStage;
|
|
||||||
import net.irisshaders.iris.shadows.CommonShadowRenderer;
|
import net.irisshaders.iris.shadows.CommonShadowRenderer;
|
||||||
import net.irisshaders.iris.shadows.ShadowCompositeRenderer;
|
import net.irisshaders.iris.shadows.ShadowCompositeRenderer;
|
||||||
import net.irisshaders.iris.shadows.ModernShadowRenderer;
|
import net.irisshaders.iris.shadows.ModernShadowRenderer;
|
||||||
@@ -136,16 +129,6 @@ public class ModernIrisRenderingPipeline extends CommonIrisRenderingPipeline imp
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected CompletableFuture<MCShaderInstance> createShadowShader(String name, Optional<ProgramSource> source, ShaderKey key, Executor syncExecutor) throws IOException {
|
|
||||||
if (!source.isPresent()) {
|
|
||||||
return CompletableFuture.completedFuture(createFallbackShadowShader(name, key));
|
|
||||||
}
|
|
||||||
|
|
||||||
return createShadowShader(name, syncExecutor, source.get(), key.getProgram(), key.getAlphaTest(), key.getVertexFormat(),
|
|
||||||
key.isIntensity(), key.shouldIgnoreLightmap(), key.isText());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MCShaderInstance createFallbackShadowShader(String name, ShaderKey key) throws IOException {
|
protected MCShaderInstance createFallbackShadowShader(String name, ShaderKey key) throws IOException {
|
||||||
GlFramebuffer framebuffer = shadowRenderTargets.createShadowFramebuffer(ImmutableSet.of(), new int[]{0});
|
GlFramebuffer framebuffer = shadowRenderTargets.createShadowFramebuffer(ImmutableSet.of(), new int[]{0});
|
||||||
@@ -179,37 +162,6 @@ public class ModernIrisRenderingPipeline extends CommonIrisRenderingPipeline imp
|
|||||||
}, syncExecutor);
|
}, syncExecutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGbufferOrShadowSamplers(SamplerHolder samplers, ImageHolder images, Supplier<ImmutableSet<Integer>> flipped,
|
|
||||||
boolean isShadowPass, boolean hasTexture, boolean hasLightmap, boolean hasOverlay) {
|
|
||||||
TextureStage textureStage = TextureStage.GBUFFERS_AND_SHADOW;
|
|
||||||
|
|
||||||
ProgramSamplers.CustomTextureSamplerInterceptor samplerHolder =
|
|
||||||
ProgramSamplers.customTextureSamplerInterceptor(samplers,
|
|
||||||
customTextureManager.getCustomTextureIdMap().getOrDefault(textureStage, Object2ObjectMaps.emptyMap()));
|
|
||||||
|
|
||||||
IrisSamplers.addRenderTargetSamplers(samplerHolder, flipped, renderTargets, false, this);
|
|
||||||
IrisSamplers.addCustomTextures(samplerHolder, customTextureManager.getIrisCustomTextures());
|
|
||||||
IrisImages.addRenderTargetImages(images, flipped, renderTargets);
|
|
||||||
IrisImages.addCustomImages(images, customImages);
|
|
||||||
|
|
||||||
if (!shouldBindPBR) {
|
|
||||||
shouldBindPBR = IrisSamplers.hasPBRSamplers(samplerHolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
IrisSamplers.addLevelSamplers(samplers, this, (MCAbstractTexture) getWhitePixel(), hasTexture, hasLightmap, hasOverlay);
|
|
||||||
IrisSamplers.addWorldDepthSamplers(samplerHolder, this.renderTargets);
|
|
||||||
IrisSamplers.addNoiseSampler(samplerHolder, this.customTextureManager.getNoiseTexture());
|
|
||||||
IrisSamplers.addCustomImages(samplerHolder, customImages);
|
|
||||||
|
|
||||||
if (IrisSamplers.hasShadowSamplers(samplerHolder)) {
|
|
||||||
IrisSamplers.addShadowSamplers(samplerHolder, shadowTargetsSupplier.get(), null, separateHardwareSamplers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isShadowPass || IrisImages.hasShadowImages(images)) {
|
|
||||||
IrisImages.addShadowColorImages(images, shadowTargetsSupplier.get(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderTargetStateListener getRenderTargetStateListener() {
|
public RenderTargetStateListener getRenderTargetStateListener() {
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in new issue
Block a user