PnP TerrainCreator - Forum

The PnP TerrainCreator Forum
It is currently Thu Sep 09, 2010 2:58 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Resize filter
PostPosted: Sat Feb 27, 2010 7:14 pm 
Offline

Joined: Tue Aug 04, 2009 3:53 am
Posts: 15
Hey,

It'd be really nice if we could choose which filter to use when doing an alphamap resize (for pow2).
Atm it's hardcoded to Mitchell, however this filtering appears to break the bordering of the alphamaps (as selected via the BorderPixel option) in some cases.
I've altered it locally for my plugin for now, but a generic solution so that any plugin can choose would probably be better.
The two lines I'm looking at here are exporter.cpp:2271 and exporter.cpp:2581

Unrelated, is there an ETA for a new release (of SDK too)? :)

Thanks.


Top
 Profile  
 
 Post subject: Re: Resize filter
PostPosted: Sun Feb 28, 2010 9:46 pm 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 875
Location: Braunschweig
Hi,

actually i tried a lot with different filters and especially looked in the issue of smooth transitions between sectors/patches. Thats actually why there are so many filters available via the SDK (I didn't wanted to delete the code). I found the Mitchell filter to work best and didn't noticed any problems in the transitions.

What are the changes you have made to the resizing code? Or which filter are you using instead of the Mitchell one? The general trick for ensuring a smooth transition is to put a border around the exported patch/sector which integrates information from the surrounding. When saving, this border is removed again in order to get the correct size. Maybe it will be sufficient to just enlarge this border by 1 or 2 pixels into each direction.

However, adding a filter selection drop-down-list is surely a good idea. I'll add this.


Top
 Profile  
 
 Post subject: Re: Resize filter
PostPosted: Sat Mar 06, 2010 10:30 pm 
Offline

Joined: Tue Aug 04, 2009 3:53 am
Posts: 15
Ralf wrote:
Hi,

actually i tried a lot with different filters and especially looked in the issue of smooth transitions between sectors/patches. Thats actually why there are so many filters available via the SDK (I didn't wanted to delete the code). I found the Mitchell filter to work best and didn't noticed any problems in the transitions.

What are the changes you have made to the resizing code? Or which filter are you using instead of the Mitchell one? The general trick for ensuring a smooth transition is to put a border around the exported patch/sector which integrates information from the surrounding. When saving, this border is removed again in order to get the correct size. Maybe it will be sufficient to just enlarge this border by 1 or 2 pixels into each direction.

However, adding a filter selection drop-down-list is surely a good idea. I'll add this.


I find that no filter works best. I'm exporting with BorderPixel set to 2.
This gives me an alphamap for each patch. Then in my engine I sample the alphamap (e.g. size 128x128) at;

float2 alphaCoord = texCoord*(127.0/128.0)+(0.5/128.0);

This gives me no issues at the borders between patches.

If I leave filtering enabled then I end up with this effect at the borders between patches;

http://img52.imageshack.us/img52/629/splat.png

I believe to get a smooth transition the border of each alphamap should be exactly the same as the border pixels of it's neighbouring alphamaps. Filtering apparently breaks this.

Something else worth mentioning, is that if I leave filtering enabled but export as non-power-of-2 I don't seem to get the border effect.


Top
 Profile  
 
 Post subject: Re: Resize filter
PostPosted: Mon Mar 08, 2010 12:11 am 
Offline
Programmierdochfix
User avatar

Joined: Tue Apr 27, 2004 12:53 pm
Posts: 875
Location: Braunschweig
Maybe the problem is located somewhere else.
What setting do you use for "Border pixels"?

What parameters do you use for "smooth factor", "patch size", "scale factor", and "file format".
Maybe... could you simply upload a screen shot of the export settings, so I can try to find out, why you get unsteady transitions?


Top
 Profile  
 
 Post subject: Re: Resize filter
PostPosted: Wed Mar 17, 2010 12:48 am 
Offline

Joined: Tue Aug 04, 2009 3:53 am
Posts: 15
CTexturemapExporterAlphamap alphaMapExporter;
alphaMapExporter.SetParameter("PatchSize", 128);
alphaMapExporter.SetParameter("SmoothFactor", 0);
alphaMapExporter.SetParameter("FileFormat", string("PNG"));
alphaMapExporter.SetParameter("NoBlackFiles", true);
alphaMapExporter.SetParameter("FlipY", false);
alphaMapExporter.SetParameter("PowerOfTwo", true);
alphaMapExporter.SetParameter("MaxNumChannels", 4);
alphaMapExporter.SetParameter("BorderPixel", 2);
alphaMapExporter.SetParameter("ScaleFactor", 1);
alphaMapExporter.SetParameter("ExportMaterialFiles", true);
alphaMapExporter.SetParameter("GaussSmoothMax", false);

Which gives this border artifact: http://img21.imageshack.us/img21/3238/borderqx.png

My splatting pixel shader basically does this;

float2 alphaCoord = texCoord*(127.0/128.0)+(0.5/128.0);

surfaceColor = tex2D (texDiffuse1, texCoord);
surfaceColor *= tex2D (texAlpha1, alphaCoord).x;

float4 tempColor = tex2D (texDiffuse2, texCoord);
tempColor *= tex2D (texAlpha1, alphaCoord).y;
surfaceColor += tempColor;

tempColor = tex2D (texDiffuse3, texCoord);
tempColor *= tex2D (texAlpha1, alphaCoord).z;
surfaceColor += tempColor;

tempColor = tex2D (texDiffuse4, texCoord);
tempColor *= tex2D (texAlpha1, alphaCoord).w;
surfaceColor += tempColor;

tempColor = tex2D (texDiffuse5, texCoord);
tempColor *= tex2D (texAlpha2, alphaCoord).x;
surfaceColor += tempColor;

etc. if more textures are needed, pretty simple.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

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