- Home /
How do I make a mesh visible only under a certain light?
Ie for UV/infrared lights.
I already know how to get a particular mesh to be affected only by a specific light, but this can't affect its visibility (just how much it reflects the light).
Basically- I want its visibility (alpha) to change, depending on how much light(from a specific source) it has recieved.
Answer by AlbeyAmakiir · Nov 02, 2010 at 05:50 AM
I'm fairly new to Unity, so I don't know if this is possible, but could you perhaps render once without the UV light, then make the object visible and render again, this time only using the UV light, and overlay the second image on the first?
Answer by Grumblekeen · Oct 15, 2010 at 12:55 PM
I'm sure there is a neat technical way to do this, but I'd just fake it with some triggers.
If you want an object to appear near certain lights, fade it in when it is near them and out when it isn't.
If you want the player to see them when wearing goggles or something, that's even easier. You can just flip them visible when he/she activates the item.
Its slightly more complicated than that. Imagine a first person game where the player moves a infrared torch around the room. Anything within that beam of light needs to show up.
In saying that, I could fake it with a long collision box which encompases the light beam and anything in the box alphas in?
Sound good enough?
That should work.
$$anonymous$$y first thought was to cast a ray (or four) from your light source every half second or so (no need to do this every frame), and make anything it collides with visible, and anything it doesn't invisible.
http://unity3d.com/support/documentation/ScriptReference/Physics.Raycast.html
You might try both and see which works better in practice. I can see potential problems with the ray cast idea, such as smaller items popping in and out because they just happen to dodge rays, etc.
Answer by Matthew Crawford · Dec 09, 2010 at 07:48 PM
You can look at a specular shader for an example. Instead of increasing or decreasing reflection strength, you can increase or decrease alpha strength. You would have to make a map for it, depending on what you want the player to see, weather you want to view the object as a colored heat signature or just as a regular diffuse looking textured object.
Your answer
Follow this Question
Related Questions
How to make always visible(rendering) weapons in FPS? 2 Answers
Making a Game object appear and dissapear 3 Answers
i need script c# scrollview object hide/unhide 0 Answers
EditorWindow is visible 2 Answers
3D Text visible from/in x distance/place 0 Answers