making a light switch


(mazdaplz) #1

is it possible?
ive been doing some research and i found a def called TARGET_LIGHTRAMP
so i added it to my def file and tried linking it to a light and a func_button to no effect. then i replaced the func_button with a func_invisible_user, no luck.

any of you ever tried this? im wonderin how many rabbits i need to pull out of my hat this time. thanks in advance


(Shaderman) #2

Use the search function, there’s a tutorial about it.


(mazdaplz) #3

oh i see thanks a lot i guess i’ll be using dlights on a tiny room then :smiley:


(nUllSkillZ) #4

There’s a little tutorial that uses remapshader with a lightmap.


(]UBC[ McNite) #5

Null, doesn’t that affect the whole map then? Sounds creepy lol because you d need 2 very identical lightmaps except for that one room.

There was a thread once where someone described how to do it with 2 identical interiors, one of which did get shadercommands which disabled the lighting in the LIGHT stage i think, and then setstates to have either the dark or the bright room showing up. Anyways I never tried it, sounded too complicated.

mazda, plz be aware that dlights do eat a lot of performance and really bring down the FPS. You really might wanna check on it.


(WeeBull) #6

I wanted to know this a while back and someone said to me that there was a rtcw map that has it, so I mailed the mapper and this was his reply:

The setup itself is a bit complicated, but the idea is simple. It will be easiest if i just run through how to build it. Start with your room, and any surfaces that will be affected by any of the lights you wish to turn on/off. Copy all of that geometry and move it directly above, under, right or left of the origional, or as close as possible without obscuring any other geometry. Make the selected brushes a script_mover. Create an origin for it and two path_corners, one where the origin is, the other aligned so the script_mover is in perfect alignment of the origional room. Now you must apply the same texture as in the origional room, but using a special shader for them.

This is a shader i built for the script_mover, using an existing texture in the game.

textures/silo_wall/concrete_c07bcmp_offset
{
    qer_editorimage textures/miltary_wall/concrete_c07bcmp.tga
    surfaceparm nonsolid
    surfaceparm nomarks
    polygonoffset
 
    {
        map $lightmap
        rgbGen identity
    }
    {
        map textures/miltary_wall/concrete_c07bcmp.tga
       blendFunc GL_DST_COLOR GL_ZERO
        rgbGen identity
    }
}

Notice i used the polygonoffset parameter, this is the most important one of all them. Also surfaceparm nonsolid, nomarks are necessary.

Now once you have all these aligned properly, go ahead and setup your script_mover. For the scripting here is what i have.

//LightSwap Trigger
lightswitch
{
    spawn
    {
    }
 
    trigger toggle
    {
        trigger lightmap toggle
    }
}
 
//LightSwap Lightmaps
lightmap
{
    spawn
    {
        accum 1 set 0
        wait 500
        alertentity lightbulbs //fixing bug...
        wait 500
        alertentity sparks
        alertentity lightbulbs
        gotomarker on 9000
    }
 
    trigger toggle
    {
        //halt
        trigger lightmap off
        wait 5
        trigger lightmap on
    }
 
    trigger off
    {
        accum 1 abort_if_not_equal 0
        resetscript
        accum 1 set 1
        alertentity lightbulbs
        alertentity corona
        alertentity sparks
        gotomarker off 9000
    }
 
    trigger on
    {
        accum 1 abort_if_not_equal 1
        resetscript
        accum 1 set 0
        alertentity lightbulbs
        alertentity corona
        gotomarker on 9000
        alertentity sparks
    }
}

This works so the light can be toggled on or off and stay that way until the mover is triggered again. some of the other things ive used are corona’s and light models, as well as sparks for a broken light.
If you still have any questions feel free to drop by my forums whitch are dead and ask a question or just email me back. Hope it works out!

I tried it and it worked, but the light will still be there, so any player models will still light up, you just won’t see the lightspots on the floor and walls if you know what I mean.


(nUllSkillZ) #7

How about crushing by using script movers?

Edit:

Only the lightmaps that represent the room are affected.

Edit:

Found the tutorial:
Switchable lights tutorial


(carnage) #8

is it somehow posible to make Dlights only light dynamic models so you can compile the lightgrid so that its actuly dark and when the lights are on use Dlights on the dynamic models to give the illsuion that the players are still lit up


(]UBC[ McNite) #9

If you want to light the models only, use lightjuniors (i think). They do work actually by lighting up playermodels and weapons, and you can define a color for them too.

Also there s a shadercommand you could use to avoid that textures are bing lit by the dlights used. But I think that would only eat more performance.


(carnage) #10

If you want to light the models only, use lightjuniors (i think). They do work actually by lighting up playermodels and weapons, and you can define a color for them too.

Also there s a shadercommand you could use to avoid that textures are bing lit by the dlights used. But I think that would only eat more performance.

lightjuniors are unsultable for this as my idea with dlights was to overcome the fact that even when you swap the lightmaps the lightgrid is still showing players as if they are lit, even if the lightmaps show the area is totaly dark

the sahdercommand sounds interesting though. It posibly could eat more performance but by the sounds of it its probably an obsucre command because in a game like rtcw or ET there would be very few surfaces you would want to have a dlight near and not light

a simple test having a dlight light up a large number or surfaces then use the same map but apply the no dlight shader command to them and watch the fps fall/rise. To me it would make sence that you would get an increase in perforamance since you would save a lot of time working out the actual effect of the light

EDIT//

4.8.10 nodlight
Read as “No Dee Light”. A texture containing this parameter will not be affected or lit by dynamic lights, such as weapon effects. And example in Quake III Arena would be solid lava.

this also made me think of another problem. when the lights are off it might be quite noticeable that gun flashes are lighting up player models while the souroundings are totaly uncahnged. you could perhaps remap shader out the entire building or whaterve you were going to make dark to them make it respond to dynamic lights after the dlights used to light up player models have been turned off


(kamikazee) #11

I was wondering: what about writing shaders for the room walls which have a black texture at 90% alpha filtered on top of it instead of map $lightmap?


(BigBadWolf) #12

i sent the message to weebull. In my map for degeneration called DGDM_Underground i had a tunnle whitch had switchable lights, i used an identicle tunnle underneath it made of nodraw brushes, and had the walls made of the same texture but with a special shader to them to allow polygonoffset and nonsolid properties. The only problem with this setup is any other textures such as explosions, wallmarks from weapons, and player shadows, they zfight and look weird. If enough people are interested ill write a tutorial on how i did it and build a small example map.


(carnage) #13

@kam im not sure that would give a very good result. You might want to still have the room lit but only dimly as if you are changing between two differnt lighting theams. remapshaer the lightmap would seem the better option to me if you export large lightmaps then isolate only the ones you need to change out you could end up using only one or two remapshaders and when lightmaps are converted to JPEG there isnt much wory about increasing the pk3 size from having the extra lightmap images


(mazdaplz) #14

to badwolf: yes im interested, please do try to write the tut if you could, im trying all i can here but looks more trouble than its worth
id appreciate it thanks. also im having trouble with fog?

im tried several fog shaders applied to a brush with no worldspawn keys, i made it with only 1 way to enter it and nothing, also i tried making it as big as the room but no luck… i hear volume fog has been changed in 2.56 onwards??? any way around it? i dont want to have the whole level foggy just one room


(C) #15

I use 2 script_mover entities, 1 is unlit, the other is lit.
There is no need to use special shaders.
There is no need to use path_corner entities.

This is the lit “room”, which is hidden from the player.
This selected script_mover is called “light_engineer”.

This is the unlit “room”, with the switch to turn the light on/off.
It is the area where the player will walk.
This selected script_mover is called “dark_engineer”.

You can see the lit room still selected in the editor.

A red engineer toggles the switch, and the light “turns on”.
In-game it looks like this. You can see a lit and unlit pad next to eachother:

The mapscript:

  • “dark_engineer” is allready in position and visible. NOP.

  • when “light_engineer” spawns, i reposition it at the position of “dark_engineer” and hide it. Here is the code:

light_engineer
{
	spawn
	{
		wait 100
		setposition dark_engineer
		setstate light_engineer invisible
	}
}
  • when someone triggers the switch, i simply hide the unlit “room”, and unhide the lit “room”. Here is a piece of code:
	...
	trigger button_in
	{
		// light on
		setstate dark_engineer invisible
		setstate light_engineer default
	}
	...
  • when the switch is released, i toggle states again:
	...
	trigger button_out
	{
		// light off
		setstate light_engineer invisible
		setstate dark_engineer default
	}
	...

You can see it all in full effect in my map: UJE_00.
download UJE_00: http://www.ujeclan.com/UJE_00.html

I experimented with this technique on a terrain, but then i encountered some other problem. It seemed that the terrain was using a different part of the alphamap; Both terrain-parts(script_movers) turned out to be textured differently…and the light/shadow-effect was unrealistic.


(BigBadWolf) #16

C’s way would be best, as it would work faster and not require as many entitys or any shaders. Mines still old school wolf scripting.

Nice work by the way C.


(mazdaplz) #17

yes what a good way to do it, kickass post! and your map is also very cool i always get wasted chuggin down all those beers ;D


(BigBadWolf) #18

OK!

I got the example files put together, this is using C’s updated method.
I still have to write a tut on how its done exactly. But if you look at the map files, it can be figured out.
The first (light_tut1) is a single light that you can toggle on or off.
The second (light_tut2) is more complicated, with two lights within each others radius.
Any more than 2 lights intersecting would require a ton of work. Considering how many on/off combinations the lights can make.

http://home.comcast.net/~bkaltec/light_tutorial.zip

If anyone has any improvements, please say so.


(mazdaplz) #19

whoa! thanks for postin that last file man u saved me! i was drowning in my script :frowning:

you got it man!!! sehr guht!!! :smiley:


(C) #20

That is a nice example You put together BigBadWolf.
Well done!..