Search Unity

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

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

  1. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    Hi everyone,
    I like to contribute to the framework.
    I implemented some of the features of parallax corrected cubemap with multiple cubemaps in the scene.

    upload_2014-7-10_3-12-34.png

    upload_2014-7-10_3-14-27.png

    upload_2014-7-10_3-15-21.png
     
    x_african_warrior_x and SememeS like this.
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi eddie,

    so you have added support for dynamic cubemap blending based on the object’s distance to the probes?
    that sounds cool and will probably very well appriciated.
    do you mind describing your approach and may be posting a webplayer?

    thanks, lars
     
  3. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    Hi Larsbertram,

    The approach is based to this presentation: http://seblagarde.files.wordpress.com/2012/08/parallax_corrected_cubemap-siggraph2012.pdf

    First, in editor time, it is calculated the graph of intersection of the boxs of all LuxEnvProbes. The black line in the first image indicated this connection.

    To the object do you want to blend, It is added a component. In each update, as in the presentation, is calculated the influence of each probe to the object. But I use only the 2 probes with biggest influence.

    I will prepare a webplayer...
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    fine.
    i just wonder, what happnes if you have 3 probes and a sudden change from being probe 1 + 2 beeing the most important to e.g. 2 + 3?
    will you get a sudden pop?

    lars
     
  5. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    Last edited: Jul 10, 2014
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @EddieLopes : Interesting, is it already commited in the git hub? or you have your own branch???
     
  7. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
    Well... that is the problem... I never worked with commit in github... :p
    So, if anyone can help me, I apreciated... :confused:
     
  8. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    or maybe put the probe scripts here or send it to lars just to be safe
     
  9. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi eddie,

    that looks promising.
    if i find the time i will have a look into it and come back to you.

    lars
     
  11. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Is there a version of the Bumped Specular Metalness shader that also has Self-illum? If not, how would I go about adding this?
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    right now there is no self illuminated shader using the metalness workflow.
    however it is pretty easy to write one.

    if you have a look at the "Lux Bumped Specular Metalness" shader all you would have top do is adding self illumination right after:
    #include "LuxCore/LuxLightingAmbient.cginc"

    this include calculates the diffuse and specular ambient lighting and writes those to "o.Emission".
    self illumination would be added on top of that right after the include.
    so it could look like this:

    ...
    #include "LuxCore/LuxLightingAmbient.cginc"
    o.Emission += _IllumColor * _IllumMask;

    you will of course have to specify _IllumColor and _IllumMask. Color might be a single color property or you can sample it either from a special illumination texture or from the main texture (as unity’s built in shaders do). the mask will most likely always be sampled from a special mask texture tough.

    nevertheless i have just added a "Lux Illumin Bumped Specular Metalness.shader" to the repository:
    https://github.com/larsbertram69/Lux
    it samples _IllumColor and _IllumMask from a special texture but it should be pretty easy to change this to make it fit your needs.

    lars
     
  13. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Thank you so much! I really need to learn how to write shaders that aren't one solid colour...
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you are welcome!
    writing shaders in fun – at least if is as easy as when using lux: you just have to get known the basics of writing surface shaders then you will find a lot of examples in the provided shaders.

    lars
     
  15. EddieLopes

    EddieLopes

    Joined:
    Apr 19, 2014
    Posts:
    11
  16. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
  17. Dhialub

    Dhialub

    Joined:
    Nov 11, 2013
    Posts:
    41
    Hy everyone!
    Recently I started working with Unity again, and I've come up with this:
    Screenshot 2014-07-14 16.49.53.png
    Lux version is better than in Cycles :)

    And I have some questions:
    First, should I use dx9 or 11? I've been always working in 9, but I'm about to switch. What are the drawbacks and the benefits?
    Second, I'm trying to find a good solution for terrains, any ideas? The basic unity terrain is nowhere in quality and performance compared to lowpoly normal baked blender sculpts, but I can't get desired texture resolution.
     
    SememeS likes this.
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    lux does not use any dx11 only feature (like compute shaders or tessellation) so using dx11 instead of dx9 would exclude some possible users/players from your game or whatever you you are going to create.
    on the other hand dx9 seems to be more buggy.
    so personally i do not have a proper advice (but i am on mac anyway).

    not using the built in terrain is not really an option i think as you would loose the following features:
    • automatic and fast LOD.
      you could mimic this using the built in LOD functionality but i guess it would be more expensive as far as processing and rendering time and memory consumption is concerned.
    • easily added details like grass (bending in the wind) and small rocks
      here you could buy my advanced foliage shader which lets you add grass and foliage just anywhere in you scene – be it on top of a terrain or any arbitrary geometry – and supports bending and advanced lighting features next to a lot of other great things ;-) https://www.assetstore.unity3d.com/en/#!/content/3253
    • billboarding of trees
    so i would always try to get the best out of the built in terrain solution (which might get updated in the nearby future).
    lux itself ships with an enhanced terrain shader which can give you some very nice results supporting bump mapped detail textures next to using a global color and global normal map.
    alternatively you could think about buying my color map ultra shader ;-) (no pbs in its current version though) which comes with some more features (like mesh blending and parallax mapping): https://www.assetstore.unity3d.com/en/#!/content/4722
    or even rtp3 which is by far the most complete/complex terrain replacement shader: https://www.assetstore.unity3d.com/en/#!/content/5664

    lars
     
    Dhialub likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    as ludiares has started to bring wetness and rain effects to lux (thanks a lot for sharing) i have decided take on work on this topic again.
    so right now i am working on physically based wetness and rain effects based on the fantastic work of sébastien lagarde whose work also contributed a lot to the already existing core of lux.

    so what do i have right now?

    • dynamic water accumulation (based on heightmaps and puddle masks (texture or vertex color based))
    • dynamic rain drop animations (based on water accumulation and rain strength)
    • dynamic water flow (water may run down walls or slopes) based on slope angle and water accumulation
    • dynamic adjustment (darkening) of the albedo based on calculated porosity based on the specular color
    • dynamic adjustment of the specular color and roughness based on wetness
    the lux setup script will allow you to control rain strength (rain drops) and amount of accumulated water separately so you can easily have puddles although the rain has already stopped. but it will be up to you to sync those parameters nicely ;-)

    i hope i can make "wetness" part of the core so practically each single shader can take advantage of it – no matter if it is a transparent cutout, parallax self illuminated, vertex blending or box projecting shader.

    so here we go with a first preview of dynamic raindrops and puddles:
    (the puddle is added using vertex colors and the amount of triangles is very low – so its shape looks a bit hard edged, sorry)



    lars


     
    Last edited: Jul 14, 2014
    red2blue and SememeS like this.
  20. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    Oh wow lars.. that is amazing
     
  21. jmatthews

    jmatthews

    Joined:
    Jul 27, 2011
    Posts:
    199

    That's where DX11 would come in handy. You could tesselate up your tri's to get rid of your hard edges. Not the right direction for LUX but funny that someone just asked about it.

    I'm not sure if it would help visual quality but a ramp texture or edge finding algo that adjusted the translucency may, "take the edge off"
     
  22. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    I prefer to go with decals for the puddle
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    thanks for the feedback.
    personally dx11 tessellation is no option – but the are several other and probably cheaper ways to improve the outer shape of the puddles as you will see in the image attached.

    @rea: do you mean decals added as independent geometry?
    well, those would be more expensive to render and make it difficult to add features like refraction (would need grabpass – pro only). but mixing vertex colors, the heightmap and a general puddle distribution texture (may be perlin noise) should give us really nice results.

    lars

     
    mgear, hopeful, SememeS and 1 other person like this.
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    btw.: does anybody happen to have a nice rain particle system?
    lars
     
  25. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Could be, but i still prefer doing it by decal, of it's possible :p

    Btw the last image looks awesome lars,

    unfortunenately no, never find any decent rain system in Unity :(. Or maybe i missed it.
     
  26. Dhialub

    Dhialub

    Joined:
    Nov 11, 2013
    Posts:
    41
    Ok, I think I'll stick to Terrain+Lux shader, and make some parts in Blender. Any advice for high amount of draw calls?
    I've experienced 800-900 on a mid sized terrain with the basic shaders.

    BTW, this advanced foliage shader is pretty cool, I'd definitely buy it, but I don't have any money at the moment since I'm only a student.
     
    Last edited: Jul 15, 2014
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    well you will not be able to lower the number of draw calls unless you reduce the quality:
    • do not use add pass (so only use 4 detail textures on the terrain) as using 8 detail textures will cause the terrain to be rendered twice (double number of draw calls). the color map should help you to create an interesting looking terrain anyway.
    • play with the pixel error value.
    • if you have added any details to your terrain: lower the detail resolution. details like grass cause a lot of draw calls. a low detail resolution will not allow you to have grass placed very accurately but that is ot needed most of the time anyway. if you have some areas where you need to place grass and other details very accurately use the advanced foliage shader (once you have bought it ;-) ).
    lars
     
    Dhialub likes this.
  28. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey lars the wetness effect looks incredible. Exactly what I was thinking about. Thanks. The dynamic water flow sounds even more awesome.
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks baldinobody,

    right now i am putting all the functions to an include and writing to documentation.
    so puddles work already. next will be the dynamic water flow...
    quite expensive as it uses triplanar texturing but that is the only way i could handle it without any pre computation.

    lars
     
  30. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Looking good! I've been talking with folks about making asset store stuff and i'm thinking Lux seems really a great choice to bundle in with any art stuff, even given Unity 5's nods to PBS/R, Lux seems like it'd be much more agile than Unity's usually glacial updates. As usual nothing's definite, stuff keeps changing in importance and health is screwing me but it's good to see this still being worked on
     
  31. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Puddles it's very cool, Lars, I'm looking forward to it!
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks id0!
    but i am still working on the dynamic water flow (sloped based only) so it could some more days...

    lars
     
    id0 likes this.
  33. youarebritish2

    youarebritish2

    Joined:
    Nov 7, 2013
    Posts:
    29
    Very awesome work, Lars! I've been following this thread for a while and was floored to see your work on the wet shaders, as I happen to be working on a project at the moment that sorely needs it. I'll be sure to give it a whirl when it's done and show results.
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    slope based water flow is finally done.
    it does not support all features i would like it to support but – well – there is still a bunch of those included.
    so right now i have:

    • define overall water accumulation in cracks and on the overall surface + define water accumulation in puddles: this should depend on the time it has rained and the amount of rain that has fallen and can (must) be controlled by your weather/environment script (the shaders offers 2 independent inputs for that).
    • define puddles by applying vertex colors (puddle mask): define lower regions on your geometry where you want to have puddles to built up according to the water accumulation
    • define completely dry areas by applying vertex colors (wetness mask): you can mask areas which should not be affected by rain at all.
    • alternatively you can define puddles and the wetnessmask using a texture
    • overall wetness can be damped by the worldnormal so faces facing down might never get wet (i use the face normal here – not the pixel’s normal)
    • in case you use the water flow shader (which is the most expensive one) you may have water flowing down the surface according to the face’s world normal
    • all wetness shaders support parallax mapping, texture blending (2 textures only), boxprojected cubemaps and ambient occlusion using uv2.
    please just let me know if i miss anything.

    lars
     
    SememeS and John-G like this.
  35. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    And the skin shader?
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    well, i guess you will not need puddles or flowing water on the skin...
    so it would be more or less just some lerping between 2 different roughness and specular color values based on a mask texture, smoothing the normal and darkening the albedo:
    all this is one function call of the wetness include – and should be easy to add even to the skin shader.

    lars
     
  37. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    I see, Lars, thanks for the answer.
     
  38. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    Woot! Awesome Lars!
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    the first version of the wetness shaders is online and can be downloaded from the github repo:
    https://github.com/larsbertram69/Lux

    Please make sure that you upgrade the Lux core files, especially: "LuxLightingAmbient.cginc" and of course the whole new "Wetness" folder.
    You also need to update the "SetupLux" script and import the "Lux Shader" --> "Wetness" folder which contains the wetness shaders.

    In "Demos" --> "02 Lux Wetness Assets" you will find the mesh of a simple street (including vertex colors to distribute puddles) and all corresponding textures.

    Please have a look at the "_Lux Wetness Shaders".txt file which should answer most questions of how to use the shaders and set up their properties.

    dx9 and forward rendering currently does not support fog. Please have a look at the "_Lux Wetness Shaders".txt file to get around this.

    and post your feedback as it is really needed!

    lars
     
    SememeS likes this.
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi SememeS,

    just get it, play around with it and tell us your feedback ;-)

    lars
     
  41. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    sure thing lars :)
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    wetness core updated, sorry.
     
  43. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    this is seriously awesome lars! Thank you

    I'm making an example scene to show it off

    I really like that you can control it through Lux Setup. Plus you can change the flooding(water level) &rain amount&intensity dynamically during runtime


    .
     
    Last edited: Jul 24, 2014
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks sememes,
    being able to control wetness globally at runtime is very essential, isn’t it? ;-)

    lars
     
    SememeS likes this.
  45. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I don't know if this was me being slow but through using the Quixel Suite for texturing and prep (And YES Quixel Suite and Megatextures, and for that matter any of the superlatively authored and bargainpriced work over at gametextures.com added as a custom material into the new dDo, works brilliantly with Lux) i've realised that the output maps for a Skyshop calibration (Once I figure out how to write a calibration i'll do one for Lux although it it's not too dissimilar to skyshop for the basic maps) match up just as we with lux as they might with skyshop. I always figured you'd have to do some messing around with inverting channels because of the wording - Roughness/Glossiness but the difference between roughness and glossiness seems entirely semantic? I can use the same Spec RGB Gloss Alpha produced for Skyshop in both skyshop and Lux and get expected results

    I wasn't clear on this for ages and I thought it was worth making a point of just in case anyone else wasn't sure

    Might sound a bit sneaky but after staring at the one 3D model in all manner of lighting, shading and wotnot I must profess I love Skyshop's authoring tools they're best of class but they do cost money, Lux's actual visual output is superlative, in fact I don't know any shaders in this field producing results that are so incredibly convincing and so well implementated - Sticking to surface shaders was genius, making any kind of shader you can imagine is becoming possible without even needing any real sense of shader writing because of the tools Lux provides, it's a kinda light introduction to shader writing for those who dare (and they really should dare! it's simple and will help you understand the entire system) while giving mindbogglingly versatile results.

    The only reason Lux isn't an enormous number of shader permutations in size is because it's work that Larsbertram shouldn't have to do, the instructions are clear and the tools are all given to you in LuxCore, making your perfect shader is trivial - and the list of attributes you can give a shader is now impressive! with use cases becoming increasingly marginal and starting to verge on the black words of tessellation and compute shaders, but i'm definitely waiting until Unity 5 for any of that ho haa (I'm really, really intent on getting a Lux framework shader working through Shaderforge so I can write a shader with Lux in mind for an ocean shader that will knock socks off - probs Suimono-targeted for all the gameplay specific stuff however). Ah yes and the choice of offering both Blinn Phong and Cook-Torrance was a masterstroke to be honest. I'm lucky enough to have a decent nvidia card, Cook-Torrance can look phenomenal whe in a cohesive scene

    I'm making this big loud re-entry in the thread as i've decided to do a bunch of assets, initially environmental, heavily based on the kitbash collections here http://www.bulgarov.com/ and further (thankfully easier on the pocket) kitbash selections here http://www.badking.com.au/site/ - so lots of techy shiny bits with some gooey bits for fun. Lux is so far extremely well featured, and available to everyone, and with the addition of wetness shaders I'll just have to cook up a nice rainfall particle effect to be able to provide materials in-scene and as its constituent parts. These will be available to everyone, i'll add and update in the Asset Store when I have enough to be worthwhile. They are intended to get newcomers making cool looking stuff using a PBS workflow provided by Lux and also to be used as a free resource for any shader programmers being frustrated by 'programmer art' to get a go at some artwork that might offer a few different looks at what they are creating

    Kinda hoping I get Lars' blessing on this - And it wont be necessarily a quick process, it's essentially my learning path to getting proficient enough to be making PBR assets for both Unity 5 and Unreal 4 for projects upcoming that are being led by other people as i've concluded I cant lead this stuff myself

    So! To get started i'm working on the simplest of simple scenes - it is, in fact, maybe amusingly, a scene made of the same model repeated endlessly, using a cobbled lux bump spec self illum shader, a ton of camera effects and now lars shows up with his fancy wetness stuff, and excuse to add some rain to the Bladerunner ambience (And vpaint to the asset collection). A video will pop up at some point soon, i'd love to do a demo but i don't want to get into a difficult conversation with UT just yet.

    Sorry for the long one, i'm just glad to be back in this thread, and in the end what got me here was that Lux, when you think about how it works, how flexible and powerful you can make it, if you want to do that, Lars has made this possible, is a solution i deeply hope takes strong root into Unity 5, for adding fringe, interesting and forward thinking capabilities into it's fold (I'm very much tempted, having had everything I really need handed to me on a plate, to consider going into volumetrics as a possible option for growth). Oh and at it's most basic, Lux Bumped Specular with Selfillumination with Cook-Torrance BRDF looks fecking amazing.
     
    SememeS, hopeful and John-G like this.
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    just found a bug in the wetness shaders and how they handled roughness (not at all!) – and fixed it.
    please grab the latest version from the repo.

    lars
     
  47. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    All this clicking! Aha. Cloning to Github once and for all
     
  48. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Might want to fork it into your own repo and add Lars repo as remote repo.
    So it's Repoception....:p
     
  49. SememeS

    SememeS

    Joined:
    Nov 27, 2012
    Posts:
    127
    Ok, I thought I was doing something wrong late this morning, gave up went to sleep to keep it for today. You're always one step ahead lars :cool: Thanks for the fix!


    .
     
    Last edited: Jul 24, 2014
  50. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Hi Lars, have you tried Lux on mobile platforms? How does it perform on Android or iOS?
    I'd like to make use of pbr/pbs for a mobile game and Lux seems to be the ideal candidate in terms of shading quality, features and costs (aka: no money, just time to learn and implement).