PnP TerrainCreator - Forum

The PnP TerrainCreator Forum
It is currently Sat Nov 18, 2017 9:55 am

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 30 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Wed Jun 18, 2008 3:49 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
What I've decided on is to use the Texture Splatting Indexmap export feature so I can have the adjacent textures and blend the surroundings for each tile ( square ).

It seems to give me a 128 x 128 pixel indexmap per sector chunk ( 8x8 chunks using 128 patch size ) that I've exported. I have managed to load in the indexmap and process the pixels and store the textures at those locations, however, I've run into a snag.

My project uses the DX 9.0 SDK and I've been using DrawSubset() to render the detail texture exported .x model. Now that I'm attempting to override the texture at each tile, I don't think DrawSubset is gonna get it done. I'm still pretty new to DX progging, so is there any information available online for loading a .x model and converting it to triangle strips? I could probably rip through the vertex buffer and build my own strips ( 128 x 128 ) and render them with DrawPrimitive, but why reinvent the wheel if someone else has done it. ;)

Any ideas where I can get examples of this?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 6:35 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Looks like I figured out the hard part. I'm able to render individual pairs of faces using the existing models' vertex and index buffers by calling DrawIndexedPrimitive. :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 12:21 am 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Ok, so that works GREAT, but it's SLOW.

Any comments on how I can draw the blended textures to a single large texture that I can splat each frame instead of re-blending each quad each frame? Or will that kill RAM?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 4:42 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Ok, more progress... I'm now drawing all tiles to a splat then splatting the splat each frame. Speed is back!

Next is blending the tiles before rendering to the splat.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 5:28 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
err... I suspect I don't understand what you mean by "drawing all tiles to a splat then splatting the splat"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 5:36 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Sorry - prolly the wrong term.

I'm rendering each detail texture quad in a terrain patch to a texturemap ( splat ), then applying ( splatting ) that texturemap to the terrain mesh patch. This allows me to use a higher resolution texturemap than PNP-TC exports, and gives me control on how each quad is blended with the neighboring quads.

I'm now on to the blending stage.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 7:25 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
I would like my engine to blend the quads the same as in PNPTC. I've read through the documentation, and it covers blending a single tile using all 4 corners of the quad, but I didn't see anything covering how it blends the rest of the quad. Is there a code + alphamaps sample somewhere I can download / view?

Here is my blend using just the 4 corners.

Image

and here is the blend inside PNPTC.

Image

These are fairly similar, but where I run into trouble is where the textures are randomly generated

Mine:
Image

PNPTC:
Image

I get some strange striping and center fill problems. I'm apparently not doing it the same as PNPTC.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 8:10 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
To clarify how I'm doing it:

I have 5 texture passes and 5 alpha maps - one in each corner and one in the middle.

Below, with 5 being the tile I'm rendering, here are the stages I render.

1 2 3
4 5 6
7 8 9

Image Center alphamap = tile 3
Image Top left alphamap = tile 2
Image Top right alphamap = tile 3
Image Bottom right alphamap = tile 6
Image Bottom left alphamap = tile 5


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 9:26 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Had to flip Y on my textures to fix the striping problem.

Everything looks fine here:
Image



I still have problems emulating PNPTC when it comes to walk paths as they turn 90 degrees.

This one is bad:
Image

This one is tolerable:
Image


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 24, 2008 9:20 am 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
Hello, you have done a really good work so far. Looks really nice.

Interesting technique you are using. But I'm not sure if I really understood it. Are you rendering every single terrain quad separately using the small alphamap tiles (the 4 corners and the center) to blend the detail texture onto this quad? You will surely not achieve high poly throughput on your graphics card using this method, as you have many many render calls.

Usually alphamaps (as exported by the alphamap exporter of PnPTC) are generated for a larger terrain area (let's say 128x128 quads), so you can render thousands of terrain quads at once for one detail texture.

The rendering in PnPTC is done in a different way using vertex alpha instead, mainly because of performance resons for the interactive terrain texturing. The blends of this technique are not perfect, so I wouldn't suggest using it in a game engine. However, if it helps, I could try to formulate a small article about how the textured rendering is achieved in PnPTC.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 24, 2008 2:45 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Hi Ralf,

Thank you! I'm enjoying learning this stuff!

Yes, I am rendering each quad with each alphamap onto a larger 4096x4096 texturemap and retaining 30-60fps. The way I do this and retain high fps is that I preload the patch ( 128x128 quads ) in a different thread ( not the render thread ) when the player gets into range. After it is preloaded, I then replace the PNPTC generated 1024x1024 texturemap with my 4096x4096 texturemap. This works very well on Dual Core and Quad Core CPUs.

With this method, the player always has a 4096x4096 texturemap under him, and at most, 4 are preloaded ( if he's in a corner where 4 patches meet ). Some hardware can only handle 2048x2048, so I allow it to be scaled down. I may convert it to use 64x64 quads instead. 64 quads = 64 meters in my engine which is still far enough to mask the transition from 1024x1024 to 4096x4096. 64x64 quads -> 2048x2048 texturemap has the same close detail as 128x128 quads -> 4096x4096 texturemap which will help PCs with low RAM.

Soon, I plan to move the 4 corner alphamaps into a single combined alpha map and use a shader to speed up the process as well.

I would love to read how blending is done in PNPTC with vertex alpha if you have time!

Thanks again!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 27, 2008 8:44 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Ok - better approach. Pitch the internally generated 4096x4096 texturemap idea I was testing. ;) It was VERY fast, but I couldn't figure out how to efficiently render the texturemap and scene using the same device.

Now:
Rip each quad from the model for each patch when I pre-load the patch ( in a separate thread ).

Render the PNP-TC generated texturemap first

Render / blend those individual quads that are in a specific viewing frustum ( approx 30 yards - distance adjustable based on hardware ) over the top of the PNP-TC generated texturemap for high detail.

Will upload some pics as soon as I clean it up a bit.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 28, 2008 4:50 pm 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
The combined alphamap can use some refining, but that's can come later. I'm happy with the result.

Here it is using a PNP-TC texturemap of 16/8.
Image


Here it is in my engine after blends.
Image

I still need to do some optimization since I'm changing render states for each patch each frame, but this is good enough for now. Also, I need some higher resolution textures for the bricks, etc. and I'll be set. :)

Thanks for the help!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 29, 2008 9:50 am 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 892
Location: Braunschweig
good work, really looks great.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 6:42 am 
Offline

Joined: Fri Mar 07, 2008 8:21 pm
Posts: 62
Thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 30 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron