Skip to main content
gamedev.net
🔒 Locked

Multi-Texturing problem.

Started by michiwalter 2 replies 550+ views
Original Post
michiwalter
michiwalter
Hello all guys out there, I''m currently trying to program a 3d landscape engine. All rendering does well so far - except to the texturing. My engine does the following job: Reads a height-map and creates vertices, normals and diffuse parameters. The problem: I have 2 textures, and I want them to blend into one another via the diffuse parameters. But if I try to do that, I''m confusing about the SetTextureStageState() function. I don''t know how to set D3DTOP_COLOROP and _ALPHAOP and so on to do this job. I''d really be happy about help, because I looked in "Inside Direct3D" (MS Press) and 2 other 3D books without getting help. Thanks, Michi
Draigan
Draigan
With diffuse blending (I assume you mean the alpha component of the diffuse color from the vertex), you need to enable the D3DTSS_BLENDDIFFUSEALPHA. However, I''ve been unable to get this to work as a colorop on my voodoo3 or a Rage Pro. I can get it to work with the reference rasterizer however so I''m assuming that the video cards just can''t do it.
You should be able to set BlendDiffuseAlpha as the alpha op on your first texture stage.

With the landscape, you will have to draw many polygons to get it to blend your textures together. You''ll probably have to render to an offscreen surface to create your texture. There is an article around somewhere about terrain texture splatting which uses the hardware to create your textures. It will only work with the latest Nvidia cards however.

Most people (including myself) simply synthesis the terrain textures using the CPU. This can be optimized with MMX to make it run pretty fast. A texture cache would also help.

Take care.
-Dion
Draigan
Draigan
Use the MFCtex sample that comes with DirectX to test your blending. This can save you a bunch of time. And if something doesn''t seem to work, then switch to the REF driver and test it there. It will be slow, but it will support all features.

-Dion
michiwalter
michiwalter
Thanks man,

the MFCTex tip was quite good Thinks do well now.

Bye ''til next time...,
Michael

btw: how can I calculate the cos-1 of something???

Topic Locked

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

Sign in to reply to this topic.