Sign in to follow this  
thiago.pastor

[XNA 4.0] Multisample showing white borders

Recommended Posts

thiago.pastor    100
[size="2"][color="#1c2837"][color="#000000"][font="arial, verdana, tahoma, sans-serif"][size="2"]hi all,
iam using xna to make a deferred rendering.
dx 9 normally does not support msaa with mrt, so i render in a first pass the normal and the depth without msaa
and after in a second pass i render the diffuse color with msaa
after i make the light pass and finaly a combine pass

the problem is that im getting with boarder ([url="http://imageshack.us/photo/my-images/194/advanceddemos2011051716.jpg/"]https://picasaweb.google.com/lh/photo/gVaAUsCPs09aOCAG_-sd7b8h9DxdSU2auIMAsUbJnQ8?feat=directlink[/url]) when i enable MSAA, when i disable everything works
it should work (KKK), i dont undertand way it does not (followed the ideas here [url="http://drilian.com/2008/11/25/understanding-half-pixel-and-half-texel-offsets/"]http://drilian.com/2...-texel-offsets/[/url])

the shaders used to render the normal/depth and the color are "normal", i dont align pixel, texel .....

in the light pass (small part of the directional light -- fullscreen quad pass) i do:

[code]

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
input.Position.x = input.Position.x - 2*halfPixel.x;
input.Position.y = input.Position.y + 2*halfPixel.y;
output.Position = float4(input.Position,1);

output.TexCoord = input.TexCoord ;
///.....
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
///.....

//read depth
float depthVal = tex2D(depthSampler,input.TexCoord).r;

//compute screen-space position
float4 position;
position.x = input.TexCoord.x * 2.0f - 1.0f;
position.y = -(input.TexCoord.y * 2.0f - 1.0f);
position.z = depthVal;
position.w = 1.0f;
//transform to world space
position = mul(position, InvertViewProjection);
position /= position.w;
///....
}
[/code]



the global variable halfPixel is the 0.5f/(viewport resolution)
(after i change to pixelsize and change the 2*halfPixel to just pixelsize)

Showed how i recover the depth to get the world position.
the other textures i access using input.TexCoord (without halfPixel)
Tried changing the PS (subtracting the halfpixel of the position but .... )

in the combine phase i use: (fullscreen quad pass)
[code]

float2 halfPixel;
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
input.Position.x = input.Position.x - 2*halfPixel.x;
input.Position.y = input.Position.y + 2*halfPixel.y;
output.Position = float4(input.Position,1);
output.TexCoord = input.TexCoord ;
return output;
}


float4 PixelShaderFunctionNormal(VertexShaderOutput input) : COLOR0
{
float procces = tex2D(extraSampler,input.TexCoord).a;
float3 diffuseColor = tex2D(colorSampler,input.TexCoord).rgba;
///.... (just to show how i access the textures)


[/code]

(iam not subtracting halpfixel in the texture coordinates)
All my render targets (except the MRTS are configured to use MSAA)

IT WORKS without MSAA (correct image), i thought using the shift in the position would resolve .... (is not theoricaly correct ?)
Pls, what iam doing wrong ?

If more info, or more code is needed, tell me that i add =P

[/size][/font][/color][color="#000000"][font="arial, verdana, tahoma, sans-serif"][size="2"](i posted this in other gamedev forum, but got no answer)[/size][/font][/color][color="#000000"][font="arial, verdana, tahoma, sans-serif"][size="2"]Thanks as always people =P[/size][/font][/color][/color][/size]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this