Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So I'm writing a small game using Direct3D 9 and I'm using multitexturing for the terrain. All I'm doing is sampling 3 textures and a blend map and getting the overall color from the three textures based on the color channels from the blend map. Anyway, I am getting a massive frame rate drop when I sample more than 1 texture, I'm going from 120+ fps to just under 50.

This is the HLSL code responsible for the slow down:

float3 ground = tex2D(GroundTex, multiTex).rgb;
float3 stone  = tex2D(StoneTex, multiTex).rgb;
float3 grass  = tex2D(GrassTex, multiTex).rgb;
float3 blend  = tex2D(BlendMapTex, blendMap).rgb;

Am I doing it wrong ? If anyone has any info or tips about texture sampling or anything, that would be nice.

Thanks.

share|improve this question
    
What hardware do you have? Four texture samples shouldn't be a problem on any new hardware. –  Axel Gneiting Oct 27 '10 at 13:20
    
I have a Radeon X1950, yeah it's a couple years old, if not more. I'm guessing it's maybe not the best hardware. What do you think ? –  dotminic Oct 27 '10 at 16:26

3 Answers 3

up vote 7 down vote accepted

If you want to speed things up you can use something called a texture atlas.

Wikipedia — A texture atlas is a large image, or "atlas" which contains many smaller sub-images, each of which is a texture for some part of a 3D object. The sub-textures can be rendered by modifying the texture coordinates of the object's uvmap on the atlas, essentially telling it which part of the image its texture is in. In an application where many small textures are used frequently, it is often more efficient to store the textures in a texture atlas which is treated as a unit by the graphics hardware.

It is more efficient for a GPU to sample a single large texture 4 times versus 4 images sampled once each. Here is an example of a terrain texture atlas.

alt text

share|improve this answer
1  
Thanks for the advice, I've implemented my shader using a texture atlas, I'm "only" getting a 109fps now, but it's a neat improvement from the 55fps I was getting. Thanks! –  dotminic Oct 23 '10 at 2:21
1  
+1 for a good answer. May I ask where you got that texture atlas image? Is it proprietary or free for any use? –  Cameron Jul 5 '12 at 19:38

Another thing to consider is the texture format. Is it a raw 32bpp texture? If so, consider using a compressed DXT1 texture, which is 4 bits/pixel (taking 1/8th of the space), or DXT5 if you need the alpha channel, at 8 bits/pixel.

Reducing the size of the texture data should result in reduced texture memory bandwidth requirements, and improved texture cache performance.

Also, check that you've not setting maximum quality anisotropic filtering - that can add a fair bit of cost.

share|improve this answer
    
thx for the advice, I'll give that a try next time. –  dotminic Jan 5 '11 at 13:50

Do your textures have mipmaps?

Without mipmapping, texture sampling can be particularly expensive (loads of cache misses)

share|improve this answer
    
Yep the textures have mipmaps, I exported them as a *.dds from the DirectX texture tool. But how do they use textures in commercial games where there are loads of high def textures all over the place ? I'm just sampling 1 texture atlas and getting a frame rate of 109 fps while rendering a terrain, all on the gpu. –  dotminic Oct 27 '10 at 16:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.