Search Unity

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

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

  1. ArtisticSliz

    ArtisticSliz

    Joined:
    Jan 4, 2014
    Posts:
    40
    upload_2016-9-8_16-16-19.png
    upload_2016-9-8_16-20-19.png

    Here's another pertinent question about refraction: Why do objects in front of refractives do this? Is it samplying the image, refracting it, and then filling in the void with the original image?

    Not a game-over scenario, as there will always be compromises, but this is the kind of thing that will affect most every object in one of my game levels. Turns out, this isn't real light physics. lol

    I wonder, can you render the refraction without close objects visible and THEN appear the closer objects after, or does that add a whole order of render calls?
     
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Transparent/refractive objects was always a problem for real time rendering due to the pipeline of rendering stuff at 1/60th of a second, it's a sorting vs performance problem. If you look at AAA games they avoid them whenever possible, use hacks in controlled situations (ie no overlapping or intersecting transparent geometry) or get away by facking them entirely. You are basically designing for the worse case here lol.

    Here some explaination:
    https://jakobknudsen.wordpress.com/2013/07/20/transparency-and-sorting/

    It's a general problem not specific to Lux.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    transparent and refractive objects are always a bit cumbersome.
    that is by design... refractive materials by default use all the same grab texture (for performance reasons) as defined by:
    GrabPass{"_GrabTexture"}
    this "global" grab texture will only contain opaque geometry – so refractives can't refract other refractives nor transparent objects.
    in case you need refractives refract other refractives or transparent objects you would have to change the code to:
    GrabPass{}
    this will make each object grab its own grab texture (which of course do cost some more time).

    grabpass.png

    changing the shader as described above MIGHT already solve this problem.
    but that would be a pure accident... in order to draw transparents in front of transparents unity has to sort the objects from back to front and draw them in exact this order.
    assuming that unity uses the pivots to perform the sort a small sphere of glass MIGHT be visible (as it would be drawn on top of the dome) in case its pivot is closer to the camera than the dome's pivot. as you can walk around your dome this would be the case for 180 degrees – for the other 180 degrees the sphere would vanish.
    if you could not enter the dome you could solve this by using different render queues:
    - set the shader used by the dome to "Queue" = "Transparent"
    - set the shader used by the objects inside the dome to "Queue" = "Transparent+1"
    doing so objects inside the dome will always be rendered on top of the dome which gets rendered first (regardless of its position).
    breaking up the dome into e.g. 8 game objects might also help – although you would have to make sure that the pivots of those objects are NOT located in the center of the dome (as this would just give you the same sort ing results...)

    hmm, i don't think so. just have a look at the image attached:
    the tea pot looks pretty clear to me. all i had to do was adjust albedo and alpha and set the fresnel factor in the refraction settings to 5 (which would be the "correct" factor).

    Bildschirmfoto 2016-09-09 um 16.06.21.png

    the shader renders only front faces...
     
    Alverik likes this.
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    simply because there is nothing else they could refract :)
    as the heads are opaque objects they are part of the grab texture – although they should not because they are in front of the refractive.
    so when the shader looks in the grab texture for how the refracted pixel should look like it will also do a depth comparison: if the "refracted" pixel is in front of the refractive it skips the refracted uvs and takes the original ones:
    if (sceneZ <= (IN.viewSpaceNormal_ProjPos.w)) {
    distortedGrabUVs = IN.grabUV;
    }
    simpl comment these lines and you will get a strange "glow" around the heads as now they will be refracted.
     
    neoshaman likes this.
  5. ArtisticSliz

    ArtisticSliz

    Joined:
    Jan 4, 2014
    Posts:
    40
    Could you not render each item in depth order, and therefore render refractives behind opaque foreground objects? I can see only occlusion culling causing an issue with this, by disappearing objects out of view. Wouldn't rendering closer objects second allow you to render truer refractions (yes, they would be more expensive)? Lars, you say they "shouldn't be" part of the Grab, so why are they? Would you have to write that into your shader, or is that a limitation of Unity you can't work around?

    Do you have any idea how much performance loss there is by rendering transparent geometry behind refractives? Maybe you could make it NOT refract thru anything but the front refractive. But maybe that would make refractions pop in and out if a refractive was partially covered by a different refractive.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    nope. all opaque objects(deferred and forward) have to be fully lit before the grab pass can take place. then transparents and refractives are rendered on top using forward. that is the way things work.
    Simply because they exist in the frame buffer, see above. it is no limitation of the shader nor unity.
    it depends on the number of refractives and their screen size as each will have to grab their own grab texture using:
    GrabPass{ }
    instead of:
    GrabPass{ "_GrabTexture" }
     
  7. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I am sad to report lux is not work on 5.5b3 with many errors such as

    "Shader warning in 'Hidden/Lux/Terrain/Lux-Standard-AddPass': implicit cast from "half4" to "half3" at line 93 (on d3d9)"
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    well, 5.5. beta is far out of scope right now. but i guess you could fix it by:
    o.Specular = _SpecColor.rgb;
     
  9. Tesrym

    Tesrym

    Joined:
    Dec 2, 2012
    Posts:
    64
    Using http://forum.unity3d.com/threads/released-kode80-volumetric-clouds-ver-1-1-0.371747/

    Now, I used lux a bit before unity 5, and I was a big fan of using vertex colors to mask the wetness away.
    This would allow me to have dry floor under bridges.
    I could even mask away ripples, so I -could- have wet floor under bridges without having rain rippling down on it.
    I cannot make this work in the new lux.
    Changing "puddle mask" between "vertexcolor green" and "height map(r)" had no effect.

    The beautiful material inspector tells me that i can mask snow with blue. No effect. However, vertex color red and green masks snow away.

    Wind? I cannot find wind anywhere, and I think it was important to break up the uniformity of the rain ripples.

    Textures on large terrains (4k>?) doesnt tile like i tell them to. The tile size values i set in the terrain inspector for each texture are ignored.


    My current thoughts. Using 5.4.
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i am pretty sure that it used to work. however i did a quick test using unity 5.3.5 and you are right:
    for some reason the per material keyword "BILLBOARD_FACE_CAMERA_POS" gets overwritten by the global quality settings keyword.
    you could comment it in the shader though as a quick workaround.
    find:
    #pragma shader_feature _ GEOM_TYPE_MESH BILLBOARD_FACE_CAMERA_POS
    and change it to:
    #pragma shader_feature _ GEOM_TYPE_MESH
    (you have to do this for either all passes or the one you are using).
    i will push a fix as soon as possible.
    hmm, that in spite works fine for me:
    Bildschirmfoto 2016-09-16 um 10.29.26.png
     
    Alverik likes this.
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hopeful likes this.
  12. Tesrym

    Tesrym

    Joined:
    Dec 2, 2012
    Posts:
    64
    http://i.imgur.com/rS8y52q.gifv
    Confirming that vertex coloring works. I grabbed your fresh files.

    As for snow mask, I misunderstood. My bad.
    Blue = Snow. I thought it was the opposite :)
     
    Last edited: Sep 16, 2016
  13. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    166
    This is really amazing. I've only just started playing with it.

    I was wondering, would it be possible to have the snow generate on the terrain based upon if it can see the sky? so if you have a bridge or some other thing covering the ground that part would not get snow?

    And as a dreaming request, could it be possible for the snow to actually accumulate and deform the model so that the snow gets some depth. like having it snow on a railing you can see the snow accumulate over the course of a snow storm.
    eg.
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you can use masks.
    it is possible but it will most likely kill your frame rate.
     
  15. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    113
    Hi, we have recently released a technology which does exactly what you want. It gives you the possibility to deform the snow precisely based on the mesh with low performance impact and you can also easily create effects of snow accumulation. Here is more information: https://forum.unity3d.com/threads/released-wreckit.433358/.
     
  16. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    509
    Hi, what happened with Lux Plus?
     
    Drommedhar likes this.
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i haven't had the time to look further into it. i t works fine with unity 5.3, has to have some adjustments to work with 5.4 and a few more ones to work with 5.5.
     
    nxrighthere and Crossway like this.
  18. wdw8903

    wdw8903

    Joined:
    Apr 2, 2015
    Posts:
    48
    Hello, when I try the lux skin shader, it is easy to get noise artifact. The build-in demo also has this artifact if the head is scale to about 20cm, which is normal head size.
     

    Attached Files:

  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the noise is caused by the dynamic calculation of the curvature... you may however reduce it by lowering "Curvature Influence".
     
  20. wdw8903

    wdw8903

    Joined:
    Apr 2, 2015
    Posts:
    48
    OK, is it possible to complete avoid this artifact in the future update or Lux Plus?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    setting curvature influence to 0.0 totally removes those artifacts.
     
  22. wdw8903

    wdw8903

    Joined:
    Apr 2, 2015
    Posts:
    48
    OK, thank you.
     
  23. momocoast

    momocoast

    Joined:
    Nov 5, 2012
    Posts:
    5
    I am a fan of hair Dither/Jitter. The only thing that misses, is that there are no Sample Counts, Blur Iterations or anything in it you could adjust. I read the paper for CoD Advanced Warfare so it should be at least possible to add a Blur. Otherwise there are also things like the Halton Sequence or other Random Vector Matrix techniques you could try out for the Dither/Jitter? Would do it myself but i am still extremely new to Shaders.

    Anyways good job and thanks for all those good and free shaders, cheers.
    dither.png
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,
    thanks for your feedback. but as i was looking for a way to do hair shading in both forward and deferred (including shadows) i can't add any blur here...
    dithered alpha like used on hair is meant to by used together with temporal AA – which in fact already looks quite nice using the current version of the cinematic image effects.

    lars
     
    momocoast and hopeful like this.
  25. momocoast

    momocoast

    Joined:
    Nov 5, 2012
    Posts:
    5
    I see, i completely overlooked that problem. Anyways, I've added TemporalAA as you said and some more image effects and you are right, it looks nice that way. I am not yet 100% satisfied with it because i am kind of a perfectionlist lol :D, but it's a good start for me. Thanks for the quick reply and help.
     
    hopeful likes this.
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you are welcome!
     
    neoshaman likes this.
  27. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Would there be benefit using unity 5.5 with Lux? Or would it be a simple port? I am still over the fence with 5.5.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    lux personal currently does not support unity 5.5.
    and the first version that will do so will most likely be the plus version of lux.
     
  29. Zaki_X

    Zaki_X

    Joined:
    Jul 5, 2016
    Posts:
    55
    Hi!

    I've been playing with your LUX shader (skin in particular) and I have to admit that it really looks great :) and is pretty easy to set up, but I have a question about rendering method. When I'm trying deferred rendering all looks fine, but after switching to forward rendering the head models start to look reddish/waxy when looking from a distance. Is there any way of fixing this as I would really like to use this shader with forward rendering. (I'm using Unity 5.4.0.f3).

    Regards,

    Mike
     

    Attached Files:

  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi mike,
    that is pretty strange and i have never encountered something like you have described nor has anybody reported similar issues.
    it is even stranger as in both cases (deferred and forward) the shader uses forward rendering.
    so what platform are you on (win, mac, linux) and which graphics API do you use (dx11, dx9, ogenglcore,...)?
    anything else i should know about your project?

    lars
     
  31. momocoast

    momocoast

    Joined:
    Nov 5, 2012
    Posts:
    5
    I use the same version and had this problem too. Somehow this bug appears when you have fog enabled, or rather it's the color of the fog you have enabled, so either disable Fog or change the color to fix it, downside to this "fix" is that you cannot use Fog properly, except maybe through extern Fog solutions. Go to Window->Lighting->Fog and take a look.
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    fog! well, that makes sense!
     
  33. larsbertram1

    larsbertram1

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

    for all that have been waiting for Lux Plus: I have just submitted it to the asset store.
    it needs unity 5.4. – but also runs with unity 5.5.0b10 :) and unity's new post processing stack.

    what is Lux Plus?
    Lux Plus brings Lux's advanced lighting features such as pre-integrated skin, anisotropic and translucent lighting to the deferred rendering pipeline.

    LuxPlusU55b10.jpg
     
  34. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I have a question: what does the built in shader replacement in the graphic setting do? Lux seems to work just fine without it. And if I use Lux's customs shader, would that work if I want to use UBER or other shaders that seems to want to replace it as well?

    What features are dependent on it?

    What happens if I just use Lux without?
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    In Lux area lights, diffuse fill lights and real lambert lighting rely on the lux deferred lighting shader.
    if you do not need or want any of these features you do not have to assign it.
    you can only use one deferred lighting shader of course. so you will have to choose which one better fits your needs (or merge them manually).
    regarding Lux Plus and UBER e.g.: not assigning the UBER deferred lighting shader but the one that ships with Lux Plus would let you use all UBER shaders and features except from translucency and pom self shadowing i think. deferred translucent materials would always have to use Lux shaders. but you would get deferred skin shading, defrred anisotropic lighting, area lights and diffuse only lighting.
    regarding the free version of Lux and UBER you would loose deferred translucency when using the Lux deferred lighting shader. when using the UBER deferred lighting shader you would loose area lights and diffuse only lighting.
     
    hopeful and yc960 like this.
  36. Zaki_X

    Zaki_X

    Joined:
    Jul 5, 2016
    Posts:
    55
    Thanks for the reply Lars.

    I'm using PC/Windows machine. After uploading images that you may see above I've tried the other test scene with head and various materials (you've pasted a screenshot of this scene 3 posts above this one) and all was working fine there. I've checked this scene on 4-5 other machines and all worked great. Maybe I had deleted the config prefab (--Lux setup). I don't know what had happend. It works like a charm now- doesn't matter if I use deferred or forward rendering.
    This test scene uses hdri + direct light (sun) + point light to emphasise specular highlights.
    2016-11-04_22h42_51.jpg

    Mike
     
    Last edited: Nov 4, 2016
    Baldinoboy likes this.
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    in fact it was fog: i set teh fog in the demo scene to red and at a very high density to do some tests and forgot about reverting it. but fog only gets renderd when using forward...
    btw. the head looks georgeous!
     
  38. Zaki_X

    Zaki_X

    Joined:
    Jul 5, 2016
    Posts:
    55
    Thanks for checking this issue and for your comment. This head is still WIP. I'll try to post something more complete later (if I get a permission of doing so :) ). I'm learning Adam's Goodrich Gaia (and new Gena) system at the moment and I think that I will have to give one of your terrain shaders a go too.

    Mike
     
  39. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Hello,

    To make a very long story short, I have a project that's giving me errors, and to help me solve it, I want to try taking Lux out of the project. The problem is that when I do so, the lighting is ruined, and everything turns neon pink or green. I've narrowed the problem down to the PrePassLightingShader (delete that, and the problem occurs), but I don't know what to do about it. This is in Unity 4.5.

    Any ideas? :)
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    oh, i haven't opened unity 4.x for more than 1.5 years now. so i am sorry, but do not know anything about your problem.
     
  41. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    2016-11-11 05-02-49.jpg Hello again Lars. I'm really like Lux, especially weather effects. But I have some question. Is it possible make some "dry zone", where snow of rain effects fading somehow (under the tent?), of just igmore global weather?

    And another question: are you planning make skin shader using weather effects too?
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    just scroll e a little bit up on this page :)
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    nxrighthere and Reanimate_L like this.
  44. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I am using Amplify Shader Editor that support custom nodes, anyway to incorporate Lux into it so we can easily write lux based shaders?
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i haven't looked into that yet. and i might get a bit complicated...
     
  46. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello! I I havae a question what is the difference Beetwen LUX and LUX plus, I'm totally under impressed of weather shader and I would to use it in commercial project, Should I buy Lux plus?
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    lux plus supports deferred translucent lighting, deferred skin shading and deferred anisotropic lighting.
    if you do not need these features (or use forward anyway) you do not need lux plus.
     
  48. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    I'm using forward but I will but it to support you, or Iwill buy Color Map ultra shader, What about Color Map ultra shader is it working with LUX yes? Because in lux there is also shader for terrain but as I understand Color Map is better for terrain, What I need is Adding mainly snow and water to terrain in different scenes. And There is my last question Because Lux shader is great for terrain Grass! IT is really amazing, but will it work with grass placed and combined (with your foliage shader) ? Or can I make it in any way work with combined grass, plants etc? Best Regards Thank you for amazing work!
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    then cmu version 3 should be best.

    not out of the box. but you could merge both shaders.
     
  50. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Lars,
    I have been a huge fan of yours since ur vegetation/terrain shaders!
    I'm impressed about Lux features, but im still searching shaders that support quad tessellation since unity oficialy support it in Unity 5.XX.
    Any way you could try to add quad tessellation to Lux plus?