Skip to content

Instantly share code, notes, and snippets.

@lowercasebtw
Created January 4, 2026 00:31
Show Gist options
  • Select an option

  • Save lowercasebtw/4cc3a936fec18d8a7c4d91715c91bf45 to your computer and use it in GitHub Desktop.

Select an option

Save lowercasebtw/4cc3a936fec18d8a7c4d91715c91bf45 to your computer and use it in GitHub Desktop.
public RenderPipeline.Snippet toSnippet(final RenderPipeline pipeline) {
final RenderPipeline.Builder builder = RenderPipeline.builder();
builder.withVertexShader(pipeline.getVertexShader());
builder.withFragmentShader(pipeline.getFragmentShader());
for (var sampler : pipeline.getSamplers()) {
builder.withSampler(sampler);
}
for (var uniform : pipeline.getUniforms()) {
builder.withUniform(uniform.name(), uniform.type());
}
for (var define : pipeline.getShaderDefines().flags()) {
builder.withShaderDefine(define);
}
final Optional<BlendFunction> blendFunction = pipeline.getBlendFunction();
if (blendFunction.isPresent()) {
builder.withBlend(blendFunction.get());
} else {
builder.withoutBlend();
}
builder.withDepthTestFunction(pipeline.getDepthTestFunction());
builder.withCull(pipeline.isCull());
builder.withColorLogic(pipeline.getColorLogic());
builder.withDepthWrite(pipeline.isWriteDepth());
builder.withColorWrite(pipeline.isWriteColor(), pipeline.isWriteAlpha());
builder.withVertexFormat(pipeline.getVertexFormat(), pipeline.getVertexFormatMode());
return builder.buildSnippet();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment