PnP TerrainCreator - Forum
http://forum.pnp-terraincreator.com/

Resize filter
http://forum.pnp-terraincreator.com/viewtopic.php?f=7&t=900
Page 1 of 1

Author:  Xordan [ Sat Feb 27, 2010 7:14 pm ]
Post subject:  Resize filter

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.

Author:  Ralf [ Sun Feb 28, 2010 9:46 pm ]
Post subject:  Re: Resize filter

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.

Author:  Xordan [ Sat Mar 06, 2010 10:30 pm ]
Post subject:  Re: Resize filter

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.

Author:  Ralf [ Mon Mar 08, 2010 12:11 am ]
Post subject:  Re: Resize filter

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?

Author:  Xordan [ Wed Mar 17, 2010 12:48 am ]
Post subject:  Re: Resize filter

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.

Author:  alextc [ Wed Nov 02, 2011 5:45 am ]
Post subject:  Re: Resize filter

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.

Author:  arronlee [ Thu Dec 19, 2013 4:01 am ]
Post subject:  Re: Resize filter

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.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/