This topic is now archived and is closed to further replies.


Heightmap Terrain Generation?

Recommended Posts

peckerpeck    100
hey guys, i''m trying to figure out how to blend my height bmp with a plane in order to render a heightmap. I don''t know how to set the render state. also just to clarify the esoteric MS docs. i see render ops as follows: lpDev->SetTexture(0,lptex); lpDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); lpDev->SetTextureStageState(0, D3DTSS_COLOROP, D3D_SELECTARG1); now, from what i think i know, doing all 3 lines is basically an explicit way of simply doing the top line. i.e. it says (1) associate the texture to be used, (2) set the 1st argument as the texture (3) output the texture What i''m getting at is i often see lines of texture ops that seem to be...redundant. is my thinking right?

Share this post

Link to post
Share on other sites
invective    118
I agree that the texture stage functions can be hopelessly confusing. In fact you see the same sequences so often that you wonder why there aren''t macro''s defined for them to make things simpler for beginners. But, each one of those lines actually does something different, and the flexibility given by having all this micromanagement allows you to do all sorts of effects like alpha blending, lightmapping, bump mapping, etc.

selects lptex as the texture for stage 0 (you have up to 8 stages). note it doesn''t say how stage 0 is used.

lpDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
sets the argument for stage zero to the texture color. not we still don''t know how the argument is used.

lpDev->SetTextureStageState(0, D3DTSS_COLOROP, D3D_SELECTARG1);
sets the operation for stage 0 to take color from arg1, which happens to be the color of lptex.

Is that a really long and convoluted way to do things? It sure is, but you will appreciate the flexability later on when you have to do multitexturing effects.

By the way, the hieghtmap has nothing to do with the textures, but rather the vertices. Basically you take the x,y values of the bitmap for the hieghtmap vertices, and use the color value for the z coordinate. I have some code to do this if you need help.

Share this post

Link to post
Share on other sites