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

PostProcess: Add hooks to alter shader code used by post processes #13256

Merged
merged 9 commits into from
Nov 16, 2022
Merged

PostProcess: Add hooks to alter shader code used by post processes #13256

merged 9 commits into from
Nov 16, 2022

Conversation

Popov72
Copy link
Contributor

@Popov72 Popov72 commented Nov 16, 2022

This PR allows you to customize the shader code used by the post-processes when specific needs arise.

It allows something like:

    BABYLON.PostProcess.RegisterShaderCodeProcessing("dofMerge", {
        processFinalCode: (ppName, shaderType, code) => {
            if (shaderType === "fragment") {
                code = code.replace("#define CUSTOM_FRAGMENT_DEFINITIONS", "uniform vec4 colorFilter;");
                code = code.replace("original,", "original*colorFilter,");
            }
            return code;
        },

        defineCustomBindings: (ppName, defines, uniforms, samplers) => {
            uniforms.push("colorFilter");
            return defines;
        },

        bindCustomBindings: (ppName, effect) => {
            effect.setFloat4("colorFilter", 0.3, 0.9, 0.4, 1.);
        }
    });

PG: https://playground.babylonjs.com/#B8LWGL#12

Fix #13243

@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

@Popov72 Popov72 marked this pull request as ready for review November 16, 2022 19:25
@sebavan sebavan enabled auto-merge November 16, 2022 20:49
@sebavan sebavan merged commit e95bda8 into BabylonJS:master Nov 16, 2022
RaananW pushed a commit that referenced this pull request Dec 9, 2022
PostProcess: Add hooks to alter shader code used by post processes
Former-commit-id: ef786d400f77b9867fbdc6d0004464996479679e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow customization of the depth sampling function in post processes.
2 participants