Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Shaders #36

Open
yusshu opened this issue Dec 12, 2023 · 3 comments
Open

Support for Shaders #36

yusshu opened this issue Dec 12, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@yusshu
Copy link
Member

yusshu commented Dec 12, 2023

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(); }
    }
}
@yusshu yusshu added the enhancement New feature or request label Dec 12, 2023
@yusshu yusshu self-assigned this Dec 12, 2023
@dev-hydrogen
Copy link
Contributor

I really like the idea of JLSL. I haven't tried it in practice, but i imagine having access to all the comfort of intellij (autofill, copilot, etc.) for shaders is way better than any text editor / VSCode.

@BiConsumer
Copy link
Member

If this is ever implemented we have to consider the json description of core, program shaders and post shaders. I personally believe that JLSL might be way too much of a hassle, especially for includes

@MelonHell
Copy link
Contributor

The mixin option looks like a dream 🤤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants