identify extremity of an object

38 views
Skip to first unread message

William Eguienta

unread,
Apr 24, 2020, 12:05:25 PM4/24/20
to OSL Developers
Hello,
I'm starting learning OSL and I try to make a ramp shader over the all geometry over different axes, no matter the uv and udim.
I dont found how to identify the bottom and the top of my geo (or any other axis) to determine the range of my gradient
If I use UV, it works until I use object with UDIM

I was expecting that I can identify the origin of the object with :

point geoBot = point("object",0,0,0);

and the top part with :
point geoTop = point("object",0,1,0);

then as i need a float value :
y = distance(geoBot,geoTop);

but it seems I miss something
any idea how i can make it works ?

thank you

Larry Gritz

unread,
Apr 24, 2020, 12:34:55 PM4/24/20
to OSL Developers List
IF the object was completely and exactly enclosed in the y range of [0,1] of its local object coordinate system, then this should work.

But there's no particular reason to think that the object is normalized, engineered to always fit in a [0-1] sized cube of its local coordinate system.


--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osl-dev/11d6dd14-ae1c-4a52-81fc-6cb087978cd4%40googlegroups.com.

--
Larry Gritz




William Eguienta

unread,
Apr 25, 2020, 1:07:10 AM4/25/20
to OSL Developers
Hello,
yes i've seen that, that's for the example
the problem is that i can't find a way to match any object size and shape extremities to then map my gradient on it


Le vendredi 24 avril 2020 18:34:55 UTC+2, Larry Gritz a écrit :
IF the object was completely and exactly enclosed in the y range of [0,1] of its local object coordinate system, then this should work.

But there's no particular reason to think that the object is normalized, engineered to always fit in a [0-1] sized cube of its local coordinate system.
On Apr 24, 2020, at 8:21 AM, William Eguienta <kaiz3...@gmail.com> wrote:

Hello,
I'm starting learning OSL and I try to make a ramp shader over the all geometry over different axes, no matter the uv and udim.
I dont found how to identify the bottom and the top of my geo (or any other axis) to determine the range of my gradient
If I use UV, it works until I use object with UDIM

I was expecting that I can identify the origin of the object with :
point geoBot = point("object",0,0,0);
and the top part with :
point geoTop = point("object",0,1,0);

then as i need a float value :
y = distance(geoBot,geoTop);

but it seems I miss something
any idea how i can make it works ?

thank you

--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl...@googlegroups.com.

--
Larry Gritz




Larry Gritz

unread,
Apr 25, 2020, 2:09:11 AM4/25/20
to OSL Developers List
You can use getattribute() to retrieve information about an object. What queries are supported is dependent on the renderer.

In our renderer, as it turns out, you can do:

    point bbox[2];
    getattribute ("geom:objbounds", bbox)

to retrieve the object space bounding box of the primitive being shaded (and "geom:bounds" for the world space bounds).

I don't know if the renderer you are using supports something like that, you'd have to ask them.

It seems we haven't written this into the language spec. Perhaps it would be helpful to standardize these names (and maybe some of our other queries), much like the spec mentions several "camera:thingie" attributes that we should expect to always work across all renderers.

It's kind of up to the renderer authors to chime in on whether standardizing this, and expecting them to conform, is fairly easy and helpful, or would make life difficult for them. Perhaps it's a topic to discuss here, or at the next TSC meeting when we have everybody together.

Of course, even with this query implemented, if you had an object composed of several separate geometric primitives (not just one single mesh, for example), then even this might not get you quite what you are hoping for. Maybe it's possible for a renderer to understand a different query that would give you the bounds of the full *logical* object, even when consisting of several individual geometric primitives? But, ugh, even that may be tricky for your purposes -- it might work for a totally static object, but if any primitive deforms, or if the multiple primitives comprising an object are anything other than rigidly and unchangingly attached to each other, you might get the bounds changing from frame to frame as the object moves, and thus altering shading when you don't intend it to. The whole approach is fraught with danger and interesting edge cases.

-- lg


To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osl-dev/9b7f1e2f-4190-4a6b-8759-c27ba0c91273%40googlegroups.com.

--
Larry Gritz




Reply all
Reply to author
Forward
0 new messages