Search Unity

Sampling Texture3D with Bilinear/Trilinear SampleState is not respected on iOS

Discussion in 'Shaders' started by PolySean, Feb 18, 2020.

  1. PolySean

    PolySean

    Joined:
    Aug 9, 2016
    Posts:
    2
    Title says all. I have a Texture3D and when I set filter mode in the inspector to Bilinear or Trilinear and sample from it on PC it looks fine. However, when I build for iOS and sample using tex3D() or using _Cache.Sample(Cache_Trilinear_Mirror_Sampler, ... it renders as if were sampling using point filtering.

    Anybody know what's going on here?

    Here is where I'm declaring the Texture3D:
    Code (CSharp):
    1. Texture3D texture3d = new Texture3D(width, height, frameCount, TextureFormat.RFloat, false)
    Here is where I'm transfering the data over from a Texture2D:
    Code (CSharp):
    1. colors[x + y * width + i * width * height] = (byte)(255 * texture.GetPixel(x, y, 0).r);
    2.  
    Here is where I'm applying the data to the Texture3D:

    Code (CSharp):
    1. texture3d.SetPixelData<byte>(colors, 0);
    2.  
    PC
    upload_2020-2-18_14-37-24.png

    iOS
    upload_2020-2-18_14-39-33.png

    Thanks for any help.

    (Update)
    I worked it out, someone kindly on Discord pointed me to this PDF:
    https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
    I switched my Texture3D format to R8 from RFloat and it started filtering correctly.
     
    Last edited: Feb 19, 2020