leht

How to change blend equation?

Recommended Posts

Hello,

Could you tell me how to use the blend equation other than GL_FUNC_ADD and GL_FUNC_SUBTRACT? For example I want to use the GL_MIN and GL_MAX.

I've read about the Material.alphaMode property but cannot find the suitable option for my case.

Share this post


Link to post
Share on other sites

I find the function setAlphaEquationParameters(rgb: number, alpha: number) in class Engine but it isn't called anywhere. Could you call it in the setAlphaMode function in some way?

Share this post


Link to post
Share on other sites

@leht gotcha, you can probably call setAlphaEquationParameters with an onBindObservable call on the material:

 

let mat = new BABYLON.StandardMaterial("standard", scene);
mat.onBindObservable = function() {
    engine.setAlphaEquationParameters(...); // pass parameters here
}

 

Share this post


Link to post
Share on other sites

Thank you very much! It works.

A bit correcting: we should call engine._alphaState.setAlphaEquationParameters(...)

Do you think we need some clearer way to customize blend mode (blend equation, blend func parameters)? I think Material.alphaMode  is easy to use but not enough. And do the trick like above seems quite ugly ...

Share this post


Link to post
Share on other sites

Thanks @Deltakosh,

Of course I can do a PR for some more options, but I think there will be not many people here need them, since those options are only for some special needs. (I'm working in the MIP / MinIP feature of a DICOM viewer medical application, not a video game.)

Recently I worked with Three JS & they have a customBlending mode with separated methods for customizing blend equation & blend function parameters (https://threejs.org/docs/#api/en/constants/CustomBlendingEquations).

Do you think we need a similar way for easier customization?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.