Search Unity

Lux-an-open-source-physically-based-shading-framework

Discussion in 'Assets and Asset Store' started by larsbertram1, Mar 19, 2014.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    just updated the old lux texturepostprocessor script to support ggx.
     
  2. looki666

    looki666

    Joined:
    Sep 5, 2013
    Posts:
    79
    Ok. Tested and new version , uses less memory :)

    Tested Unique Shadows in clear project and all shaders from LuxCustomStandardShaders folder works , but none of the LuxStandardMetalic , LuxStandardSpecular LuxStandardTranslucentSpecular works .

    Regards.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    you do not want to use any of the lux standard shaders together with unique shadows as unique shadows do not support deferred rendering and add one more shader variant... :)
    instead create custom surface shaders which works fine.
     
  4. looki666

    looki666

    Joined:
    Sep 5, 2013
    Posts:
    79
    Thanks , is there a way to force them to work in Forward with UniqueShadows ? For now i do not care about performance and Deferred :)
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    you could comment the deferred pass.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    Hi there!

    Lux 2.01 now is officially available at the asset store (and already outdated...)
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    i just have added geometry based refractive (as shown in the screen shoot) and deferred geometry based decal shaders:

    Bildschirmfoto 2016-05-09 um 23.37.11.png
     
  8. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    269
    Thank you!!! :)

     
    punk likes this.
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    hi there,
    i just updated the github repo. so please make sure you get the latest version of lux.

    lars
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    programmer's art showing deferred geometry based decals:

    08_lux_decals.jpg
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    Dithered alpha masks as available in the lux hair shader:

    lux_dithered_alpha.jpg
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    hi there,
    finally the latest update of lux is also available on the asset store.
     
  13. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,832
    Is there an eye shader in the current version of Lux?
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    nope, but you can use any parallax instead.
     
  15. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    646
    Just tested out the package, great work as always, planning to switch to it from Uber (or even use the two at the same time), but I've got one feature request - Uber's wetness shaders add some saturation to the ground as it gets wet, the same as Witcher3's shaders; it really makes a big difference, and looks a lot more realistic. It would be great if Lux wetness supported this, as it only really supports water/rain now, not actually 'wetness'.

    Example of Uber's wetness saturation
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    thanks a lot.

    Lux calculates the porosity of the material (based on smoothness and spec color) and darkens the albedo according to the porosity and given amount of accumulated water:
    LuxDynamicWeather.cginc, line 410 – 416
    next to that it allows you to accumulate water in cracks (results in water and wetness) and puddles (mostly water). so in fact i would call it even a bit more advanced.

    i wonder why it seems to not be working for you properly.
    lars
     
  17. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    646
    I definitely agree that your water in cracks/puddles method is more advanced than Uber's, and I like the default specularity of your water much more.
    But from what I can see, there is no way to apply an actual level of "wetness" to the entire material, like Uber can, Lux can only increase water height so the whole material is 'underwater'?
    Eg, like shown in that video, the ground should be able to get "damp" or "wet", without there actually being puddles, and it actually looks like wet dirt. In Lux, I can see rain on the ground, and puddles, but I can't make the entire ground "wet" or "damp" like that.
     
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    well, you could editing the textures – but not dynamically, you are right :)
    so i gave dynamic wetness a quick look and added it to the "lux dynamic weather" script as well as to the "LuxDynamicWeather" cginc.

    script
    wetness has its own accumulation and evaporation settings. next to that you can define the (global) influence on smoothness and the darkening of the albedo.
    cginc
    smoothness and the darkening of the albedo are also driven by the porosity of the given pixel (which is calculated dynamically from smoothness and specular color): so rough dielectric materials get more darkening and less smoothness while metals do not get any darkening but more smoothness. last but not least wetness smooths the per pixel normal just a little bit.

    it would be great if you could test the attached script and cginc before i push an update to the repo.
    thanks,
    lars
     

    Attached Files:

    GoGoGadget likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    dry:
    Bildschirmfoto 2016-05-17 um 15.41.22.png

    full wetness:
    Bildschirmfoto 2016-05-17 um 15.41.42.png

    full wetness + fully flooded cracks
    Bildschirmfoto 2016-05-17 um 15.41.51.png
     
    Alverik and elias_t like this.
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    GoGoGadget likes this.
  21. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    646
    Nice! Just very quickly tested it out, looks great. Missed out the notification to test it, but I'll definitely try and make a few pull requests in the future to fix any issues that I run into.
     
    Alverik likes this.
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    hi there,

    it would be great if you could give some more feedback, please :)
    thanks, lars
     
  23. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    This might have already been asked, but I didn't find it in a cursory search. Is there a particular reason you kept with the Unity image packing format other than compatibility? Would using the G for height and B for occlusion (so that you could use the same texture for metal/height/occlusion/smoothness cause any problems? Would the lower accuracy of the B channel matter for occlusion? Would filling the GB channels affect the quality of the R channel due to DXT5 compression? Would we get any performance gain only having one texture for m/h/o/s instead of three textures?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    no, compatibility is the reason why.
    mixmapping needs both heightmaps to be stored in the same texture to by efficient (next to the mix map).
    that should answer the other questions as well :)
     
  25. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Great, thanks, I hadn't looked at the mix-mapping yet.
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    you are welcome.
    and when writing custom surface shaders you may do better texture packing (except from height maps – unless you change the lux parallax functions).
     
  27. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,154
    So I read somewhere that the skin shader used in Lux isn't very compatible with wrinkle map because of the stress tex2D lod impose on the GPU or something?

    So I tried something to approximate that,

    Code (CSharp):
    1.            float3 Snorm = float3(0,0,1)*3;//IN.worldNormal * 10;
    2.             Snorm = normalize(half3(o.Normal.xy + Snorm.xy, o.Normal.z * Snorm.z));
    3.             Snorm = WorldNormalVector( IN, Snorm );
    4.  
    5.             #if defined (_LUX_SKINMICROBUMPS)
    6.                 half3 MicroBump = UnpackScaleNormal(tex2D(_MicroBumpMap, IN.uv_MainTex * _MicroBumpMapTiling ), _MicroBumpScale);
    7.                 o.Normal = normalize(half3(o.Normal.xy + MicroBump.xy, o.Normal.z * MicroBump.z));
    8.             #endif
    9.  
    10.             o.BlurredNormal = Snorm;
    11.  
    12.             fixed Curvature = 0;
    13.             //    Calculate the curvature of the model dynamically
    14.             if (_CurvatureInfluence > 0) {
    15.             //    Get the scale of the derivatives of the blurred world normal and the world position.
    16.                 #if (SHADER_TARGET > 40) //SHADER_API_D3D11
    17.                 // In DX11, ddx_fine should give nicer results.
    18.                     float deltaWorldNormal = length( abs(ddx_fine(Snorm)) + abs(ddy_fine(Snorm)) );
    19.                     float deltaWorldPosition = length( abs(ddx_fine(IN.worldPos)) + abs(ddy_fine(IN.worldPos)) );
    20.                 #else
    21.                     float deltaWorldNormal = length( fwidth( Snorm ) );
    22.                     float deltaWorldPosition = length( max(1e-5f, fwidth ( IN.worldPos ) ) );
    23.                     deltaWorldPosition = (deltaWorldPosition == 0.0) ? 1e-5f : deltaWorldPosition;
    24.                 #endif    
    25.                 Curvature = (deltaWorldNormal / deltaWorldPosition) * _CurvatureScale;
    26.                 Curvature = lerp(combinedMap.b, Curvature, _CurvatureInfluence);
    27.             }
    28.             else {
    29.                 Curvature = combinedMap.b;
    30.             }
    instead of

    Code (CSharp):
    1.             fixed3 blurredWorldNormal = UnpackNormal( tex2Dlod ( _BumpMap, float4 ( IN.uv_MainTex, _BumpBias, _BumpBias ) ) );
    2.             blurredWorldNormal = normalize( lerp(o.Normal, blurredWorldNormal, _BlurStrength
    3.             #if defined (LUX_LIGHTINGFADE)
    4.                 * IN.blendState ) );
    5.             #else
    6.                 ) );
    7.             #endif
    8.  
    9.             blurredWorldNormal = WorldNormalVector( IN, blurredWorldNormal );
    10.             o.BlurredNormal = blurredWorldNormal ;
    11.  
    12.  
    13. //----- usual curvature code
    14.  
    15.  
    Seems to work rather well



    Can you tell which is which?

    the one on the right is the modified skin shader

    EDIT:
    Also what happened to the texture LUT? PISS shader isn't supposed to have one I don't see any in the folder?
     
    Last edited: May 28, 2016
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    the LUT is located in the "resources" folder and is not attached per material – but globally via script.
    please have a look at the docs.
     
  29. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,154
    I have some strange behavior I don't know what's causing them :eek:

    This is one scene

    And in the next scene light is different, despite data being the same :confused:

    Also notice the scan data on the left? the shader don't works, there is no specular nor bumpmap, but it works with unity's standard shader :(

    I understand nothing at all (the hdr box change nothing in case off)

    What's going on o_O
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    it seems as if you have not added the Lux setup script – which passes the skin LUT to the shader.
     
  31. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,154
    Thanks I redid Test with proper set up


    Left one is modified shader
    It's less crunchy but overall behavior seems to hold well
     
  32. LucidRapture

    LucidRapture

    Joined:
    Nov 19, 2013
    Posts:
    4
    Any plan to add support for your Advanced Foliage Shaders? I would be personally be thankful :)
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    that will come with the next update of AFS.
    but afs already supports "some" kind of deferred translucency – whereas Lux will support deferred translucency only in its plus version – not the personal one…
     
    LucidRapture likes this.
  34. Zireael07

    Zireael07

    Joined:
    Apr 27, 2016
    Posts:
    47
    I downloaded the 2.01 files from git. How do I use them in an existing project? I am interested in the wetness/snow, so I need the script, and what else? Please help... the download doesn't seem to be a Unity project nor package...
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    you need the shaders and scripts.
    but to get started simply download the whole repository and import it into a NEW project by simply dragging the files and folders into your project tab.
    please make sure that you keep anything in place/the right folder.
     
  36. Zireael07

    Zireael07

    Joined:
    Apr 27, 2016
    Posts:
    47
    Well, if I wanted to start a new project, it'd be easy. The problem is, I want to use it in an existing project :(
     
  37. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,293
    Just drag the Lux folder into your project. Worked for me.
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    i would never import an asset i have not tested into my project... but anyway: it should just work.
     
  39. Zireael07

    Zireael07

    Joined:
    Apr 27, 2016
    Posts:
    47
    I ended up making a spare project, exporting a package from it and importing it into my game. Works like a charm! Thanks for the tip to drag the folder into the project :)
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    fine!
     
  41. Tesrym

    Tesrym

    Joined:
    Dec 2, 2012
    Posts:
    55
    I added lux, and set it up like mentioned in the docs (but I did not touch fog setup).
    However, I have this terrain problem and I don't know how to fix that.
    All I have is this link: http://i.imgur.com/Zm9KSfe.gifv I hope this post can enlighten me a bit :)
    Also have the exact same problem with the ATS shaders.
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    looks like a problem with the base map shader.
    how does it look with the built in shaders?
    what color mode do you use? linear or gamma?
     
  43. Tesrym

    Tesrym

    Joined:
    Dec 2, 2012
    Posts:
    55
    I can confirm the standard shader has the same problem too now.
    Using linear colors like the docs say :)
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    hmm, deffered shading using lux deferred lighting shader?
    if so go through the different gbuffers (albedo, normal , spec, smoothness) and look which one shows the great difference between base and first/add pass shaders.
     
  45. Skolstvo

    Skolstvo

    Joined:
    Dec 21, 2015
    Posts:
    107
    Amazing work. Do you handle lights in the same way Unity does? Alloy has custom quadratic light falloff, with the range being just a cut off point.

    Unity stupidly takes the range into account for the whole light falloff, which makes the same lights look completely differently depending on their range.
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    falloff indeed is the original unity falloff...
     
  47. Skolstvo

    Skolstvo

    Joined:
    Dec 21, 2015
    Posts:
    107
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    well, you are right but people often complain if something suddenly looks different from what they are used to.
    but hey, you may jump in and add the quadratic falloff. :)
     
  49. Tesrym

    Tesrym

    Joined:
    Dec 2, 2012
    Posts:
    55
    So in the end, I just set the terrain basemap distance to something ridiciously high so that I dont have to see it.
    It might be a hack, but it will do.
    Leaving you a little something: https://gfycat.com/TatteredFormalAphid
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    4,729
    nice!

     
    UnLogick likes this.