Search Unity

Camera.RenderWithShader does not render to texture with OGLES 3, but does with Vulkan?

Discussion in 'General Graphics' started by dotsquid, Oct 8, 2019.

  1. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Some time ago I published a small open-source demo of my idea how to easily render a "Lens flares" effect in 2d games [https://github.com/dotsquid/LensFlares] (how it works [http://dotsquid.com/2019/06/26/simple-gpu-occlusion-for-lens-flares/])

    It works fine on Windows, WebGL and my Xiaomi Mi4c with Android 7.1.
    But it appeared that it does not work on Samsung S10+ and iPhone 8.
    By "does not work" I mean that the render texture used under the hood keeps holding zero values in any case.

    I tried to use different formats for the render texture, enable and disable depth and stencil buffers (which are not required, but anyway), tried various manipulations with camera with no luck. And then I tried to use Vulkan and voila - it started to work on Samsung S10+.
    But obviously it's not a solution. I want it to work under OpenGL ES on any device as it does on my Xiaomi Mi4c. (I'm using Unity 2018.4.10 LTS)
    Any ideas?


    { Not working }


    { Working }
     
    Last edited: Oct 8, 2019
  2. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Can you please report a bug? We can then investigate. Thanks!
     
  4. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
  5. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Any news?
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    You'll get an email from QA once it's processed.
     
    dotsquid likes this.
  7. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    It's being processed for more than 1 month, which did not happen for any of my previous bug reports. Is it ok?
    We have a release date in 2 months and I'd wish to know whether I can expect any information on this problem.
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    No, it's not OK.
    I poked them to check this.
     
    dotsquid likes this.
  9. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    The problem is caused by render texture format R32_SFLOAT, some GPU drivers report that it does not support mip maps generation or blending for this format. Solution would be to use other format like R16_SFLOAT or any other depending on your needs.
     
    dotsquid likes this.
  10. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Ah, thanks a lot! I was sure that I tried this format and it appears that I didn't. It indeed makes things work on the problem devices.
     
  11. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Is there an API in Unity to get information about whether the driver / hardware supports generation of mipmaps for the given format?
    I tried SystemInfo.SupportsBlendingOnRenderTextureFormat but it seems it does not work for my case.
     
  12. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    For mipmaps generation to work the texture format has to be color-renderable and texture-filterable. As per https://www.khronos.org/registry/OpenGL/specs/es/3.0/es_spec_3.0.pdf pages 130-132 the 32bit floating point formats are not filterable. Of course there are extensions like https://www.khronos.org/registry/OpenGL/extensions/OES/OES_texture_float_linear.txt that make these formats filterable. To check for this extension you can use https://docs.unity3d.com/ScriptReference/SystemInfo.IsFormatSupported.html with FormatUsage.Linear.
     
    dotsquid likes this.
  13. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Thanks!