Download

Sample colour value at specific uv coordainte in a texture?

Hi all,

I’m wondering is it possible to return an RGB value for a specific pixel in a texture sampled as a uv coordinate?

For example say i have a texture that is 32x32 pixels, and I want the rgb value of pixel 12U, 7V, supplying 12 and 7 as the specific uv coordinate in this case.

I’m not concerned about sampling the point from the camera, or in word space etc, just purely in texture coordinate space.

Is this possible, and would it then be possible to work with that info in blueprint?

I’m keen to see if I could use textures as methods of defining layouts of objects generated in a blueprint.

Cheers.

It is possible but there no simple way to achieve mentioned effect as far as i know. I would start witch texture coordinate and floor node to separate part of u and v space them multiplying them to get cross section.

tex coordinate > mask R > add 0.5 > floor, this way you can split uv space in two halves in one direction but making this working as parameter where you input for example 2 values to specify place on grid is much more complex

I think he want get this value into blueprint, not inside shader. I had same idea for defining touch areas, but could not find way to get data out of texture.

I am also really curious on how to do this, i’m thinking about making ambilight tv like effects in the engine (so having it work for animating/mediatextures would also be required) :wink:

I think that without some C++ this is not doable. Maybe can be done in BP but this would be total hack.

I had thought about a hacky way to do it:

make a blueprint with a camera aligned with a mesh plane, with the texture applied as an emissive material. Then loop through an array of pixel coordinates, casting a ray from the camera to each pixel position on the plane and return the colour at the hit point. I haven’t tested this yet of course.

I did my touch zone layout with simple 3d meshes. then i packed everything into single blueprint and did trace at x,y coordinates from 200 down to 0. Z value was number of touchzone. but this is hack, I had more problems introduced by this than it solved.

Texture scaled/filled right to resolution of viewport would be best. OR even better class of empty widgets with render level, custom svg shapes etc. That can tell me which one is at the top at xy coordinates. Then we could just paing gui areas, touch zones or anything really there in empty/dummy widget.