Search Unity

[Released] Lux URP Essentials

Discussion in 'Assets and Asset Store' started by larsbertram1, Jul 18, 2019.

?

Does Lux URP Essentials need a Discord Server?

Poll closed Apr 29, 2021.
  1. yes - even if there was no moderator

    4 vote(s)
    57.1%
  2. no, the forum is all we need

    3 vote(s)
    42.9%
  1. raidzhi

    raidzhi

    Joined:
    Jan 13, 2016
    Posts:
    32
    TIM图片20191130115850.png
    In the Decals Demo,the grass prefabs mssing script.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    as far as i can say it does not get any camera opaque texture ("transparent" parts are gray).
    make sure it is activated in the render pipeline settings.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    that is irrelevant.
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    next update will let you disable refraction in the water shader. it turned out to be a bit more complex than my initial hack if you want proper fog and shadows.
     
  5. Azirell

    Azirell

    Joined:
    Oct 16, 2015
    Posts:
    29
    Hi everyone! I am wonder about Android Single-Pass (Multiview) support.
    At the moment I'm trying to run LWRP (URP) project on Oculus Quest.
    Obvious that fragment shaders require specific code to run properly. I did modify water shader. It almost works.
    The only problem at the moment is with ZTest. LessEqual option does not behave right. Could you pls provide any help with that?
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it runs fine on the rift without any modifications.
    i doubt it is ZTest. i guess it is the soft edge blending using the camera depth texture as provided by lwrp/urp.
    and could you provide some images showing your problem?
     
  7. Azirell

    Azirell

    Joined:
    Oct 16, 2015
    Posts:
    29
    I know it runs fine on desktop, that is the point - Android requires more work, unfortunately.
    For example there are parts of code I had to do to make it work at least somehow.
    1. Different camera related declarations:
    Code (CSharp):
    1. #ifdef UNITY_EDITOR
    2.             TEXTURE2D(_CameraDepthTexture);
    3.             TEXTURE2D(_CameraOpaqueTexture);
    4. #else
    5.             TEXTURE2D_ARRAY(_CameraDepthTexture);
    6.             TEXTURE2D_ARRAY(_CameraOpaqueTexture);
    7. #endif
    8.             SAMPLER(sampler_CameraDepthTexture);
    9.             SAMPLER(sampler_CameraOpaqueTexture);
    2. Sampling those camera related textures require differ macro
    Code (CSharp):
    1. //first time
    2. float refractedSceneDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, screenUV + offset, unity_StereoEyeIndex);
    3. //second time
    4. refractedSceneDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, offset, unity_StereoEyeIndex);
    5. //guess white time
    6. refraction = SAMPLE_TEXTURE2D_ARRAY(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, ( offset ), unity_StereoEyeIndex).rgb;
    Yes I will provide you a video tomorrow.
     
    Last edited: Dec 1, 2019
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i see what you mean.
    but you should have a look into the URP version of Lux LWRP (included as package):
    it uses TEXTURE2D_X and LOAD_TEXTURE2D_X - which both are not available using LWRP and the related Core RP.
    these defines handle double wide textures (single pass) and texture arrays (single pass instanced) automatically without any additional define like your "#ifdef UNITY_EDITOR"
    see: Core.hlsl (in URP) and GLES3.hlsl (in Core RP).
    so you would have to go with unity 2019.3.
     
  9. raidzhi

    raidzhi

    Joined:
    Jan 13, 2016
    Posts:
    32
    thaks,after turn on opaque texture , it works.
     
    Last edited: Dec 2, 2019
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    version 1.28 is available!

    ### Fixed:
    - Cloth Shader: Fixed per pixel tangent and bitangent for very strong normals.
    - Decals Demo scene fixed (decals excluded using render queue did not use a proper material).
    - Grass Prefab: Missing script removed.
    ### Changed:
    - Water shader: Lets you disable Refraction.
    ### Added:
    - Preview of the grass displacement system added (URP only)
     
    osss likes this.
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    version 1.28 lets you disable refraction so water is rendered as a real transparent material.
     
  12. Youdaman

    Youdaman

    Joined:
    Apr 8, 2017
    Posts:
    8
    FYI some problems with materials/shaders when using URP and updating via the provided package:

    The various M Default Decal materials in the Decals Demo scene are pink (shader is set to Hidden/Internal Error), fixed by changing their shaders to either the lit or unlit Lux LWRP/Projection/Decal.

    Also the 2nd and 4th objects in the Fuzzy Lighting Demo scene had the M Fuzzy material set to Hidden/Internal Error, fixed by setting to Lux LWRP/Simple Fuzz.

    The Lux LWRP/Glass shader in the Glass Demo scene is almost an opaque gray rather than transparent -- just read the docs and this is a known "problem".
     
    Last edited: Dec 3, 2019
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    damn – i will have to include that scene in the urp package then as well... thanks!
     
    Last edited: Dec 3, 2019
    Youdaman likes this.
  14. Youdaman

    Youdaman

    Joined:
    Apr 8, 2017
    Posts:
    8
    Edited my post above with some extra things, plus also just found with the decal demo that the decal that should get drawn under the water is drawn on top. It still conforms to the terrain, just the draw order is not working with the custom renderer as shown in the demo video.
     
  15. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    71
    Hi, I'm using the skin shader, but got a wierd issue. On iOS on some iPhones you see 'cracks' in the skin. It looks good on the iPhone XS (2436 x 1125 resolution at 458 ppi) but on the iPhone XR (1792-by-828-pixel resolution at 326 ppi) and XS Max (2688‑by-1242‑pixel resolution at 458 ppi) is looks cracked... See screenshots, one with cracks, other without...

    IMG_0934.jpg IMG_0063.jpg
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    according to the color of the "cracks" i thinks these are self shadow artifacts or "shadow acne".
    so you may try to play around with the shadow bias settings of the light (depth/normal offset).
    why it appears one only one phone? i don't know. maybe screen to shadow map resolution?

    and i do not know what you want to achieve – but rendering at full res will drain your batterie...
     
    timbokoppers likes this.
  17. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Hello, so i'm using LUX LWRP with UMA and I've been having a small problem when UMA combines the materials into one single atlas.

    The problem is the alpha channel in the diffuse texture. When the atlas is written, it combines with the empty texture, darkening it.

    I reached out to the UMA dev who has been awesome at helping me out on this. He mentioned that I could do this.

    Move the smoothness map to the alpha of the normal map, and modify the shader to pull it from there. The shader name is "Lux LWRP Skin.shader".

    Change line 262 from this:
    outSurfaceData.smoothness = albedoAlpha.a * _Smoothness;
    to
    #if defined (_NORMALMAP)
    outSurfaceData.smoothness = SAMPLE_TEXTURE2D(_BumpMap, _BumpMap, uv).a * _Smoothness;
    #else
    outSurfaceData.smoothness = albedoAlpha.a * _Smoothness;
    #endif


    When I do this it breaks Lux haha and I get this error.

    Shader error in 'Lux LWRP/Human/Skin': 'Sample': no matching 2 parameter intrinsic method; Possible intrinsic methods are: Texture2D<float4>.Sample(SamplerState, float2|half2|min10float2|min16float2) Texture2D<float4>.Sample(SamplerState, float2|half2|min10float2|min16float2, int2) Texture2D<float4>.Sample(SamplerState, float2|half2|min10float2|min16float2, int2, float1|half1|min10float1|min16float1) Texture2D<float4>.Sample(SamplerState, float2|half2|min10float2|min16float2, int2, float1|half1|min10float1|min16float1, out uint status) at line 263 (on d3d11)


    Any idea how to move the alpha to the normal channel so I can get the smoothness to work with Lux and UMA? Right now I'm nuking the alpha that's in the Albedo Smoothness alpha so I can have the atlas work with UMA.

    Thank you!
     
  18. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    71
    Thanks for the hints, will try that out. What do you mean with 'rendering at full res'? You are talking about the shadow?
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    oh, you can't do this...
    depending on the platform any normal texture imported will be repacked by unity.
    on dx11 e.g. your RGB normal will become a RGBA texture where A already contains the regular R channel...
    if you pack your normal in a custom way you have to manually sample and unpack the normal in the shader.
    your shader errors because it should be:
    SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, uv).a * _Smoothness;
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i mean: rendering at e.g. 2436 x 1125 resolution.
    of course you get super crisp results but it is a lot of work for the gpu... 4 times more than using half res.
     
  21. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    71
    Yes thanks for your reply. I render already on a lower resolution, use this script : https://docs.unity3d.com/Manual/DynamicResolution.html

    Is that the best way to go? I'm using LWRP / URP..
     
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    should be fine. any news regarding the cracks?
     
  23. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    71
    Yup, tweaking depth / normal offset does the trick! Thanks for the hint.
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    fine!
     
  25. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Ok well then is it possible to change the code so we can put the gloss map into the Red Channel in the SkinMask/Thickness/Occlusion map?

    So change it to be Roughness/Thickness/Occlusion Map instead?

    The problem is UMA and Lux are not working together because of the Alpha channel in the Color map. So can we move it?
     
  26. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    We don't need the Skin Mask for what were doing.

    Thank you!
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    red i not ideal because it is heavily compressed. it is the worst channel.
    you can move it where ever you want. even the red channel.
     
  28. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Ok good to know, How do I go about moving it? ;) Or tell the code not to use it as a Skin Mask and use it as the Roughness.
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i would contact uma: you do not need transparency in the albedo alpha when it comes to skin – unless i miss something here.
     
  30. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    You are correct, but when UMA makes a texture atlas and combines the meshes together, if there is any value other then white in the Alpha of the color, it makes the different meshes show up much darker. I had a two our call with the UMA dev about it.

    So Id like to remove all data from the alpha slot when working with LUX if possible. So only use RGB in the color slot.
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    outSurfaceData.skinMask = 1;
    ...
    outSurfaceData.smoothness = SSSAOSample.r * _Smoothness;
     
  32. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Thank you! I will try this!
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    has anybody here yet tried the new grass displacement feature?
     
  34. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Hey larsbertram! Got it working, thank you. The ... in between the two lines of code messed me up for a second so I just removed it. Not sure if that just mean a space between them. Totally not a coder here ;)

    So I took your advice and didnt move it the red channel. I moved it to the blue channel. Can I ask you why you have the smoothness map in the Albedo alpha and not using the Blue channel of the other packed map? Totally just wondering, just in case we run into problems later on. Thank you again for your help.


     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the "..." marked some missing lines:
    outSurfaceData.skinMask = 1; is a few lines above the original line:
    outSurfaceData.smoothness = albedoAlpha.a * _Smoothness;
    which would overwrite:
    outSurfaceData.smoothness = SSSAOSample.r * _Smoothness;
    if you inserted it right after the change of the skinmask.
    alpha has the best compression. it is uncompressed. blue shows already a lot of artifacts.
    and smoothness is said to be the most important ingredient when it comes to physically based lighting.
     
  36. mfitzpatrick-1

    mfitzpatrick-1

    Joined:
    Oct 8, 2013
    Posts:
    31
    Ok good to know. I switched it again. I moved the smoothness to the alpha and the Occlusion to the blue.
     
  37. osss

    osss

    Joined:
    Jan 20, 2014
    Posts:
    27
    It's great!! :)
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    oh, nice!
    the pending update should make it more versatile and easier to work with as it adds some example scripts showing how to handle distance to ground to attenuate the bending and allows you to rotate the displacers around the y axis.
     
    osss likes this.
  39. Krasshirsch

    Krasshirsch

    Joined:
    Apr 26, 2017
    Posts:
    36
    Thank you, that's great news.
     
  40. raidzhi

    raidzhi

    Joined:
    Jan 13, 2016
    Posts:
    32
    Screenshot_20191209-113452_LuxLWRPEssentials.jpg
    this is the "Stupid but full feature decal" on my Qualcomm snapdragon 835 device with Graphics API : Vulkan. And Graphics API : OpenGLES 3 got the same result.
    Unity version 2019.2.12
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    depth and shape look fine. just like the unlit decal in the upper right corner.
    how do other lit decals look like?

    if these look fine i guess something with the mask map (T Decal Floor MOES) texture settings goes wrong.
    i noticed that in the package its import settings are set to: sRGB(Color Texture) = checked.
    this should be unchecked – although it does not make much visual difference on win.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    version 1.3 is available:

    ## Version 1.30
    ### Added:
    Alpha tested outline shader added.

    ## Version 1.29
    ### Changed:
    - Preview of the grass displacement system updated (URP only).
    ### Fixed:
    - Decals Demo scene fixed (URP version).

    Bildschirmfoto 2019-12-06 um 20.47.33.png
     
    osss likes this.
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i am working on a lightmapped demo scene right now – and wondered if it was feasible to derive ambient specular occlusion from the baked lightmap (baked indeirect lighting and ao). i think it is:

    Lux_LWRP_AOfromGI.gif
     
    ChinChiaYeh, Quast and osss like this.
  44. osss

    osss

    Joined:
    Jan 20, 2014
    Posts:
    27
    Last edited: Dec 10, 2019
  45. raidzhi

    raidzhi

    Joined:
    Jan 13, 2016
    Posts:
    32
    Screenshot_20191210-093506_LuxLWRPEssentials.jpg
    uncheck the sRGB is useful,it looks better,but the color still seems not correct.
     
    Last edited: Dec 10, 2019
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    way better.
    regarding the color: does unchecking "enable mask map" restore the colors?
    and the lighting? i can't see light effecting the decal...
    how do simple lit decals look like?
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    yes, of course. but that needs a custom lighting function.
    and an additional texture lookup :(
    the example showed above is just a cheap fake in case you use lightmaps which only needs 2 multiplications.
     
  48. raidzhi

    raidzhi

    Joined:
    Jan 13, 2016
    Posts:
    32
    Screenshot_20191210-190223_LuxLWRPEssentials.jpg
    Uncheck the "enable mask map" get this result. and the left decal is an sample lit decal.
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, no lighting?!
    and the "stupid" decal has no color information – while the lit ones has. altho they use the same shader and features?!
     
  50. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    Is there blending mesh with terrain shader or still not ?