Skip to main content
GameDev.net gamedev.net
🔒 Locked

Large bitmap world

Started by Herr_O Sep 7, 2003 at 3:44 AM 0 replies 1k views
Original Post
Herr_O
Herr_O
Hello! I''m thinking of starting to write a small game with RPG elements, something like the old game Moonstone on the Amiga. The game area will be a large bitmap put together by a bunch of texture mapped quads (going to use OpenGL for rendering). The trouble comes to sorting / occluding. First I thought I could use a pre-fabricated z-buffer, but then I realized that the accuracy would be too poor with a large picture (say 2000*2000 pixels). Then I thought of sorting different objects such as trees, stones etc. with "hot-spots"/"zones". What do you think of this idea? When the player walks into a zone, it will activate an associated object to be rendered on top of the player so the player gets occluded by the tree or stone. You could also use the same technique to get collision detection and entity selection etc… Good / bad? -----------------------------
Sometimes a Guru meditation must be followed by a Vulcan neck grip.
Wyrframe
Wyrframe
If we''re remembering the same "Moonstone", that game was quite large... I hope you''re not going for that scale.

A prefab Z-buffer''s accuracy won''t depend on the size of the picture, but the range of depth that you''ll be using.

Let''s think this through... let''s say your camera is looking straight down the negative Z axis at your world quad, which is laid in the XY origin plane. Because we will need a number, let''s put the camera at (Xc,Yc,20), looking at (Xc,Yc,0), with the "up" vector (0,1,0) (higher Y values will be at top of screen).

I chose 20 for "20 meters". Let''s keep things real, here. You want to see a wide area, but not too much.

Now, the first thing we do each frame is draw the colormap of our world quad, with Z-write ON (establish our "zero altitude" plane), and Z-check OFF (ignore the previous frame''s Z-buffer).

Second, we draw the prefab Z-buffer of our world quad. This is done differently depending on what API you end up using. Some abstraction APIs (ie SDL) won''t let you do it at all. Preferably, you should be able to write to it like a normal render, with the slightly different render target. One thing for certain, you''ll want a bitdepth higher than 8 bits for your prefab Zbuffer; let''s go 16-bit at least. Something to keep in mind is that the camera height and position will change what you want to choose this as, unless you can find some way of doing a "this +/- the prefab map" render.

Next, we draw objects in the world. If you are using sprites, these CAN ALSO have their own personal prefab Z-buffers, believe it or not. What you do, is render their prefab Z-buffer first, with Z-write and Z-check ON; if the new value is further away than the existing, do not make the write. Then render your "texture" of the sprite with Z-write off and Z-check on. If you want plain and flat sprites, ignore the z-buffer write. If you want to use 3D models, go ahead; just render them and go.

Now, I''ll explain some of my reasoning and choices.

The camera; to avoid some trippy artifacts, you must put the camera directly above the world. Why? Because you want "altitude" in the world, and you want obscuring to happen because some things (or rather, some pixels) are "closer" to the camera than others. So, go study some SNES RPGs, and see how, despite a flat and planar tilemap, trees look like they''re standing "up".

The prefab Z-buffers; when you render the world, you don''t want to store the actual camera-to-pixel Z value; you want the physical Z (height) value of the pixel in the world. Configurable raytracers are your friends. You must take this "actual Z" value, and convert it into an appropriate value for the Z-buffer you''re using; that is, a 16- or 24-bit floating point number, with the camera''s height being at Z-buffer value 0.0

If you have more questions, ask the people in the "Graphics Programming and Theory" forum on these same boards.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.