Hello all, a new demo for you to play with. And this time, you can actually have an effect on it
This one just expands a bit on the last one, but also, demonstrates a simple method to use bitmaps to place objects. In this case, some trees, billboarded plains. And don't make fun of them, I've said it many times before, I'm no artist.
Basically, this works like this. A 101x101 pixel bitmap corresponds to a tile terrain. Each pixel represents a vertice position on the tile. The code just checks for certain colors. So, if I want trees, they can be green; buildings could be red, etc. There is really no limit to the way this can be used. Simple, small, effective. If you want to try it out, just modify the trees2.bmp file. I just load it in Paint, zoom in, and turn on the grid. Make sure you have green (0,255,0) selected. Each pixel is a tree. In this demo, it will repeat this pattern across 4 terrain tiles. There are a total of 12 tiles in the demo.
Ok, this demo also uses a shader for per-pixel lighting. The vertex lighting was, well, ok, but per-pixel, looks much better. Gone are the strange "x" patterns caused by the vertices trying to shade the terrain. This is just simple directional lighting, N dot L, plus ambient. You can play with the ambient level and light direction. A sphere indicates the position of the light, but, its actually backwards on the x/z axis, I'll fix later. Also, there is a house, a crude one, with no lighting effects at all. And the trees are only affected by the ambient. So, this shows you can use a mix of lighting for your scenes. Its interesting to see the house when you turn the lights down low.
The shader performs another function, as well. I had a problem with the welded mesh..how to tile it if I wanted to. Well, the shader fixes this, and fixes it easily. I could think of no way to do this in the fixed pipeline. So, you can in real time increase or decrease the amount of texture tiles, per terrain tile. I capped it at 100x100. But it can go more.
And lastly, I put in my tried and true intersect object() walking code. Also, you can fly over the terrain as well. And, if you are in a big hurry, you can press the fly mode key AND the walk code key in the same direction to move alot faster (Nothing I did, it just happens, like walk/run).
Oh, almost forgot, I put a skysphere in. Its not the best, but, its not the worst either. You can play with the scale of it. I think a little flatter on top looks better than just round, but thats just me.
Please, don't make fun of my art, this is all just testing/learning stuff still. I'm pretty sure the .bmp object method will get used. I still have to figure out why adding 500 trees slows down so much when its really not alot of polys. I'm thinking instead of instancing them, I'll make them one object and limb them...just a thought.
Anyway, there are 2 files. The .exe, and the .bmp you can modify. Have fun, comments welcome.