I’m trying to make something like a color map that shall be clickable and when I click a color (from a voronoi-cellnoise texture) I want to be able to save it into a variable.
From a line trace hit location I calculate UV coordinates that I then use in a c++ function to try and get the color.
Now the problem is, this is highly dependend on the compression settings of the texture. This article even shows a work around that updates the compression settings of the resource before reading the color values.
Other topics pointed towards the Render Thread and RHITexture info, now I worked something out with ENQUEUE_RENDER_COMMAND but without further work, it is also depending on compression settings.
The problem is, I can kinda get the color when the texture has compression set to VectorDisplacementmap, but it’s not the color that will be displayed, which looks more like the color that comes from HDR compression. And also, I am trying to match the color in the material and the material doesn’t seem to get anything else than the HDR texture sample, so I can’t ever match selected colors with any cells in the material.
Here’s the two textures, VectorDispl left and HDR right… As you can see it’s way darkerd. I only ever managed to read the then correct but to me useless values from VD, but what I get from the TextureSample node in the material is seemingly always more something towards HDR…
I read through the docs and found something about “Pow(1/2.2)” so when I take the HDR version in the Material and exponentiate it with 2.2 before comparing it, I can kind of match them correctly. But it somehow seems awfully inaccurate. As you can see “selected colors” are highlighted, but sometimes other areas get selected as well.
Of course the noise doesn’t provide uniqueness from the start, but sometimes is just comes from inacurracy… I am comparing each channel from both colors and sum up the differences. An accumulated difference of <= 0.03 is seen as “equal”. If I change that to 0.05, more double selections start to appear. If I change it to 0.02, some colors can’t even be selected at all.
Is there no better way to make something like this? Of course, if the map would have higher accuracy / the collors had higher differences, this wouldn’t be much of a problem, especially with hand drawn maps, but the ultimate goal is of course procedural generation.
Hi there.
Could you please explain how you got the UV Coords from hit result?
I am trying to make a clickable map and by search I saw you were looking for that too.
Can you please help me?