Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question Sampling a pixel from Texture2D not working on Quest 2

Discussion in 'VR' started by sgeiger, Jan 26, 2023.

  1. sgeiger


    Feb 22, 2018
    I'm trying to sample color from a pixel of a RenderTexture, using the method of copying the RT to a Texture2D and then sampling with GetPixel:

    Code (CSharp):
    1.        = renderTex;
    2.                 tex2D.ReadPixels(new Rect(0, 0, tex2D.width, tex2D.height), 0, 0);
    3.                 tex2D.Apply();
    4.                 Color col = tex2D.GetPixelBilinear(pixelPos.x, pixelPos.y);
    This works great on the editor, but when building for the quest it gives some weird behaviour: most of the time the color it returns is black (regardless of the real texture color), but every now and then it "flashes" the correct color for a single frame.
    Couldn't find a solution for this specific behaviour anywhere...