- Home /
Exclude certain objects from getting lit
Hi there guys. Im trying to implement the instant radiosity technique in unity, and im having a problem. I need to make so, that each emissed photon(pointLight) wouldnt light the surface its hitting. Since i have about 300 photons(pointLights) and about 100 object in the scene its impossible to use Culling Mask on lights, i just wont have enough layers to cover all the objects. So, is it possible to exclude the one object (not layer) from being affected by light? And if possible, how can i do this?
Answer by Bunny83 · Aug 26, 2012 at 04:25 AM
No, afaik there's no way to implement this. That's nothing you can do on shader level since it's different per object in your case.
Your question title is a bit confusing since it asks for the opposite. You asked to exclude "certain objects" from being lit, but you actually want exclude a certain light (per object). Lighting happens the other way round. The object is drawn and all lights that are in range are taken into account inside the shader. Maybe there's a way to write a custom shader and intercept a given light "position", but i've never done something like that :)
I guess it makes sense in both ways :) I was talking about something, like in 3d max - there is a button in the light properties, which opens the menu, where you can exclude objects from getting lit. The thing about shaders: i dont know anything about shaders, and i find this kinda difficult for me to understand how they work, and coding it into every shader i use is a lil bit too much work. I found this thread in forums http://forum.unity3d.com/threads/12752-having-a-light-only-affect-one-object. when they have similar to my problem, but opposite. And there the unity developer said that theres no way to implement it, besides coding the shader. Thats upsetting.
$$anonymous$$aybe you could use OnWillRenderObject in a script attached to each object and disable the "own" light. However, i'm not sure if there's a way to enable the lights right after the object has been rendered. Also i never tried something like that with OnWillRenderObject. $$anonymous$$aybe batching could interfere with it as well.
Answer by flokkienathur · Aug 25, 2012 at 06:01 PM
Well if you use the selfillumative (i think it calles :x) shader it does not get lit. But that is sometimes a little annoying if you are using a custom shader.
Hope it helps
This is not what i exactly need. I need the object to be affected by all the lights as usual, except those light, that lie on his surface. I guess you cant do that with selfillu$$anonymous$$ative shader. But thanks for the answer.
Your answer
Follow this Question
Related Questions
The light is not blending 0 Answers
Prefab asset lights differently in different scenes 0 Answers
How can I make lighting in scene shine at every part of objects 0 Answers
URP Point light range doesn't increase light range? 2 Answers
Change fade distance of shadows on pointlight through script in HDPR 0 Answers