How do I create a material that is only visible under one specific light?
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?