0
$\begingroup$

I'd like to build a custom OSL Emission shader which behaves as follows:

1) Input parameters:

  • float Initial = 0 // minimum emission intensity
  • float Final = 1 // maximum emission intensity

2) Output:

  • output closure color Emission = 0

3) Applied to a plane with Origin at the left side edge it produces a light emission varying (linearly or by whatever else rule) from:

  • Initial at left side edge

    to:

  • Final at right side edge

I've no problems applying the Initial rule but can't figure out how to apply the Final.

Initial emission is to be assigned at X=0 (in Object coordinates) but what about Final emission?

If I knew information about the size of the current object I could derive the rule to make the emission assume the Final value at the right edge.

Is there a way to get such information inside an OSL script?

Thank you.

$\endgroup$
2
  • 2
    $\begingroup$ I don't think you can get that large of a view, you are limited to what is needed for the point being sampled. You can get the UV coordinates, if the plane is unwrapped to fill the uv layout then you get a value from 0-1 to match the sides. $\endgroup$
    – sambler
    Aug 18, 2018 at 3:40
  • $\begingroup$ Thank you, at the simple cost of adding UV mapping, this provide a relative reference to the points of the plane independent from the size of the actual object. $\endgroup$
    – Antonio
    Aug 20, 2018 at 15:16

0

You must log in to answer this question.

Browse other questions tagged .