Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Jan 2012
Offline Last Active Jun 10 2013 01:16 PM

Topics I've Started

SSAO in Direct3D10

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
     float4 position : POSITION;
     float3 normal    : NORMAL;
     float2 tex0    : TEXCOORD;
     float3 boneLinks : BONELINKS;    
    float4 pos : SV_POSITION;
    float3 normal : TEXCOORD0;
    float depth : TEXCOORD1;

    float4 skinnedPos = skinVert(IN.position, IN.boneLinks[2], MatrixPalette[IN.boneLinks[0]], MatrixPalette[IN.boneLinks[1]]);
    float3 skinnedNormal = skinNorm(IN.normal, IN.boneLinks[2], MatrixPalette[IN.boneLinks[0]], MatrixPalette[IN.boneLinks[1]]);

    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
        SetVertexShader( CompileShader( vs_4_0, vs_SSAO() ) );
        SetPixelShader( CompileShader( ps_4_0, ps_SSAO() ) );
        SetGeometryShader( NULL );


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

Shadow Mapping: Bleed through?

20 November 2012 - 03:53 PM


I have recently started working on implementing shadows in my rendering engine using shadow mapping with Direct3D10 and HLSL. So far, the algorithm is working nicely, except for a small problem.

When I move the camera behind an object that is lit on one side by a light source, the areas where the shadow is bleed through onto the other side of the model. For example, a character model has it's arm crossed in front of it's chest, and when you move behind the model you can see the shadow on the model's back. I'm assuming this is because the shader is just testing the depth values to see if the pixel is behind an occluder, and the back of the model is determined to be behind an occluder.

So, my question is, what would be the best and easiest way to fix this?

Thanks in advance!

Implementing SSAO in Direct3D 10

27 September 2012 - 03:06 PM


Could someone explain to me how I could implement SSAO in my Direct3D 10 program? Would it be possible to do all the calculations in one pass? I somewhat understand how the SSAO technique works, but I'm completely confused when it comes to implementing it.


Direct3D Not Displaying Vertex List

31 May 2012 - 03:27 PM

This probably seems like a generic question, but could somebody tell me why this code will not display these points? I'm sure there's a simple solution that I've missed.

I attached a zip containing the program's source file, header file, and a csv that contains all the vertex data the program is trying to load. The columns go x, y, and z respectively.

The MdlLoader class is a class that I wrote to load the data from the model file. I know for a fact that it is loading correctly because as you can see in the code, the program is correctly outputting another csv with the same vertex data in it. This is the one I included in the ZIP.

Thank you in advance!

EDIT: Sorry, apparently the ZIP was corrupted when uploading to here. Please use this one: www.justinman.net/dx.zip

Math Help - Automatically calculate camera rotation

24 March 2012 - 11:13 AM

Here's my issue:

My program has just a back wall and floor. The user is able to move the virtual camera around and zoom in and out. I need the floor to appear completely level, where the camera can only see the front of it, no matter what the Y translation coordinate or FOV is. What would the correct way to calculate the camera's Y rotation from the Y translation coord and FOV be?

Currently through experimentation, I was able to form an equation where it calculates rotation based on the Y translation coord, but obviously it does not work when the user zooms in or out (change in FOV).

I am using gluPerspective, and I would not like to change this.