Setting up the World
One of the interesting decisions that a programmer must make at the start of a 3D project is figuring out what scale to work in, because the renderer doesn’t care. Perhaps you want to set things up so that nearby things are a unit away, and the stuff in the distance is 100,000 units away. Or nearby is 0.00001 and far is 0.0001. It’s up to you to pick a scale and to decide what the arbitrary units mean. Are you working in meters? Feet? Cubits? Fathoms? The effective range of an African swallow carrying a coconut? In Unreal Tournament, characters were around 160 units tall. (I think that the intent was for 128 units to = 1 meter.) In my day job, we work with a system where 1 unit = 1 meter.
While the renderer doesn’t care, it’s important to devise a system that makes sense to programmers and artists so that making content is as easy as possible. If you make something like 1 unit = 2.333 meters, then your artist making a 1.5 meter object is going to use a calculator all day and then spend their evenings plotting how they plan to conceal the body after they murder you. Perhaps 1 unit = 1 kilometer seems reasonable, but making furniture that’s 0.0005 tall is going to be really annoying.
In this program, I’ve decided to eschew using real-world measurements and adopt an arbitrary system of measurement where 1 unit = 1 window. A building that’s 20 units wide will have 20 windows across its face*. 1 unit will also equal 1 traffic lane, so a road 5 units wide will be 5 lanes. Is the typical building window really the same width as a traffic lane? I don’t know, but I’m betting it’s close enough to look believable from a vantage point over the city, which is how the place will be viewed.
* And by “window” I mean an 8×8 little square of pixels. I might have black lines in the space to make that square look like (say) two windows side-by-side, but it’s still a window as far as the program is concerned.
This scale will make it easy to track how I’m using land. I allocate space for my city: 1024 x 1024. According to Wikipedia, a U.S. traffic lane is 12 feet which works out to about 4 meters. So my city will be about 4 kilometers on a side, or ~16Km2 and have just over a million individual 4-meter plots that can be assigned as space for buildings or streets.
One thing you end up doing all the time in programming is subdividing things. Searching, sorting, and grouping things usually involves taking whatever stuff you’ve got and cutting the group in half until it’s found, sorted, or organized. Let’s take a group of 1,000 things and repeatedly divide it in half and see how it goes:
1,000, 500, 250, 125, 62.5, 31.25, 15.625, 7.8125, 3.90625, 1.953125, 0.9765625
Now let’s try it with 1,024:
1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1
But hey, we have the same number of numeric digits as we have fingers, and that’s pretty awesome, right?
So I take my city and mark areas of it as “streets”. The streets will be invisible in the final version, but I’m rendering them here as blue lines so I can see what I’m doing.
Now I place 20 big impressive skyscrapers in the middle area of the map. These are buildings with a large footprint and they range from 45 to 55 units tall. (And since units are windows, that’s how many stories tall they are.
Next I scatter around a few dozen smaller buildings. These are just as elaborate as the last batch, but these range from 25 to 35 stories tall.
And finally I fill in the remaining empty space with simple cube buildings.
4,752 buildings. The framerate is still shockingly high considering what I’m asking of the GPU. Still, I’m well under 100 FPS now and I’m betting this would be unacceptably choppy on low-end hardware. On the other hand, I have made no effort to optimize things yet. I don’t even know where the current bottleneck is. That will come in a later step, when I have a little more of the technology written.
I try turning off the dev background and the blue “roads” and seeing what it looks like. Disappointingly, the place looks a little… homogeneous:
Looking back to my reference pictures, I notice that each building seems to have its own color. This is either due to the color of the interior lights, the color of the interior stuff like walls and carpeting, or the tint of the windows. In any case, each building has a slightly different tint. I pick a narrow band of hues and apply them to each building:
It’s hard to see in this screenshot, but the overall effect is pretty striking. It adds another layer of randomness to the world, so that even if two adjacent buildings happen to be using the same texture, they’ll likely be different colors. COUNTERPOINT: Uh, in the middle of this screenshot are 3 buildings the same texture and color. Ugh.
I cruise around the city and take notes:
- I notice some buildings don’t look quite right. Yellow, blue, and white lights look fine. Green and red hues look wrong. This suggests that the real source of the color is the type of light used in the building. I do see some greenish windows in the photos (albeit very pale) but they look wrong in my simplified little world.
- The window distribution is just too uniform. As I pointed out last time, some buildings should have spaces of dark areas. Right now all buildings are unbroken grids of windows, and it just feels monotonous.
- Related to the above: I think some protruding ledges, rooftop A/C units, and other clutter would help a lot, particularly if those items were simple black silhouettes against all of these white grids.
- As some people have pointed out: The “mirroring” is quite noticeable in some places. The window pattern on the east side of every building will be an exact mirror image of the front, so that when you look at the northeast corner it’s like a Rorschach blot test. Same goes for the west and south walls. This is due to the cheap way I used to map textures onto walls. It was quick & dirty, and I thought it would be fine, but the mirroring is too obvious. How I think it needs to work is that I need to wrap a texture around a building, except that when I turn a corner I should step back exactly 1 window. This means the windows at the end of one wall will be identical to the column of windows that begins the next. Since those windows ostensibly look into the same room, their lighting pattern needs to match or it looks screwy.
- I don’t like the rigid grid of streets. Some angled or curving streets would help a lot, but that would add huge complexity to the program. Right now the fact that streets run perfectly along an axis without obstruction simplifies many things. I think I’ll live with this problem for now rather than over-complicating things.
We’re probably 15 or so hours into this 30 hour adventure. Still on my to-do list:
- Lights, both streetlights and lights on buildings.
- Car lights.
- The big one: Optimization. I’m eager to get to this step and find out what’s slowing the program down.
- All the fixes and changes I’ve mentioned earlier.
What did web browsers look like 20 years ago, and what kind of crazy features did they have?
Final Fantasy X
A game about the ghost of an underwater football player who travels through time to save the world from a tick that controls kaiju satan. Really.
What is this silly word, why did some people get so irritated by it, and why did it fall out of use?
Starcraft: Bot Fight
Let's do some scripting to make the Starcraft AI fight itself, and see how smart it is. Or isn't.
Marvel's Civil War
Team Cap or Team Iron Man? More importantly, what basis would you use for making that decision?
49 thoughts on “Procedural City, Part 4: City Planning”
Now Shamus, everyone knows that the African swallow is non-migratory and therefore would not be carrying a coconut anywhere.
To me, it already looks rather promising, with one gigantic caveat: Of all the big cities I know, none have a grid layout. In Europe or Japan it’s quite uncommon. But as a CS person myself I know what kind of problem that would be. Good idea to do it at a later time, possibly by designing “Areas”. You could slightly alter base height levels (hills), change grid orientation, put a river inside and some parks. All big cities have parks and such, and it’s really missing in your example.
You wanted to spend another 100 hours on this, right? :)
Also, since you use the generic OpenGL pipeline, you will be CPU-bottlenecked. Your GPU is probably idling without use of its shaders. Doing the same stuff but with shaders would considerably speed things up, probably by a few orders of magnitude. Since I have not even seen any source code (are you planning to opensource this at some point?) I’m guessing wildly, but at least it’s an informed guess. ;)
I also suggest more hues and/or coloured lights (of which you won’t be able to have many as the pipeline is hardcapped on that). This is going to be a problem. You should probably have static lighting and recalculate textures with those lights in mind (did I mention how useful shaders are?), as real lights will just not work on that scale.
Are you going to add directional lighting simulating the moon? Whenever I’m making an image, I always squint like crazy and if the forms become invisible, I need to change something. Trying that here, pretty much every building disappears. Or maybe you could use vertex lighting to make the street-level stories be brighter.
– Your contrast is too low, buildings are incredibly hard to distinguish. Colour borders more explicitly?
– Bloom! Night scenes with just a bit of it (A BIT!) look incredible. Not incredibly realistic, mind you, but incredibly good.
– Quad Trees. Your performance should skyrocket with those, especially if you make the grid a lot bigger.
– zBuffer tricks. Not rendering stuff that is not visible helps a lot. Rendering from back to front and deactivating zBuffer is also very useful. As your shapes are very simple, this should be doable.
I’m still very much enjoying this series!
I wonder, Shamus: would it be difficult for you to capture a video of the current state of the city-scape? I bet I’m not the only person who’s eager to see what it looks like as you “fly” around it!
Couple people have mentioned hills – could you plug the whole thing into a tuned-down version of your terrain generator to get base altitude?
Shamus, not sure if you’ve covered this elsewhere, but do you have any interest in hosting this code in a publicly available source control system, such as github (http://github.com/)? It might be instructional for people to watch the code evolve (and maybe play with it themselves). I’d certainly love to toy around with it – 3D programming is something that I know the theory behind (and have done some work on, with a toy ray tracer), but I’d love to see some code from someone who knows what they’re doing.
What if instead of a grid, you had streets just randomly terminate for several blocks, causing an interruption of the perfect grid pattern. This would be less complex than adding curves or angled streets to the design, and still break up the grid.
Ooo, Shiny! Nice work, Shamus, now just make it explode!
@Strangeite Who says it has to be migrating? Maybe its just flying around Africa. Or perhaps a strong desert wind blew into Europe and it’s trying to return home, or maybe it’s half European swallow and unsure about whether it should migrate or not.
The real question here is actually: “Why the devil is the blasted bird carrying a coconut in the first place?!”
Any chance of seeing one or two of your “reference photos”? A side-by-side might be interesting.
Looking very good so far! I am excited to see the finished result when you are all done.
While probably not big enough to be counted as a Big City, Salt Lake City in Utah has a grid layout. And not just the downtown area. Most streets in Utah follow a grid layout (except for neighborhoods, which can be annoying). Not only that, but the streets are numbered starting from the city center and going out, where “100” is roughly equivalent to a block. It actually makes navigating a thousand times easier than in other places, because you can always figure out what direction you’re heading in, and how far away you are from your destination, just by looking at the street signs.
Also, fascinating series, Shamus! I really enjoyed your terrain project too. Having some programming background, I can appreciate the complexity of your problems.
You should use a different sky for us to have an idea of the thing; reddish cloudy sky should do the trick to have the buildings pop out at us, i think.
Another quite important thing is that your buildings currently exist in a vacuum, sort of. What you should have when two buildings are facing each other is the amount of light coming out of one building should illuminate the building in front. That’s what you intuitively felt with the different tints, but i would suggest the calculation either of a whole texture luminosity (this building has 64 windows lit so it should lit its neighbors’ exterior by x% / distance), or a (albeit not in your time budget) more complicated light projection matrix that you would apply to the neighbors according to their height, etc, etc
Good job anyway!
maybe it would be useful to compare it with real panoramic shots of skylines which are available in the public domain.
I simply love this shot of Vancouver. Some of the stuff you can take away from that shot is that:
– There is some funky stuff on top of a few landmark buildings with colored lighting
– empty space containing parks trees, trainlines, powerlines, highways etc.
– different base color buildings (you could have a 1-pixel border around each window with a slightly different dark colour)
– not all buildings have been built! would it be overly complex to put in semi-built buildings?
– instead of curving roads, have kinked roads instead that “kink” for a few diagonal boxes. Have a program randomly “blot” a few hotspots on the map from which roads are more likely to kink away from the centre of the blot.
I don’t think the grid is a problem. Many American cities are grids. Perhaps most of them. Chicago’s loop is a very rigid grid, and the rest of the city conforms strongly to a grid pattern even in areas where it does not make much sense, such as along the river or lakefront. The interstates ignore the grid, and a couple of streets run diagonally from northwest to southeast, breaking things up a tiny bit. But otherwise it’s just like asterism described for Salt Lake, only bigger.
A map of New York shows only a handful of streets that don’t conform to the grid.
There’s nothing wrong with a grid layout. I think your problem is that it’s too perfect.
Manhattan has a very regular grid, but if you fly over it at night and pay attention to the streets, there are a few things you notice:
1) Central Park. Every city has some amount of parkland.
For your purposes, a small park is just a segment of a block that has no building. A large one like Central Park is an area of multiple blocks that has neither buildings nor car lights (once those are implemented), because streets don’t go straight through it.
2) The outline. The streets may be a grid, but no city’s outline is a perfect square. Either border it with an irregular curve, or just “soften” the edges by reducing building density based on distance from the center.
3) Broadway. One big diagonal street that cuts across part of the grid. If you can implement diagonals at all, you only need one or two to add a lot of plausibility.
I’m enjoying reading these, and seeing the progress. ;D
I demand a public code repository, or I shall taunt you a second time.
R4byde: The question of why the swallow is carrying the coconut does not bother me. But when you consider the simple question of weight-ratios it become obvious that the swallow must be receiving help from another swallow in order to be laden with said coconut. Possibly by using a strand of creeper.
Now the real question is what we as humans are going to do now that swallows (African or European, it matters not) are using teamwork and rudimentary tools? It is only a matter of time before they wage war.
Thirding Salt Lake. Having lived both in Utah and Alabama, I’ll take the grid over the spaghetti bowl for navigation any day. (And numbered streets over named streets.) It may be a bit boring, but it’s a whole lot nicer to live in.
Elevation won’t help much, since the buildings are already varied in height, and we’re looking at their tops, not their bases.
“Zones” might be a good way to go, especially if they are more or less self-contained with irregular borders (which could stagger the grid a bit here and there if a zone is offset by a fraction of a block or picks up a slight rotation from the cardinal directions). Each zone can have an identity based on internally consistent shapes (say more “apartment buildings” in Zone B, and more “office buildings with blue lights” in Zone C). That could give a sort of “organ” structure to your city, a subtle layer of organization to the mass.
Likewise, making the building size scale down a bit away from the city center (or a bounded radius from your key buildings) could be nice for a differently scaled city.
It probably looks a bit flat because your sky is totally black. Maybe a very dark blue or grey would be more night like. Even at night there’s a fair amout of ambient light and if you have a full moon there’s a LOT of ambient light. Leave the buildings black and you’ll probably have the silhouette effect you’re looking for. Still – for 15 hours work it’s looking fantastic. Well done man!
Would it cost much effort or efficiency to create a set of smaller but more varied window textures, instead of using different parts of one large one?
Say, 30 or 40 textures (and perhaps their 180 degree rotations) sized no larger than the maximum building size? Then with some of those textures, you could make the windows vary quite a bit more – say, double-width ones, narrow ones, extra-tall ones, vertical channels, double-hung ones (for smaller, apartment–type buildins), floors with no windows, etc.
Hi Shamus. Amazing!
What about parks, squares and plazas??
I think they would break up the monotony a bit and they can stay squares to keep things easy?
I’ve been living in a wonderful little city in Northern Europe for the past two years and the abundance of green spaces really does make a huge difference compared to living in a typical American city.
As I see it, the real question is, exactly why are these tool-using swallows trying to move coconuts around in the first place? It’s not like the can eat them, or like coconuts are any use in nest-building. Unless they plan on dropping the coconuts onto hard rocks to smash them open. Or possibly they’ve already declared war, and plan on using the coconuts as weapons …
Just wondering, perhaps the streets could vary in width. Some twice width, one or two thrice?
It’ll still be a grid, but might just create a little sense of non-uniformity. (It’s always the little things that matter.)
As for the city layouts, I’ll agree that the Salt Lake grid makes navigating a world easier. Downtown Sacramento is a bit similar, with numbered streets in one direction and lettered in the other. Of course, if you get much beyond the central area, it starts to descend into the usual gridless chaos.
On the numbers thing, I’m not a programmer, but rather am in hardware (silicon level), and those numbers work best for us simply because all the circuitry works in binary. I’m sure most here are at least familiar with bits and bytes, well each bit is one signal with two states, either on or off. Put a bunch of signals together and everything just naturally adds up in two’s.
Looking at the one decent picture I got from my hotel window in Tokyo (here, from this location facing north), I see that a lot of what visually separates the buildings is colored lighting coming from street lights and signage. Varying the brightness of different sides of a building (possibly by designating some streets as “main” and brightening/coloring everything that faces them) might be useful.
While I laud the above commenters for not rising to the flamebait, I shall leave a passing factoid of relevance.
The Babylonians and their inheritor cultures (the Assyrians, etc.) used a base 6 system for a similar reason programmers use base 2 and base 16. Most Babylonian arithmeticians were astronomers/astrologers, and thus had to have an easily divisible number system in order to record astronomical data. This tradition survived in part by Ptolemy using Babylonian astronomical data to write his Almagest, which was then used in medieval universities to practice angle geometry, leaving us with the system of 360 degrees per revolution, 60 minutes per degree, and 60 seconds per minute.
Not exactly flaming material, but I get the feeling readers here like this sort of info.
Interestingly, Jian’s photo shows pretty much only yellow lighting. There’s some very nice depth fog in there too that you might want to consider.
It looks pretty damned good so far.
Unsolicited advise follows.
To me, the majority of the tints you are using are still too “blue”. If/when you get around to emulating the orange glow of ground-level sodium-vapor street lamps, I suspect the bluish tints will begin to stand out. And it may be a nightmare, but finding a way to procedurally tint blocks of windows (beyond the baseline color you’ve already applied) within a single building will do a lot to break up the monotony. Not every office within a building is lit the same. The average cube-farm is lit with cold fluorescent tubes while the boss’ nice corner office has warm yellow torchieres and desk lamps.
I think green tints might work, but it has to be very specific shades of green. I know I’ve often noticed buildings with one red column (unlit stairwells with red glowing exit signs on each floor).
The other thing, specifically for the buildings with the pyramids on top: If a building’s going to have one of those, they’re going to light the heck out of it. If that’s what you’re talking about in your #2 point, I think it’ll help a lot.
But let me also add to the chorus of “awesome work there Shamus!” I love it!
On the contrary — I feel that (after having been dropped onto a rock to break it open) a coconut would make for quite respectable nest-building material.
I can’t presume to speak for Shamus, but I suspect this code will be ready, possibly in it’s different iterations, when he has finished it all.
If I were doing something like this, I would keep my code close to the vest for fear of someone “working ahead”, taking the project in some other direction before I was finished and then linking a finished product. That would have a real impact on my motivation to finish the damn thing myself.
Me, I admire your ability to taskmaster yourself, Shamus. I have plenty of projects on “the back burner” which may not see the light of day unless I can sit down at a computer and write code, rather than playing games by other people. I already have a 40 hour job but it involves no coding, and i have that itch sometimes.
one thing you need to do is decide where the city ends.
at some point, you’re going to hit a river, the ocean, ect, and there will be a distinct line where the buildings stop
that raises a good point — why fill every gridquare with buildings? Cities are not constant — there are gaps with short buildings, parking lots, billboards
actually billboards would be a good thing to add, if you can think of a good way to do them procedurally without adding too many polys.
also, many buildings are reflective surfaces.. can that be added to some without breaking the rendering engine?
A suggestion regarding street map generation:
Your current setup doesn’t seem to be attracting too much praise, and I don’t really like it either, so I’ll say one of the things I thought of when reading your post on building generation.
I saw the image that had the squares adding to the grid, and I thought that was supposed to be a quick, sloppy way to generate a street-map, until I saw the end result.
Perhaps you could amp up your rectangle-adding process to come up with an oddly shaped, not quite uniform but still simple grid street map?
I know that’s what I plan to try when I get to that part with my zombies…
And after seeing that panoramic thingy up above, I’d say that your building lights are too white-colored. I can barely notice color differences in your screenshots, and the windows in the photo above has lights that all look very yellowish, while yours are all very bright, and not-yellowish.
Also, to add to your idea of having AC units and lights on top of buildings, I suggest that you add billboards, as a previous commenter suggested, and add huge signs to the fronts of buildings with lights shining up at them, and some up on top of buildings as well. You could probably make the program just randomly generate some company names by slapping random names or words together and adding “Co.” or “Inc.” or “Studios” at the end or such, then just make the sign big bubble letters and color it. It would be much more interesting, and probably make the city much more credible.
I notice that in your screenshots, the closer buildings look like they’re coated with TV screens. Not quite sure what it is about them that has that effect, but for some reason… ah! It’s ’cause the more dimly lit windows look like they extrude from the building thanks to the dark furniture blotches in them. It makes them look like bumps instead of flat windows.
I wouldn’t worry too much about homogeneity. I think you’ll be pleasantly surprised by the variation imparted by the color splashed from street lights (most common: old school blue-white mercury vapor, true white color corrected mercury, orange low-pressure sodium vapor, pink-orange high-pressure sodium (lately most popular)).
PS The red aircraft warning lights on top of the taller buildings will also help.
Ah! Know what you’re missing? Parking garages! And maybe a few parking lots, too (especially when you get a certain distance away from the center). Some of them (both garages and lots) should be attached to specific buildings, and some should be freestanding. I see some green bits that might pass for parking lots, but I don’t see anything that really looks like a parking garage.
Yar Kramer: I, for one, welcome our new swallow overlords.
EDIT: I apologize to everyone actually trying to have a conversation on programming; but, Shamus started it.
Just to add to the general chatter about road layout:
Western US cities are far more frequently arranged on grids than Eastern US cities. This is largely due to the fact that most of them were founded in modern times, with planning going into them rather than growing organically. Very few cities in Europe are younger than 200 years old, so most are built on designs that don’t keep cars, or even carts, in mind. The US, on the other hand, is much younger, and so the problem of street navigation is often solved by building on a grid, rather than having random ambling streets.
So as long as this is a city west of the Mississippi river, you probably don’t need to put too much thought into making it less grid-like.
Have you seen the stuff the guys from Introversion are going for their Subversion game? It’s amazing.
This is a fascinating series, Shamus. You mentioned you needed to work on the sky eventually. I don’t know if you mean “atmospheric model” or “how the overhead sky appears” so I’ll address them both.
Atmospheric: In my business (which involves visual perception in a military context) a lot of effort has been spent developing a realistic “sky model” which is really an atmospheric transmission model that accounts for sky glow, refractive scattering of sunlight and moonlight, and atmospheric “bluing” where things in the distance get more hazy and take on a bluish tint.
I remember being impressed by the photorealism of the first Shrek movie, but disappointed that they got lazy with their sky model: objects far off in the distance looked far too clear. Kinda spoiled an otherwise great movie for me.
I don’t know much about video card capabilities, but if you have the capability of adding a slight amount of haze to the atmosphere without sacrificing much frame rate, that would do a lot for the realism.
Overhead: Most games seem to use a bitmap for the horizon that includes the sky. You could do this; however, if you’re planning a clear sky, your buildings need some exterior illumination from starlight and moonlight, not to mention self-illumination from all those lit windows in other buildings. An overcast sky eliminates the problem of having overhead illumination sources — all you need is ambient light, and clouds that appear illuminated from the city lights below.
Looking forward to how you address your sky problem.
I haven’t read all the comments, but they all seemed to be on the topic of coding, and my comments are from the perspective of a photographer… So hopefully, I won’t be repeating what everyone else is saying…
First: Color of lights… Large buildings (skyscrapers, office high-rises) will have fluorescent light. Fluorescent light is green, but those buildings won’t be green. Why? Because green light makes people look, and eventually feel, ill. So no one makes unfiltered fluorescent lights for offices or homes. Probably someone makes them for photographic applications (i.e. if the filtration is intended to be added later.) Depending on the filtration, fluorescent light can be any color. If you are photographing this sort of scene, normally you would use daylight-balance, which would make everything look a bit yellow-orange. Fluorescent lights would tend to appear very subtly orange, or slightly magenta…
Smaller buildings (apartment high-rises, individual homes…) will tend to use tungsten, which, going on the assumption of a daylight balance, should appear very warm. orangeish-yellow all the way into reddish-orange.
I wish I remembered this better. Anyway, streets should have streetlights. Those would mostly be bright pink or orange. I can’t remember which type shows up which color.
For added realism, try to add a few random windows (or better yet, floors) which are not the same color as the dominant color in a building.
Next: Sky. I was going to object to the person who suggested that the sky be blue, that it should be a night scene… But the truth is, you want to go to any length necessary to keep the eye from expecting to see detail in the walls of the building. A silhouette effect will keep the eye from any expectation of seeing detail in the shadows. If the sun is just peeking from above the horizon, and the sky is pink & orange…
Only problem there, is it only works when the sun is in frame. If you rotate the camera to another angle, it will create the expectation of texture. Ah well. Still working on that. If you have mountains in the distance, the whole city might be in a valley… In shadow… No sun visible except when the camera is raised above the height of the city… :)
I don’t profess any experience with procedural generation (and really would appreciate references to pick up and learn), but I recommend this paper for street generation.
I do find it very intriguing – it starts with large highways and expressways and goes down to ring roads and then small streets.
I’m now reading this while at work. In my cubicle.
You made me turn my head and look at our windows and how they’re spaced.
I don’t know if it’s typical, but it’s pretty much the same width as a traffic lane. :-)
Hey, Seamus, great series!
Not to be pedantic, but the bit about the number system based on 10 being messy isn’t quite true, though. The reason we use base-2 numbers in programming is because early transistors which were (and are) used in microprocessor switches only had 2 states: on or off. Even that isn’t quite true – it’s just that’s a lot easier to use the on/off states in a transistor than to use its current flow for logic gates.
The reason for digital rather than analogue is that you can take a noisy digital signal, very easily strip the noise off and reasonably expect to get the exact original signal back. Even with the most sophisticated noise filters, this is simply impossible for an analogue signal.
True,but digital signal does not have to necessarily be in base 2.As long as you have clearly defined and spaced values,you can use other bases.In fact,one of the proposed future advances for computers may be an expansion to a higher base(most likely 16),if memristors prove as useful as theorized.
Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*
You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>
You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?
You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.
You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!
You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>