Skip to main content
GameDev.net gamedev.net
🔒 Locked

Landscape

Started by Zmax Sep 18, 2005 at 9:27 AM 6 replies 1.1k views
Original Post
Zmax
Zmax
Thanx to some guys here i succeded creating a nice landscape:(take a look if you want,...i'm a beginer i've started playing with dx9 a week ago,...so don't tell me it sucks pls) Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us My problems is that i'm rendering the scene more times,..one time for each texture i use. It is working slower and slower for each texture i add to my landscape(staccato). I wanted to ask you this thing: is there any way to loading everything somehow in a buffer and rendering only one time? And one other thing: I'm using DrawIndexedPrimitives,...which of these thing draw faster: DrawIndexedPrimitives or drawing each triangle one by one?Thanks for your help :). [Edited by - Zmax on September 18, 2005 11:27:57 AM]
Kippesoep
Kippesoep
The links you posted give me the message "Accesul catre aceasta resursa este refuzat." (which I assume means something like "access to this resource is refused"), so I don't know what your landscape currently looks like, making it hard to give some pointers. I'll try anyway:

There are multiple texture units on all modern graphics cards. IIRC, pixel/vertex shader capable card has to support at least 4 textures simultaneously. Any card from the past 5 years or so would be capable of doing that anyway. You need to find a way to combine multiple textures, say by using an alpha map. This assumes that you're blending multiple textures together in multiple passes at the moment.

The system I'm using renders 4+1 textures per pass. What I do is this:
- each vertex has a vertex colour (which makes for a "texture" the size of the entire landscape), used as a base
- each vertex has an input to the pixel shader of 4 bytes packed to a DWORD
- a pixel shader fetches from 4 textures, multiplies the values by the corresponding level in the input mentioned above and adds them together (so: r0 + t1 * levels.r + t2 * levels.g + t3 * levels.b + t4 * levels.a)

This can be inefficient when there are many places where only 1 or 2 textures are used, but it works quite well in my landscape.

Another thing you may want to do, is to split up the landscape into chunks and render only the chunks that are in view (frustum culling) and skip a chunk altogether when it doesn't use the texture you're rendering.
Kippesoep
Zmax
Zmax
I'm using a trick and I can draw as manny textures as i want at a time.How can i uppload a picture here on GameDev,..so you can see...I asked somebody to test those links(it is from my country) and it worked...i don't know what could be.(it is a ftp domain i'm using)
sirob
sirob
To upload images, I'd recommend Image Shack. You upload it there, then copy the links it gives you and place them here, in a comment or a post.

Theres also photobucket, but I don't have a link handy.
Sirob Yes.» - status: Work-O-Rama.
Kippesoep
Kippesoep
What "trick" are you using? My original point was that you should be able to draw multiple textures simultaneously (that is: in 1 DrawPrimitive call per vertex buffer). That's the difference between "single pass" and "multiple passes".

From your description, I think you're using multiple passes, but I'm not quite sure. If you handle the drawing in a single pass, things tend to slow down less if you add a texture.

BTW, your grass texture doesn't seem to have mipmapping enabled. (Possibly the other textures, too, but that's less obvious). Enabling mipmapping can dramatically improve visual quality as well as performance.
Kippesoep
Zmax
Zmax
Yes i'm not using mitmaping yet.(I've created this as a test of speed for the textures drawing,..i want to choose the best,fastes way)
Here i'm using multiple passes...drawprimitive used manny times.I only wanted to know which is the best,fastest way to texturate a shape,height map.
shaders, drawing tile by tile, mulitple passes with alpha blending->drawindexedprimitives(this one i'm using now,..but i'm not so satisfyed about it..),...or other techniques i don't nothing about.hmmm.....
Kippesoep
Kippesoep
Well, enable mipmapping. It provides a performance boost too.

DrawIndexedPrimitive is the way to go, but to get the maximum amount of speed, you need to batch as many triangles together in one pass as possible and minimise state transitions (sort by shader, by texture and by vertex buffer).

The slowness is caused by several things:

1. You're changing state too much. This is slow because the GPU has to stop the actual rendering to switch to another texture (or shader or vertex buffer). Fix this by batching and sorting, as mentioned above.
2. Multiple passes, requiring alphablending. Multiple passes are slow because all the work has to be done several times. Alpha blending is slow because it's not just writing to the framebuffer, but it's read, process, write. Fix this by writing a good shader, combining multiple passes into one.
3. Mipmapping being disablled. This results in larger textures being used which uses up more bandwidth and cache thrashing.

There is no perfectly universal way to speed up D3D usage. It depends on the exact data you send the card, the driver, the actual card itself etc. Some programs may get great results by sorting by shader, then by texture, then by vertex buffer. Others may speed up by sorting the opposite way (vertex buffer first, then texture, then shader).
Kippesoep
Zmax
Zmax
Ok thank you for your help i rated you here on GamedDev as an excellent guy. :)
I'm not using shaders yet but only simple textures.Anyway i'll try doing something you mentioned.I'll use bunches of vertexes that share the same texture and try not using alpha only where is needed.Thanks again, :)

Topic Locked

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

Sign in to reply to this topic.