Original Post
I've searched the web for days to find any good material on texturing terrain and found that there isn't very much to find about it. But I found one site which seem to have exactly what I need but it's written in Pascal and OpenGL: http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm The problem is that I'm not sure how to convert it to DirectX and they don't really cover the topic very extensivly so I made some guesses :) It would be great if you could help with this problem. The operation which is required to product the blended terrain is: Unit: Texture: Output: 0 T1 T1 1 T2 LERP(Col0.RGB, T1, T2) 2 T3 LERP(Col0.A, Unit1, T3) So here is what I've done so far: (However the 2nd stage I still do not understand how to get the Col0.A) And also I suspect that if I use the RGB color of (1.0f,0,0) of a vertex then that vertex should ge enterlty covered by the first texture. While (0.33f,0.33f,0.33f) would cause a blend of all three is that correct? When I execute the code above I get strange result:http://staff.envox.com/fredrikk/output.JPG
p3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
p3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
p3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_LERP );
p3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG0, D3DTA_DIFFUSE );
p3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_CURRENT );
p3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
p3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_LERP );
p3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG0, D3DTA_DIFFUSE ); //how do I get the Col0.A in here??
p3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_CURRENT );
p3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_TEXTURE);