Skip to content

Commit

Permalink
Fix bad flipping behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jan 27, 2024
1 parent 9ea4079 commit acbd3b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ public void prepareNewPipeline(NewWorldRenderingPipeline pipeline, boolean dhSha
}

ProgramSource terrain = pipeline.getDHTerrainShader().get();
solidProgram = IrisLodRenderProgram.createProgram(terrain.getName(), false, terrain, pipeline.getCustomUniforms(), pipeline);
solidProgram = IrisLodRenderProgram.createProgram(terrain.getName(), false, false, terrain, pipeline.getCustomUniforms(), pipeline);

if (pipeline.getDHWaterShader().isPresent()) {
ProgramSource water = pipeline.getDHWaterShader().get();
translucentProgram = IrisLodRenderProgram.createProgram(water.getName(), false, water, pipeline.getCustomUniforms(), pipeline);
translucentProgram = IrisLodRenderProgram.createProgram(water.getName(), false, true, water, pipeline.getCustomUniforms(), pipeline);
dhWaterFramebuffer = pipeline.createDHFramebuffer(water, true);
}

if (pipeline.getDHShadowShader().isPresent() && dhShadowEnabled) {
ProgramSource shadow = pipeline.getDHShadowShader().get();
shadowProgram = IrisLodRenderProgram.createProgram(shadow.getName(), true, shadow, pipeline.getCustomUniforms(), pipeline);
shadowProgram = IrisLodRenderProgram.createProgram(shadow.getName(), true, false, shadow, pipeline.getCustomUniforms(), pipeline);
if (pipeline.hasShadowRenderTargets()) {
dhShadowFramebuffer = pipeline.createDHFramebufferShadow(shadow);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class IrisLodRenderProgram
private final ProgramImages images;
private final BlendModeOverride blend;

public static IrisLodRenderProgram createProgram(String name, boolean isShadowPass, ProgramSource source, CustomUniforms uniforms, NewWorldRenderingPipeline pipeline) {
public static IrisLodRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, NewWorldRenderingPipeline pipeline) {
Map<PatchShaderType, String> transformed = TransformPatcher.patchDH(
name,
source.getVertexSource().orElseThrow(RuntimeException::new),
Expand All @@ -92,7 +92,7 @@ public static IrisLodRenderProgram createProgram(String name, boolean isShadowPa
.addSources(transformed)
.setName("dh_" + name)
.print();
return new IrisLodRenderProgram(name, isShadowPass, source.getDirectives().getBlendModeOverride().orElse(null), vertex, tessControl, tessEval, geometry, fragment, uniforms, pipeline);
return new IrisLodRenderProgram(name, isShadowPass, translucent, source.getDirectives().getBlendModeOverride().orElse(null), vertex, tessControl, tessEval, geometry, fragment, uniforms, pipeline);
}

public int tryGetUniformLocation2(CharSequence name) {
Expand All @@ -104,7 +104,7 @@ public int tryGetUniformLocation2(CharSequence name) {
// Noise Uniforms

// This will bind AbstractVertexAttribute
private IrisLodRenderProgram(String name, boolean isShadowPass, BlendModeOverride override, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, NewWorldRenderingPipeline pipeline)
private IrisLodRenderProgram(String name, boolean isShadowPass, boolean translucent, BlendModeOverride override, String vertex, String tessControl, String tessEval, String geometry, String fragment, CustomUniforms customUniforms, NewWorldRenderingPipeline pipeline)
{
id = GL43C.glCreateProgram();

Expand Down Expand Up @@ -160,7 +160,7 @@ private IrisLodRenderProgram(String name, boolean isShadowPass, BlendModeOverrid
customUniforms.assignTo(uniformBuilder);
BuiltinReplacementUniforms.addBuiltinReplacementUniforms(uniformBuilder);
ProgramImages.Builder builder = ProgramImages.builder(id);
pipeline.addGbufferOrShadowSamplers(samplerBuilder, builder, isShadowPass ? () -> pipeline.flippedBeforeShadow : () -> pipeline.flippedAfterPrepare, isShadowPass, new InputAvailability(false, true, false));
pipeline.addGbufferOrShadowSamplers(samplerBuilder, builder, isShadowPass ? () -> pipeline.flippedBeforeShadow : () -> translucent ? pipeline.flippedAfterTranslucent : pipeline.flippedAfterPrepare, isShadowPass, new InputAvailability(false, true, false));
customUniforms.mapholderToPass(uniformBuilder, this);
this.uniforms = uniformBuilder.buildUniforms();
this.customUniforms = customUniforms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public class NewWorldRenderingPipeline implements WorldRenderingPipeline, CoreWo

public final ImmutableSet<Integer> flippedBeforeShadow;
public final ImmutableSet<Integer> flippedAfterPrepare;
private final ImmutableSet<Integer> flippedAfterTranslucent;
public final ImmutableSet<Integer> flippedAfterTranslucent;

public boolean isBeforeTranslucent;

Expand Down

0 comments on commit acbd3b1

Please sign in to comment.