April 15, 2010

Nontechnical Explanation of Color in 3D Games

Actual pixel value sent to the pixel on the monitor is, in a typical 3D game:

Texture value * Light value, where each value is a scale from 0.0 to 1.0.

The scale measures from black to white. Or rather, from the monitor displaying that pixel as dark as it go at 0 to as bright as it can go at 1. Different monitors have different maximum outputs, but because of how our eyes work we don't actually notice this as anything except "better contrast". The fact that the colors are recorded as relative to the amount the monitor can output is the cause of problems when designers are making art to be displayed on different monitors, or for print, or whatever.

(As opposed to a 2D game which typically merely blits, i.e. copies the values directly from a sprite image, which is actually analogous to a texture, in a way.)

Thus a 'fully lit' scene will display exactly what the texture is (texture value * 1), while a 'fully dark' scene will display black (texture value * 0). A black texture will always show up as black, and a white texture will show up as whatever the light hitting it is.

Texture value is the value of the pixel of the texture map at that position on the screen, based on the position of the polygon it's mapped to, the way it's mapped to the poly, occlusion, and so on. This is all going on in the GPU is is the majority of the math needed for rendering. You've got to worry about how the poly is rotated, scaled, skewed, and so on. But basically eventually you get a result that says, "This pixel is pulling from THIS spot on the texture image." So this is what I mean by it being analogous to blitting: You've got an image, and you want to get a pixel it from it and draw it at the right spot on the screen.

Light value is the amount of light hitting that spot on that poly from lights placed in the scene. Each light object has it's own value from 0 (no light) to 1 (max light) Note I don't say 'black' and 'white', because that's technically not what's happening.

The lights are all casting some amount of their value on that pixel, usually based on distance. In nature, this falloff has to do with the brightness of the light and the inverse-square law: The intensity of illumination is proportional to the inverse square of the distance from the light source.

This law doesn't actually work though because the value of the light is NOT the luminosity, which I'll explain later.

Rather, the typical game physically sets a radius for each light (set by the level designer, actually) and makes it so the light falls off linearly (although often it's a square falloff) until at the max radius, it's 0. So at the center of the sphere, the light amount if equal to whatever the light is set to, let's say 1,0.5,0.5 for a pinkish light, and at the surface of the sphere it's 0,0,0.

So, the game is finding how much each light in the scene is casting on our pixel, based on each light's distance and value. Once we have a list of all these values, simply add them all together! This part is easy, and even naturally results in lifelike color blending. A red 1,0,0 light and a blue 0,0,1 light will combine to end up with a purple 1,0,1 result. This is why colored lighting was a very early bullet point feature of 3D games.

Now, whatever value you have is the total amount of light being cast on that pixel, which can be anywhere from 0 to infinity (assuming you can place anywhere from 0 to infinite lights). We can't actually store a value on that scale though, we want a scale from 0 to 1. You could set 1 to be whatever the highest value in the scene is and normalize everything else based on that, OR you could simply clamp at at 1,1,1. This is what most games do. Thus, in the level designer's mind, lights will never add together so much that they make the texture render brighter than it is.

Thus if you take a pixel, and its got 0.5 light coming from light A, and 0.75 light coming from light B (after distance check), they'll add together to 1.25 light and be clamped to 1, and we say that that pixel is "fully lit" at 1. In practice it might even be rare for a pixel to ever be fully lit though. It's usually some distance away from all the lights in the scene, and they're often not even max value lights. This is why in, say, Quake 2 if you disable lighting and let everything just be based on texture value everything looks really bright and stark. You're not used to ever seeing those values.

But basically nothing will ever become so bright that it goes outside the range of values possible for the monitor to display.

March 22, 2010

West Marshes - Magic Items

Magic items are made using "shares" of arcane components. These are things such as rare, magical metals and acids, or extracts from magical creatures. Powdered unicorn horns, dragon's blood, basilisk venom, things like that.

These materials have magical energy which is transferred to, and shaped by, the ritual caster in the creation of a magic item.

Each level of magic item needs a certain amount shares. There's no easily explained progression for the amount it needs, other than it sort of increases not quite by half from the amount needed for the previous level.

One share costs 50 nobles. This is both the price the players pay when buying it from others, and the price they can sell it for.

Residuum weighs more than as given in the PHB. One share of residuum weighs 1/50th of a pound, or about the same as two cents (which are, in turn, the size and weight of modern US pennies). This means a pound of residuum, 50 shares, is worth the same as pound of gold, which is worth 2500 nobles. Gold and residuum are both rare and valuable, and both are used as trade currency when dealing with especially large amounts.

When you disenchant a magic item, or use a ritual to convert magical components into residuum, you get it as small, 1/50th pound lumps, rather than powder. These lumps are often minted into coins, slightly larger than a rupee and worth half a crown. When buying ritual components (something only possible in the largest of cities), you're much more likely to find people (a person, usually) selling residuum coins rather than raw materials.

When reading these prices, keep a few things in mind: two gold coins (200 nobles) is more money than many master craftsmen make in a year. Collecting enough magical components to create a level 15 magic item would be hundreds of thousands of man-hours (assuming non-adventurers) of dangerous work, hunting magical creatures or harvesting rare substances from dangerous areas. Wealthy nobility and kingdoms might be able to afford magic items for themselves, but certainly no army would be equipped with issued magic items.

Adventurers are very lucky indeed, to find such fantastic treasures.

Level | Shares |
Value | Shares From Disenchant
1 5
250 1
2 7
350 1
3 9
450 2
4 12
600 2
5 14
700 3
6 25
1,250 5
7 36
1,800 7
8 47
2,350 9
9 58
2,900 12
10 69
3,450 14
11 125
6,250 25
12 181
9,050 36
13 236
11,800 47
14 292
14,600 58
15 347
17,350 69

March 19, 2010

West Marshes - Coinage



From left, clockwise: A noble, crown, rupee, and cent. The cubes are standard d6s, for reference.

I'm throwing out the 4e coins basically entirely, because according to the DMG the players should have found something like six million pounds of gold (as a party), in addition to magic items, by the time they reach Paragon tier. This is the point at which they're supposed to be "starting" to become famous and interacting with things on a national level, such as commanding or ruling nations.

That outrageous number is for two reasons, one of which is that coins in D&D are described as extremely heavy compared to historical coins. The other reason is because the amounts given for treasure and the cost of magic items are mostly arbitrary, and tend to favor handing out huge piles of gold or platinum as a rule. The prices of everything else are scaled to match.

So in my world, as minted by the Empire of the Unnamed Kings, to which Blanche-Piste belongs, there are four coins.

The base unit is the "noble". This is the second largest coin, 30mm in diameter (about the size of a US half dollar) and 0.03lbs of near pure silver. One of these coins is the equivalent, usage-wise, of a modern $20 bill: larger than any single transaction you're likely to make, but accepted pretty much anywhere and easy to make change for.

The second coin is the "cent". This is a third largest coin, 20mm in diameter (about the size of a US nickel), worth 1/100th of a noble, and is 0.01lbs of near pure copper. This coin is used to make change or for small transactions among commoners, it is something like a US $0.50 or $0.25 coin in the mind of the average person.

The third coin is the "rupee". This is the smallest coin, and is worth 1/10th of a noble, or 10 cents. It is 19mm in diameter, smaller than a cent (about the size of a US penny), and is not pure silver, but rather an alloy of silver and copper, weighing in at 0.006lbs. This is the coin most commonly used among commoners, it would be equivalent, to something like a US $1 bill.

The last coin is the "crown". This coin is 38mm in diameter (about the size of a US silver dollar), the largest coin, and 0.04lbs of near pure gold. It is worth 100 nobles, and thus most commoners will rarely handle more than a handful of these per year, if any. It is difficult to make change for, and used mostly among merchants for large transactions.

Larger transactions, such as gifts between kingdoms or purchases of entire regions, are made using silver or gold bars.

1 pound of cents/copper: 1 noble, 100 coins.
1 pound of rupees: Roughly 16 nobles, 166 coins.
1 pound of nobles/silver: Roughly 33 nobles, 33 coins.
1 pound of crowns/gold: 2,500 nobles, 25 coins.

To put it into real world terms:

If one were to go out to lunch in an average tavern, you would go in with 1 noble (a silver coin), buy a meal, a drink or two, and expect to get back a rupee or two as change.

Crowns, on the other hand, are very rare; try to imagine something like a $1000 USD bill: the amount is something you might expect to pay for certain things, but rarely will you need to actually handle crowns for transactions. You're more likely to just use 100 nobles.

All prices are measured in nobles. When a person sees a crown, they don't think of it as "one crown," but rather, "a hundred noble coin." A rupee is thought of as, "10 cents." The decimal system is in use, so one might see prices such as "23.50", which would be 23 nobles and 50 cents. If you gave the merchant 24 nobles, you would get 5 rupees as change.

The average town-person will carry maybe 1-10 each of nobles, rupees, and cents on their person.

March 4, 2010

West Marshes

This is a general overview of my D&D campaign, mostly for the benefit of my players.

Setting: Orid Kajeth, the region to the east of your kingdom, across an inland sea. The area was formely settled by a tiefling kingdom, long ago, but they migrated away because the area is very dangerous and was not considered valuable. It is most mostly swamp and marsh, criss-crossed with slow, lazy rivers. The weather is hot and humid year round, with frequent rain in the summer.

Recently (as in nearly a century ago), the dwarven kingdom to the east of Orid Kajeth starting mining in the hills of the region, and found rock salt. Your kingdom established the town of Blanche-Piste to be able to import this resource. The town's name means "White Road", named for the chief trade good: white gold... salt.

The town is only 50 years old, and it was built almost entirely at once by an expedition sent over for the purpose. Now it acts as a port for traders, who come into town, drop off their goods, and take salt. Then merchants in Blanche-Piste take those goods to the dwarves by barge, and trade for more salt for next season's traders. This process happens over about a month, each season except summer, when it's too stormy in the sea.

However, the area is still very dangerous. Your kingdom has sent over soldiers of fortune to help explore the area, guard the barges, and defend the town if needed.

Campaign Structure: We already have ten players, and I'm still pushing for more. This is already twice the size of a normal party, but the idea is for smaller groups of those players to schedule games whenever they can, with whomever they can, instead of everyone committing to a weekly session. Some of the players are playing characters who already live in the town, some are characters coming by ship as a soldier of fortune, and some are drifting in for other reasons.

There's a world map divided into hexes. Each hex is about 2 1/2 miles across, and represents one "area of interest". For each session, the players will decide on a hex, travel to it, explore it, and return to town at the end of the "day". Then next session is free to any other combination of players, who can choose another hex or the same one as they please.

Each hex has a certain type of terrain and certain denizens. These will not be adjusted to match the adventuring party. If you're level one, and stumble across the red dragon: run. But as you go, you'll get a feel for how the wildlife and monsters are dispersed. Many of the hexes will not actually have combat, but require exploration and puzzle solving. You will often find things that help you explore other areas.

Each character will receive a flat amount of XP for each time they go out and explore, plus bonuses for overcoming certain situations. XP is not awarded by headcount of defeated enemies.

Roleplaying: All players are encouraged to visit the IRC channel #lovely-lodge on EsperNet. This channel represents the tavern in Blanche-Piste that becomes the de facto headquarters of the adventurers in town. This is where characters will talk about events that have occurred, speculate on what they mean, and plan their outings into the wilderness. This roleplaying is encouraged to take place at any time between sessions, representing the characters hanging out in town between days of exploring.

Players are encouraged to keep a map of the world, to mark where they've found things, or areas to avoid. Many of the "dungeons" will be too large to explore in a single session, or might require higher level abilities and items to get into the deeper places, even if the dungeon is in a low level area. It will be worth your time to keep note of any doors you haven't been able to open, pits you haven't been able to cross, and things of that nature.

House rules:
Sight and Cover:
Instead of tracing from every corner to determine line of sight and cover, we use Maptool's LOS, which traces from the center. This means it's harder (impossible?) to shoot around corners, you can see less of the map than you would "normally", and it's easier for creatures to hide from each other. You're less likely to gain cover by standing behind a wall (instead you'll block off your view of the battle entirely), so keep that in mind and look for low walls, furniture, windows, etc. to hide behind instead.

If Maptool covers a target's square by half or more, they have superior cover from you. Half or less, normal cover. Usually, lines of cover will radiate out diagonally from where's your standing, while orthogonal will be either clear shot, or entirely hidden. That's what happens when everything is a grid!

Light:
All bright light sources now cast dim light in the outer 1/3rd of their radius. Creatures with lowlight vision see that dim light as bright light, and see an extra 50% of the radius beyond that as dim light. Effectively, they see all light sources expanded by 150%, but what seems dim to you still counts as dim light when determining concealment. If you have lowlight vision, keep in mind that what looks dim to you is total darkness to creatures with normal vision. Keep your allies informed, or your enemies confused, appropriately.

Perception & Insight:
I'll be making these rolls secretly. Additionally, if any player notices something using their passive checks, I'll inform that player with a private message, and it will be up them to have their character tell their allies in character. This means, when a character says something, they might not just be making it up, it might be because I told them.