l’m attempting to identify and estimate areas of particular colors in a scene and have had some success using a USceneCaptureComponent2D with the “BaseColor in RGB” capture source.
However, I’ve started attempting to generate the colors randomly and have noticed a discrepancy between the colors I’m feeding into a dynamic material instance (Which is just a material with a vector parameter into the Base Color pin) and the colors I’m reading in from my FTextureRenderTarget2DResource::ReadLinearColorPixels.
The variation seems to be around 0.01, although it’s very consistent (So for a particular color, the pixels from the render target will have the same discrepancy every time), which makes me think I’m missing some conversion or something I could do.
Has anyone had any experience with this?
Here’s an abbreviated version of the code I’m using:
USceneCaptureComponent2D* colorCapture;
FTextureRenderTarget2DResource* RenderTargetColor = static_cast<FTextureRenderTarget2DResource*>(colorCapture->TextureTarget->GameThread_GetRenderTargetResource());
TArray<FLinearColor> LinearColorArray;
RenderTargetColor->ReadLinearColorPixels(LinearColorArray);
Also, just for fun, here’s a graph of the variation (How far from the materials set color the captures color is) for 50 colors ( r=0.02 g=0.02 b=0.02, then r=0.04 g=0.04 b=0.04 etc)
There’s some weird patterns that also make me think the variation isn’t random.