View Single Post
Old 06 January 2017, 22:26   #1
Registered User
rsn8887's Avatar
Join Date: Oct 2006
Location: USA
Posts: 822
NULL Filter discrepancies

Hello Toni,
I think I found a problem that might affect all user-made D3D filters, or it might just be my stupidity. I made my own D3D Null filter and it gives different results with tons of pixel wobble compared to the preset "Null Filter" in the menu and the filter setting "none". All NULL filters should give the same result. The filter and example pics are attached.

I have a hunch it might be related to the quad aligment as in this article:

I tried all combinations of re-aligning the quad in the vertex shader and/or applying the 0.5 pixel offset to texture coordinates, but there's always distortion.

The fact that the internal Null Filter gives a nice image without pixel distortion is encouraging. If I can reproduce that behaviour in a user D3D filter, I can make the perfect bilinear_prescale work also.

Do you have the .fx source for the internal NULL filter, so I could compare what is going on?

To test, simply use Integer scaling, only point filtering (bilinear obscures the differences), and look for the differences when you switch filters. The internal filters give much nicer pixels, the NULL filter attached shows tons o wobble.

Here's the shortest NULL Test filter that should give the same results as internal NULL filter, but doesn't:
string combineTechnique : COMBINETECHNIQUE =  "NULL_TEST";
float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;
sampler	sourceSampler = sampler_state {
	Texture   = (source_tex);
	MinFilter = POINT;
	MagFilter = POINT;
	MipFilter = NONE;

struct VS_OUTPUT {
	float4 oPosition 	: POSITION;
	float2 oTexCoord 	: TEXCOORD0;

VS_OUTPUT vShader (float3 pos : POSITION, float2 texCoord : TEXCOORD0) {

	OUT.oPosition = mul(float4(pos,1),WorldViewProjection);
	OUT.oTexCoord = texCoord;
	return OUT;

float4 pShader ( in VS_OUTPUT inp ) : COLOR {  
	return float4(tex2D(sourceSampler, inp.oTexCoord).rgb, 1.0);

technique NULL_TEST {
   pass P0 {
     VertexShader = compile vs_3_0 vShader();
     PixelShader  = compile ps_3_0 pShader();
Attached Thumbnails
Click image for larger version

Name:	NULLTEST_D3D.jpg
Views:	119
Size:	82.8 KB
ID:	51609   Click image for larger version

Name:	NULL_Internal.jpg
Views:	120
Size:	83.7 KB
ID:	51610  
Attached Files
File Type: zip (689 Bytes, 38 views)

Last edited by rsn8887; 06 January 2017 at 22:33.
rsn8887 is offline  
Page generated in 0.04255 seconds with 12 queries