Sign in to follow this  

[DirectX 10] Sampling MSAA textures. The best way?

This topic is 2662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First I write the normals to a 8x MSAA render target.
Then I pass the normals texture to a shader.
In the shader I declare the texture like this:

Texture2DMS<float3,8> normalTex;



Then, in the pixel shader, I sample the texture in a loop:

for(int i = 0; i < 8; i++)
{
normal = normalTex.Load(pIn.pos, i);
}



But this doesnt work... when i = 0, Load returns a value, but then in any i values Load doesnt return anything....

What am I doing wrong?

Share this post


Link to post
Share on other sites
You're right, if I add a 0 offset to the load function I get the image more aliased, but incorrect...

Light Buffer:http://img718.imageshack.us/img718/5431/msaalighting.png

Final Image:http://img836.imageshack.us/img836/4756/msaafinal.png

So as you can see the image has a incorrect offset that create a border around the boxes, etc...

I ran the program in PIX and noticed that my SV_Postion (pIn.posH) is always (x.5, y.5) and in Load function the location var needs a int2 so pIn.posH is changed to (x, y). And I cant create an offset of (0.5, 0.5) because the offset must be a int2 too...

This is a bit of my shader:

int2 loc = int2(pIn.posH.xy);
int2 offset = int2(1, 1);

for (int i = 0; i < 8; i++)
{
float depth = 0.0f;
float4 normalData = float4(0.0f,0.0f,0.0f, 0.0f);

depth = gDepthMap.Load(pIn.posH.xy, offset, i);
normalData = gNormalMap.Load(pIn.posH.xy, offset, i);




So any idea?

Share this post


Link to post
Share on other sites
Casting to an int2 is the right way to do it. If SV_Position is (100.5, 100.5), then you want to Load with location (100, 100) and an offset of 0. So just do this:

int2 loc = int2(pIn.posH.xy);
int2 offset = int2(0, 0);

for (int i = 0; i < 8; i++)
{
float depth = 0.0f;
float4 normalData = float4(0.0f,0.0f,0.0f, 0.0f);

depth = gDepthMap.Load(loc, offset, i);
normalData = gNormalMap.Load(loc, offset, i);
}

Share this post


Link to post
Share on other sites

This topic is 2662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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