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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Sampling a pixel from Texture2D not working on Quest 2

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

  1. sgeiger

    sgeiger

    Joined:
    Feb 22, 2018
    Posts:
    2
    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.                 RenderTexture.active = 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...
     
  2. fla19991510

    fla19991510

    Joined:
    Mar 8, 2020
    Posts:
    3
    I have same issue. Did you solve it?
     
  3. sgeiger

    sgeiger

    Joined:
    Feb 22, 2018
    Posts:
    2
    No. Had to work around it. Sorry.
     
  4. fla19991510

    fla19991510

    Joined:
    Mar 8, 2020
    Posts:
    3