slew of questions [easy ones though ;)]

Okay I’ve been working on a project [my first openGL encounter] for a few months now, and have run into a few major questions about the ‘right way’ (is there EVER one? :P) to do some different things in openGL, so here goes.

For all intents and purposes, I’m working on a deformable landscape engine, that uses uniform length quad shaped polys in rows/columns, with a user defined size of the map… so it could be 100 x 100 or 500 x 500, I want to do my best to keep this open.

Right now, I’m keeping all of my data as what I believe you call an ‘indexed array’, keeping the data in a matrix and referring to it with a matrix of pointers (because some points are referenced as parts of 2 or 4 different ‘spaces’, maybe this ISN’T indexed arrays?), and I’m loading in the map and building it into a large datalist. Also, I’m sorting my textuers to do drawing one texture at a time.

Now, here starts the problems!! First off, I was reading a thread that described a similar program and Gorg mentioned that using a datalist for that was a bad idea, because it reduced what you could do with culling. I thought this was the case, but I do not know what a better way would be? I’ve heard of stuff like “view frustrum culling”, but the only times I’ve read about it, it was just way over my head and didn’t explain what was really happening. I’m sure there are some other ways?

Another question, datalists are kept in COMPUTER ram as low level video card instructions/whatever, NOT on video ram - correct??

Another sub-issue here, I’ve been reading a lot on nvidia’s site and all over about the stencil buffer (does EVERY EXAMPLE use that stupid dinosaur?? :P), and I’ve got a couple of questions about it. First, in that dino example they have it casting a reflection on the floor – i know they draw either the dinosaur or the floor with alpha?? Which one is transparent, which is drawn first?? I can’t quite get the same effect. Also, with shadows and the such I follow the examples and the theory alright, but I’m confused when they talk about specifying a matrix to use / using glMultiMatrixf(); I understand the syntax I just do not understand what this is all about and how it’s used to do anything??

And lastly, when a scene seems to have a light source that shines places (maybe this is called radiosity light? I’m uncertain), is this effect generally caused by ‘casting light’ or by ‘casting dark’ – is it just shadowing everything BUT a specific part or is it really somehow ‘casting light’ ?

TIA to anybody that responds, even posting a link to an example of anything here or leaving a quick note will really go a long way, I’ve just reached a lot of dead-ends and a lot of the older threads leave me a little bit confused.

-oliver

I’m sorry to spam, but I know somebody reading this has to have at least something they can say about one of these topics. Please respond if you can :stuck_out_tongue:

–stumped new gl programmer

To answer your first question, in order to efficiently perform view frustum culling, its best to store your landscape (or parts thereof) in a tree structure, be this a binary, quad or octree. Often rejecting a higher level node in the tree will automatically enable all children to be rejected also. Plenty of research\examples of this available - try to google for it!

For a terrain engine of that size, you can get away with brute force rendering. That is, draw everything and dont care about what’s visible and what’s not. A 500 by 500 sized terrain may be a little bit large for brute force rendering though.

When you say data lists, I assume you mean display lists. There’s not such thing as data lists in OpenGL. Never mind. Display lists can be good for a somewhat static landscape. You can split your terrain into squares of 30-40 blocks per side, and compile each block into a display list. When the terrain is modified, you can recompile the affected display lists. This assumes you don’t modify your terrain too much/often. Each display list can go through a larger frustum visibility test, and not draw it if it’s outside.

How and where a display list is stored is an implementation detail, and you will never know, nor should you care, how and where it’s stored. Let the driver decide how and where to store the display list.

For the reflection, why not look in the source? The only good way I can see, is to first draw the reflected dino, then blend a transparent floor over it, and then draw the “real” dino. But again, if you have the source, you also have the answer.

glMultMatrix is used to upload a matrix to OpenGL, and multiply it with the current matrix. The program probably generates a reflection matrix, reflecting an object in a given plane. If the plane of reflection is the XZ-plane, then a scale along the Y-axis by -1 is all you need. The matrix is used to transform the dino from it’s original position (above the floor), to end up “below” the floor and upside down, just like a reflection.

Radiosity is a very advanced lighting technique, and is not used by OpenGL, since it requires knowledge about the whole scene, not just individual primitives. How it works is therefore up to you to decide, since it’s up to you to code it.

Thanks very much for the advice both of you; (i did mean display lists sorry) –

I’ve thought about breaking up the terrain into smaller chunks and doing it like this, as I’m planning to use static terrain. What I’m wondering though, is how frustrum culling actually works. I’ve seen gl commands that looked something like glFrustrum(), but I can’t help but think that’s unrelated. Is this something that’s already in the implementation, or do I have to figure out my own clever way to figure out if something is visible or not? tia on this one!

Also thanks very much for clearing up the MultMatrix stuff, I think I’m finally really beginning to get the whole hang of what the matricies in gl are actually doing!! Time to get my own dinosaur to reflect now =P

glFrustum is very much related to frustum culling. glFrustum creates a perspective view volume, and it’s against this view volume you have to make the frustum culling. For a great tutorial on frustum culling, have a look here .

Alright thanks very much, I got both reflections going and shadows casting, and I understand what’s going on now. But here’s something I’m curious about –

All these examples and theory-pages I find explaining stenciling and shadowing, demonstrate with a flat plane. The terrain I’m working with is far from flat, and I’m wondering how shadows can work with this? The stenciling part I think I’m okay on with examples, but if I have a scene of terrain that has like 500x500 ‘planes’, do I have to run the calculations and get a matrix to multiply with for each plane, for every pass??? This seems like it would be extremely expensive, and I can’t help but think there’s a smarter way out there to do this. Also, I can imagine how I would set up stenciling on this… but wouldn’t I have to stencil each plane sepeartely, cast a shadow using that plane’s calculations, and then move on to the next one with a fresh stencil?? I’m a little confused here.

Any takers on this one? =P tia