Search Unity

WebGL no shadows?

Discussion in 'Web' started by Onsterion, Mar 5, 2015.

  1. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    In Editor works perfect:



    In WebGL Firefox 35.0.1

     
  2. ShabihDesperado

    ShabihDesperado

    Joined:
    Oct 27, 2013
    Posts:
    41
    Edit -> Project Settings -> Quality
     
  3. ShabihDesperado

    ShabihDesperado

    Joined:
    Oct 27, 2013
    Posts:
    41
    The default qualitty settings are set as Fastest, for this reason you are not watching the shadows. Try to change it to Good or Fantastic
     
  4. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    I always use Beautiful setting and I probed with Fantastic and nothing happens o_O
     
  5. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Delete all quality settings but one and make sure this one has shadows enabled.
     
  6. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Unity Version : 5.0.0f4

    My quality settings:



    o_O
     
  7. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Well, solution:

    Set Default the quality setting desired with shadows turned on

    The shadows are ugly, is normal?

     
  8. ShabihDesperado

    ShabihDesperado

    Joined:
    Oct 27, 2013
    Posts:
    41
    Are soft shadows active? High resolution?
     
  9. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215

    Yes.
     
  10. ShabihDesperado

    ShabihDesperado

    Joined:
    Oct 27, 2013
    Posts:
    41
    I didn't try 3D in webgl get but it looks like a bug. Sorry
     
  11. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Well, time to report a bug :rolleyes:





    Done.
     
    yuliyF likes this.
  12. sjayadevan

    sjayadevan

    Joined:
    Mar 24, 2015
    Posts:
    2
    Would you be able to add the issue tracker ticket here please? I'm curious about this as well.
     
  13. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
    Sure, Ticket ID: 677747_9l911ai9t3d5a4b9
     
  14. sjayadevan

    sjayadevan

    Joined:
    Mar 24, 2015
    Posts:
    2
    That's odd, I'm unable to search anywhere by issue id. I also tried looking at the dates of all tickets and can't find it :(. Could you post an exact link please?
     
  15. Onsterion

    Onsterion

    Joined:
    Feb 21, 2014
    Posts:
    215
  16. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
  17. romaing

    romaing

    Joined:
    Feb 11, 2010
    Posts:
    24
    So it's not fixed yet but is there any workaround?
     
  18. ShabihDesperado

    ShabihDesperado

    Joined:
    Oct 27, 2013
    Posts:
    41
    WebGL is not a final release, what we are using is a preview mode and we'll have to wait a bit more for a stable version. You can check the Patch releases if you want.
     
  19. romaing

    romaing

    Joined:
    Feb 11, 2010
    Posts:
    24
    Thank you, we know it's not the final release, and of course I check the Patch releases ; just wanted to know if - right now - there is a workaround to force the shadows to use better resolution textures.
     
  20. HonoraryBob

    HonoraryBob

    Joined:
    May 26, 2011
    Posts:
    1,214
    I'm having a similar problem, although it isn't identical: in WebGL shadows only show up at close range in spite of distance settings, although when they do show up they are normal soft shadows. My procedural ground detail is also blurry and seemingly threshholded like an old palette-based VGA display even though it's produced mathematically on the fly in the shader rather than being based on a texture. And the mute button doesn't work in WebGL.
     
  21. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    Currently it is expected that you get lower quality shadows on WebGL, compared to Standalone. That's because the rendering API is basically GLES2 and we make some assumptions about the GPU. Which is not ideal because normally GLES2 is used on Mobile devices with lower specs than Desktop.

    This is obviously something we want to fix. For the time being you might be able to get better quality by tweaking the Shadow Settings (# Cascades, Distance, etc..) in the project QualitySettings.
     
  22. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    I would just stay clear of shadows on WebGL. I'm having a hard enough time to optimize my own game and I don't even use shadows. Maybe try blob shadows if you really need it.
     
  23. MXAdd

    MXAdd

    Joined:
    Apr 23, 2015
    Posts:
    74
    Hi

    I'v solved the issue with ugly shadows by modifying standard shader (that I use in my project)
    The thing is that, there is no 'SCREEN' shadow texture, and the ShadowMap have filtering set to point.
    To apply fix just duplicate standard shader into your project (it's in unity builtInShaders zip)
    and in UnityStandardCore.cginc add just before 'half4 fragForwardBase'

    Code (CSharp):
    1. #if defined (SHADOWS_SCREEN)
    2. #if defined (UNITY_NO_SCREENSPACE_SHADOWS)
    3.  
    4. float4 _ShadowMapTexture_TexelSize;
    5. #define USE_LIGHT_ATTENUATION_SOFT
    6. #define LIGHT_ATTENUATION_SOFT(a) unitySampleShadowSoft(a._ShadowCoord)
    7.  
    8. inline fixed unitySampleShadowSoft(unityShadowCoord4 shadowCoord)
    9. {
    10.     half shadow = 0.0;
    11.     // simple 3x3 filter, could be more fancy, but looks OK
    12.     for (float x = -1.0; x <= 1.0; x+=1.0)
    13.     {
    14.         for (float y = -1.0; y <= 1.0; y+=1.0)
    15.         {
    16.             shadow += UNITY_SAMPLE_SHADOW(_ShadowMapTexture, (shadowCoord.xyz + float3(x * _ShadowMapTexture_TexelSize.x, y * _ShadowMapTexture_TexelSize.y, 0.0)));
    17.         }
    18.     }
    19.  
    20.     shadow/= 9.0;
    21.     shadow = _LightShadowData.r + shadow * (1-_LightShadowData.r);
    22.     return shadow;
    23. }
    24. #endif
    25. #endif
    and then in half4 fragForwardBase (VertexOutputForwardBase i) : SV_Target
    replace
    half atten = SHADOW_ATTENUATION(i);

    with

    #ifdef USE_LIGHT_ATTENUATION_SOFT
    half atten = LIGHT_ATTENUATION_SOFT(i);
    #else
    half atten = SHADOW_ATTENUATION(i);
    #endif

    and all should work fine (for Standard shader - for all the others similar change needs to be applied)
    if someone is uncommon with shaders editro
    here: http://mxadd.org//Unity/StandardSoftShadowsWebGL.unitypackage
    is provided modified Standard shader (called "Standard-SoftShadows") that does the trick
    (for unity 5.1.1f1 !!!)

    hope this helps someone :)
     
    jonkuze likes this.
  24. nawash

    nawash

    Joined:
    Jan 29, 2010
    Posts:
    166
    Are you kidding me ??? You just saved me!!!!!
    Thank you
     
  25. Matt_at_mindtrigger

    Matt_at_mindtrigger

    Joined:
    Jan 20, 2014
    Posts:
    60
    Hi,

    I tried your SoftShadow solution in 5.1.2f1 and I could not get the desired result. The build looked exactly the same as beforehand. Also I do not seem to get Shadow Cascades to work with WebGL, there is no difference in shadow appearance at all. I'm using the newest version of Unity with Forward Rendering since it proved to have a significantly higher framerate on our project.
     
  26. MXAdd

    MXAdd

    Joined:
    Apr 23, 2015
    Posts:
    74
    what kind of light you'v put - directional ?
    meybe they changed something inside renderer and now other set of macros is different, hard to tell as I dont have 5.1.2f1 right now. Anyway - this should be fix by unity dev - so 'ask them' :)
     
  27. Matt_at_mindtrigger

    Matt_at_mindtrigger

    Joined:
    Jan 20, 2014
    Posts:
    60
    Yes I do use a skydome solution for my scene that uses a directional light
     
  28. MXAdd

    MXAdd

    Joined:
    Apr 23, 2015
    Posts:
    74
    if you are REALY determined to find a solution:
    - build your game
    - install WebGL inspector inside chrome (it's on the chrome store)
    - go to WebGL inspector page and read how to use it (if you are not familiar with it)
    - use WebGL inspector to capture frame in question and see what's going on, figure out with shader is responsible for your bad shadows, see it's code, now find that same place in unity in your HLSL code (this is little complicated, couse shaders are translated from HLSL to GLSL in the build process - but you will have overal idea where you should look)
    - fix the shader and be happy

    or ... 'ask devs'
     
  29. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    FWIW, we have some changes to the Unity shader compiler going into Unity 5.3 which result in shadow setting no longer being tied to the graphics API being used - which will mean that soft shadows will then work in WebGL as expected.
     
    nawash, arumiat and Dantus like this.
  30. ITGEEK

    ITGEEK

    Joined:
    Apr 29, 2014
    Posts:
    1
    When will this be released?
     
  31. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  32. 747423517

    747423517

    Joined:
    Jan 29, 2015
    Posts:
    8
    The built WebGL will automatically degrade. Set the low, middle, high, and shadow display Settings to the same parameter, and it will display correctly.
     
    TaroBall likes this.