I wanna create a Raw texture to pass some data to vertex shader using uniform. I am trying to create a texture and tried to debug it by putting it on plane, but it shows the total black texture.
const size = 100;
const data = new Float32Array(size * size);
for (let index = 0; index < size * size; index++) {
data[index] = index % 3 === 0 ? 1 : Math.random();
}
const texture = RawTexture.CreateRGBATexture(
data,
size,
size,
this.scene
);
here is playground
Also I wanna use float32Array as data
In your case you need only 1 channel so CreateRTexture instead of RGBA which would contain 4 colors.
Also, you want to specify the type of the texture as float:
1 Like
I wanna use RGBA So I can store 4 floats per pixel and why same thing does not works with RGBA texture??
Still could not solve this, if anyone has any idea on how to solve it please let me know.
Hey thanks, but playground isn’t opening. Giving 404 in console.
It doesn’t work for me when I use float32Array as data, even after specifying Float as type for raw texture
Same issue, unable to open. : (
roland
July 6, 2024, 6:56pm
13
Or actually:
var createScene = function () {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("camera", BABYLON.Tools.ToRadians(90), BABYLON.Tools.ToRadians(65), 10, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
scene.createDefaultLight();
const width = 2;
const height = 2;
const data = new Float32Array([
1, 0, 0, 1,
0, 1, 0, 0.3,
0, 0, 1, 1,
1, 1, 0, 1
]);
const texture = BABYLON.RawTexture.CreateRGBATexture(
data,
width,
height,
scene,
false,
false,
BABYLON.Texture.NEAREST_SAMPLINGMODE,
BABYLON.Engine.TEXTURETYPE_FLOAT
);
return scene;
};
2 Likes
Its working, for some reason playground is only opening in incognito. Need to check why. But thanks : )
1 Like
roland
July 8, 2024, 5:40am
15
Bhushan_Wagh:
But thanks : )
You’re welcome!
Try to clear the localstorage for the playground:
Tried that already, still not working.
roland
July 8, 2024, 6:00am
17
What error do you get in the Network tab when trying to access the playground url?
it gives 404 for snippet api
roland
July 8, 2024, 12:06pm
19
You will not believe but it started to happen to me as well!!
I did the following to make it working again:
Disable the cache:
Refresh the page. It will load.
Uncheck Disable the cache, refresh and it loads…
cc @RaananW in case it hides smthg else
1 Like
might have been a temporary issue. If it happens in the next 1-2 days it is because of me
2 Likes