Skip to content

Support for ShadersΒ #36

@yusshu

Description

@yusshu

Make creative support shaders and add API for shader modification.

Imperatively (this would require us to parse the shaders):

Shader shader;
shader = shader.modify(m -> m
    .addUniform("mat4", "ModelViewMat")
    .addUniform("mat4", "ProjMat")
    .addUniform("mat3", "IViewRotMat")
    .addIn("vec2", "texCoord1")
    .addIn("float", "part")
    .injectMain(At.START, "if (...) discard;"));

Or maybe using patches (this doesn't require parsing):

Shader shader;
// diff format
shader = shader.patch("""
17 + uniform mat4 ModelViewMat;
18 + uniform mat4 ProjMat;
19 + uniform mat3 IViewRotMat;
20 +
21 + in vec2 texCoord1;
22 + in float part;
""");

Or maybe even something like Mixin, but for GLSL. have a look at JLSL.

@ShaderMixin("rendertype_entity_translucent")
class RenderTypeEntityTranslucentMixin implements FragmentShader {
    @Uniform private Matrix4Float ModelViewMat;
    @Uniform private Matrix4Float ProjMat;
    @Uniform private Matrix3Float IViewRotMat;
    
    @In private Vector2Float texCoord1;
    @In private Vector2Float part;

    @Override
    @Inject(At.START)
    public void main() {
        if (...) { discard(); }
    }
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions