Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

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

  1. Botanika

    Botanika

    Joined:
    Nov 2, 2013
    Posts:
    59
    well, not just the convolution, Lux specular power range is between 0.25 - 2048, while Skyshop is between 0 - 256, so for a surface using Lux shader, and skyshop's cubemaps, the specular highlights from lights will be soft, while the Ibl from cubemaps will look much smoother.
     
  2. larsbertram1

    larsbertram1

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

    There is a materialtest shader fo the spec workflow which offers separat inputs for the specular and roughness textures. and one might easily write one for the metalness workflow too.

    As long as you use forward lighting you should not have any problems using lux along with Skyshop or Alloy (or any other shader).
    When it comes to deferred lighting either Lux will change the look of materials using Skyshop or Alloy shaders or vice versa.

    However you can use all Lux shaders that always render using forward without any interference. Right now these are: Lux Skin, Lux Hair and Lux Transparent Bumped Specular.

    Well, neither Skyshop’s nor Lux’s direct specular highlights 100% fit the convolved specular cubemaps no matter if you use Skyshop’s or Lux’s cubemap tools.

    To be honest: i do not really know how Skyshop convolves specular cube maps. Lux uses a cosine power filter and is based on the modified cubemapgen.

    I know this shader only from its description on the asset store where the author mentiones Kajiya and Scheuermann. You will find "ideas" from both of them in Lux’s hair shader too.
    But the Lux hair shader uses alpha cut out and supports multiple shells, real time shadows and ambient image based lighting.
    Visual differences are definitly caused by lighting and textures – may be by different implementations of the suggested lighting functions – i do not know.

    Lars
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
  4. Cogent

    Cogent

    Joined:
    May 14, 2013
    Posts:
    356

    Thanks for your work on this and your choice of license Lars!

    Just downloaded and played around with Lux today. Very Nice!

    Cheers
    :cool:
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,874
    @Botanika: Very impressive dude! I should have a decent screenshot soon as well. (Mine's a podracer i made when i was bored ;))

    @Lars: Just a question about the box projected shader: I tried it with a sphere, and it looked really weird... does it only work with box-like objects? BTW, nice hair! May get the new version soon. and the box-projected shader takes a millenium to compile!
     
  6. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,740
    Could you please elaborate on this?
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    hi unlogick,

    when using forward rendering or shaders that always use the forward pass even in deferred lighting each shader can have its own lighting function.
    but if your camera renders in deffered lighting all shaders that support deferred lighting share the same lighting function (blinnphong) which is defined in the internal prepass lighting shader.
    Both Alloy and Lux hack this shader to bring in their modified lighting functions.
    Skyshop does not but its materials will be effected by those modifications of course as long as they are rendered using deferred lighting (which almost all opaque materials do).

    So you won’t have any problems using any forward only shader along with Lux (e.g.: water or glass – mainly transparent shaders) and you won’t have any problems using Lux’s forward only shaders (like the skin or hair shader) along with any other.

    lars
     
  8. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    723
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    hi christian,

    thanks for the test shots.
    but as far as i can see you will have to work on the roughness or gloss texture: taht is the most comprehensive part when it comes to authoring pbs textures. specualr color on skin should just be a very dark shade of gray – but the roughness texture should have a lot of different values in it as there are quite "oily" parts (nose, forehead and around the cheekbones – not to forget lips which are not oily but "wet") and matter parts of the skin. the same for the whole body. just my 50 cent – i hope you do not mind.

    lars
     
  10. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    723
    Not at all :) But for the first round of testing I was quite pleased with the improvements. will be developing further over the next few weeks
     
  11. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,874
    Ok guys, here we go again... I present what i have done with Lux. Note that some of the materials use the Lux Materialtest shader. The other parts use the metalness shaders

    Here is the front view of my podracer, modelled in blender:
    $Picture1.jpg
    Here is a rear view:
    $Picture2.jpg
    And here is a first-person view from the cockpit:
    $Picture3.jpg
    Feel free to do some constructive criticism - it helps me take advantage of Lux better for my games.


    @SoloChristian: Impressive screenies! just a question though: where are thier legs? It looks kinda odd...
     
    Last edited: Mar 31, 2014
  12. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,016
    I actually bought this shader and it look incredible, sans the light probes don't work on it. And I love that his shader uses the full range of the alpha channel in the cutout, so no ugly artifacts
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,439
    Pretty cool FuzzyQuills. Do you have it working?
     
  14. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,325
    I have to wonder if the difference lies in the tube shaders ... whatever those are! ;)
     
  15. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,874
    @baldinoboy: Whatcha mean bro? if you mean the framework, then yes, it works in my test project dedicated to lux!
    If you mean podracer physics, though, then no, not yet...

    @hopeful: yes... what are the tube shaders, "whatever those are" ! :)
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    does it support casting and (probably more important) receiving real time shadows?

    lars
     
  17. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,016
    It's strange. I haven't seen any shadows being cast... and I have a directional light on it too...

    EDIT: Yes, it's casts and receives shadows :). I'm using IBL so it is not immediately evident.
     
    Last edited: Mar 31, 2014
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    upps, then may be i will have to have a look at it.
    could you please post a screenshoot?

    lars
     
  19. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,740
    Hey Lars

    Yesterday we discovered a problem with controlling the results from the Lux\Bumped Specular shader. When working with a bright material even a completely black specular map could not prevent the lighted areas from becoming too bright.

    Our goal was to attempt to tweak the bumped specular shader into giving acceptable results for skin. UMA have an extensive overlay system, so using the bumped specular shader instead of the skin shader would allow us to do metallic piercings/implants directly as an overlay without mesh parts.

    To put it short it seems the intensity of the color of our specular texture didn't matter, and the alpha channel of the main texture was similarly ignored. You can't seriously say that the only way to control the specular intensity is to ramp the Custom Diffuse Cube.
    $lux_failed_lighting.png
    This screenshot is using all specular channels on the face set to 0.
     
  20. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,740
    Hey Lars

    Perhaps I wasn't clear enough. I wasn't talking about the specular highlights. When I set specular to 0,0,0 they go away as they should. But in order to get a decent skin color in the dark/shadowy parts of the head, the color needs to be so bright that the normal diffuse lighting pushes it out of bounds.

    $skin vs spec.jpg

    So using the same light and lux settings, this is the results of the bumped specular and the skin shader. As you can see the specular shader's dark areas are darker and the light areas are brighter. And there is no material/texture channel I can use to change that. All I can do is add specular highlights on top and make it worse. That is why I'm missing an overall lighting coefficient to dampen the diffuse light and make the two results a bit more alike.

    The only way I could do it now is to use different cube maps for them, but there is no tweak that will allow me to use the same cubemap. The reason I mentioned the diffuse alpha is because that channel is not being used for anything and that would let me do a per pixel thing that would give me optimal freedom.
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    Hi unlogick,

    as you can see on previous pages of this thread using the specular bump along with skin shader does not cause any problems nor does it force you to do any changes to the lighting of course.
    And as we are talking about physically based shading: It does not need to change any mystical sliders either! ;-)

    So i guess you have probably somehow messed up with the texture channels?
    - specular bumped uses spec color(rgb) roughness (a)
    - skin uses spec color (r), roughness (g), sss mask (b), ao (a)

    and here is what i get putting both shaders next to each other, assigning the "correct" textures but do not apply any other changes at all:
    (spec bumped on the left, skin on the right)
    both textures uses the same shade of gray in their "spec color slots" and the same roughness mask.

    $Bildschirmfoto 2014-03-31 um 15.43.14.png


    But if you just want to dampen diffuse lighting you can use the color attribute and set it to some shade of gray.

    Lars
     
    Last edited: Mar 31, 2014
  22. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,016
    Are you guys using GI and Skyshop for these skin renders? Right now, the light is too harsh on the skin...
     
  23. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,874
    It's more likely that they are using linear lighting my friend, as i have seen over-exposure problems with gamma-based lighting with some Lux shaders.
     
  24. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Lars do you have a general idea how Lux might play along with Skyshop? (Not including eithers env map makers)

    It seems i'll be using dDo for the fast amount of my texturing, their previewer is Marmoset based so that would be the look I would expect - However be it from solidarity or simply because Lux is looking really bloody impressive, and being updated extremely quickly, i'd like to use Lux extensively, certainly if it can piggyback some of Skyshop's upcoming features as they demonstrated at the recent GDC. Ideally it would be lux through and through but as one cant reasonably expect exact parity between features a mix might seem ineveitable - So I was wondering wether a mix would actually mean a slight discontinuity between appearance, at least one that the layman might notice anyways

    It's nice, in fact, to feel that after a few months doing nothing but learning things that I may, MAY be close to actually being able to have some fun and my work at the moment, should hopefully be a lot of creativity, and I would certainly hope a gratifying showcase for the breadth of Lux's abilities (And skyshops too, given they do have some specific focus on mobile in places which is where other work is heading)
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    as i have written before: if you use forward rendering everything should be just fine.
    if you use deferred rendering then either lux or skyshop shaders might look dull.

    textures that have been authored to be used with skyshop should just work within lux – except from the roughness (gloss) texture as lux uses another and much broader range. so may be you will have to simply adjust the curve of your glossmap. specular color is the same.

    lars
     
  26. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    That sounds perfectly fine, if it's texture authoring idiosyncracies then I can't see that being a problem at all as i'd only be using specific shaders from one of another for specific purposes

    I dont suppose anybody knows how the near-instant map convolution and blending will work out in practice other than Marmoset atm but i'm certainly hoping they can be used by other opportunities such as Lux
     
  27. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,346
    This is an awesome project,

    Would this work on Mobile ? Iphone 4 ?

    Cheers.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    it has been tested on ipad by some other user and works.
    but it is not optimized for mobile devices though.

    lars
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    Hi there,

    it took quite a while but now lux is available at the asset store:
    https://www.assetstore.unity3d.com/#/content/16000

    So please download and rate! it.
    Make it visible to the community so it will get much more feedback and attention.

    Lars


     
    Last edited: Apr 1, 2014
  30. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,874
    That sir is a really lovely looking screenshot!

    The things gradients do... ;)
     
  31. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,439
    So true. Glad it finally got accepted. Thanks lars.
     
  32. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,346
    I'm speaking for myself yet quite certain that there are many mobile users that would really love to have Lux in their projects. Would you consider a humble request to support mobile in the near future. Having mobile support will surely increase the popularity and adoption rate of LUX .

    Cheers.
     
  33. elacamlee

    elacamlee

    Joined:
    Mar 20, 2014
    Posts:
    6
    Hi Again Lars

    i'm trying to use the box projected shader but can't seem to make it work, sorry i'm a noob at cubemaps

    $test.png
     
  34. larsbertram1

    larsbertram1

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

    next to assigning the correct shader you will also have to feed the shader with the correct params (cube map position and size).
    best would be to use the "lux environment probe" script to handle all this for you.
    so please have a look at the "_Lux Cubemapper" documentation.

    lars
     
  35. larsbertram1

    larsbertram1

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

    as i have written before lux already works on mobile – but is quite expensive of course.
    so first: do not use cooktorrance on mobile.
    second: you could gradually simplify the direct lighting functions to make it faster for mobile:
    "LightingLuxDirect" in "LightingLuxDirect.cginc"
    - skip "Visibility"
    - skip "Fresnel"

    lars
     
  36. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    Hi Lars

    When I try and import the Lux package from the Unity asset store I get the following compiler error


    Internal compiler error. See the console log for more information. output was:
    Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

    at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

    at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0

    at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0

    at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0

    at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0


    Any ideas ? I'm running Unity 4.3.4 in directx 11 mode .

    Also is the fact that the package contains some sub packages that aren't automatically compiled intentional ? An example of on of these is the Lux_BoxProjected package.

    Thanks,

    Ian
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    hi ian,

    i have no idea, where the errors come from... for me everything work ok.
    however, you can try to get rid of the scripts (not the shaders or the demo content) and get them from the git repo instead.

    as far as the additional packages are concerned: importing all shaders at once would take more than 30 min.
    so i have decided the just add the core shaders directly. all other shaders can easily be loaded in case you need or want to have a look at them by importing the related "sub" package.

    lars
     
  38. elacamlee

    elacamlee

    Joined:
    Mar 20, 2014
    Posts:
    6
    Thanks lars,

    i now know what i'm doing wrong i forgot to use the setupLux script, that's why it isn't working lol at myself.
    thanks for a well written documentation and also thanks to rea :)


    -Lee
     
  39. elacamlee

    elacamlee

    Joined:
    Mar 20, 2014
    Posts:
    6
    ok so got it working i guess that the cubemapping is still not on it's final stage the edges are a little off when i got to the sides or is this behavior normal on box projected environments?

    $edge.png

    but still such greatness in this asset, guys please rate this asset so others can know about it
     
  40. larsbertram1

    larsbertram1

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

    box projected cube maps are just an approximation: so they will never be 100% accurate.
    i thought about making them more accurate but that would be more expensive on the pixel shader...
    so for now: in most cases i guess you will have a rough and bumped surface being the "reflector" and on that kind of reflector even the approximation should be fine.
    using a 100% mirror as reflector will break illusion as soon as you have some moving objects within your scene anyway.

    [edited] nevertheless even your broken reflection just looks fine to me ;-)

    lars
     
  41. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,874
    @Lars elecamlee: That is still decent for Unity Free! And artifacts like that aren't that obvious to most people. well, except us game designers. ;)
     
  42. elacamlee

    elacamlee

    Joined:
    Mar 20, 2014
    Posts:
    6
    @lars thanks, i'm searching on tutorials on how to use multiple box projections on multiple rooms can't seem to get the hang of it, i wish that parallax-corrected cube mapping will be also implemented if that is what it is called, ;)
     
  43. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,339
    I'm having trouble getting the Bumped Specular shader to work on a metallic object when there's no IBL Cubemap. For example, a gold material with full black diffuse and bright yellow specular. When I have an IBL Specular Cubemap it looks fine, but with no cubemap it's almost completely black. I assumed it would use the directional light and ambient light settings, but is that not the case? Is an IBL Cubemap required?
     
  44. larsbertram1

    larsbertram1

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

    although you might not like to hear that: it is completely fine the way it is.

    metals simply do not have any albedo or diffuse as they immediately reflect the incoming light. so their diffuse color is always black.

    they ARE effected by directional lights (and any other light of course) – but direct lighting only adds the specular highlights which get colored by the specular color (metals color the secular highlight, none metals or dielectrics do not).
    they also ARE effected by ambient lighting but not by diffuse ambient lighting (as they have no diffuse) only the specular ambient lighting – specifically the specular reflection map or specular cube map.
    so yes: if you want to display proper metal surfaces you need an ambient specular cube map or IBL.
    you can simply use lux’s cube map tools to create a proper reflection or ambient specular cube map.

    if you can’t afford any cubemaps you will have to break the physically based approach and raise the diffuse color. but that will probably look very odd.

    lars
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    hi there,
    in order to get different cube maps applied to different "rooms" you will have to create several game objects: each of those having its own "Lux Environment Probe" script assigned to which mark the boundaries of your room and hold the unique cube map of course.
    change the "Cube mode" to "Box" and the script will let you add game objects which will be effected by the box projected cube map, which means that the script will pass all needed params like cube map, its position and size to the assigned game objects or better: their materials.
    make sure that those game objects use the box projected shader!
    that is pretty much all you have to do.

    lars

    p.s.: cube maps are already "parallax-corrected" by the way...
    p.p.s.: you could rate lux on the asset store too ;-)


    the screen shoot attached shows 2 "rooms" next to each other:

     
    Last edited: Apr 3, 2014
  46. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,339
    Ah ok that makes sense; I thought the specular would reflect the ambient light in Render Settings, but it makes sense that that is only diffuse ambient. I'm currently doing a day/night scene and was changing the ambient color but I suppose I will have to blend between different cube maps instead.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    just by the way: lux has been downloaded 111 times from the asset store within the last 3 days.
    may be we have to make some more noise!
    so please go and rate it, leave your comments and post your thoughts here on the thread.

    lars
     
    Last edited: Apr 4, 2014
  48. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,339
    Though following up on that... is there a reason you can't use the same value for diffuse ambient and specular ambient? It's the same light; I don't really understand how a light can have a diffuse and specular component... those are properties of a material. I would think that a metal should treat an ambient light color the same way it would treat a solid cube map of that color. Similarly, I don't really understand why there needs to be two separate cubemaps for diffuse and specular... aren't they supposed to be the same thing, representing the light around an object?
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,143
    hi there,
    no, absolutely not.
    diffuse and ambient specular or not related to the light but only to the material – just as you said.
    so not the light got the diffuse and ambient component but the material.
    as far as the different cubemaps are concerned: you are right – both represent the light around the objects. but that is all.
    for lighting on a given surface simply consists of 2 completely different parts: diffuse and specular. and that relationship defines the material. that’s physics and that is the base of physically based shading.

    you might want to read some more background information about lighting.
    so you could start at: http://filmicgames.com/archives/547
    or you could watch this video: https://www.youtube.com/watch?v=LNwMJeWFr0U

    but let me assure: lux just handles it right.

    lars
     
  50. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I'll be making some noise soon, the basis of my rtp 3.1 terrain that id had planned for quite a while is pleasantly roughed in, tomorrow i do a bit of cleanup but not too much as someone will make me change it anyways - after Nuaj looks good with it, Suimono 2 beta 8 fits the bill and Skyshop plays nice, i start with your foliage shaders, and then every 3rd party asset I use to populate the terrain (More cleaning up mainly) i'll be adjusting for Lux use, and the only time I wont be using Lux is if it cant provide a shader that is unequivocally on-par with any competitor, which doesnt seem a problem

    I'm finding it funny that i bought skyshop to get their sky object, in the end, but oh well, if the gdc improvements sit well with Lux then everyone wins
     
unityunity