I have an FPS, the weapon is a part of the HUD, and I want it to be affected by lighting in scene 1. I can have it be affected by sun and main things, but it wont work when your character moves and there's a spotlight or a point light. How could I make objects in other scenes be affected by lighting in the main level scene?

-I have gotten a great answer but no .blend; therefore, I will ask kindly for another answer.

Place steps, and a gif(Recommended: http://recordit.co/), and post a .blend. Try to avoid python as much as possible. Sorry this might be asking for too much, but the answer is sitting there, just do it. I want it to be the best type, that is, have it be affected even by walls in the first scene. In other words, I want the weapon to be JUST as it would be in the regular scene but another. Thanks!

  • $\begingroup$ Would it work to link the lamps into the second scene? (Ctrl L > Link objects to scene) $\endgroup$
    – gandalf3
    Jul 22, 2014 at 23:35
  • $\begingroup$ Im not sure, but in scene 2 the weapons are still. There are no movements $\endgroup$
    – blackhole
    Jul 23, 2014 at 21:37
  • $\begingroup$ Ensure, that your spot light Energy is way higher. Also, ensure your weapon material has good material. For starter, use a simple 50% gray material (no spec) and try to move it under the sport lights, which aren't showing up , and play with light energy. $\endgroup$
    – Ali Jibran
    Jul 27, 2014 at 16:09

1 Answer 1


One thing comes to mind:

Create the same light source in your second scene (weapons scene) at the same origin, with all properties being the same as the light source in the first scene.

Then save the transformation matrix of your camera from the first scene -> inverse the matrix -> and apply it onto the light source in the second scene.

This way the light source in scene2 will move according to the player movement (camera), and will affect the weapons in the correct way.

Now, to have even more realism, we would want to stop seeing the light affecting the weapon, when the player is outside the direct reach of the light source. The simplest solution would be, casting a ray from the 8 corners of the bounding box (bbox) of the player, towards the desired light source, if any of them gets to the light source without hitting any obstacle on the way (we assume no transparent objects), than some part of the player is still in the light, so we set a flag, like so: bool inLight = true.
This flag is used in the second scene, and we compute the light affecting the weapon, only if the flag is true...
Now if you like to be even more specific than that you can create a bbox in scene1, in the place where the weapon would be, and do the same procedure. However, I wouldn't bother going into so much detail in a game (keep it lighter), especially in a FPS game.
What I would do to achieve a similar effect for an FPS game is just cast a single ray from some offset from the front of the character (presumably where the weapon would be) and proceed with the check.

As for the ray-tracing check, in the case that you do not have a space partitioning algorithm (octree, kd-tree, etc), you would have to check the ray, brute force, against all objects (not very nice, especially in a game), so I suggest at least having a Bounding Volume Hierarchy to store the objects in your scene, as that would optimise things, and I strongly recommend using a spacial partitioning algorithm too. However prove that it works first, with the easiest way! Slow and correct is better than quick and wrong! Not always true for games though. ;)

  • $\begingroup$ My computer doesn't work as of now but I'm sure this works. I will accept this answer at the end of the bounty unless I get a better answer. $\endgroup$
    – blackhole
    Jul 25, 2014 at 23:06
  • $\begingroup$ Well, in theory it should work. However, even if it does it wont be perfect as it wont take into account other objects and thus, being in shadow (if the player is behind a wall - hidden from the main light source, the weapon will still be lit) There are ways around this but it can become quite involved... Do let me know if that has worked in the first place, I will edit if i think of a better solution. $\endgroup$ Jul 25, 2014 at 23:30
  • $\begingroup$ Yeah as I said I don't have my PC right now. It would be nice if you could explain how do do it, even throught walls. $\endgroup$
    – blackhole
    Jul 27, 2014 at 6:25
  • $\begingroup$ Can you place a .blend? $\endgroup$
    – blackhole
    Aug 2, 2014 at 4:46
  • $\begingroup$ You mean, place a .blend in the 2nd scene? I wouldn't think so. .blend is a project file, hence that would mean you are working on separate projects. Keep them in one place, you can export and import objects or even append objects into a scene, see this thread: blender.org/forum/viewtopic.php?t=8799 $\endgroup$ Aug 2, 2014 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .