Enforce single channel texture


How can one specify the # of channels / format of a texture? Looking at the docs and your code it should be the format parameter of the texture constructor. (Texture | Babylon.js Documentation)

This either doesn’t work or I’m using it in a wrong way. :slight_smile: When inspecting the texture with the inspector it’s always giving me RGBA or querying the texture format results in -1.

I’ve created a simple repro here:

It works as expected, the inspector does not take it in account but as you can see here with a colored texture, it ends up in grayscale: https://playground.babylonjs.com/#ZKX1TH#3

Thx for the quick reply. Yes, it’s visually working but I was unsure if it’s actually using a single channel texture under the hood or just doing a grayscale conversion in the shader (have to admit that I didn’t check your shadercode in that regard). I did some profiling and also couldn’t really tell a memory consumption difference, that’s why I wasn’t sure.

Do you guys have a reliable way of profiling GPU memory? I’m coming from the C++ world, so web development and its profiling is sometimes kind of frustrating and cumbersome for me.
I used plain nvidia-smi now to get somewhat reliable numbers (where I could verify that the texture format actually has an impact) but the browser GPU mem tracking is basically useless since I didn’t get anything that would make much sense.
Sorry for going OT but maybe someone has an hint, otherwise I can also open a new thread for it

As an alternate way to GPU memory tracking (which I don’t think is really possible on the web), you can also use Spector to check the format: