Jump to content

Recommended Posts

Hello,

I've been messing around with some colormaps I generate. I have a ShaderMaterial and would like to send some colormaps to the shader using ShaderMaterial.setTexture(). My colormaps are dynamically generated and result in a RGB image stored as a Uint8Array. To illustrate the test, I am using a 1x1 texture.

I have no problem a RGBA image as uniform on the shader, like that:

// this works well
let cmTexture = new BABYLON.RawTexture(
  new Uint8Array([128, 128, 128, 255]), // data
  1, // width
  1, // height
  BABYLON.Engine.TEXTUREFORMAT_RGBA, // format
  this._scene, // scene
  false, // gen mipmaps
  false, // invertY
  BABYLON.Texture.TRILINEAR_SAMPLINGMODE,
  BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT
)

But, if I want to create a RGB texture (no alpha channel), it does not work:

// JS lets me do it, but WebGL yells at me
let cmTexture = new BABYLON.RawTexture(
  new Uint8Array([128, 128, 128]), // data
  1, // width
  1, // height
  BABYLON.Engine.TEXTUREFORMAT_RGB, // format
  this._scene, // scene
  false, // gen mipmaps
  false, // invertY
  BABYLON.Texture.TRILINEAR_SAMPLINGMODE,
  BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT
)

Then, I have the following error:

5ad8cb13eae4d_Capturedecran2018-04-19a12_57_39.thumb.png.709e3acc8af2464da9660f81491fc2c2.png

The first warning ("WebGL: ...") occurs at the creation of the RawTexture, while the second one occurs when doing shaderMaterial.setTexture(...)

I can still use RGBA so it's not a super big deal, but there is probably a little bug somewhere...

Cheers.

 

 

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.

×
×
  • Create New...