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

Lux has been updated for Unity 5 — so please start form page 23 in case you are using untiy 5.

If you are looking for a Hotfix for Unity 5.6. please go to page 28.

Hi there,

welcome to Lux – an open source physically based shader framework.

Why physically based Shading?
First of all physically based shading will give you much more convincing results than traditional lambert or blinnphong shading: No more fights with washed out specular highlights or boring dark areas as everything is shiny.
Second: psb will help you to get much more constant and predictable results under varying lighting conditions: Author once, use everywhere!

Lux and Unity 5
Unity 5 is right around the corner bringing built in psb shaders. So why should you use Lux?
Hardly anybody really knows about the capabilities of the upcoming built in shaders and hardly anybody knows when they will be available.
So Lux just enables you to get familiar with pbs today and author your materials properly as both use the same approach which is a specular reflectivity workflow. For this reason switching to Unity 5’s native shaders should just be a simple step. And who knows: May be Lux even competes with the new shaders…

Why open source?
There are already some commercial solutions out there available at the asset store, but none of those is free, some even break other shaders. So it might be rather difficult for the community to develop and improve unity’s rendering capabilities. But that is the whole idea behind this framework.

Test the webplayer
https://googledrive.com/host/0B7wuYyJnwF9ddHY5Ul9pbk9RZmM/lux01_standarddemo.html

Read the old development thread
http://forum.unity3d.com/threads/221985-Lux-%96-an-open-source-physically-based-shading-framework

Download Lux form the asset store
https://www.assetstore.unity3d.com/#/content/16000

Get the latest updates directly from the GitHub Repo
https://github.com/larsbertram69/Lux

Framework Features
· Normalized BlinnPhong or CookTorrance lighting
· Schlick-Smith or GGX Visibility Term
· Fresnel
· Image based ambient diffuse and specular lighting
· Box projected environment probes
· Forward and deferred lighting
· Gamma and linear color space
· HDR and LDR rendering
· Lightmaps and Lightprobes
· DX9, DX11 and OpenGL
· Specular reflectivity or metalness workflow

Included Base Shaders
Although it it pretty easy to write your own Lux shaders the package ships with a wide range of basic shaders to just let you get started:
· Bumped Diffuse
· Bumped Specular
· Box Projected Bumped Specular
· Detail Bumped Specular
· Alpha Test Bumped Specular
· Transparent Bumped Specular
· Self Illum Alpha Test Bumped Specular
· Parallax Bumped Specular
· Vertex Blended Bumped Specular
· Vertex Blended Parallax Bumped Specular
· Bumped Specular Translucent
· Dedicated skin, eye and hair shaders
· Physically based wetness including water accumulation and water flow

Advanced Terrain Shaders
Supporting a global color map, global normal map, a detail normal map and advanced blending between the different passes.
· Terrain first pass
· Terrain add pass
· Far Terrain
· Waving Grass
· Waving Grass Billboard
· Vertex Lit

Advanced Tree Shaders
Fixing most problems you might run into using linear lighting.
· Tree Creator Leaves (optimized)
· Tree Creator Bark (optimized)
· Tree Billboard

Editor Features
Lux lets you capture and convolve ambient probes based on ATI’s Cubemapgen directly within Unity.
· Capture Probes (Unity Indie & Pro)
· Convolve diffuse cube maps
· Convolve mipchained specular cube maps
Lux also supports cubemaps created with Skyshop or Jove.

Lars

1 Like

Some images showing the feature.

Awesome! Congrats on your release and getting it onto the store. So I had 2 more questions.

  1. Do I require a vertex painting plugin from the asset store to use the Lux vertex blend shader.
  2. Mind giving a breakdown of how you achieved that delicious looking water/wet look in your last screenshot? :smile:

Tyler

  1. you can use any (even free) vertex painter from the asset store or your 3d app like maya, modo or blender.
  2. i took one texture from the stones (diffuse, specular color, roughness, normal) “painted” a heightmap and assigned it as 2nd texture to the vertex blend parallax shader. the 1st texture is just a darkened version of the diffuse map and a very smooth (more or less white) roughness texture. no normal map needed as the wet surface it more or less flat. blending is controlled by vertex colors.
    everything else is done by lux.
    it is a bit heavy for a wet shader – but i did not have the time to write a special shader.
    but all you would need is diffuse map, spec map, roughness map, blend map or vertex colors, color which determines how much the wet parts get darkened, a height map and 2 normal maps: one for the dry parts and one for the wet parts. the last one even could be animated: think of raindrops!

i might have a deeper look into this later.

lars

Here’s a quick Kitbashing of Stealth Scene And Lux Latest version :slight_smile:

and Yes…the floor is shiny…it’s on purpose :stuck_out_tongue:

hi rea,

thanks for posting the image – although i liked your the one you sent me better...
so i am just pasting it here (i hope you do not mind).

lars

Lux Box Projected Shader (floor)

Lol…no problem :stuck_out_tongue:
it’s just i did some light rebake that’s why it’s bit different :smile:

Well done rea! another epic Lux contribution! I will hopefully have an image too sooner or later to showcase...

For those who have more knowledge than me: does anyone know of any plugins to generate specular maps in Photoshop or GIMP?

hi there,

just a preview on lux box projected capabilities: not as accurate as i would like it them be but that will probably change in future releases.
and as soon as you add some normal maps to the reflecting surfaces it looks quite convincing i think.

I have not found one. I use insanebump plugin for gimp. It makes specular maps but all it does is make a grey scale and raise the contrast.

lars that screenshot is amazing.

thanks,

and as far as specular maps are concerned: you won’t find a plugin for that.
but first of all you have to get the wording clear:
specular means specular reflectivity – not gloss or roughness nor smoothness.
and specular reflectivity depends on the material you have. it is just a single color value for a given material like wood or copper.
there are look up tables available for those.
so you probably mean gloss or roughness.
you could use e.g. crazy bump for this although i highly recommend to author or finish your roughness maps manually.
or use advanced terxturing tools like ddo.

find out more about a pbs texturing workfow here:
http://www.marmoset.co/toolbag/learn/pbr-practice

lars

Wow, you really did fix the billboard trees with HDR linear lighting! I can actually make outdoor HDR scenes now! I'm doing a happy dance in my chair right now. I don't do my happy dance for just anyone, lars. You should feel honored. ;)

thanks, i am glad that trees and billboards now work for you.

lars

Awesome work and thanks for the reply on creating the wet puddles. I’ll definitely be using that on the ship my friend has shown you :slight_smile:

I do have one question that comes to mind. That being environments with time of day or dynamic weather. How is it possible to use this properly with IBL? Would there have to be some sort of system which blends/automatically changes the cube maps by detecting the current type of weather active?

One example is that I have created a cubemap of a sunny clear sky and I’d like it to change to storm once the dynamic weather system changes to it. If I recall realtime cubemaps are very expensive to render.

Cheers!

Yes there is DDO pluguin for Photoshop, the old version is free, but it does a great job when it comes to spec/gloss maps creation.

you can get it for free her : http://quixel.se/dDo/dDo_release.exe

or spend 200$ for the Quixel suite if you want.

https://www.youtube.com/watch?v=QkLFWFskgxE

I made this image with reflectance values from DDO, for a friend who use GIMP, you can use it to author your textures :
https://www.dropbox.com/s/os4ukv0deaxiz4l/full%20doccument.jpg

Thank you Larsbertram1 , Cant wait to try this.

hi there,

for those you would like to be up to date i have just created a repo:
https://github.com/larsbertram69/Lux

it already contans the box projection shader and the lux cubemapper scripts (next to an updated version of the core)

lars

Is it normal that compiling each single shader takes ages? o.O

Yep…

yes due to the fact that each shader has to be compiled multiple times:

  • blinnphong / cooktorrance
  • linear lighting / gamma
  • using spec cube / not using spec cube
  • using diff cube / not using diff cube
  • ao / no ao

you find those instructions here:

#pragma multi_compile LUX_LIGHTING_BP LUX_LIGHTING_CT
#pragma multi_compile LUX_LINEAR LUX_GAMMA
#pragma multi_compile DIFFCUBE_ON DIFFCUBE_OFF
#pragma multi_compile SPECCUBE_ON SPECCUBE_OFF
#pragma multi_compile LUX_AO_OFF LUX_AO_ON

when using the git you have direct access to the code before import.
so if you now what you want or need you can just comment those lines and replace them by e.g.:

#define LUX_LIGHTING_BP // use blinnphong direct lighting
#define LUX_LINEAR // compile for linear lighting
#define DIFFCUBE_ON // use diffuse ambient image based lighting
#define SPECCUBE_ON // use specular ambient image based lighting
#define LUX_AO_OFF // do not add an extra ambient occlusion texture

that will speed up compiling time dramatically!

lars