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?

For example, I'd like to write a shader such like this.

surface
constant()
{
Ci = color(1, 0, 0);
}

Unfortunately, as spec 5.10 says, we cannot assign color value to
closure color, thus the above expression cannot be compiled by oslc.

--
Syoyo

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To post to this group, send email to osl...@....
To unsubscribe from this group, send email to osl...@....
For more options, visit this group at http://groups.google.com/group/osl-dev?hl=en.

--
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?

For example, I'd like to write a shader such like this.

surface
constant()
{
       Ci = color(1, 0, 0);
}

Unfortunately, as spec 5.10 says, we cannot assign color value to
closure color, thus the above expression cannot be compiled by oslc.

--
Syoyo

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To post to this group, send email to osl...@....
To unsubscribe from this group, send email to osl...@....
For more options, visit this group at http://groups.google.com/group/osl-dev?hl=en.

--
Larry Gritz
l...@...




--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To post to this group, send email to osl...@....
To unsubscribe from this group, send email to osl...@....
For more options, visit this group at http://groups.google.com/group/osl-dev?hl=en.


Adam Martinez <adam.m...@...>
 

Hi Syoyo,

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:

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?

For example, I'd like to write a shader such like this.

surface
constant()
{
Ci = color(1, 0, 0);
}

Unfortunately, as spec 5.10 says, we cannot assign color value to
closure color, thus the above expression cannot be compiled by oslc.

--
Syoyo

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To post to this group, send email to osl...@....
To unsubscribe from this group, send email to osl...@....
For more options, visit this group at http://groups.google.com/group/osl-dev?hl=en.


--
Larry Gritz
l...@...




--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To post to this group, send email to osl...@....
To unsubscribe from this group, send email to osl...@....
For more options, visit this group at http://groups.google.com/group/osl-dev?hl=en.