Search Unity

URP soft shadow pixelated on Android? Comparison screenshot

Discussion in 'Universal Render Pipeline' started by Dawdlebird, Sep 28, 2020.

  1. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    88
    Ok, should have done this straight away, but I've adjusted the shaders a bit so I can actually demonstrate the issue. On the screenshot there is the desktop version and the android version of the same shadow cast. Android is extremely pixelated. I don't recall this being the case in the past, but either way: why? And can this be fixed? The project shaders rely on the smooth soft shadow as rendered on pc... Is this not possible on Android?
     

    Attached Files:

    Last edited: Oct 14, 2020
  2. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    88
    updated thread title and topic start with proper screenshot comparisons and issue description
     
  3. Dawdlebird

    Dawdlebird

    Joined:
    Apr 22, 2013
    Posts:
    88
    Ah dang, this was totally my own doing! After
    Light mainLight = GetMainLight(inputData.shadowCoord);
    I wrote
    half shadows = mainLight.shadowAttenuation;
    where I should have written
    half shadows = mainLight.distanceAttenuation * mainLight.shadowAttenuation;

    This would have been during an optimization, since originally I would have used the proper version (grabbed from the URP shaderlibrary). I would have rewritten it, finding that on Desktop there was no difference at all without this "distanceAttenuation", whereas on Android it results in a very pixelated shadow though. So for anyone trying to accomplish a pixel-art like shadow rendering, you might want to try writing your shader this way...