Search in sources :

Example 1 with ProgramImages

use of net.coderbot.iris.gl.program.ProgramImages 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();
    }
}
Also used : GlShader(me.jellysquid.mods.sodium.client.gl.shader.GlShader) ResourceLocation(net.minecraft.resources.ResourceLocation) ProgramSamplers(net.coderbot.iris.gl.program.ProgramSamplers) ProgramImages(net.coderbot.iris.gl.program.ProgramImages) GlProgram(me.jellysquid.mods.sodium.client.gl.shader.GlProgram) ProgramUniforms(net.coderbot.iris.gl.program.ProgramUniforms) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GlProgram (me.jellysquid.mods.sodium.client.gl.shader.GlProgram)1 GlShader (me.jellysquid.mods.sodium.client.gl.shader.GlShader)1 ProgramImages (net.coderbot.iris.gl.program.ProgramImages)1 ProgramSamplers (net.coderbot.iris.gl.program.ProgramSamplers)1 ProgramUniforms (net.coderbot.iris.gl.program.ProgramUniforms)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 Nullable (org.jetbrains.annotations.Nullable)1