DGS exploited

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2005   #1
Lightbulb DGS exploited

Well. If you ever cared (at least a bit) about what some call 'physical correctness', this might be of interest for you. If you never cared, you simply might skip this confusing (and ridiculously long) post.

What is it about? Most time when we say 'physical correct' we mean, in case of mentalray, the usage of DGS (diffuse, glossy, specular) shaders. Some people say you should at least use them as photon shaders, just because they're fast and, yes, phyiscally plausible. But how do they act differently than the maya base shaders? If you ever used dgs shaders other than for photons, you probably asked yourself if it was possible to 'mimic' the dgs behavior somehow - just because they are yet simple, but sometimes very hard to bear with (just think of the glossy samples that cant be set - very annoying). What if we could tell a maya base shader to act like it's dgs companion? I went ape on this for days.

Let's have a look at how 'different' they actually look (without using photons - we're only out for the usual shading for now). I took a phong material without highlights/reflectivity (so actually it's a lambert) for comparison:

These are the settings:


The dgs (left) is obviously much darker - just a matter of settings you'd say. So let's tweak them a bit - let's increase the dgs' diffuse to total white:



Better, but still very dissatisfying - and the 'Color' attribute of our phong is still darker (0.5 value!) than the dgs'. How does this come? Having a look at the dgs shader sources which are freely availabe we see the reason for this
* m->diffuse is reflectance rho (0 <= rho <= 1). BRDF f_r = rho/pi.

This means, the radiance (rho), or 'color', is being divided by pi (approx. 3.1415etc...). Uhm.

[interlude]
What does radiance actually mean?
Originally Posted by Stephen H. Westin, [url: www.dotcsw.com/poy2001.txt][/url] Briefly, radiance is pretty much what a pixel expresses. Technically, that's energy flux per unit area ber unit solid angle. Irradiance is slightly different: it s the energy flux per unit area.

[/interlude]

How could we achieve, what the dgs is doing, with our maya shader? You guessed it, let's use the 'Diffuse' attribute, which acts as a multiplier for the 'Color' value. Since we cant literally divide, we need to multiply by the fraction: 1/pi (approx. 0.318). Let's do it:


Oops, what went wrong? Sure, we set our dgs' diffuse color to white, let's do so with our phong.

Set the phong 'Color' to total white:

Jackpot!

But whats about finalgathering? Let's see:

FG on, all settings same as in the last image:


Golly gosh! What happened? Lamrug.org gave me the answer:
Originally Posted by http://www.lamrug.org/resources/mayafgtips.html: When a shader gathers irradiance with mi_compute_irradiance, it should normally divide the result by π, since the irradiance is the energy gathered over the hemisphere above that point. Dividing by π makes it a color at the point.

So the irradiance is being divided by pi already. Our irradiance is now actually divided 2 times, because 'Diffuse' is multiplying our irradiance as well - not good. But we can overcome this by a simple trick: we just multiply the irradiance by pi again. By clicking on the 'Irradiance Color' (NOT 'Irradiance'!) the color picker pops up. We then replace the 1.000 in the 'Value' field by pi (3.1415):


Allright, let's have a look if it worked out:



Bingo!

Adjusted light intensities:

(Yes, the right one is the phong ;-)

This way we can safely use dgs shaders for the dirty photon job (they're still unbeatable speedy at this), and a maya base shader for the beauty:


The 'physical correctness' is approximately and satisfying convergent to a dgs.


But what about reflectivities? That's way easier, because the phong's 'Specular Color' acts the same as the dgs' 'Specular' - you only need to set the (tuned) base shader's 'Reflectivity' to 1.




And glossiness? Well, the glossy color is again the same as 'Specular Color' (with reflct. 1), the shininess is controlled by 'Reflection Blur' - where a 'Shiny' value of 5 equals (experimentally obtained) approx. a 'Reflection Blur' of 13.

That's it! I hope you enjoyed the little brain candy!

PS: I cant guaranty all of the stuff explained is correct - everything has been deduced by only theoretical thoughts and ideas by myself. And I am no expert at all at this.

PPS: Transparency is even another story. Maybe another time.
__________________

Astro Man
!!!!!!!

Six Tuts On Light And Shade

Last edited by floze : 04 April 2005 at 03:52 PM.
 
Old 04 April 2005   #2
very interesting information!
 
Old 04 April 2005   #3
Hehe, nice research project. Clears up my confusion as to why DGS reacts differently. Thanks.
 
Old 04 April 2005   #4
Really deep and useful, thanx a lot.

I always desired to learn more and more about MR shaders
__________________
*God is the King of procedural creation*
 
Old 04 April 2005   #5
Hi floze!

Thank you very much for the time and effort invested on this!

I just 'discovered' mental ray shaders less than a couple of weeks ago, and everytime I use'em I catch myself smilling for no (aparently) reason and now, I feel comfortable to do pretty much everything with the combination of DGS/Dielectric/mix8layer/misssfast and bumpcombiner... and the best thing is the render time


Well, I don't know if I'm doing anything wrong, but I only get nice multibounce results using mental ray materials so I gave up completely about maya materials... I've tried using regular maya material but with no go when dealing with multibounce...

Question: Does your 'tuned' maya shaders works better with multibounce than the regular ones?

cheers and thanks again!


regards from the south
__________________
Rodrigo Ribeiro
www.design-o-rama.com.br

 
Old 04 April 2005   #6
Smile DGS Shaders are better

I noticed the ‘DGS exploited’ post today because I've been curious about DGS shaders myself recently. Information on DGS shaders seems a little sparse at the moment - although CGTalk has posted a link to a good article in the Alias Maya > Maya Tutorials section titled “A full tutorial for DGS shaders”.

‘DGS exploited’ left me asking why dgs shaders would be used for any other purpose other than in combination with Global Illumination and Final Gather. This shader is just designed for these photo-realistic tools.

I have recently posted a tutorial to my own website explaining the benefits of using DGS materials with GI at the following address:
http://www.lemiere.com/html/tutorials/DGS/DGS.htm

There I explain that "As the DGS material is a physically accurate representation of a material, the Diffuse, Glossy and Specular attributes need to be set with accuracy in mind. For example, it is not possible to have a randomly rough, shiny object. Each Value of the HSV for Diffuse, Glossy and Specular can not exceed a combined value of 1. For example, a semi-glossy surface might have a Diffuse of 0.2, a Glossy value of 0.5, and a Specular value of 0.3 - giving the combined Value of 1.0. It is however possible to have a combined Value of less than one. As these attributes describe the reflection of light, smaller values simply mean that more light is being absorbed."

Looking closely at floze's post it can be seen that the DGS material has been set-up incorrectly. The Diffuse attribute has been set to a Value of 1.0 and Specular set to 0.5, giving a total Value of 1.5. Unfortunately the post makes no claims at trying to be physically correct. It seems to me that the basic philosophy of the DGS shader has been misunderstood.
 
Old 04 April 2005   #7
Originally Posted by digones: Question: Does your 'tuned' maya shaders works better with multibounce than the regular ones?

Probably yes! To break the whole stuff I described down to a simple term, it would be like:

Radiance (Color) = DiffuseAttribute*ColorAttribute

Irradiance = DiffuseAttribute*ColorAttribute*IrradianceColorAtt ribute

So in usual case the Irradiance is <1 because the Diffuse is (in most cases) <1 - often 0.8, the default value. With 0.8 Diffuse your irradiance also becomes 0.8 and the finalgather/multibounce solution will be quite dark - and the radiance (the actual color you see) will be disproportional bright. So there are two things that skew your multibounce.

You also could set the Diffuse to 1 and leave the IrradianceColor as is, but consider to lower the Radiance somehow (by multiplying it by 1/pi). You could, for example, also do this by lowering the ColorAttribute (or the associated fileTextures ColorGain) to 0.318. With perfect situation (ColorAttribute = total white) the solution of the above described term must look like:

Radiance = 1/pi = 0.318

Irradiance = 1

But why, you may ask? If you followed me, you know: The irradiance is, when being gathered, divided by pi, because:
Originally Posted by lamrug.org/resources/mayafgtips.html: When a shader gathers irradiance with mi_compute_irradiance, it should normally divide the result by π, since the irradiance is the energy gathered over the hemisphere above that point. Dividing by π makes it a color at the point.

So Radiance and Irradiance are (like with a DGS shader) in harmony. Quite logic, isnt it?
__________________

Astro Man
!!!!!!!

Six Tuts On Light And Shade

Last edited by floze : 04 April 2005 at 11:45 AM.
 
Old 04 April 2005   #8
Originally Posted by floze: Probably yes! To break the whole stuff I described down to a simple term, it would be like:

Radiance (Color) = DiffuseAttribute*ColorAttribute

Irradiance = DiffuseAttribute*ColorAttribute*IrradianceColorAtt ribute

So in usual case the Irradiance is <1 because the Diffuse is (in most cases) <1 - often 0.8, the default value. With 0.8 Diffuse your irradiance also becomes 0.8 and the finalgather/multibounce solution will be quite dark - and the radiance (the actual color you see) will be disproportional bright. So there are two things that skew your multibounce.

You also could set the Diffuse to 1 and leave the IrradianceColor as is, but consider to lower the Radiance somehow (by multiplying it by 1/pi). You could, for example, also do this by lowering the ColorAttribute (or the associated fileTextures ColorGain) to 0.318. With perfect situation (ColorAttribute = total white) the solution of the above described term must look like:

Radiance = 1/pi = 0.318

Irradiance = 1

But why, you may ask? If you followed me, you know: The irradiance is, when being gathered, divided by pi, because:

So Radiance and Irradiance are (like with a DGS shader) in harmony. Quite logic, isnt it?



Perfect, floze!!



Another question, if I may (a little off topic):

What about the dielectric materials? Everytime I need glass, dielectric materials are the "only" solution for me inside maya.

By the time I was using lightwave, I used to duplicate the object then flipping it's faces (to invert the normals) to get the glass to act properly. Could it be plausibe to make the same thing with a 'tuned' blinn and/or phong, or is there any other workaround?


thanks again, floze... you're the man!
__________________
Rodrigo Ribeiro
www.design-o-rama.com.br

 
Old 04 April 2005   #9
interesting test
thanx for share this tips very usefull

ciau

mat
 
Old 04 April 2005   #10
Originally Posted by lemiere: I noticed the ‘DGS exploited’ post today because I've been curious about DGS shaders myself recently. Information on DGS shaders seems a little sparse at the moment - although CGTalk has posted a link to a good article in the Alias Maya > Maya Tutorials section titled “A full tutorial for DGS shaders”.

‘DGS exploited’ left me asking why dgs shaders would be used for any other purpose other than in combination with Global Illumination and Final Gather. This shader is just designed for these photo-realistic tools.

I have recently posted a tutorial to my own website explaining the benefits of using DGS materials with GI at the following address:
http://www.lemiere.com/html/tutorials/DGS/DGS.htm

There I explain that "As the DGS material is a physically accurate representation of a material, the Diffuse, Glossy and Specular attributes need to be set with accuracy in mind. For example, it is not possible to have a randomly rough, shiny object. Each Value of the HSV for Diffuse, Glossy and Specular can not exceed a combined value of 1. For example, a semi-glossy surface might have a Diffuse of 0.2, a Glossy value of 0.5, and a Specular value of 0.3 - giving the combined Value of 1.0. It is however possible to have a combined Value of less than one. As these attributes describe the reflection of light, smaller values simply mean that more light is being absorbed."

Looking closely at floze's post it can be seen that the DGS material has been set-up incorrectly. The Diffuse attribute has been set to a Value of 1.0 and Specular set to 0.5, giving a total Value of 1.5. Unfortunately the post makes no claims at trying to be physically correct. It seems to me that the basic philosophy of the DGS shader has been misunderstood.

Yes, you're completely right.
The reason I set these values is a) I was too lazy to change the diffuse and b) I didnt want to disturb the flow somehow..

But this leads me to this comment: The dgs actually is not quite physically correct. If it was, you wouldnt need to keep the 'dont exceed the sum of 1.0' thing in mind. Out of the dgs shader's source:
 * Known limitations:
 * An off-specular peak is not simulated by the Ward glossy reflection model.
 * To get that effect, the Torrance-Sparrow model should be used (but it might
 * be necessary to use rejection sampling for that model).

You easyly can practice what you suggested with a simple maya lambert/phongE. The result will be (approximately of course) the same.

Nice tut by the way, thx!
__________________

Astro Man
!!!!!!!

Six Tuts On Light And Shade
 
Old 04 April 2005   #11
Originally Posted by floze: Yes, you're completely right.
The reason I set these values is a) I was too lazy to change the diffuse and b) I didnt want to disturb the flow somehow..

But this leads me to this comment: The dgs actually is not quite physically correct. If it was, you wouldnt need to keep the 'dont exceed the sum of 1.0' thing in mind. Out of the dgs shader's source:
 * Known limitations:
* An off-specular peak is not simulated by the Ward glossy reflection model.
* To get that effect, the Torrance-Sparrow model should be used (but it might
* be necessary to use rejection sampling for that model).

You easyly can practice what you suggested with a simple maya lambert/phongE. The result will be (approximately of course) the same.

Nice tut by the way, thx!


Thanks floze. At the end of the day a 3d virtual world is a 2d world and I tend to think of 'physical correctness' as achieving photo-realism. You know what would really be good to know is how to get Maya to make the Photon Shader inherit the Surface Material or Material Shader attributes. I read in the Mental Ray manual that it is possible, but haven’t managed to make it work yet. Then we could work with our Shader of choice.

Thanks for the Known limitations quote. I'll check it out.
 
Old 05 May 2005   #12
As a flip to this topic, I'm curious as to why a white dgs shader does not render out as white when used in a normal scene with regular lights (and mr rendering of course)?

The reason I'm interested is that I like to use mr for rendering most of the time, but I only occasionaly use FG. But my DGS shaders are all dark when I render with no FG.
 
Old 05 May 2005   #13
Ahh, part of the confusion may have to do with the lights you're using, the scene distances, etc.

[And recall from above, the diffuse part of dgs will be a factor of pi darker than a basic lambert, which uses traditional shading models.]

Floze, which light shaders are you using, physical_light?

Typically, one matches the traditional shaders with the traditional lights, and the
physical shaders with the physical lights.

When using the traditional shaders with the traditional lights, you 'fake out' the need for pi.

In physical land, the incoming energy needs to be divided by pi (following Lambert) to give a diffuse outgoing color/radiance.

So, the question is whether your lights are representing energy, and whether you are gathering up all of the energy coming in from the hemisphere above your shading point.

Last edited by bgawboy : 05 May 2005 at 12:07 AM.
 
Old 05 May 2005   #14
On a related note, it is quite interesting that radiance, as it is defined, does not have a distance fall off. Whereas, when we use a physical light, it has a distance falloff, and we specify its strength in terms of energy.

Then, think about the difference between traditional lighting models and direct illumination vs. physical lighting models using both direct and indirect illumination. In the parameters of traditional lights without falloff, it's like we're representing radiance.

And, by the way, I'm pretty loose with my definition of energy. Lets tighten it up a bit. Power is a rate of energy, energy per second. Thats what the Watts in a light bulb represent. And irradiance is measured in Watts per square meter.

If you want to get into this a bit more, here're a couple interesting links by just typing in radiance, irradiance and photometry into Google. [I do that every once in a while to look for good images to depict this stuff. In the top one, I like the solid angle pictures.]

http://www.intl-light.com/handbook/ch07.html
http://www.optics.arizona.edu/Palmer/rpfaq/rpfaq.htm

Last edited by bgawboy : 05 May 2005 at 11:36 PM.
 
Old 05 May 2005   #15
Phillipe,

In your question about inheritance, I think you are referring to an optimization for mi scene file syntax. A photon shader without any arguments specified, ie (),will inherit the same arguments as specified by the surface/material shader. Keep in mind that this assumes that the parameters for the photon shader match the parameters for the surface/material shader.

Another option exists for photon-surface/material shader pairs. You could set up the shader to work in both slots. For example, the DGS shader will call its photon shader automatically if it is used in the photon shader slot. So, in Maya you can use the exact same node to plug into both slots, guaranteeing that you don't make mistakes keeping them in sync,when you change its parameters.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:56 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.