Jump to content

  • Log In with Google      Sign In   
  • Create Account

Gives us the happy juice!

Posted by ApochPiQ, 15 March 2006 · 123 views

I'm officially addicted to this.

Today I've moved up from a single quad to a vertex buffer and index buffer, generating a flat mesh of several quads. The idea is to eventually turn this into a heightmapping system of sorts. Step one of course is to actually generate the mesh data.

I got the mesh generation working pretty quickly with the help of some Google and a little elbow-grease. I think that having a fairly comprehensive amount of experience thinking in 3D coordinate systems (from the Freon project) is making this a lot easier to go through. Despite the fact that I've barely touched polygon rasterization engines since I wrote my own software rasterizer 6 years ago, a lot of things are familiar and make a lot of sense.

The main thing I'm having trouble wrapping my head around at the moment is how I'm going to structure the code so that I can acheive optimal batching to the video hardware. I'm aware of all the tricks like texture baking (so multiple surfaces can be textured with a single SetTexture() call) and all that, but I've yet to really grok how to make my code do all this elegantly. This is of course made slightly more complex by the fact that I'm trying to learn C#'s design paradigms at the same time.

Once that's all sorted in my brain, I still have to find out how programmable shaders fit into all this mess. Incidentally, if anyone knows of a good online site that explains how all the modern pipeline stuff works at a reasonably abstract level, I'd much appreciate a link.

Needless to say, I'm finding all of this ridiculously fun [grin]

Anyways, once I got the mesh generated, I wanted to confirm that it was working. A little bit of Google turned up the ever-handy FillMode flag, so I swapped the renderer over to wireframe mode. That, however, renders the edges of each polygon textured, which I wasn't wanting - I wanted to see nice white lines. So a little bit of playing around with IntelliSense turned up the appropriate flags, and I figured out how to render solid white wireframe overlays on top of the actual textured surface.

The actual technique is pretty stupid, as it basically brute-force renders the entire scene twice, but IMHO it's not bad for a DX newbie [grin]

I absolutely love Managed DirectX, though. The code boils down to basically this:

dev.RenderState.FillMode = FillMode.Solid;
dev.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
dev.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;

dev.RenderState.FillMode = FillMode.WireFrame;
dev.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
dev.TextureState[0].ColorArgument1 = TextureArgument.Constant;
dev.TextureState[0].ConstantColorValue = 0xffffff;

So much more readable and sensible than the C++ bindings. It's borderline orgasmic. Anyways, here's the rendered result:


So far it's just a blob of polygons on a flat plane; my next project is to build in proper world and camera transforms so I can look at this from a more isometric-style angle and show the effects of the heightfield. Woot.

It's for GLSL, but Lighthouse3d might help
Nice, thanks.

That prompted me to surf around a bit more, at which point I discovered that I suck [grin]

September 2014 »

141516171819 20

Recent Entries

Recent Comments