use of net.coderbot.iris.gl.program.ProgramBuilder in project Iris by IrisShaders.
the class DeferredWorldRenderingPipeline method createEntityPass.
private Pass createEntityPass(ProgramSource source) {
// TODO: Properly handle empty shaders
String geometry = source.getGeometrySource().orElse(null);
String vertex = AttributeShaderTransformer.patch(source.getVertexSource().orElseThrow(NullPointerException::new), ShaderType.VERTEX, geometry != null);
String fragment = AttributeShaderTransformer.patch(source.getFragmentSource().orElseThrow(NullPointerException::new), ShaderType.FRAGMENT, geometry != null);
ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment, IrisSamplers.WORLD_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
throw new RuntimeException("Shader compilation failed!", e);
}
return createPassInner(builder, source.getParent().getPack().getIdMap(), source.getDirectives(), source.getParent().getPackDirectives());
}
use of net.coderbot.iris.gl.program.ProgramBuilder in project Iris by IrisShaders.
the class FinalPassRenderer method createProgram.
// TODO: Don't just copy this from DeferredWorldRenderingPipeline
private Program createProgram(ProgramSource source, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot, Supplier<ShadowMapRenderer> shadowMapRendererSupplier) {
// TODO: Properly handle empty shaders
Objects.requireNonNull(source.getVertexSource());
Objects.requireNonNull(source.getFragmentSource());
Objects.requireNonNull(flipped);
ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getFragmentSource().orElse(null), IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
throw new RuntimeException("Shader compilation failed!", e);
}
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
CommonUniforms.addCommonUniforms(builder, source.getParent().getPack().getIdMap(), source.getParent().getPackDirectives(), updateNotifier);
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
IrisImages.addRenderTargetImages(builder, () -> flipped, renderTargets);
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noiseTexture);
IrisSamplers.addCompositeSamplers(customTextureSamplerInterceptor, renderTargets);
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowMapRendererSupplier.get());
IrisImages.addShadowColorImages(builder, shadowMapRendererSupplier.get());
}
// TODO: Don't duplicate this with CompositeRenderer
// TODO: Parse the value of const float centerDepthSmoothHalflife from the shaderpack's fragment shader configuration
builder.uniform1f(UniformUpdateFrequency.PER_FRAME, "centerDepthSmooth", this.centerDepthSampler::getCenterDepthSmoothSample);
return builder.build();
}
use of net.coderbot.iris.gl.program.ProgramBuilder in project Iris by IrisShaders.
the class CompositeRenderer method createProgram.
// TODO: Don't just copy this from DeferredWorldRenderingPipeline
private Program createProgram(ProgramSource source, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot, Supplier<ShadowMapRenderer> shadowMapRendererSupplier) {
// TODO: Properly handle empty shaders
Objects.requireNonNull(source.getVertexSource());
Objects.requireNonNull(source.getFragmentSource());
Objects.requireNonNull(flipped);
ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getFragmentSource().orElse(null), IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
throw new RuntimeException("Shader compilation failed!", e);
}
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
CommonUniforms.addCommonUniforms(builder, source.getParent().getPack().getIdMap(), source.getParent().getPackDirectives(), updateNotifier);
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
IrisImages.addRenderTargetImages(builder, () -> flipped, renderTargets);
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noiseTexture);
IrisSamplers.addCompositeSamplers(customTextureSamplerInterceptor, renderTargets);
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowMapRendererSupplier.get());
IrisImages.addShadowColorImages(builder, shadowMapRendererSupplier.get());
}
// TODO: Don't duplicate this with FinalPassRenderer
// TODO: Parse the value of const float centerDepthSmoothHalflife from the shaderpack's fragment shader configuration
builder.uniform1f(UniformUpdateFrequency.PER_FRAME, "centerDepthSmooth", this.centerDepthSampler::getCenterDepthSmoothSample);
return builder.build();
}
use of net.coderbot.iris.gl.program.ProgramBuilder in project Iris by IrisShaders.
the class ShadowRenderer method createProgram.
// TODO: Don't just copy this from ShaderPipeline
private Program createProgram(ProgramSource source, PackDirectives directives, Supplier<ImmutableSet<Integer>> flipped) {
// TODO: Properly handle empty shaders
Objects.requireNonNull(source.getVertexSource());
Objects.requireNonNull(source.getFragmentSource());
ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getFragmentSource().orElse(null), IrisSamplers.WORLD_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
throw new RuntimeException("Shader compilation failed!", e);
}
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds);
CommonUniforms.addCommonUniforms(builder, source.getParent().getPack().getIdMap(), directives, pipeline.getFrameUpdateNotifier());
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, gbufferRenderTargets, false);
IrisImages.addRenderTargetImages(builder, flipped, gbufferRenderTargets);
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, normals, specular);
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noise);
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, this);
IrisImages.addShadowColorImages(builder, this);
return builder.build();
}
Aggregations