Designing OSL for use with UI ?

73 views
Skip to first unread message

Viewon01

unread,
Mar 25, 2011, 5:51:16 AM3/25/11
to OSL Developers
Hi,

If I have a user interface that allow me to setup a specific shader
like the "glass" one in the example, where I have :

surface glass [[ string description = "Simple dielectric material" ]]
(
float Ks = 1 [[ string description = "Color scaling", float UImin
= 0, float UIsoftmax = 1 ]],
color Cs = 1 [[ string description = "Base color", float UImin =
0, float UImax = 1 ]],
float eta = 1.5 [[ string description = "Index of refraction",
float UImin = 1, float UIsoftmax = 2.5 ]],
int caustics = 0 [[ string description = "Enable indirect lighting
through glass" ]],
int TIR = 0 [[ string description = "Enable Total Internal
Reflection" ]]
)

in fact, "caustics" should be interpreted as a "boolean" by example...
how do I know this for my UI ?

I have the same problem by example with a "string" that should point
to a "image file" for texturing. How do I know that it is used to
choose a file ?

Larry Gritz

unread,
Mar 26, 2011, 1:02:36 AM3/26/11
to osl...@googlegroups.com
OSL builds a library, liboslquery, that lets an application query a compiled shader (i.e., .oso file) and find out about the arguments, and any metadata associated with the argument. The OSLQuery class can be found in src/include/oslquery.h and is simple enough to be virtually self-documenting. Also, in src/oslinfo/oslinfo.cpp, you'll see the library in use, and for that matter, the "oslquery" program that is built as part of OSL is a command-line utility that prints info on the parameters and metadata for any compiled shader.

In section 4.3 of the OSL spec I make a recommendation. Among other things, I suggested a string metadata called "UItype" to suggest what kind of UI element should be associated with each parameter, and "bool" is one of the suggested values. Also, the value "texture" for the "UItype" metadata is intended to indicate that the string is supposed to be a texture file name (so an app might let you set it via a file browser interface rather than simply a string entry field).

But the metadata conventions of section 4.3 are merely a recommendation, it is not enforced in any way, and in fact at SPI we don't use this (instead using the UI hint names that our old pre-OSL system used), so of course you are free to come up with your own conventions if the ones I suggested don't suit you.

-- lg

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

--
Larry Gritz
l...@imageworks.com


Reply all
Reply to author
Forward
0 new messages