View Full Version : Writing energy conserving MR or prman shaders
shanega 01-09-2008, 12:26 AM How is a shader such as mia_material written to be energy conserving? Can anyone provide a simple reference, ideally with some source or pseudo-code in any language? I know that the dgs_material shader source is provided with MR, but that is specifically the ward anisotropic model. How is this generalized to any shader?
Thanks,
Shane
| |
floze
01-12-2008, 03:52 PM
I guess it strongly depends on what BRDF you are using; some of them are energy conserving per se, others not. And on how this BRDF is afterwards combined with others. Generally, the totalized input values of each should then not exceed 1.0, to conserve the energy.
The mia_material apparently does this by applying the fresnel term to one input part (specular reflection/[multilayered?]ward) and the inverse of the fresnel term to the other (diffuse/lambertian/oren-nayar). Depending on how strong the IOR or 0°/90° reflectivity is chosen, the input values get balanced accordingly and the sum can never be larger than the maximum of either. I suppose that's sort of a 'trick' to combine the BRDFs because the inputs are chosen rather arbitrarily, but its nicely working in practice and the results speak for themselves. A more universal BRDF which would include both diffuse, specular and also transmission, etc., would probably be more expensive to calculate, since the amount of parameters typically increases the computation time of a function, opposed to the 'trick' where two functions are simply combined, so after all its a question of efficiency.
floze
01-12-2008, 09:27 PM
[...]since the amount of parameters typically increases the computation time of a function, opposed to the 'trick' where two functions are simply combined, so after all its a question of efficiency.
..though of course one might find a whole different approach, i.e. BRDF, making the distinction between 'diffuse' and 'specular' obsolete. I guess the crux lies in the convergence efficiency of the raytracing part (if you are after this, however).
CGTalk Moderation
01-12-2008, 09:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2009, Jelsoft Enterprises Ltd.