I am trying to write a demo where a user can click on a texture and console.log the pixel color at that point. I use a ray to pick the uv coordinates. Now I am having trouble sampling the texture at those coordinates.
readPixels() returns null when called on the texture. I’ve tried extracting the value from the promise using .then, but I’m still getting null. I haven’t used promises much before though so it is possible I am misusing it.
I remember I did similar with Eyedropper - https://playground.babylonjs.com/#CNGLV3#22
2 Likes
Interesting. I did not know this EyeDropper tool existed.
I’m not sure if this solution will work for my future purposes. This demo is just a proof of concept, and I think I’ll still need to be able to sample a texture directly. It seems like the EyeDropper samples the actual fragment color post illumination.
As for EyeDropper, it does reads the final color.
I believe your question is answered here - Get Texture color value at ray collision point
For the sake of simplicity I would recommend to test your example with usual textures first, without any shader code etc.