hey i am a newbie in babylon.js and javascript. i want to make a post processing manager. suppose that i created a default rendering pipeline of babylon.js or maybe a random post processing effect. note that i don’t store these rendering pipelines and post processing effects inside a global variable so i can’t directly access them after creating them.
Now, i want a function to get a rendering pipeline or a post processing by its name
now that i have accessed the rendering pipeline or post processing, i want functions to delete it and rename it and edit its properties.
I tried using “scene.getPostProcessByName( input.name );” but it didn’t work :((
now i have no clue how to do it and i am stuck, i really need help
PostProcessRenderPipieline is not a PostProcess and is not added to the postProcess array in the scene.
To do that you will need to keep a reference to the render pipeline you are creating, for example in the manager you are creating.
I believe all that you need for pipelines is in the class PostProcessRenderPipelineManager - Babylon.js docs
For postprocesses it is possible to use scene.postProcesses to get full array of scene postprocesses or scene.getPostProcessByName() to get it by name.
i had a little doubts remaining, if u would help me it will be really great,
first, “const pipeline = scene.postProcessRenderPipelineManager.supportedPipelines;” gets all the render pipelines in a array. but how do i access just a single with a unique name? maybe something like “pipeline[//name of the pipeline]” this to access a single one?
second, how do i make a function that returns all the names of pipelines in the array. (just the names)
third, how do i make a function that returns all the names of the post processes in the scene (just the names)
fourth, how do i make a function that returns the names of all the post processing effects present inside a rendering pipeline(just the names)
fifth, can i console log a single post process inside a rendering pipeline? (the entire post process data)
for (const pipeline of supportedPipelines){ console.log (pipeline.name) }
for (const postP of scene.postProcesses){ console.log (postP.name) }
A function that returns names of all active (enabled) post-processing effects inside a DefaultRenderingPipeline
function getActivePostProcessEffectNames(pipeline) {
const enabledEffects = [];
if (pipeline.bloomEnabled) enabledEffects.push("Bloom");
if (pipeline.fxaaEnabled) enabledEffects.push("FXAA");
if (pipeline.sharpenEnabled) enabledEffects.push("Sharpen");
if (pipeline.horizontalBlurEnabled && pipeline.verticalBlurEnabled) enabledEffects.push("Blur");
if (pipeline.chromaticAberrationEnabled) enabledEffects.push("ChromaticAberration");
if (pipeline.depthOfFieldEnabled) enabledEffects.push("DepthOfField");
if (pipeline.grainEnabled) enabledEffects.push("Grain");
if (pipeline.vignetteEnabled) enabledEffects.push("Vignette");
if (pipeline.contrastEnabled) enabledEffects.push("Contrast");
if (pipeline.colorBalanceEnabled) enabledEffects.push("ColorBalance");
if (pipeline.imageProcessingEnabled) enabledEffects.push("ImageProcessing");
return enabledEffects;
}
if (pipeline.fxaa) { console.log("FXAA post-process:", pipeline.fxaa); }
Also note that post-processes are usually attached to a specific camera. If your scene uses multiple cameras with different post-processes, make sure to check the correct camera.
function getPostProcessesForCamera(scene, targetCamera) {
return scene.postProcesses.filter(pp => {
const camera = pp.getCamera();
return camera && camera.id === targetCamera.id;
});
}
const activeCamera = scene.activeCamera;
const pps = getPostProcessesForCamera(scene, activeCamera);
console.dir(pps); // Logs all post-processes attached to activeCamera