Multipass Texturing

Started by
12 comments, last by INVERSED 18 years ago
I created a terrain engine using Multipass Texturing to blend multiple textures. For every texture a trianglelist is created with different alphablending values. The problem is drawing the entire terrain for every texture takes a lot of time, and the engine is running pretty slow at the moment because instead of just drawing one trianglelist it has to draw 6 for each frame. Now I'm not sure of any solutions for this problem. I myself thought of the possibility of blending all maps together at the start and then render this one, since the map is static and the blending values are not changing during gameplay. Quinnie, Edit: Maybe not needed but for the record i'm using DirectX 9.0 for the terrain engine. [Edited by - Quinnie on March 27, 2006 10:58:19 AM]
Advertisement
Sounds like a good idea to me. Offline work is better then doing stuff at runtime, (unless resolution is an issue). Other options would be to use shaders and put your blend weights there, or store the alpha in the textures themselves, and then just alpha blend. Either way, six passes over your geometry seems excessively wasteful.
Write more poetry.http://www.Me-Zine.org
why do you use Multipass Multitexturing? you could use singlepass multitexturing(without shaders).

regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."
Quote:Original post by INVERSED
Sounds like a good idea to me. Offline work is better then doing stuff at runtime, (unless resolution is an issue). Other options would be to use shaders and put your blend weights there, or store the alpha in the textures themselves, and then just alpha blend. Either way, six passes over your geometry seems excessively wasteful.


The idea is that in a height map I can set for each tile what the alhpa value is... So at some tiles I render the texture with half transparency and in some with a quarter etc... is that possible using shaders?

And Six passes indeed are wastefull....

Quote:Original post by m4gnus
why do you use Multipass Multitexturing? you could use singlepass multitexturing(without shaders).

regards,
m4gnus


Ummm... I need to set for each texture on each tile the alpha value, and it happens often that on a tile there is a half transparent texture and for the other half an other texture.... as far as i know this is not possible using only one pass...

Edit: Maybe not needed but for the record i'm using DirectX 9.0 for the terrain engine.
Have a look into multitexturing
On todays hardware you can draw something like 8-16 textures onto one triangle in ONE pass.. Each with their own alpha values I should assume.. And multitexturing goes back to the Riva TNT days, so anyone should be able to handle it.

Otherwise, generate a large texture beforehand but this may not be the best solution..
Delphi C++ OpenGL Development: www.nitrogen.za.org
Ok Thnx... I will do some research...

Also I stumbled into this article http://www.gamedev.net/reference/articles/article2238.asp and I was wondering if this is what I need...
Terrain texturing a subject near and dear to my heart:

http://www.grinninglizard.com/lilith/

If you are comfortable with the hardware requirements for shaders, I strongly recommend shaders combined with multitexturing. I haven't used the DirectX API for multitexturing, but assuming it's roughly comparable to OpenGL then setting up the API for just the right blend and color combinations is difficult and frustrating to experiment with.

On the other hand, it's very easy to write a fragment shader that combines the textures just the way you want, and adds special visual effects on the way. For example: perhaps you want specular reflection just on the snow layer. Or add a little random height noise so the terrain doesn't look to regular. Or experiment with texture splatting. Straightforward with shaders, time consuming with the fixed function API.

lee
I have to admit I'm not quite familiar with DirectX shaders, though some of the advantages you name seem quite handy :P So for now I will work myself through an article about multitexturing in one pass... than later on I'll inform myself a bit about shaders....

Thanks for the info...
Using single pass multi texturing, guided by this tutorial "http://www.two-kings.de/tutorials/dxgraphics/dxgraphics12.html" I already ran into problem:

This codes seems to assume that the texture for the entire trianglestrip has the same opacity... and if I understand correct, that would not allow me to create parts in the terrain where some textures are more transperant tehn others. Also this seems to assume...

g_App.GetDevice()->SetTexture(0,pBaseMap); //set base texture (NEW)
g_App.GetDevice()->SetTexture(1,pDarkMap); //set dark map (NEW)
g_App.GetDevice()->SetStreamSource(0,pQuadVB,sizeof(D3DVERTEX));
g_App.GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);

I'm quite lost at the moment... and maybe I'm totaly wrong about everything :P Or maybe it's alreay too late to be programming :P

Anyway here some code snippits of how I orginally implemented my tecture blending maybe totally unusefull:

Drawing the Lists:
// Pass 1 :: Set The StreamSource For The VertexBufferg_pd3dDevice->SetStreamSource( 0, g_pVertexBufferBlendOne, 0, sizeof(CUSTOMVERTEX) );// Pass 1 :: Set The Texturing Modeg_pd3dDevice->SetTexture( 0 , g_pTerrainTexture[0]);// Pass 1 :: And Render The Terrain TriangleStripg_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, HeightMapY * HeightMapX * 2);// Pass 2 :: Set The StreamSource For The VertexBufferg_pd3dDevice->SetStreamSource( 0, g_pVertexBufferBlendTwo, 0, sizeof(CUSTOMVERTEX) );// Pass 2 :: Set The Texturing Modeg_pd3dDevice->SetTexture( 0 , g_pTerrainTexture[1]);// Pass 2 :: And Render The Terrain TriangleStripg_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, HeightMapY * HeightMapX * 2);


Setting the alpha blending using the difuse colors:
// First Triangle		:: Alpha Bledning SettingsMapVertices[(x*120)+(y*1) + 0].DiffuseColor = D3DCOLOR_ARGB(*TexturePointerOne, 255, 255, 255);MapVertices[(x*120)+(y*1) + 1].DiffuseColor = D3DCOLOR_ARGB(*TexturePointerTwo, 255, 255, 255);MapVertices[(x*120)+(y*1) + 2].DiffuseColor = D3DCOLOR_ARGB(*TexturePointerThree, 255, 255, 255);// Second Triangle		:: Alpha Blending SettingsMapVertices[(x*120)+(y*1) + 3].DiffuseColor = D3DCOLOR_ARGB(*TexturePointerTwo, 255, 255, 255);MapVertices[(x*120)+(y*1) + 4].DiffuseColor = D3DCOLOR_ARGB(*TexturePointerFour, 255, 255, 255);MapVertices[(x*120)+(y*1) + 5].DiffuseColor = D3DCOLOR_ARGB(*TexturePointerThree, 255, 255, 255);
I mentioned this earlier, but why not store the alpha in the texture. If you're using a TGA say, you can store your alpha values there, and then, viola, different alphas for each layer. Of course, I still reconmend compressing as many of those textures down as possible, any textures that are repeated with the same frequency can just be merged together. Sure you CAN do 8 - 16 texture reads in one pass, but that doesn't mean you should. In my engine, I have the option of rendering multipass, or rendering multi-texturing, and on some vid cards the advantages of multi-texturing was neglegible (I still use it of course), but that is to say reading from a bunch of texture isn't always fast.
Write more poetry.http://www.Me-Zine.org

This topic is closed to new replies.

Advertisement