Moving spotlight


(Wezelkrozum) #1

I’ve made a spotlight which can move. Here is a screenshot:

Only one thing is the problem. How can i make the spotlight shine on something. So that the walls are orange when the light is shining on it.


(murka) #2

only way would be to use dlights, or if you can manage to use the 2 fake methods(remapshader texture with different lightmaps or setstate different stages of the room).


(Flippy) #3

I don’t think you’ll be able to do this…

If you are going to use dlights (can you move them? I’ve never tried), you need to make sure that the light stays very close to the wall, and more importantly that it stays the same distance from the wall at every place (otherwise the lightspot on the wall will grow/shrink…)
If you have a circular room and the spotlight is just rotating, then you can just rotate the dlight in sync with the spotlight. But if the room is not circular you need to figure out exactly how to move the dlight so it stays the same distance from the wall everywhere…


(murka) #4

you can put the light to gotomarker every corner of the not-so-round room, so the grow/shrink effect is gone.


(Wezelkrozum) #5

nice to hear that. But how can I make the dlight bigger or smaller?


(Flippy) #6

Yes you could, but how do you determine to which marker it has to go?

I guess it all comes down to how the spotlight moves. Can a player control it, is it scripted, is it rotating, is it irregular (random), etc…? If it is simply rotating a bit of trial and error might get you a reasonable result. If it is irregular it will be much harder, if it’s random (or player controlled) I would say impossible.

EDIT
Here is what I’m trying to explain, I made a little animation of a spotlight moving across a wall (gray). The red dot represents the dlight you would need. Notice especially how the spotlight rotates at a constant speed (10 degrees per frame in this case) but the dlight does NOT move at a constant speed (it accelerates).

Now, you could theoretically calculate exactly how fast your dlight would need to accelerate in this one, straight wall example, and you could fake that using a lot of path markers, but this is way to much work for an irregular shaped wall and again impossible for player controlled or random movements…

In addition, as wezelkrozum probably tries to ask, you would need to change the size of the dlight depending on how far it is from the spotlights origin (where it rotates)… As the lightspot on the wall gets more and more to the right in my animation, the spot also grows larger and you would need a larger dlight to create a realistic feeling.


(BigBadWolf) #7

Theres actualy some trickery you can do with shaders to accomplish a cheap spotlight effect.

If you make a shader that when you see it through one side, it brightens everything, kinda like GL_ONE GL_ONE on a gray texture. And do the opposite to cancel it out on the backside of the same shader. This way, when you apply the shader to a cone like curve or a brush, when you see both sides it looks normal. But if something is blocking one side of the texture, you will see a brightened spot.

Heres a little pic.


(Wezelkrozum) #8

A script_mover with a bright decal you mean? But how can I let a script_mover shrink and grow?


(-SSF-Sage) #9

Afaik there’s no other way to do it rly without animated model. To fake it you can have many separate things, that you setstate to grow.


(murka) #10

a dlight that goes nearer/further away would give a smoother effect of growing/shrinking…


(BigBadWolf) #11

Its not a bright decal, its a whole brush or cone with the shader applied as i mentioned. First you make a spotlight beam out of a script_mover, so you can control it. Then apply the shader to the sides. You have to make the brush/cone extend to the furthest surface you wish the spotlight to shine on. Then it will adjust accordingly when it moves in closer. The problem there is it will protrude into anything beyond the surface your trying to light to the extent of the beam size.