Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Lux – an open source physically based shading framework

Discussion in 'Works In Progress - Archive' started by larsbertram1, Jan 10, 2014.

Thread Status:
Not open for further replies.
  1. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,524
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
  3. larsbertram1

    larsbertram1

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

    eskovas reported problems with the grass and vertex lit shaders.
    and rea got some errors importing them although those have gone as far as i can say.
    so nay other feedback on those shaders would be great.

    lars
     
  4. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @larsbertram1: I sometimes get terrain shader errors, but once the game starts, it's fine. only when stopped do the errors pop up. I don't think the grass shaders threw up errors. (or maybe that's why the grass looks dead...)

    About the water shader: fair enough, i am going to start a dedicated thread on my River Water, so i will include the Lux version for those who use your package. And mind if i create a link to your package too when i write it? could attract curious people (Like me!)

    @mgear: I could try that, but Lars ported my shader using custom coordinates. still worth a try though! And apparently, the coordinates were fine on a mac. typical... :p
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    pretty weird...

    i also think about maintenance. it takes pretty much time to get a package updated when it is on the asset store (where i would like to publish lux within the next days/weeks).

    i think you could use something like this:
    #if defined (SHADER_API_D3D11) || defined (SHADER_API_D3D9)
    flip y coord
    #else
    do not flip
    #endif
    in the vertex program to flip the y coord.

    lars
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    btw: version 0.061 is online:
    http://bit.ly/1jwBzn0


    lars

    changelog version 0.061


    - lighting
    - - blinn phong: visibility term now is more robust (by adding saturate)
    - - cook torrance: sign corrected, no more magical numer needed to make deferred match forward
    - terrain shader
    - - normal blending enhanced
    - detail shader
    - - normal bending corrected
     
  7. hd_

    hd_

    Joined:
    Jan 23, 2014
    Posts:
    29
    Dude you're a machine, I can't even keep up with the updates ! Thanks for the amazing work !
     
  8. QI

    QI

    Joined:
    Oct 27, 2012
    Posts:
    229
    Very great man.
    Love it and enjoying !!!

    Thanks.
     
  9. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    Just some quick feedback,
    I deleted Lux folder and imported the new version. so every file would be updated.

    After importing the package, these types of errors appeared: (434 errors)

    Shader error in Hidden/TerrainEngine/Details/...

    - BillboardWavingDoublePass
    - WavingDoublePass
    - VertexLit

    : D3D shader assembly failed with ( X ): error X5204 ......

    There are also 2 more shader errors:
    Shader error in 'Lux/Nature/Tree Creator Leaves': Program 'SurfShaderInternalFunc', unable to find compatible overloaded function "texCUBE(error, float3)" at line 18
    Shader error in 'Lux/Nature/Tree Creator Leaves': Program 'SurfShaderInternalFunc', undefined variable "_DiffCubeIBL" at line 18

    And some shader warnings:
    Shader warning in 'Lux/Nature/Tree Creator Leaves': Program 'SurfShaderInternalFunc', implicit cast from "float3" to "half" at line 64
    Shader warning in 'Lux/Nature/Tree Creator Leaves': Program 'SurfShaderInternalFunc', implicit cast from "float4" to "float3" at line 274
    Shader warning in 'Lux/Nature/Tree Creator Leaves': Program 'SurfShaderInternalFunc', implicit cast from "float4" to "float3" at line 277

    In the previous version, there was something off with the terrain shaders where textures were intersected, having way more specular light on those areas than it should, and if i looked at the terrain in the opposite direction of the sun, it would also look a bit off. I'll try to make some screenshots to describe it better.

    I also wanted to know if anyone else is also having these errors... It might just be because of my project.
     
  10. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I meant convolving an image using a compute shader, as there are examples online, and its part of creating the cubemaps used for ibl, which currently is done by skyshop, hence everyone using skyshop to create these maps, when a free alternative might be nice
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    hi eskovas,

    thanks for taking the time.

    what comes after the: error X5204?


    ups, i checked the demo scenes but not each single shader.
    you are right. that shader throws errors. but you can quickly fix those.
    so open the "Lux/TreeCreatorLeafs" shader.
    find:
    #ifdef DIFFCUBE_ON
    samplerCUBE _DiffCubeIBL;
    #endif

    and replace it with:

    #if defined(USE_GLOBAL_DIFFIBL_SETTINGS) defined(GLDIFFCUBE_ON)
    samplerCUBE _DiffCubeIBL;
    #endif

    that will also get you rid of the warnings.

    having another very close look at the terrain let me do mopst changes in version 0.061.
    so this should have been fixed by the latest update.
    nevertheless faked fresnel in deferred might overbrighten your terrain. so use the fresnel strngth slider in the material inspector for the tertain material.

    lars
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    yes, a free alternative would be nice…

    lars
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,527
    This is really great. Thanks lars. Have not used physical based shading before. Any difference in performance?

    Also can I use these shaders in my asset store packs?

    Another thing. Are you going to set up your Advanced Foliage Shaders to be physically based?
     
    Last edited: Feb 25, 2014
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    performance
    lux is more expensive than the built in shaders and lighting functions of course: more calculations that have to be done, more textures involved...
    but if you need numbers – well, i do not really have them. so just from a quick test:
    rendering 1440 spheres using the built in bumped specular shader takes around 14ms (renderer only).
    rendering 1440 spheres using lux’s bumped specular shader takes around 18ms (renderer only).
    both tested in forward.
    those numbers do not really tell much – because they are taken from a quite generic scene.
    i real life it might look completely different. and lux might even make the race: as you can control roughness and specular color per texel lux lets you combine a lot of different materials which will probably safe you a lot of draw calls. whereas unity’s shininess and spec color parameter and gloss texture won’t let you combine e.g. polished metals (high shininess, colored spec color) and dry wood (low shininess, dark gray spec color). All you could change would be the gloss value.

    adding lux to your packages
    this is the main idea behind lux as an open source framework. so: yes, go for it.
    nevertheless this leads to the question of how to do this best. and i have no answer to this yet.
    including the whole lux package will blow up your own package (as lux already takes 120 mb). so i would definitely only pick the core and the shaders you need plus your own (lux based) shades. and i would make sure that the lux folder is not inside your package.

    advanced foliage shader
    i am not sure right now which parts will be included but you could expect at least image base ambient lighting.

    lars
     
  15. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @eskovas: try ignoring the shader errors, they happened to me, yet the shaders work in play mode, so it's because the shaders aren't setup by lux yet. so give that a shot, i recommend it!
     
  16. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    It's just like the other errors that i posted before.
    I'll copy some of the errors:
    Shader error in 'Hidden/TerrainEngine/Details/BillboardWavingDoublePass': D3D shader assembly failed with: (12): error X5204: Read of uninitialized components(*) in r0: *r/x/0 *g/y/1 *b/z/2 a/w/3
    Shader error in 'Hidden/TerrainEngine/Details/BillboardWavingDoublePass': D3D shader assembly failed with: (11): error X5204: Read of uninitialized components(*) in r1: *r/x/0 *g/y/1 *b/z/2 a/w/3
    Shader error in 'Hidden/TerrainEngine/Details/BillboardWavingDoublePass': D3D shader assembly failed with: (22): error X5204: Read of uninitialized components(*) in r2: *r/x/0 *g/y/1 *b/z/2 a/w/3

    etc.

    I'll try that



    There is also more information to each error , but i don't really want to post it here since it would make this a really loooong post.
    If you want, i can send images through private message.

    EDIT:
    Is it also supposed to take such a long time to import the shaders? it takes 20-30 minutes to import the shaders.
     
    Last edited: Feb 26, 2014
  17. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,527
    Thanks for the response. This pack will help a lot of developers.

    I am having a problem importing. At a certain point CgBatch.exe starts up and the import permanently pauses. I have had this problem with other packs too. Even importing my own. Something with my computer. I try killing the .exe but it comes right back. Not sure what to do.

    Edit: Got it working. Had to kill Unity.exe and then re-run unity. It then imported everything correctly.:D
     
    Last edited: Feb 26, 2014
  18. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    Here's just one more quick feedback.
    I created a new project and only imported lux to it. after i imported it, the console has 408 errors and 1 warning.

    The errors are the same as before and the warning is this:
    Assets/Lux/Lux Scripts/Editor/LuxMaterialInspector.cs(56,25): warning CS0618: `UnityEditor.MaterialEditor.TextureProperty(string, string, UnityEditor.ShaderUtil.ShaderPropertyTexDim)' is obsolete: `Use TextureProperty with MaterialProperty instead.'

    So, unless my Unity program is somewhat damaged, then these errors are not because of my project folder. Hope this helps.

    EDIT: I'm using Unity 4.3.3
     
  19. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @eskovas: the length of time it took for my laptop to import a Lux shader only took 2 minutes, perhaps computer specs would help here? and like i said in the previous post, ignore the shader errors: i did, and the terrain rendered fine. you could try updating your unity too, since Unity is now up to 4.3.5 or something. (they are damn fast!!!)

    @baldinoboy: Hi! good to hear you discovered this too! I actually got my water shader ported to this package, and it looks great, now that it has a fresnel!
     
    Last edited: Feb 26, 2014
  20. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,527
    @FuzzyQuils: Are you already updating on the water package? Will look great with this.

    Hey lars. Got the pack running and it looks great. Having this thing with the fog and the terrain. Do not know if this was already reported. Squares of the terrain receive fog at the same time. So there is no fog and then a square of fog pops up.

    $Terrain_Fog_error.jpg

    Also the tree leaf shader has a lot of does not contain property ' ' errors.

    This works great considering the release version. Looking forward to updates.

    Thanks again lars
     
    Last edited: Feb 26, 2014
  21. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    @lars and @Lazygunn : it looks like i was misread who's post that i read and who did i ask about convolution, sorry for the confusion guys :p

    Damn another release...you are crazy lars.... do i need to clean import or i can just update the package??
     
    Last edited: Feb 26, 2014
  22. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Hi Lars,
    Sorry if maybe i missed something but how come the Specular Value is different between forward and deferred??
    $Lux_Spec.jpg

    Oh btw, i found bug....
    Deferred DX11
    $LuxBug.JPG
     
    Last edited: Feb 26, 2014
  23. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Baldinoboy: Yep, the water is updated with the new shader. not uploaded yet as i am planning to start a new thread dedicated to this water shader. (because, unfortunately, the terrain thread appears to be dead... no one seems to notice it anymore!)

    @Larsbertram1: ANOTHER ONE!? i only just downloaded your previous version! Ah well, won't need it just yet, until you put out some rather large feature that would need to be downloaded...

    @rea: I know right? Some people seem faster at coding than i have ever known. makes me think of the Unity Team sometimes... ;) BTW, that specular bug is weird...
     
    Last edited: Feb 26, 2014
  24. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Hmmm the specular diferrence is kinda bummer, i like how it looks in forward. But i prefer using deferred....Oh it's cook torrance btw, but in deferred looks like standard BP.
    @Lars, don't worry i believe it's not your fault about GGX in deferred...:D
     
  25. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    Well, i have a pc with an I5 3570K @ 3.4GHz, GTX 650, 8GB ddr3 @ 1333MHz, so i don't think the problem is with the computer. Maybe there is really something wrong with my Unity folder... I also created a new project and imported Lux there and it took almost 30 minutes to import everything.
    I'm currently using Unity 4.3.3.
    I don't need 4.3.4 since it's only for Maverick users.
     
  26. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,527
    I have an okay computer and it took an hour to import this pack. I am having a lot of problems with unity. Am going to re-install windows. Maybe that will fix this problem. Even if it does not a clean computer is always nice to have.
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    you can ignore the warning. it is from the custom material editor but it works.
    i will have to have a look at this later on.

    but the errors… weel, it would be good if you could send me a screenshoot.

    lars
     
  28. larsbertram1

    larsbertram1

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

    from what i can see on your screenshoot:
    - fog works with the terrain far shader but not the terrain first pass shader.
    i have seen this on my virtual machine (only in forward, deferred works for both lighting paths) but thought it is just my virtual windows machine.
    so i will have a look into this.
    - the tree creator bark rendertex shader does not seem to work as the bark on the billboards is pink. does it work for you on close ups?
    please try to just reimport the "LuxTreeCreatorBarkRendertex" shader and see if it throws any errors.

    lars
     
  29. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    I took 14 images of some errors (they all looked different). There are many more different ones but it would be way too many images.
    Hope this helps.

    Do you have any idea related to the import time?
     

    Attached Files:

  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    there is always a little difference between forward and deferred (due to the faked fresnel for instance) but there should not be that much of course.
    which version of lux do you use?
    is dx 11?
    and which lighting model? looks like cook torrance…


    hmm, that might be the same as in the old blinnphong lighting function – in case it is cook torrance.
    please tell me it is cook torrance and if you switch to blinnphong everything looks ok! ;-)

    lars
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    thanks for the images. i will have a look at them.

    as far as the import time is concerned: it is the same i get: 20 – 30 min...
    it is just due to the fact that each shader has to be multi compiled and multi compiled and multi compiled…

    may be i will just include the base shaders and pack all other shaders into additional packages?
    or i might deactivate most multi compile options and you will have to enable them on those shaders on which you will need them?

    lars
     
    Last edited: Feb 26, 2014
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    @eskovas:
    please edit the "WavingGrass" shader.

    find:
    #define NORMAL_IS_WORLDNORMAL

    and replace it with:
    // #define NORMAL_IS_WORLDNORMAL

    then find:
    // float3 worldNormal;
    // INTERNAL_DATA

    and uncomment those lines by deleting "//"

    recompile just this shader and look if it throws any errors.

    thanks, lars
     
  33. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    Just did that and no errors appear on that shader anymore. I recompiled everything just to make sure.
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    thanks for testing.
    you can do the same for all other detail shaders.
    so it seems that we can not use the "speed up rendering function" on (at least some) windows installations.

    i will update the package.

    lars
     
  35. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    I can confirm that changing those lines of codes removes all the errors.
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    hi eskovas,

    thank you.
    it is pretty much ridiculous but if it solves the problem... we will go for it.

    lars
     
  37. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,373
    no problem.

    Just found more problems after i changed the shaders...

    If i have those shaders in the project folder and don't use terrain shaders, then the console throws these messages per terrain detail patch: ( 999+ messages)
    Shader wants tangents, but the mesh doesn't have them

    It throws those messages in editor and while playing.
    If i use the terrain shaders, then there are no errors. Same if i delete the terrain shader folder.

    But this doesn't happen in the Lux terrain demo scene.
    I also don't have that problem with the grass anymore.

    EDIT:
    If i use the terrain shaders and also use the Diffuse Cubemap IBL on the terrain script, it also gives that message
     
    Last edited: Feb 26, 2014
  38. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    OOPS! I thought you were talking about the compile speed of a single Lux shader, which on my computer did take 2 minutes. No, my Lux took longer than that, but it still only took about 20 minutes, i think. Lux is bigger than other asset packages, and Unity probably isn't used to things being 112MD instead of 500KB. And by the way, that computer's more powerful than mine, (Mine only has Intel HD 3000 being a school laptop :p) and has no excuse to be slow for you!

    And don't blame your project folder: the Lux framework is just amazingly large for a unity package file!
     
    Last edited: Feb 27, 2014
  39. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Just bodging in, hopefully not unwelcomely, i suppose i better explain that lux is.. not a particularly large package, certainly dwarved by the content packs on the store, however i can imagine the shaders take a long time to compile, when you add them to your project, hence the lengthy installs. I'm not sure how much mileage you'll get out of a computer of your specifications, fuzzyquills, but shaders such as these can take a very long time to compile on any kind of computer, it's not a reflection of the size of the package in the sense im assuming you mean
     
  40. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,527
    Now the bark shader works but the leaf shader does not. I did not even re-import. After a few plays the shader error switched. I will now re-import.
     
  41. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @lazygunn: ok then, provide an example of something bigger than this. (most of my assets have HEAPS of features, and only take up a max of 2MB!) I do agree with the shader compilation time though, one of my shaders takes about 3 minutes to compile, and it isn't a Lux Shader!

    @Larsbertram1: Did you fix the burnt grass? Because it looks like you fixed the burnt grass!
     
  42. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    That isn't really relevant conversation for the thread, and i'm vaguely sure you're not being very serious, in which case i'd hope you could keep it to the gossip forum.

    I should add i didn't hear much back regarding making a tool to convolve images - while i'd boiled it down to 'its blurring something' i hope i didnt give the impression that the limits of educating myself ended there, and i'd quite like to investigate the issue if simply for education if I didnt figure out an end result. I suppose I just wanted pointers to start my journey into google
     
    Last edited: Feb 27, 2014
  43. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    It's the latest version, Cook Torrance, and actually it's also happen with BlinnPhong the difference between forward and deferred is really big
    Dx11

    This one also happened with blinn phong in DX11 deferred

    Edit : @Lars can i request something?? can you add support for dualforward???
     
    Last edited: Feb 27, 2014
  44. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @lazygunn: sorry about that, i just haven't seen packages bigger than 100MB!
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    hi rea,
    thanks for the info.
    just my first thought: may be dx11 doesn't like the compression of the specular value.

    you could test this by editing the "Lux Internal-PrePassLighting" shader.

    find:
    res.w = log2(spec + 1);
    change it to:
    res.w = spec;

    next edit the "LuxLightingDirect" cginc.

    find:
    fixed spec = exp2(light.a) - 1;

    and change it to:
    fixed spec = light.a;

    finally just recompile one of the shaders to see if it works e.g. "Lux Bumped Specular".

    dualforward did not work for me.
    that is the reason i have skipped it. but it might just be a problem with my gpu.

    you can try this by adding "dualforward" to the initial pragma directive:
    #pragma surface surf LuxDirect noambient


    i guess i will have to get a pc sooner or later...


    lars
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    hi rea,

    i just did a quick test with the specular bumped shader and adding "dualforward" simply works!
    i don’t know what went wrong last time i tested this but it seems to be ok for the current version.

    nevertheless i do not think that i will enable it by default as it would just make the shaders even bigger…
    i guess i will add some notes to the documentation instead.

    lars
     
  47. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    When you adding dualforward, is it after you change the internal pre pass or before.
    because it throw me an error when i adding it.

    mean while....
    Lux is awesome :D


    Oh it's on forward dx9
     
    Last edited: Feb 28, 2014
  48. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,913
    hi rea,

    thanks for the images. they look very nice!
    there should be more of those – not only images showing bugs…

    adding dualforward to the e.g. specular bump shader and editing the internal prepass shader should absolutely not interfere as it justs effects 2 completely independent shaders.
    so how does the error look like?

    lars
     
  49. Ulven2

    Ulven2

    Joined:
    Apr 23, 2012
    Posts:
    64
    Some lux in action on a spaceship from The Mandate here:

    https://www.kickstarter.com/projects/1964463742/the-mandate/posts

    What I commented on previously (page 5) about the fresnel is that basically I don't think the fresnel should be reducing quite this much depending on the roughness of the material, and not really go to near 0. This is a visual observation more than a mathematical one, if I find a more appropriate formula, I will post it.
     
  50. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Hi Guys,
    just in case if any of you getting any visual bug after updating lux, try doing clean import/Update of lux by removing "Lux Script" and "Lux Shader" and reimport lux package again.
    it clean almost all visual bug for me "Except" the terrain First Pass Fog Bug in Forward, and Waving grass error in the console

    New screen after doing clean import, everything is work in Dx9 or Dx11.




    As you can see there only a small difference between deferred and forward mostly in Fresnel...
     
Thread Status:
Not open for further replies.