[Bf-cycles] UV, not working well in OSL Script node

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Oct 9 13:04:05 CEST 2012


Just remembered how Renderman does this and found a similar note in
the OSL specification:

"4.2.4 How shader parameters get their values
..
• If the parameter matches the name and type of a per-primitive,
per-face, or per-vertex primitive variable on the particular piece of
geometry being shaded, the parameter’s value will be computed by
interpolating the primitive variable for each position that must be
shaded."

So basically it's the parameter name that automatically makes it get
the attribute. Now I'm not sure if/how they implemented that in
practice, because unlike RSL the parameter is not marked varying, and
so only when we have the actual object can we know which parameters
are constants. So that means you either miss out on performance
optimizations (constant folding, ..), or compile multiple shaders or
the common denominator for all objects. Will ask on osl-dev about
this.

Brecht.

On Tue, Oct 9, 2012 at 9:17 AM, Lukas Tönne <lukas.toenne at gmail.com> wrote:
> Had a little discussion with Dalai about how to make sure such shaders
> are still portable to non-cycles renderers. Apart from the brute-force
> solution (always request UV in the OSL script node), we came up with
> two options:
>
> 1) Use a generic "Vector" input, like other nodes. This has the
> advantage of being flexible, but is not as simple as using u/v globals
> directly.
>
> 2) Use shader metadata to encode cycles attribute requests:
>
> surface
> example_shader_1
>     [[ string attributes = "UV,SomeCustomAttribute" ]]
> (
>     output closure color fora = 0
> )
> {
>     fora = color(u, v, 1.0) * emission();
> }
>
> Still this second approach would only work when actually writing the
> node *for cycles*. Using a shader from other render engines which
> doesn't have this request feature/limitation would still not work
> without manual fixing ...
>
> Maybe it should be added as an option on user level: Simple checkbox
> list in advanced options (sidebar) to enable UV and other requests.
> Not very elegant though.


More information about the Bf-cycles mailing list