DX9.0c HLSL SSAO

Started by
24 comments, last by Bonbon 13 years ago
Sorry BonBon, I've never seen that sort of thing happening before. Things to check though, would be your normal and position buffer outputs, and your render target formats.

I can say that the code I posted for my SSAO shader above is not correct, and not what I used in my final implementation. So if you're following that then you'll also have troubles. Although I didn't have the trouble you seem to be having.

Sorry I can't help you more.
Advertisement
Sorry BonBon, I've never seen that sort of thing happening before. Things to check though, would be your normal and position buffer outputs, and your render target formats.

I can say that the code I posted for my SSAO shader above is not correct, and not what I used in my final implementation. So if you're following that then you'll also have troubles. Although I didn't have the trouble you seem to be having.

Sorry I can't help you more.

Sorry BonBon, I've never seen that sort of thing happening before. Things to check though, would be your normal and position buffer outputs, and your render target formats.

I can say that the code I posted for my SSAO shader above is not correct, and not what I used in my final implementation. So if you're following that then you'll also have troubles. Although I didn't have the trouble you seem to be having.

Sorry I can't help you more.


These are the outputs and the final render. I'm not sure if these are correct

[quote name='davidc14' timestamp='1301392888' post='4791653']
Sorry BonBon, I've never seen that sort of thing happening before. Things to check though, would be your normal and position buffer outputs, and your render target formats.

I can say that the code I posted for my SSAO shader above is not correct, and not what I used in my final implementation. So if you're following that then you'll also have troubles. Although I didn't have the trouble you seem to be having.

Sorry I can't help you more.


These are the outputs and the final render. I'm not sure if these are correct
[/quote]


The normals look OK, but the position looks different from what I have. I posted a picture of my final position buffer, this is what I have in my now working implementation. This was detailed earlier in the thread. In your vertex shader you want to multiply the input Position by the WorldView matrix. The same goes for the input Normals for your normal buffer. You want both position and normals in View space.

[quote name='Bonbon' timestamp='1301409497' post='4791724']
[quote name='davidc14' timestamp='1301392888' post='4791653']
Sorry BonBon, I've never seen that sort of thing happening before. Things to check though, would be your normal and position buffer outputs, and your render target formats.

I can say that the code I posted for my SSAO shader above is not correct, and not what I used in my final implementation. So if you're following that then you'll also have troubles. Although I didn't have the trouble you seem to be having.

Sorry I can't help you more.


These are the outputs and the final render. I'm not sure if these are correct
[/quote]


The normals look OK, but the position looks different from what I have. I posted a picture of my final position buffer, this is what I have in my now working implementation. This was detailed earlier in the thread. In your vertex shader you want to multiply the input Position by the WorldView matrix. The same goes for the input Normals for your normal buffer. You want both position and normals in View space.
[/quote]


For what you output for the positions, do you always get that that stark quartering of the screen, irreleavant of cam pos or the zoom of the cam (if the model is very small).?

Yes BonBon, the screen is always divided into the pink, baby blue, dark blue and white sections.

Yes BonBon, the screen is always divided into the pink, baby blue, dark blue and white sections.


Here is the shader Im using for my normals and positions. It might look familiar.

Thanks for all the help and I look forward to the tutorial that you put out to help those trying to attempt this later

uniform extern float4x4 WorldViewProjection;
uniform extern float4x4 WorldView;
struct VSINPUT
{
float4 Position : POSITION0;
float3 Normal : NORMAL0;
//Dont need these at the mo
float4 color: COLOR0;
float2 uv: TEXCOORD0;
}
;
struct VSOUTPUT
{
// This is the standard VS projected point
float4 Position : POSITION0;
// The data we shall pass to the PS
float3 Normal : TEXCOORD0;
float4 PosData : TEXCOORD1;
float Depth :TEXCOORD2;
}
;
VSOUTPUT VSDepthNormal(in VSINPUT input)
{
VSOUTPUT output;
output.Position = mul(input.Position, WorldViewProjection);
output.PosData = mul(input.Position, WorldView);
// You can store world space or view space normals, for SSAO you probably want view space
output.Normal = mul(input.Normal, (float3x3)WorldView);
// View space Z is a good value to store for depth
output.Depth = mul(input.Position, WorldView).z;
return output;
}



float4 PSPos(VSOUTPUT input) : COLOR0
{
return float4(input.PosData.xyz, 1);
}



float4 PSNorm(VSOUTPUT input) : COLOR0
{
float3 viewSpaceNormalizedNormals = 0.5 * normalize (input.Normal) + 0.5;
return float4(viewSpaceNormalizedNormals, 1);
}



technique DrawPosition
{
pass P0
{
vertexShader = compile vs_3_0 VSDepthNormal();
pixelShader = compile ps_3_0 PSPos();
}

}

technique DrawNormal
{
pass P0
{
vertexShader = compile vs_3_0 VSDepthNormal();
pixelShader = compile ps_3_0 PSNorm();
}
}

This topic is closed to new replies.

Advertisement