Alpha channel in applyDisplacementMap

Hi everyone,

I recently ran into a situation where I needed to apply a displacement map on a mesh, from a transparent PNG, where only the opaque pixels needed to “modify” the mesh. But it looks like the function ignores the alpha channel, so a black pixel (0,0,0,255) is treated as 0 (where I needed it to be 1).

repro of the issue: Babylon.js Playground

I had to rewrite the applyDisplacementMapFromBuffer function to make this work, so I’m wondering if maybe this is a good idea to add the posibility of using the alpha channel as the gradient.

I can try to make a PR for this if requested. I feel like it’s time for me to give back to this community, after everything that it’s given to me.

Yes, I think having an option to use the alpha channel instead of r/g/b could be a good addition to applyDisplacementMap!