Wednesday, 3 October 2012

I'm working with Quake 3 lighting and shaders!

This is the first project I've put serious work into in a long time (aside from playing League of Legends), and I must say, it's quite fun. I made a small map with less than 100 brushes and no seriously complex geometry to mess around with lighting. This originally started when I was looking up some random Quake-related stuff on Google, when I found a few gorgeous skyboxes that hipshot made. I don't know how old they are, but all they were were a series of groups of images, with no accompanying shaders. He said that anyone who wanted to use them ought know how to make their own shaders anyway, so I was determined to make my own shaders for these skyboxes.

After a little while, however, I ended up messing around with sock's industrial texture pack, and made a few shapes and set up a small area to test lightmaps and how Q3Map2 lights up the world. I have only one (technically two, if you count my second sunExt in my shader) source of light, so it's easy to tell what's right and what's wrong with the shadows being created, and it turns out that quite a bit is wrong with them, that I am trying to fix.

First off, they look like shit by default. I had read something on Smokin' Guns a while ago about hi-res external lightmaps, but I was more of a noob back then than I am now, and it made absolutely no sense to me. A couple days ago, it still didn't make much sense, but as I followed the steps and ran into my own troubles, it all began to clear up, and I found a more or less complete understanding of at least what the author was trying to teach (HERE is the post, btw). I began to get proper understanding, and with that, new ideas. I thought I could make some seriously ridiculous 1024^2 lightmaps, but that ultimately failed as my system has only a measly 2Gb of RAM (ugh). I also couldn't do 512, but 256 was still far superior to 128, and was more than sufficient for my needs, as GtkRadiant can only export lightmaps of a limited size anyway, so all I would be doing is wasting graphics memory on blank spaces, because 4/5 of the created lightmaps would go unused. However, for a lot of basic purposes, 256 lightmaps are FAR superior to 128 lightmaps, and will fix a lot of problems with pixely shadows, provided you also use proper filters (-super, -bounce, etc.). So this was one thing I learned how to fix.

There is another problem that came up, however, that I really can't figure out what to do with, and that is, simply put, dirty lightmaps. What happens with low resolution lightmaps is all the ugliness generated by the 15-year-old system is masked, because there simply aren't enough pixels to display all the crap. And 15 years ago, this was perfectly fine. But if I want to make a map with a 256 or 512 lightmap, a lot of jagged edges and random lines appear on the lightmap, where it should just be flat light. I tried a few ways of fixing this, all the way from insane amounts of supersampling to manually fixing it, but none were really efficient or workable. I'm still trying to fix it, though I have a few ideas as I write this. This was the second problem that came up, and has yet to be resolved.

The third idea I had was that I could finally make toggle lights. I'm fairly certain it's been done before, and since I am by no means the most creative or technically savvy mapper, there should be no reason that it hasn't been done before. But I've been waiting to find a way to do it for some time now, and this is finally it. Since external (the only way to get 256 or higher lightmaps is by using shaders, because Q3Map2 doesn't work properly if you try to use a higher lightmap size with -lightmapsize; this was added for Wolfenstein and ET. One of many advantages of using shaders, however, is that there are a lot of fun things you can do with shaders, starting with toggling them. You can press a button and change x shader to y shader. If you're using shader lightmaps, then you can switch x light to y light, and even to z light if you want to, though I'm not sure of the engine limitations for this. I still haven't worked with toggle shaders, so there will probably be a lot of issues that I need to fix, but I know for a fact that this would work. I could make it so that you flip a switch and a light turns on, or I could even make the light flicker on using a func_random (not sure if this is actually possible, though; will need to play with it). I can couple it up with triggered sounds to make lighting and thunder, and light up an otherwise dark room for a second or two. Anyway, this is what I'm going to be working on next, and is the third idea I had and the third thing I learned.

I really can't think of much else, and if anyone got this far, then good job. It's been a long time since I've made a blog post, as is the norm, and I like to write a lot, especially when I'm tired (I'm very much tired; it's 5:30 in the morning and I had a long day). I might make some amazing discoveries meddling with the Quake 3 engine, and if I do, I'll definitely write them here, because even if nobody reads it, it's good to put these things into words, and is also a good way to store it for later comparison and reviewing.

2 comments:

  1. http://q3map2.everyonelookbusy.net/shader_manual/apI.htm

    ReplyDelete
    Replies
    1. That's actually what I've been using as a sort of guide for skylights and all the appropriate shader parms. Obsidian is a brilliant fellow indeed.

      Delete