Quake3World.com Forums
     Level Editing & Modeling
        Shader swapping and lightmap swapping?


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Shader swapping and lightmap swapping?

The Afflicted
The Afflicted
Joined: 14 Oct 2001
Posts: 581
PostPosted: 08-27-2010 05:57 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Immortal
Immortal
Joined: 12 Mar 2005
Posts: 2205
PostPosted: 08-27-2010 06:08 PM           Profile   Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

The Afflicted
The Afflicted
Joined: 14 Oct 2001
Posts: 581
PostPosted: 08-27-2010 06:17 PM           Profile Send private message  E-mail  Edit post Reply with quote


I did think about this....or triggering swapping the wall textures at the same time.




Top
                 

Warrior
Warrior
Joined: 07 Sep 2006
Posts: 82
PostPosted: 08-27-2010 06:51 PM           Profile Send private message  E-mail  Edit post Reply with quote


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/shader_manual/triggerable-shader-entities.html




Top
                 

The Afflicted
The Afflicted
Joined: 14 Oct 2001
Posts: 581
PostPosted: 08-27-2010 07:21 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Warrior
Warrior
Joined: 07 Sep 2006
Posts: 82
PostPosted: 08-27-2010 07:44 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

The Afflicted
The Afflicted
Joined: 14 Oct 2001
Posts: 581
PostPosted: 08-27-2010 09:18 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 08-27-2010 09:30 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

The Afflicted
The Afflicted
Joined: 14 Oct 2001
Posts: 581
PostPosted: 08-27-2010 10:08 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Warrior
Warrior
Joined: 07 Sep 2006
Posts: 82
PostPosted: 08-27-2010 10:20 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44139
PostPosted: 08-29-2010 10:47 PM           Profile   Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Immortal
Immortal
Joined: 12 Mar 2005
Posts: 2205
PostPosted: 08-29-2010 10:48 PM           Profile   Send private message  E-mail  Edit post Reply with quote


Yeah I thought about the lightgrid as well, Eraser. I don't think there's a way around that unfortunately :(




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 08-30-2010 07:47 AM           Profile Send private message  E-mail  Edit post Reply with quote


light_junior entities can do an averaged value so it won't look too out of place.



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

The Afflicted
The Afflicted
Joined: 28 Apr 2008
Posts: 530
PostPosted: 08-30-2010 10:27 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.


Top
                 
Quake3World.com | Forum Index | Level Editing & Modeling


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.