• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

### #Actualbearsomg

Posted 29 May 2013 - 04:23 PM

I've been working on adding SSAO support to my Direct3D10 program, but I'm a bit confused when it comes to using the normal and depth maps to build the occlusion buffer, which is then blended with the scene. From my understanding, this is the process:

(Pass 1): Generate the normal and depth maps (I use one pass and put the normal in RGB and the depth in A)

(Pass 2): Generate the AO map using the view space normal/depth map

(Pass 3): Render the actual scene using the occlusion factor from the AO map generated in pass 2

I'm confused when it comes to pass 2. I'm attempting to follow the tutorial here: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/a-simple-and-practical-approach-to-ssao-r2753 but I got confused with how to implement the shader. Namely, where does the

float2 uv


parameter come from in the pixel shader, and how is it calculated?

This is my shader for creating the normal/depth map:

//Vertex Input
struct VS_INPUT_SKIN
{
float4 position : POSITION;
float3 normal    : NORMAL;
float2 tex0    : TEXCOORD;
};
struct SSAO_PS_INPUT
{
float4 pos : SV_POSITION;
float3 normal : TEXCOORD0;
float depth : TEXCOORD1;
};
SSAO_PS_INPUT vs_SSAO(VS_INPUT_SKIN IN)
{
SSAO_PS_INPUT OUT;

float4 worldPos = mul(skinnedPos, worldMatrix);

OUT.pos = mul(worldPos, viewMatrix);
OUT.pos = mul(OUT.pos, projMatrix);

OUT.normal = mul(skinnedNormal, worldMatrix);
OUT.normal = mul(OUT.normal, viewMatrix);
OUT.normal = normalize(OUT.normal);

OUT.depth = mul(worldPos, viewMatrix).z;

return OUT;
}
float4 ps_SSAO(SSAO_PS_INPUT IN) : SV_Target
{
return float4(IN.normal,IN.depth);
}
technique10 SSAO_T
{
pass P0
{
}
}


Basically, I'm confused as how to execute pass 2 using my generated map.

### #2bearsomg

Posted 29 May 2013 - 03:49 PM

I've been working on adding SSAO support to my Direct3D10 program, but I'm a bit confused when it comes to using the normal and depth maps to build the occlusion buffer, which is then blended with the scene. From my understanding, this is the process:

(Pass 1): Generate the normal and depth maps (I use one pass and put the normal in RGB and the depth in A)

(Pass 2): Generate the AO map using the view space normal/depth map

(Pass 3): Render the actual scene using the occlusion factor from the AO map generated in pass 2

I'm confused when it comes to pass 2. I'm attempting to follow the tutorial here: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/a-simple-and-practical-approach-to-ssao-r2753 but I got confused with how to implement the shader. Namely, where does the

float2 uv


parameter come from in the pixel shader, and how is it calculated?

This is my shader for creating the normal/depth map:

//Vertex Input
struct VS_INPUT_SKIN
{
float4 position : POSITION;
float3 normal    : NORMAL;
float2 tex0    : TEXCOORD;
};
struct SSAO_PS_INPUT
{
float4 pos : SV_POSITION;
float3 normal : TEXCOORD0;
float depth : TEXCOORD1;
};
SSAO_PS_INPUT vs_SSAO(VS_INPUT_SKIN IN)
{
SSAO_PS_INPUT OUT;

float4 worldPos = mul(skinnedPos, worldMatrix);

OUT.pos = mul(worldPos, viewMatrix);
OUT.pos = mul(OUT.pos, projMatrix);

OUT.normal = mul(skinnedNormal, worldMatrix);
OUT.normal = mul(OUT.normal, viewMatrix);
OUT.normal = normalize(OUT.normal);

OUT.depth = mul(worldPos, viewMatrix).z;

return OUT;
}
float4 ps_SSAO(SSAO_PS_INPUT IN) : SV_Target
{
return float4(IN.normal,IN.depth);
}
technique10 SSAO_T
{
pass P0
{
}
}


Basically, I'm confused as how to execute pass 2 using my generated map.

### #1bearsomg

Posted 29 May 2013 - 03:47 PM

I've been working on adding SSAO support to my Direct3D10 program, but I'm a bit confused when it comes to using the normal and depth maps to build the occlusion buffer, which is then blended with the scene. From my understanding, this is the process:

(Pass 1): Generate the normal and depth maps (I use one pass and put the normal in RGB and the depth in A)

(Pass 2): Generate the AO map using the view space normal/depth map

(Pass 3): Render the actual scene using the occlusion factor from the AO map generated in pass 2

I'm confused when it comes to pass 2. I'm attempting to follow the tutorial here: http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/a-simple-and-practical-approach-to-ssao-r2753 but I got confused with how to implement the shader. Namely, where does the

float2 uv


parameter come from in the pixel shader, and how is it calculated?

This is my shader for creating the normal/depth map:

//Vertex Input
struct VS_INPUT_SKIN
{
float4 position : POSITION;
float3 normal    : NORMAL;
float2 tex0    : TEXCOORD;
};
struct SSAO_PS_INPUT
{
float4 pos : SV_POSITION;
float3 normal : TEXCOORD0;
float depth : TEXCOORD1;
};
SSAO_PS_INPUT vs_SSAO(VS_INPUT_SKIN IN)
{
SSAO_PS_INPUT OUT;

float4 worldPos = mul(skinnedPos, worldMatrix);

OUT.pos = mul(worldPos, viewMatrix);
OUT.pos = mul(OUT.pos, projMatrix);

OUT.normal = mul(skinnedNormal, worldMatrix);
OUT.normal = mul(OUT.normal, viewMatrix);
OUT.normal = normalize(OUT.normal);

OUT.depth = mul(worldPos, viewMatrix).z;

return OUT;
}
float4 ps_SSAO(SSAO_PS_INPUT IN) : SV_Target
{
return float4(normedNorms,IN.depth);
}
technique10 SSAO_T
{
pass P0
{