PnP TerrainCreator - Forum

The PnP TerrainCreator Forum
It is currently Tue Nov 21, 2017 10:09 am

All times are UTC




Post new topic Reply to topic  [ 7 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: 892
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: 892
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  
 
 Post subject: Re: Resize filter
PostPosted: Wed Nov 02, 2011 5:45 am 
Offline

Joined: Sat Oct 29, 2011 1:57 pm
Posts: 3
The basic idea behind these filters is to provide some sharpening when the input video has to be resized automatically by ConvertX display properly on your TV screen. Resizing up or down causes some loss in sharpness of the input video, so the filters try to compensate for that by adding some sharpening effect again.

The different filters have different ways of sharpening, and some sharpen more than others in specific parts of the scene. Because different input videos might have different scenes and different issues(some videos are noisy/grainy, some not, some have lots of objects in the scenes with sharp edges, some mostly people and little in the way of sharp-edged objects, etc., a different filter might work better for some videos than with others.

However, if you're doing mostly regular theater release movies of good quality and know nothing about filters, then the general consensus is that the Lanczos filter is generally the best overall. It produces good sharpening compared to some that soften the look of the image and might even cause slight color changes.

_________________
Nice & Easy 2 Use Red Hair Color & Clairol Hair Color


Top
 Profile  
 
 Post subject: Re: Resize filter
PostPosted: Thu Dec 19, 2013 4:01 am 
Offline

Joined: Tue Jul 16, 2013 2:39 am
Posts: 6
alextc wrote:
The basic idea behind these filters is to provide some sharpening when the input video has to be resized automatically by ConvertX display properly on your TV screen. Resizing up or down causes some loss in sharpness of the input video, so the filters try to compensate for that by adding some sharpening effect again.

The different filters have different ways of sharpening, and some sharpen more than others in specific parts of the scene. Because different input videos might have different scenes and different issues(some videos are noisy/grainy, some not, some have lots of objects in the scenes with sharp edges, some mostly people and little in the way of sharp-edged objects, etc., a different filter might work better for some videos than with others.

However, if you're doing mostly regular theater release movies of good quality and know nothing about filters, then the general consensus is that the Lanczos filter is generally the best overall. It produces good sharpening compared to some that soften the look of the image and might even cause slight color changes.

Thanks for your sharing.

_________________
Best Regards,
Arron



Next Tomorrow is Another Day.


Last edited by arronlee on Sun May 31, 2015 11:39 am, edited 1 time in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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