Shader swapping and lightmap swapping?

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
dONKEY
Posts: 566
Joined: Mon Oct 15, 2001 7:00 am

Shader swapping and lightmap swapping?

Post by dONKEY »

I'm not sure if this is possible, but if it is I'm sure you guys have done it.
I've been thinking about Tig's SP contest.
I worked out a while ago how to set up shader swapping so I could design a situation where a player could shoot a light or window and break the glass.
Is it possible however to swap lightmaps, or at least hack that makes it look like lightmaps have been changed.
I'm rambling a bit...
What I want to do is shoot a light and have the room go dark.
I can shoot a light and swap the shader image so my light is broken, but can't think how I can make the room go darker.
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Shader swapping and lightmap swapping?

Post by Silicone_Milk »

My thoughts would be to set the room up where each face has a duplicate face hidden about 2 units or so under the surface of the lit faces.

The hidden faces would have a multiplicative dark gray or even black shader and when the light is shot, they pop up 1 unit over the lit surfaces so they multiply the light away making a "dark room".

I did something like this for a "moving" lightmap that was just a patch with a multiplicative shader that was set to follow the movement of a bobbing brush that moved side to side.
dONKEY
Posts: 566
Joined: Mon Oct 15, 2001 7:00 am

Re: Shader swapping and lightmap swapping?

Post by dONKEY »

I did think about this....or triggering swapping the wall textures at the same time.
Quack
Posts: 82
Joined: Thu Sep 07, 2006 6:56 pm

Re: Shader swapping and lightmap swapping?

Post by Quack »

I have considered how to achieve an effect like this a long time ago but I've never tried it. Let's say you have a light that illuminates a room. You can have a small invisible button or door that has to take damage to be activated. This trigger will be the same size as the visual representation of the light and extrude a few units away from the light so the player can damage it. The visual representation of the light will show the light on. This is the base shader that you will use to remap to the broken light shader. When the player shoots the trigger, it will remap the light using targetShader to the broken version of the light. At the same moment, the trigger will go inside the wall and have a long wait value so it will not trigger again. If this trigger does come back out it will be of no consequence visually, because if it is triggered again, it will already be remapped to the broken version of the light. But since this is unnecessary, you should have a very long wait value for the trigger so it does not get triggered again. You could also trigger a sound of the light breaking since a relay system will be used to remap the light shaders.

The only real problem is with the area that is lit by the light. One option I've considered is having two different shaders with precompiled lightmaps. You have the same texture, but two different light maps: one lit & one dark. Manually apply the lightmaps you create to two different shaders. When the trigger remaps the visual representation of the light to make it look broken, the trigger will also remap the shader for the floor/wall to the dark version. The only problem is that characters and entities in game are vertex lit, so they will appear to have the original lighting that was used before the remap. You are only changing the way the shaders look so the difference between light and dark should be similar so vertex lit models appear to be lit properly.

Triggerable Shader Entites
http://robotrenegade.com/q3map2/docs/sh ... ities.html
dONKEY
Posts: 566
Joined: Mon Oct 15, 2001 7:00 am

Re: Shader swapping and lightmap swapping?

Post by dONKEY »

Yep, I know how to do the shader swap part. It was how to set up a lightmap swap. I'm not sure how or if I can set up a shader to do that. I don't understand the precompile a lightmap and manually attach it to a shader part.
I can and have got around this by using alternative images, the down side of which is doubling up on the amount of textures I use. The other problem is the area or areas I use this in would need individual shaders or textures so that I don't change images level wide.
I agree with you about the player model problem, it does look a little odd, but I think if used sparingly and carefully in the right places I can get around that.
Quack
Posts: 82
Joined: Thu Sep 07, 2006 6:56 pm

Re: Shader swapping and lightmap swapping?

Post by Quack »

A lightmap is just a compressed image that is resized and placed over the texture. You could use q3map2 to make an external lightmap and write your own stage that uses that precompiled lightmap for the dark version of the shader. This way, the lightmap is precompiled and you can use photoshop to edit and design it specifically for the dark version of that area. The only problem would be if you need more than one shader or have lots of detail pieces around, it would require too many shaders. So the only real option would be to have a couple or preferably one shader that would get hit by the light. Q3Map2 would make the lit version of the shader, and you would use your own precompiled lightmap image for the dark version of the shader with it's own stage, not an actual $lightmap stage.
dONKEY
Posts: 566
Joined: Mon Oct 15, 2001 7:00 am

Re: Shader swapping and lightmap swapping?

Post by dONKEY »

ok, I'm with you. Yes, that would seem a gud approach. I was wondering if I built a section of a level in Blender, light it in side that app and save the lightmapped images.
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Shader swapping and lightmap swapping?

Post by obsidian »

Triggerable shaders is how sock did a lot of the triggerable energy effects for Edge of Forever though it won't be able to trigger lightmaps unless you trigger between a shader with a lightmap and another shader with no lightmap at all. Triggerable shaders will only target a complete shader, not the individual stages within a shader.

Lightstyles will only flicker, they are not exactly triggerable. You *might* be able to target a triggerable shader to another lightstyle shader, but I have no idea if that will work, it could very well cause your computer to implode.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
dONKEY
Posts: 566
Joined: Mon Oct 15, 2001 7:00 am

Re: Shader swapping and lightmap swapping?

Post by dONKEY »

lol, I tried triggering a lightstyle shader but failed to make it work. Will need to experiment more as I may have done something wrong.
Quack
Posts: 82
Joined: Thu Sep 07, 2006 6:56 pm

Re: Shader swapping and lightmap swapping?

Post by Quack »

You can mimic a flickering effect without using lightstyles. Change the rgbGen identity of the lightmap stage to a desired waveform with whatever settings you want. This will work with shaders that use a regular $lightmap stage, or a precompiled lightmap stage. I'm guessing you can also add an alphaGen the same way lightstyles work.
User avatar
Eraser
Posts: 19174
Joined: Fri Dec 01, 2000 8:00 am

Re: Shader swapping and lightmap swapping?

Post by Eraser »

One problem though: lighting is applied dynamically to the gun on your hand as well. If you have point lights in your map, your gun will turn up lit brightly in the screen and not turn dark.
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Shader swapping and lightmap swapping?

Post by Silicone_Milk »

Yeah I thought about the lightgrid as well, Eraser. I don't think there's a way around that unfortunately :(
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Shader swapping and lightmap swapping?

Post by obsidian »

light_junior entities can do an averaged value so it won't look too out of place.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
User avatar
monaster
Posts: 532
Joined: Mon Apr 28, 2008 1:52 pm

Re: Shader swapping and lightmap swapping?

Post by monaster »

Might be a silly idea, but I had a thought about that "make a room dark/bright at once" a long time ago, never tested it though: If, and that's only if, your level progress allows it, make an exact copy of the room you want to be changed: one lit, the other not, and trigger a teleport to the shot light, preferably with a loud dominant sound so the teleport sound wouldn't be heard. As said, your level structure must be applied to that, so if you plan on passing this room again it could get tricky, but with this method it's possible to change quite a lot in that room (breaking parts of a wall without using lots of humble door-entity-tricks and so forth) and you don't have to cope with complex shader and photoshop stuff.
If you are caught on a golf course during a storm and are afraid of lightning, hold up a 1-iron. Not even God can hit a 1-iron.
-Lee Trevino, golfer who actually has been struck by lightning.
Post Reply