Texture Blending Shaders

Started by
19 comments, last by Plerion 14 years, 4 months ago
Hey!

Yes, the card isnt one of the best, but i actually dont need it as its only a working computer ;).

What i forgot to mention about: It can not be because of my system or because of the material i render. I use every model and every i texture i render from World of Warcraft. And as WoW is running at 40+ FPS with muuuch more terrain at once and dozens of particle effects and hundreds of models i guess that there is something wrong in my code, when i get about 16 FPS only with the terrain. I tried to get NPerfHUD working but it isnt. Is there any alternative?

Greetings
Plerion

[Edited by - Plerion on December 3, 2009 5:00:46 AM]
Advertisement

You can try Pix for profiling.
Your performance sounds a bit low. Can you please show a bit of the code which is used for drawing the terrain?

Hey!

Thats the code i use to render a terrainchunk:
http://pastebin.com/m13949e91

At the moment i render about 2000 such chunks with a framerate of ~15 FPS.

I will have a look at Pix.

Greetings
Plerion
If you disable texture blending, or make the shader simpler, does it execute faster? If not, then no amount of shader optimisation will help.

I suspect the several thousand DrawIndexedPrimitive() calls is much more of a problem than blending multiple textures - you really don't want more than a few hundred DrawIndexedPrimitive calls per frame...

Again, a GPU profiler will actually tell you where the bottleneck is.
Reducing draw calls is important here.

Some points of your code:

You may use handles instead of strings to set shader parameters
ie. get handle with the string and use the handle to set the texture

m_blendEffect[2]->SetTexture("alpha2Tex", m_alphaTex[0]);

Does each of the terrain block have it's own vertex buffer?
Reducing the amount of vertex buffers and vertex buffer switches should give you more performance.

pDev->SetStreamSource(0, m_vbuffer, 0, 28);
pDev->SetIndices(m_ibuffer);

As mentionned before, use a profiler to locate the real bottle neck. My suggestions may well be just minor things.

Cheers!
Hello!

I tried now Pix and it shows me some information. I actually dont really know for what i have to look for.

Here is what ive found
Number of DrawIndexPrimitive calls: 2308

I guess thats a problem, right? But I dont really know how to solve it differently. Every chunk may have its own 4 texture layers. How can i combine those if they dont have the same texture?

Greetings
Plerion
Hi,

First thing you could try is to draw just half of the chunks and see if your performance scales accordingly.

I can see that having this kind of terrain system is actually pretty complicated to optimize. Combining the patches is complicated because of the alphamaps.

However, are you sure that your terrain actually may use almost unlimited number of textures (as long as there is 4 per terrain patch)?

Following things things may help you a bit:
- reduce state changes
- reduce texture changes (ie. sort your terrain blocks according to their material)
- reduce vertex/index buffer changes, create one big vertex buffer/index buffer instead of many small ones.

- create a different shader for blocks with fewer than 4 textures.

Do you use frustum culling for your blocks?

[Edited by - kauna on December 3, 2009 8:34:29 AM]
Hi. I will collect some ideas how to decrease the number of renders! Here are some values if i change the number of chunks:
1536 DIP -> 20 FPS
768 DIP -> 35 FPS
256 DIP -> 61 FPS
Profiling WoW gave me the final point, that im doing it wrong :D

Number of DIP-Calls: 503

So i need to find a way to reduce the calls, though i have no idea at all how to do that :P

This may be a stupid question, but you are doing frustum culling?

In order to combine the drawing calls, they need to use common resources (ie. textures). Perhaps a texture atlas for the texture alphas would help in that sense. If I was facing that kind of a situation, I would look in to the data and see if the system actually has an artificial limit for the textures.

Good luck!

This topic is closed to new replies.

Advertisement