Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

GrabPass and _GrabTexture do not work on Android devices?

Discussion in 'Android' started by PaulT, Aug 4, 2011.

  1. PaulT

    PaulT

    Joined:
    Oct 25, 2008
    Posts:
    17
    For my current project I wrote a fixed shader program that makes use of GrabPass{} and _GrabTexture.

    This all works fine in the editor with OpenGL ES 1.x/2.0 emulation, but as soon as I run this on an Android device, it is interpreted as if _GrabTexture is a black source. The question is whether or not I am doing something wrong, it is not supported by Unity but it is never documented, or did I encounter a bug. Is there anyone who has used this successfully?

    The following shader illustrates the issue:
    Code (csharp):
    1.  
    2. Shader "FailingShader" {
    3.  
    4.     Properties {
    5.         _Color ("Color", Color) = (1,1,1,1)
    6.         _MainTex("Main Texture", 2D) = "white" {}
    7.     }
    8.  
    9.     Category {
    10.         Tags {"RenderType"="Opaque"}
    11.        
    12.         SubShader {
    13.             Pass {
    14.                 Name "BASE"
    15.                 Lighting On
    16.                 SeparateSpecular On
    17.                 Material {
    18.                     Diffuse [_Color]
    19.                     Ambient [_Color]
    20.                 }
    21.             }
    22.            
    23.             GrabPass {  }
    24.            
    25.             Pass {
    26.                
    27.                 SetTexture [_MainTex] {
    28.                 }
    29.                
    30.                 SetTexture [_GrabTexture] {
    31.                     Combine texture + previous
    32.                 }
    33.             }
    34.         }
    35.        
    36.         SubShader {
    37.             Pass {
    38.                 Name "BASE"
    39.                 Lighting On
    40.                 SeparateSpecular On
    41.                 Material {
    42.                     Diffuse [_Color]
    43.                     Ambient [_Color]
    44.                 }
    45.             }
    46.         }
    47.     }
    48. }
    49.  
    Strange thing is that it will never end up in the fallback shader, so somehow the first shader always succeeds.

    Any help would be highly appreciated!
     
  2. PaulT

    PaulT

    Joined:
    Oct 25, 2008
    Posts:
    17
    Still any help is very much appreciated. Just found out that on Android 3 the behavior is even more strange. It seems like it is parts of the screen that was visible before starting Unity.
    Hope someone is able to clarify something regarding this, or will I have better luck at the shaders forum?
     
  3. Pulseman

    Pulseman

    Joined:
    Sep 2, 2011
    Posts:
    1
    Not sure what is going on but I am having the same issue here. GrabPass works fine on Windows but not on Android. I am pretty sure Android GLES 2.0 devices can handle GrabPass, which is basically a render target that is provided to the shader. I am thinking this is probably a bug in Unity than anything else. Unity guys can you verify that?
     
  4. hardex

    hardex

    Joined:
    Jan 28, 2012
    Posts:
    1
    Any updates on this issue? Having similar problem on Tegra 2, GrabPass randomly picks a texture from VRAM intead of the framebuffer. I believe GrabPass doesn't work at all so what was left in the GPU register during last draw call is returned.
     
  5. FTKguy

    FTKguy

    Joined:
    Feb 27, 2012
    Posts:
    14
    Hello,

    Is there any update on this ? We are having the exact same issue, the shader grabpass not working on Tegra2 devices, can someone confirm if that is fixable or will be fixed ? Any workaround ? Also, apparently We must set the color buffer must be set to 32 bits in order to get the "default asset" image effect script running on Android which I am not sure if it is intended or not.
     
  6. RMGK

    RMGK

    Joined:
    Sep 30, 2011
    Posts:
    59
    Hey all, same issue here. I'm currently using Unity 3.5. Unity guys, would love a comment on this.
    Thanks :)
     
  7. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    419
    Out of curiosity did you try this variation:

    GrabPass { "TextureName" }
     
  8. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,801
    I would also want to know this. I can't make it to work on Android devices.
     
  9. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    278
    This issue still seems to be there with Unity 4.3. It seems to work when using OpenGL ES 3.0 but not with 2.0. Some definite response from the Unity devs would be very helpful here. Is GrabPass supported with OpenGL ES 2 on Android? And if so, how to make it work?
     
  10. Mike McShaffry

    Mike McShaffry

    Joined:
    Jul 18, 2012
    Posts:
    2
    I'd like to bump this thread - I'm attempting to use a Blur shader on Android, specifically a Galaxy Note 10.1, under Unity Pro 4.3.4 and if GrabPass is defined in the shader without a trivial fallback you get the dreaded "No subshaders can run on this graphics card.". I've tried using Open ES 2.0 and 3.0 without luck.

    Nevermind the wisdom of using a blur shader on Android. That's my business! :)

    A response on this issue from Unity would be sincerely appreciated.

    Thanks,
    Mike.
     
    Last edited: Mar 19, 2014
  11. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    957
    Same here. And while it works with OpenGL ES 3.0, it is buggy - the image differs from what I get on PC, also, it doesn't takes the device orientation into account.
     
  12. Griever_GF

    Griever_GF

    Joined:
    May 7, 2014
    Posts:
    3
    Any suggestion for this issue? I'm trying to use GrabTexture effect on Asus Transformer Prime TF201 (GPU Nvidia Tegra 3), with no luck yet.
     
  13. jamesflowerdew

    jamesflowerdew

    Joined:
    Apr 29, 2009
    Posts:
    10
    same here, got unusable crazy colours.
    have submitted a bug.
     
  14. gxc_8311

    gxc_8311

    Joined:
    May 27, 2014
    Posts:
    2
    You can try changing the tags line from
    Code (CSharp):
    1. Tags {"RenderType"="Opaque"}
    to
    Code (CSharp):
    1. Tags { "Queue"="Transparent+1" "RenderType"="Opaque" }
    basically, this makes the GrabPass happen when almost everything has been rendered in one frame, rather than grabbing nothing when everything is not rendered yet.
     
  15. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    40
    I know its old thread, but I'm still having the same issue with Unity 2018.3 , does anyone found a solution for this issue?
     
  16. swanickj

    swanickj

    Joined:
    May 15, 2019
    Posts:
    23
    Still having this issue, and **very** dependent on a grabpass blur in my project.
     
    Last edited: May 31, 2019
  17. WACOMalt

    WACOMalt

    Joined:
    Jul 17, 2012
    Posts:
    10
    Still looking for a solution to this. Are there really no unity team around who know the answer?
     
  18. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,542
    GrabPass should work on Android. If it doesn't, please submit a bug report.
     
  19. swanickj

    swanickj

    Joined:
    May 15, 2019
    Posts:
    23
    It works in Multi-pass stereo VR, but not in Single-Pass stereo VR.
     
  20. Mutimir

    Mutimir

    Joined:
    Dec 6, 2018
    Posts:
    23
    swanickj likes this.
  21. Inspekt

    Inspekt

    Joined:
    Aug 11, 2015
    Posts:
    4
    I have the same problem with Unity 2019.2.17. Disabling of "Use 32-bit Display Buffer" helps and shaders start to work correctly, but after this disabling I've got some color's artefacts and bandings, so I'm still looking for the appropriate way to resolve this issue.
     
unityunity