Date
1 - 3 of 3
How to assign constant value to closure color?
Larry Gritz <l...@...>
Ci = color(1,0,0) * emission();
On Jul 31, 2010, at 12:33 AM, Syoyo Fujita wrote: What is the best way to assign constant value for closure color variable?-- Larry Gritz l...@... |
|
Syoyo Fujita <syoyo...@...>
On Sun, Aug 1, 2010 at 12:20 AM, Larry Gritz <l...@...> wrote:
Ci = color(1,0,0) * emission();Hmm, I don't think using emission() is a good idea. emission() has a somewhat physical quantity(according to the spec), thus its value could be depends on scene description and the renderer. e.g. If the surface isn't a emitter, emission() should return zero for phsycally-based renderer, resulting Ci also to zero, which is not a expected behavior for the shader writer. I guess it'd be a good idea to introduce constant() closure function, which is not a physically-based, but very handy for writing non-physical shaders: for example, a shader showing normal vector as a color. -- Syoyo On Jul 31, 2010, at 12:33 AM, Syoyo Fujita wrote:What is the best way to assign constant value for closure color variable?-- |
|
Adam Martinez <adam.m...@...>
Hi Syoyo,
toggle quoted message
Show quoted text
Per the specification, the emission() closure returns a radiance value, thereby effectively turning the surface into a light source. However, we can compensate for the physical nature of the closure in two ways. Scaling the result by M_PI equalizes the apparent loss in brightness due to the units of the emission() call. We can also detect when raylevel() returns zero to return a constant result, and do something else when we do not desire emission into the rest of the scene. My constant shader would look something like this: surface constant() { if(raylevel() == 0){ Ci = color(1, 0, 0) * emission() * M_PI; } else { Ci *= 0; } } Although, I'm pretty sure the else clause isn't necessary. That being said, establishing a constant() closure has been proposed before, but would it be confusing to have a closure that does not behave the same in all contexts, versus leaving context dependent behavioral decisions to the shader? -Adam On 8/1/2010 12:20 AM, Syoyo Fujita wrote:
On Sun, Aug 1, 2010 at 12:20 AM, Larry Gritz<l...@...> wrote: |
|