Is it possible to adjust saturation, brightness and contrast of a texture?

Hi everyone,

I’m assigning a texture like this:

material.albedoTexture = new BABYLON.Texture(“texture.jpg”, scene);

Would it be possible to adjust the saturation, brightness and contrast of a texture in the scene that is already assigned to a mesh?

I tried to find this on the forum and documentation but could not find anything.

I already know how to adjust the ‘intensity’ of the diffuse map, but that doesn’t work as desired.

Thanks!

You can adjust the value of the scene itself with image processing but not at the texture level (Not directly)

But it is definitely doable with NME (but you need to write your own shader or wait for @Evgeni_Popov to publish a NME equivalent for PBR)

Okay thanks for the feedback Deltakosh! NME looks really awesome but is above my level on that front :smile:

1 Like

I was looking something like this. If change brightness is enough for you, try to use the level property.

I tried to find this via google but it was failed. But ChatGPT provide a nice and worked example, let’s see it:

Yes, you can change the brightness of a video texture on a mesh in BabylonJS.

To do this, you can adjust the brightness of the video texture by modifying the videoTexture.level property. The level property controls the brightness of the texture, with a value of 1.0 representing the original brightness and lower values representing darker colors.

Here’s an example code snippet that demonstrates how to change the brightness of a video texture in BabylonJS:

// Load video texture
var video = document.createElement('video');
video.src = 'my-video.mp4';
var videoTexture = new BABYLON.VideoTexture('video', video, scene, true, true);

// Create a material with the video texture
var material = new BABYLON.StandardMaterial('material', scene);
material.diffuseTexture = videoTexture;

// Create a mesh with the material
var mesh = BABYLON.MeshBuilder.CreatePlane('mesh', { size: 5 }, scene);
mesh.material = material;

// Change the brightness of the video texture
videoTexture.level = 0.5; // This will make the texture appear darker

In this example, we first load a video and create a video texture from it. We then create a material with the video texture and apply it to a mesh. Finally, we change the brightness of the video texture by setting the level property to a lower value, making the texture appear darker.

Note that changing the brightness of the video texture using the level property will affect all materials that use the same video texture, so if you want to change the brightness of only one mesh, you should create a new video texture with a different level value for that mesh.

© ChatGPT, an AI language model trained by OpenAI

2 Likes