I would like to know how to create a material that is invisible unless it is exposed to one specific light source, like invisible ink.
-
2$\begingroup$ I don't mean to be facetious, but everything is invisible unless it's exposed to a light, so can you elaborate? Does it need to emerge slowly? React to one light in particular? .. that sort of thing .. $\endgroup$– Robin Betts ♦Commented Aug 31, 2018 at 18:31
-
2$\begingroup$ @RobinBetts maybe like shining a UV light on a motel roof. Now you see it, now you don't. Interesting question. $\endgroup$– batFINGERCommented Aug 31, 2018 at 18:41
-
$\begingroup$ @batFINGER Oh, I'm not denying that! I just want to make sure, before thinking about the problem, that I'm thinking about the right one. $\endgroup$– Robin Betts ♦Commented Aug 31, 2018 at 18:58
-
$\begingroup$ I guess, when the intensity of the light is low, the material should be invisible. And if the intensity is high, then the material should pop-up. $\endgroup$– TejaCommented Aug 31, 2018 at 19:41
-
$\begingroup$ Why don't you manually turn visibility on and off for render since I guess you are making a video/animation, and/or you could use mix shader and plug in transparency and slowly turn switch to other shader when light is hovering for fade in effect. $\endgroup$– Black CloudCommented Aug 31, 2018 at 22:43
1 Answer
As sambler pointed out in his comment, Rich Sedman's answer to how to vary a material's response to shadow rays, depending on the light to which they are cast, is very complete. This suggestion takes the same basic approach, but instead of using drivers to feed the location of a lamp into a node tree, looks ahead down a shadow ray using OSL, to figure out which lamp is casting the shadow.
The setup for this example has cubes which are going to receive shadows, and shadow-casting circular planes just above them. The spotlight we're interested in has a plane just behind it, and parented to it, as a target for the forward-probing ray. Everything in the scene has the default Pass Index of 0, except the target plane, which has an index of 20.
(The target plane is there, because I couldn't manage to hit the spotlight with the forward ray.. perhaps someone can explain why?)
There's a little OSL script which casts a ray forward from a shading point continuing in the same direction as it arrived, and returns the index of the next object encountered.
#include "stdosl.h"
shader NextObj(
output float nextObjIdx = 0.0
)
{
if (trace(P,-I,"mindist",0.0001)){
getmessage("trace", "object:index", nextObjIdx);
}
}
It's used in this tree: If a ray is a shadow ray and the next object encountered has a Pass Index greater than 15, the multiply returns 1, else 0.
The material is applied to the circles, which are blue-transparent to any light associated with index greater than 15, but fully transparent to all other lights.
this is the sort of result:
For lots of reasons I think the geometric approach is better than this one, but maybe someone can improve it? Or come up with a way of manipulating surfaces more directly?