Search Unity

Question Render Feature not working in WebGL build, rendering all black

Discussion in 'Universal Render Pipeline' started by PineTreeDev, Oct 19, 2021.

  1. PineTreeDev

    PineTreeDev

    Joined:
    Apr 22, 2019
    Posts:
    31
    Hello,

    We have a custom render pass for blurring targeted for mobile platforms and has been working great. Now, as we want to target WebGL, this rendering feature is not working in WebGL builds, rendering everything to black. Turning off the render feature in the forward renderer data and playing it in WebGL renders everything properly but without the wanted effect.

    Is there something you generally need to avoid when targeting WebGL in custom renderer features or is it a problem with WebGL itself? The blur shader does not go against any of the recommendations for WebGL shaders (i.e dynamic indexing of arrays, etc...).

    Thanks for the help, if more information is required in order to orient me to a solution please ask!
     
  2. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    286
    I've been using custom render features with a post process effect in URP since about 7.6, it should work fine. Is there any useful information in the brower developer console? If it's coming up black, perhaps your shader is not compiling correctly and it is falling back to a diffuse shader with black _MainTex?

    Here's an example custom render pass in webGL:
    https://elliotb256.itch.io/dithered-shapes
     
  3. PineTreeDev

    PineTreeDev

    Joined:
    Apr 22, 2019
    Posts:
    31
    There is no additional info in the console sadly, no warnings or logs. Usually when a shader fails to run in webGL unity throws a log saying which shader will go into fallback
     
  4. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    286
    Is your shader added to the always included shaders in the build settings? (I don't understand why it might work for mobile and not webGL if exclusion at build time was a problem, but worth checking)
     
  5. PineTreeDev

    PineTreeDev

    Joined:
    Apr 22, 2019
    Posts:
    31
    At the moment it is added to the always include array. Trying to debug the problem, I've also tried building to windows and there works fine as well. Something that is also happening that is quite strange is that disabling post-processing in the editor shows a similar problem, everything rendering with the camera that has the render feature renders black.

    Googling more about the problem I've found this post in the forum, which seems like a similar issue, but doesn't solve it :(
     
  6. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    286
    What browsers did you test with?
     
  7. PineTreeDev

    PineTreeDev

    Joined:
    Apr 22, 2019
    Posts:
    31
    Only firefox locally
     
  8. PineTreeDev

    PineTreeDev

    Joined:
    Apr 22, 2019
    Posts:
    31
    Running it in Opera and Chrome, via uploading to itchio is still the same, presented with black screen even tho everything loads and initializes correctly
     
  9. Xa2go

    Xa2go

    Joined:
    Sep 14, 2020
    Posts:
    1
    Hi, did you fix the issue?? I m facing the same problem :(
     
    Moritzfx likes this.
  10. Sunyukun

    Sunyukun

    Joined:
    Aug 27, 2019
    Posts:
    1
    Hi, did you fix the issue?? I m facing the same problem too :(:(
     
  11. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    286
    The error (black screen on webgl) is quite generic, do you have any more information in the log for the web player?
     
  12. OccaSoftware

    OccaSoftware

    Joined:
    May 24, 2019
    Posts:
    29
    It's possible that the render texture you are using in your post-process shader is using a depth test. Temporary Render Textures have an undefined depth. Ensure that you have ZTest Always enabled in your shader or that you properly clear the temporary render texture before using it.
     
  13. felipe-fetzer

    felipe-fetzer

    Joined:
    Jul 9, 2018
    Posts:
    1
    Man, this solve my problem, thanks!