- you can sample a channel. it works perfectly for things like the layer shader.
- if you really have to sample a shader specifically, what I do is make a clone of the shader per each context.
i.e. you have 16 cores, you make 16 clones, and insert them on the material and initing them, (being sure to clean up after)
Layer shader will then work as expected, off the bat, as long as you use the thread index to reference from your list of shader clones.
clones.shader_list[context.GetLocalThreadIndex()]
you also have to make sure you project your coordinate according to the texture tag. it wont do that for you.
p is always assumed to be a UV coordinate projected, as per the tex tag. you send p as a world coordinate with vd and if the shader needs that, that is where it would look. think of it from the perspective of a shader. where will it get a world position from? if you write a shader, and you need a world position for a hit, you look in vd for that. if vd is null, or the info has not been filled, how would it know where p is?
I found in most cases sampling a channel from a material rather than a specific shader, works best, and is less problematic.
best
Paul