Hello,
I posted a topic about this problem in the general support area, but as it was concluded that shaders would be the solution I will continue this here.
The real world example I’m trying to accomplish is that something’s writting with invisible, UV-sensitive ink, then one shines on it with an UV-lightsource and the ink lights up so the message can be read.
Now, I’ve figured out I can light something only by one lightsource and leave it unaffected by others using layers, but it still shows up black if I do not point my flashlight at it. As no light doesn’t mean something invisible, this is quite understandable, but having the secret message visible spoils the surprise somewhat.
I have attached an image with a simple quick and dirty demonstration. The ‘secret message’ is for now textured to a plane in a layer ‘UV effect’; the culling of all lights is set to anything but ‘UV effect’ (so they don’t effect the texture) except of course the spotlight.
The text is black, the spots (top left, bottom right) are white. The big blob is gray and the three medium sized spots are red, green and blue from bottom to top. The rest is transparent.
This sample uses the shader I’ve written. So, yes, I’ve looked into shaders a bit, but I’m not getting much farther than this.
This image uses the following shader:
Shader "Self/Testshader"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
}
Subshader
{
Tags { "Queue" = "Transparent" }
Pass
{
Lighting On
Blend SrcAlpha OneMinusSrcAlpha
Material {
Diffuse (1,1,1,1)
}
SetTexture [_MainTex] {
Combine texture * primary, texture * primary
}
}
}
}
I’ve tried numerous options for the ‘Combine’ line. I hoped mainly that
Combine texture * primary, primary
would set the transparency to the intensity of the light (the spotlight is the only light affecting this particular material). However, although the insensity varies, it doesn’t do anything to the alpha layer.
Also, this only had vertex shaders and I’d like it to work with pixel shaders. To do that, I’m guessing I would have to dive into CG-code or whatever it’s called?
I hope you can help me out! Thanks in advance for your replies.