use of net.coderbot.iris.gl.program.ProgramUniforms in project Iris by IrisShaders.
the class IrisChunkProgramOverrides method createShader.
@Nullable
private ChunkProgram createShader(RenderDevice device, IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
GlShader vertShader = createVertexShader(device, pass, pipeline);
GlShader geomShader = createGeometryShader(device, pass, pipeline);
GlShader fragShader = createFragmentShader(device, pass, pipeline);
if (vertShader == null || fragShader == null) {
if (vertShader != null) {
vertShader.delete();
}
if (geomShader != null) {
geomShader.delete();
}
if (fragShader != null) {
fragShader.delete();
}
// TODO: Partial shader programs?
return null;
}
try {
GlProgram.Builder builder = GlProgram.builder(new ResourceLocation("sodium", "chunk_shader_for_" + pass.getName()));
if (geomShader != null) {
builder.attachShader(geomShader);
}
return builder.attachShader(vertShader).attachShader(fragShader).bindAttribute("a_Pos", ChunkShaderBindingPoints.POSITION).bindAttribute("a_Color", ChunkShaderBindingPoints.COLOR).bindAttribute("a_TexCoord", ChunkShaderBindingPoints.TEX_COORD).bindAttribute("a_LightCoord", ChunkShaderBindingPoints.LIGHT_COORD).bindAttribute("mc_Entity", IrisChunkShaderBindingPoints.BLOCK_ID).bindAttribute("mc_midTexCoord", IrisChunkShaderBindingPoints.MID_TEX_COORD).bindAttribute("at_tangent", IrisChunkShaderBindingPoints.TANGENT).bindAttribute("a_Normal", IrisChunkShaderBindingPoints.NORMAL).bindAttribute("d_ModelOffset", ChunkShaderBindingPoints.MODEL_OFFSET).build((program, name) -> {
ProgramUniforms uniforms = pipeline.initUniforms(name);
ProgramSamplers samplers;
ProgramImages images;
if (pass == IrisTerrainPass.SHADOW) {
samplers = pipeline.initShadowSamplers(name);
images = pipeline.initShadowImages(name);
} else {
samplers = pipeline.initTerrainSamplers(name);
images = pipeline.initTerrainImages(name);
}
return new IrisChunkProgram(device, program, name, uniforms, samplers, images);
});
} finally {
vertShader.delete();
if (geomShader != null) {
geomShader.delete();
}
fragShader.delete();
}
}
Aggregations