PDA

View Full Version : Energy Conservation Node



khan973
08-23-2012, 08:59 PM
Hi everyone, I've had this idea for a while but Andrew Comb's tutorial http://www.3dworldmag.com/2012/08/23/build-surfaces-in-lightwave/
Made we want to think about it again.

I wanted to make an Energy conserving node. The 3rd party dev I contacted didn't seem interested.
I think such a Node could rise the quality for us to get close to realistic materials.
The different ways to do it always lead to complex setups.

Quick Explanation
When bouncing off an object, Light can be at maximum 100% of the amount of energy that came from the light source.
When we use reflective material, let's say 30%, if our diffuse is 100%, the total amount of light will be 130% which is impossible. None of that happens in real life.
We almost never think about it but it affects realism as our brain trained to see it everyday cannot be fooled.
Also Transparency has to be taken in account.

How
So that node would consist (at minimum) in having inputs:
Diffuse, Reflection, Transparency (diffuse shading, reflection shading)
and the same outputs.

There should also be in the options an influence value. Let's say its 33% for each parameter.
It means each parameter is taken in account equally. So when you rise Reflection let's say at 100%, it will reduce its value so diffuse and transparency and reflection are equal (we can end up with diffuse 50%, reflection 50% if material is % transparent)

If reflection influence is 100%, its value will be prioritized so if I put 100% value, it will lover Diffuse to 0%

This should work with inputs like scalar values but also gradients, curves, images, fresnel and so on.
I wish I had the skills to make that but until then, any person interested in making that (D&B? TrueArts? DP? anyone?) this would be a nice addition to Nodes and surfaces realism.

Well, ideally, it should be a native LW NODE :lwicon:

Sensei
08-23-2012, 11:56 PM
Normal LW is always doing math:

Diffuse_Shading * ( 1.0 - Transparency ) +
Refraction_Shading * Transparency +
Reflection_Shading * Reflection +
Specular_Shading

Where Diffuse_Shading is sum of Diffuse, Translucency and Luminosity. They're multiplied by Raw Color.

Diffuse and Translucency never interfere each other, because Diffuse is negative part of Dot product between surface normal vector and light sample direction vector, and Translucency is positive part of above Dot product.

You should rethink your node concept - if Transparency is 100% (1.0) there is nothing taken from Diffuse Shading (Diffuse_Shading * ( 1.0 - Transparency ) = 0). Using 33% for each of Diffuse, Reflection and Transparency will have completely different result than you think.

ps. I still didn't receive your SystemInfo..

biliousfrog
08-24-2012, 12:53 AM
I thought that the material nodes were energy conserving?

grabiller
08-24-2012, 01:12 AM
Hello,

Currently I'm tackling this exact same problem, trying to setup a base "photo convincing" ( I prefer this expresssion rather than "photo realistic" :-] ) material library for our productions.


../..Well, ideally, it should be a native LW NODE :lwicon:

So far I've found that the 'Conductor', 'Dielectric', 'Delta' and 'CarPaint' Material Nodes are exactly suited for this purpose.

For instance, quoting the 'Delta' docs: "Delta is an energy conservating material. What this means is that it has realistic properties like when specularity is 100% the diffuse in turn will go down to 0%."

http://www.radfac.net/download/lw/test_copper.jpg
copper test - render time: 39s

http://www.radfac.net/download/lw/test_glass.jpg
glass test - render time: 1m52s

http://www.radfac.net/download/lw/test_ceramic.jpg
ceramic test - render time: 1m28s

I think with those nodes alone you can obtain pretty convincing surfaces.

ps: I'm in France near Paris, if you need custom Lightwave development (plugins, tools, etc..) feel free to contact me.

Cheers,
Guy.

RebelHill
08-24-2012, 02:19 AM
Yeppers... Material nodes are already energy conserving, so what you're asking for already exists. Not only do they produce the whole thing for spec/diffuse overlap, but those with specular components also contain physically correct fresnel functions and so on.

khan973
08-24-2012, 02:39 AM
@Sensei, yes, sorry, I'll send you, I was kind of busy, thanks for reminding.

From what I know, in real life, when a material is transparent, a part of the energy passes through the surface and a part rebounds.
On Kray's manual they say this:

The general balance rule that should be followed to avoid unrealistic materials is :
Color*Diffuse+Reflection+Translucency<100%
or a more complex version including transparency would be:
Color*Diffuse(100%-Transparency)+Transparency+Reflection+Translucency < 100%

@Grabiller
Indeed some of the materials react properly but we don't have an option for now to do so with any surface we make.

At Siggraph, I think it was ILM who showed that they were using an algorithm that was calculating automatically the values.

@RebelHill: yes but If I want to make a custom material and don't want to stick ith the few we have?
How would you make leather with Material nodes for example?

grabiller
08-24-2012, 02:39 AM
../.. those with specular components also contain physically correct fresnel functions and so on.

I think this is not entierly true for the Conductor node, wich does not offer a refractive index nor an extinction coefficient inputs.

Those two optical constants for metalloids can produce strong differences in specularity (reflection) depending on the used metal.

To be accurate with metalloids, one has to provide a custom specular curve ( fresnel node alone is not enough, no extinction coefficient ).

Cheers,
Guy.

khan973
08-24-2012, 02:43 AM
Are you suggesting Make Material and Standard material do the Math automatically? I really don't think so

khan973
08-24-2012, 02:45 AM
To be accurate with metalloids, one has to provide a custom specular curve ( fresnel node alone is not enough, no extinction coefficient ).

Try Fresnel from DPKit

Sensei
08-24-2012, 02:48 AM
Are you suggesting Make Material and Standard material do the Math automatically? I really don't think so

Of course they don't do any math, especially Make Material.

Material is structure which has Diffuse Shading color, Specular Shading color, Reflection shading color, Refraction Shading color and Transparency scalar. In total 104 bytes of data.

Make Material, TrueArt's Split Material are just setting up/reading structure fields.

And that it should be.

Don't change that!

grabiller
08-24-2012, 02:49 AM
../.. If I want to make a custom material and don't want to stick ith the few we have?
How would you make leather with Material nodes for example?

I think what you want is to create cutom surfaces, not custom materials, because if you want to be photo-realistic/-convincing you need to use actual materials (or cheat with multi-passes and compositing but this is another story).

Then it's a question on how you surface your material (the color, bump/normals, diffuse, specularity/reflection, etc.. and especialy how blurred are the specularity/reflection).

While I did not tackled yet leather specificaly with Lightwave, I'm pretty convinced you can do it with the Delta node or the CarPaint node (depending on the coating - ciré ou non).

Cheers,
Guy.

grabiller
08-24-2012, 02:53 AM
Try Fresnel from DPKit

I've choosed a different path, I've created a custom tool wich creates Curve Node presets with the reflectance curve computed from the IOR and Extinction Coefficient.

This way, at render time, no computation is done, just a curve lookup, wich is far faster.

Cheers,
Guy.

Sensei
08-24-2012, 03:07 AM
Those two optical constants for metalloids can produce strong differences in specularity (reflection) depending on the used metal.


What is reflection blur? Little thin bumps on surface causes light to travel in different directions in very little distance between bumps. Human eye don't see them, they are so little, and blends everything in our brains.
So, to have reflection blur/refraction blur/specularity glossiness you just have to plug procedural texture that will make those bumps..

Like I showed in
TrueArt LightWave Tutorial How To Control Reflection FullHD video 2 for professionals
http://forums.newtek.com/showthread.php?t=129613

Everything else is just cheating real world.

khan973
08-24-2012, 03:16 AM
Of course they don't do any math, especially Make Material. [...]
Make Material, TrueArt's Split Material are just setting up/reading structure fields.
And that it should be.
Don't change that!

Of course it should remain like that, that's why an energy conserving node would be welcome.

You just plug into it your stuff like you would do with regular Surface Node and from there you plug it to the Surface. Done!
All the calculation should follow accordingly for the other channels.

RebelHill
08-24-2012, 04:10 AM
Khan... if you're after a custom material, then you make it using the material nodes...

Any metallic/conductive surface type, use the conductor node, it provides a great model for all such surfaces. If you're after transparent dielectrics, water, glass, lighter fluid, use dielectric. If its non transparent dielectrics u want, wood, plastic, leather... use delta, though u can also use this with transparency to create other transparent dielectrics.

Feed each the appropriate colour inputs, set their ior (for diel and delta) and a specularity level to taste... all the energy conservation at each point on the surface will be (near as dammit) correct physically.

Ofc, u the get into carpaint, which models for things like the paint and the lacquer parts and how they play into the whole thing, etc, etc... other surface specific nodes, and so on.

Also no... the make mat/standard mat are constructs for feeding other networks to mat inputs, they wont work out the EC for whatever you give them... just the premade mat models.


I think this is not entierly true for the Conductor node, wich does not offer a refractive index nor an extinction coefficient inputs.

Actually conductor does have more or less proper fresnel... the ior comes from the diffuse colour, as colour is a representation of absorbtion at different wavelengths, giving a good approximation of the effect of this action for CG.

Most especially in case of conductor it also comes down to having the tool operate in a way that's compatible with what one aims to do with the node... namely simulate materials in the real world. And to that end metals aint so straight forward and precision values don't always mean as much. For instance brass... the raw metal (lets say perfect smooth as it can be) in its natural state has one ior... but made into a doorplate with some polish rubbed on, its different... mainly due to the thin layers of polish left behind. If that doorplate has been exposed to the elements, become scratched, dirty, etc... then its different again. So conductor makes a good base model that respects fresnel as a consequence of absorption in place of transparent refraction, but implements it along side user controllable inputs to let u give it the nudge it needs in whichever direction.

Ofc... for the rare occasion when you do explicitly need a perfectly real world accurate response... you just use a regular surface, look up the reflection graph, and enter it via a gradient curve node. And even then... we're fundamentally screwed in CG for TRUE real world materials, as the effects change depending on the polarisation of light, and CG renderers do not simulate this. Light from the atmosphere has a strong difference in levels of polarisation to that from a lightbulb indoors, resulting in a different appearance to a viewer... and as such the artist will often have to push things to one side or another, violating REAL values in order to achieve the correct look.

grabiller
08-24-2012, 04:21 AM
Those two optical constants for metalloids can produce strong differences in specularity (reflection) depending on the used metal.

What is reflection blur? Little thin bumps on surface causes light to travel in different directions in very little distance between bumps. Human eye don't see them, they are so little, and blends everything in our brains.
So, to have reflection blur/refraction blur/specularity glossiness you just have to plug procedural texture that will make those bumps..

I'm not sure to see the link with the quote you got from me.

That said, while I'm aware about what reflection/refraction blur are, bump maps/procedurals aren't always the best approach because in case of very fine irregularities on the surface, trying to match those with bumps may lead to artifacts and aliasing problems. Yet, often, even very little bump strength setting make the surface entierly blurry, wich is not always what we want.

Sometimes it is better to use as little as 1% or 2% reflection blur for instance, especialy when you want your reflection slowly becomes blurry.

Cheers,
Guy.

grabiller
08-24-2012, 05:09 AM
../. Actually conductor does have more or less proper fresnel... the ior comes from the diffuse colour, as colour is a representation of absorbtion at different wavelengths, giving a good approximation of the effect of this action for CG. ../..

Hmm.. I'm not entierly sure how one can 'guess' the IOR *and* the Extinction Coefficient just from the Material Color.

Some metalloids have like 0.6 IOR and some others have 1.62 IOR while their color is still quite white/light grey, so allow me to be a bit sceptical about this.

But that's interresting though, perhaps they used some heuristic in their code. I'll have to check that by making some tests to compare straight Conductor Node with 'raw' reflective material associated with reflectance curves computed from IOR/EC.

Cheers,
Guy.

Lightwolf
08-24-2012, 06:17 AM
All the calculation should follow accordingly for the other channels.
The problem is that you still need base values and various settings.
Since inputs can vary from the evaluated spot to the next, just massaging them to be "energy conserving" is not enough.

As for physically accurate shading... none of it really is anyhow. ;)
http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_slides_v2.pdf (which, amongst other things, also compares shading models with a real world material library).
More from the same course here: http://blog.selfshadow.com/publications/s2012-shading-course/

Cheers,
Mike

RebelHill
08-24-2012, 06:29 AM
Hmm.. I'm not entierly sure how one can 'guess' the IOR *and* the Extinction Coefficient just from the Material Color.

I think ull find its more about accuracy within the "laws of physics" of the renderer... so to speak.

Inside LW universe a diffuse reflection and colour value are pretty interchangable. This is why energy conservation, although a good principle for surfacing is violable... setting a medium grey material with a diffuse of 150% would give no different a result than one than an "accurate" 100% diff which simply had a lighter grey colour... and the result elsewhere in the render would be no different, the rays it bounced in radiosity would have the same values, etc, etc. Its why you see different packages with diff inputs, some you put the colour texture in the diffuse, etc, and why in years past we've seen plenty artists totally break energy conservation principles and yet still produce renders of highly realistic surfaces.

IOR in non transparent materials is sort of replaced by absorption... and given the way the renderer works, an easy way that lines up (conserves) against other values in LW to simulate/render absorption, is the colour value.

Again... its much like the polarisation example I mentioned before... there are certain complexities in real physics that are simulatable, or have any point in simulating... these fudges are what make it easier and possible to get the right look which matches what you would see in the real world where all these lil extras are happening.

khan973
08-25-2012, 09:17 AM
Sorry but Even though I agree for most part of what you say, Delta doesn't work for that.

Let's say you want a simple reflective red plastic.
In the Delta node, you put on your red color, then you play with specular it behaves (almost correctly).
But when changing the IOR, nothing changes at all! at least as long as the material isn't transparent.

Also reflection appears equal everywhere, no fresnel simulation.
So to me this node doesn't work for leather, plastic, and wood which is what i'm aiming.

Carpaint works wonderfully well when changing the IOR.

And one question, how do you control diffuse with this techniques? None of them have a diffuse input. Let's say I want my wood's creases to be darker, how do I do that ? with spec channel opacity?
Oh and color highlights doesn't work on them either!

RebelHill
08-25-2012, 09:43 AM
There's no diffuse input because they're energy conserving... as specualr increases at a given spot, diffuse must fall, hence, no reason to have both values... And again, colour and diffuse are interchangable, so if u were wanting a given specular but with a greater/lesser diffuse, for whatever reason... ud change the colour brighter/darker. if your wood creases, in your example are actually less diffuse reflective, then specular on them would have to incerase at those points... otherwise, its just a darker colour.

And you're right, Delta doesnt seem to provide a built in fresnel does it... my mistake. in which case though, you'd just want to feed the spec input from a fresnel node, or gradient, and the material, which is energy conserving, would take care of the diffuse, etc based on that input. Kind of like a basic surface node that also does energy conservation... but doesnt contain other physical functions.

Sensei
08-25-2012, 11:03 AM
But when changing the IOR, nothing changes at all! at least as long as the material isn't transparent.

IOR = Index Of Refraction.. No refraction (transparency), so no use for IOR.. Is it not logic?

grabiller
08-25-2012, 11:18 AM
IOR = Index Of Refraction.. No refraction (transparency), so no use for IOR.. Is it not logic?

Actualy every material has an IOR, be it transparent or not, liquids, gazes, metals, plastics, etc.. all have an Index Of Refraction.

The reflectance characteristics of materials depends on it. Not only transparency.

Cheers,
Guy.

Tobian
08-25-2012, 11:35 AM
Interesting thread :)

That Disney paper is quite interesting LightWolf, I hadn't seen that one yet, and yes I noticed that about Specular, it doesn't give a big enough 'tail', as I had noticed in real materials, which is both a problem for the 'specular' and the reflectance part of the model for any materials and shaders in LW.

There are 2 different issues here.

1) energy conservation

It's fairly simple to build energy conservation in Lightwave, and yes all the materials (except some of the older Skin nodes) are built to be energy conserving with specular's which more or less work right, without too much faff. ( I had to do a different Fresnel for the Spec as opposed to the reflectance in my tutorial) Thing is, though, there's no customizing them. You can't break out the parts of them which you want or need without nasty complex material splitters, and I wouldn't even want to begin trying to split apart the car paint shader, as it has several BSDF's within one shader. I really do wish Materials were just compounds.

The complex part with energy conserving is that the 'specular' part is almost entirely imaginary, so you more or less have to do it by eye, and that's the problem with the material shaders. If you want to do your own spec you are out of luck or see above. Also as a rule none of the Materials have anisotropy for some reason, so again, you have to roll your own there. In the examples I give I mix together 2 different types of materials and it has to be said I did entirely by eye, and they are not 'physically correct' just energy conserving so at least the physics is working right.

The major part missing from any of the shaders included in LW is the absorption tools, for either metaloids or transparent dielectrics, so you have to either use the pre-baked versions in materials, or do it by hand/eye which is NOT easy if you are not a super shader guru. I am certainly not! :) Metals are especially hard to get right with either the conductor or hand-built shaders as getting the balance of reflection to 'diffuse' component right is tricky. Doing a hand-made absorption model for your own dielectrics is REALLY tricky as designing your own gradient by eye (absorption is not linear) takes some heavy maths or endless tweaking, and I find the one in the dielectric shader a bit useless as the scale is just odd to get your head round (absorption is 2.. 2 what? 2 elephants, 2 metres, 2 armchairs worth? :D) Dielectric also can't do sss so semi-colloidal materials like most plastics, milk and orange juice so it's just a crap shoot of messing on to make anything like that.

The other major problem with LightWave is in some cases you do need multiple BSDF models (dust layers, a clear coat or just mixing up 2 materials) the problem is LightWave renders each bsdf and then composites them together, which can make such materials HELLA slow to compute in complex scenes. Hopefully Antti can get the BSDF integrator from Core into LightWave so that they are bundled together and calculated as one, with importance sampling. Half the hoops I went through on that tutorial were specifically to deal with the issues of 'material mixing' - I could have just used a single mask and done material mixer, but that would be slow to compute because there is no BSDF integration.

2) Shader models

Shader models are another issue from energy conservation. While most of the basic shader models in LW can get you most of the way there, there's that final gap for physical reality, and a couple of known bugs. Spec for example doesn't work correctly for inverse squared falloff lights.. the specular hit should get smaller NOT dimmer. Also none of the other shader models other than Lambert function as anything other than Lambert under radiosity ray sampling. Oren Nayer looks like Lamber unless you put lights in there...

It's a shame there haven't been any other good shaders from the third party, as the opportunity has been there but there aren't any others. (the Gaussian reflection shader by POMM was just a shader to correct for LW's broken reflectance model, and ditto DP's one) Reflection blur since 11 has been much better for physically accurate shading (since it properly smears samples at glancing angles) but it's just the same as if you put a random node into the normal (instead of the bad shader model used before) there should however be more models for other kinds of reflection blur, all we have is reflection blur and anisotropic reflection blur. There is a point in LightWave where you can't really push it any further because there are no tools to do that.

Pavlov
08-25-2012, 11:57 AM
what we need, and i've been asking for this for a while, is a full BSDF node.
By now we dont have a full IOR-driven, evergy preservationg node. IOR acts on transparency, while on BSDF model it controls the behavior of both transparency and fresnel for reflections. Even Mental ray basic shader is IOR driven, and you get natural looking materials without having to tweak gradients here and there. Look at maxwell material to get an idea. Once you get used to it, there's nothing better. In LW you can get IOR-based materials but you have to build a node structure... it would be nice to have it in a single node.

Paolo

Tobian
08-25-2012, 12:01 PM
There are of course other issues within Lightwave which are not flaws persay just things it doesn't yet support. Spectral rendering, polarisation and differing Fresnels (in LW there is simply a Fresnel value but it doesn't take into account polarisation for obvious reasons but also different materials have different Fresnel curves, typically metallic and dielectric have different response curves for the same IOR) Exposure, physical brightness of HDR specular (a 'sun' light gives a normalised brightness based on a model of 1, but the specular hit should be many orders of magnitude greater relativelly. Try taking a HDR capture of the sun on a Chrome surface, and go as high as your camera can, it's spec hit will be more than '1') Tone mapping (which solves most over-bright pixel AA issues) Lens simulations, such as Fraunhoffer Diffraction ('glow' is a bit crap :D) tied into the camera aperture and indeed any camera lens simulation over curvature of the lens.

hopefully some of these will come with time, but I appreciate that there is an element of 'tinkering' to LightWave and artistic friendliness, but the closer we get to physical reality with the minimum number of complex settings the better.

khan973
08-25-2012, 03:37 PM
CORE had an IOR based shader. it was working wonderfully.
Most people don't know as Guy said that IOR can define reflectivity for metal for example.

grabiller
08-27-2012, 04:09 AM
../.. Most people don't know as Guy said that IOR can define reflectivity for metal for example.

To be completetely accurate, the Refractive Index of a material is 'simply' what's define the effect this material has on light (granted you accept the fact this Refractive Index is actualy composed of the actual IOR and the Exctinction Coefficient).

To have a good idea of how this works, read this introduction paper from the 2010 SIGGRAPH Course "Physically-Based Shading Models in Film and Game Production": http://renderwonk.com/publications/s2010-shading-course/hoffman/s2010_physically_based_shading_hoffman_a_notes.pdf

The reading can stop when the maths begins, but at that point one should have a fairly accurate understanding of how matter/light work together and how to translate this into better ways of shading cgi materials.

Hope this helps.

Cheers,
Guy.

Pavlov
08-27-2012, 06:11 AM
nice read - you can also read here and next pages (in particular "Index of Refraction - ND and K")
http://support.nextlimit.com/display/maxwelldocs/The+BSDF
i dont know if access is members only tough.

As tobian says mixing BSDF in LW is tricky - it would be nice if we get a multilayer BSDF implementation in LW in one single node (please), exactly as Maxwell's.

Paolo