Hi,
In a fast check I can see several troubles on your rendering processes. Hard to explain them all but I will try with some.
Let's start with the view space normals buffer rendering shader:
1. The pixel shader input does not fit the vertex shader output. It should look like this:
float4 Shader_PS(VS_OUT input) : COLOR
2. The normals have to be converted to a 0<->1 range into the pixel shader. Otherway the normals with a negative component will fail. You will need to normalize the ponderated normals before converting them.
input.Norm = normalize ( input.Norm );
input.Norm *= 0.5f;
input.Norm += 0.5f;
return float4 ( inputNorm.xyz, 1.0f );
3. The alpha value of the returning vector of the pixel shader has to be 1.0f instead of 0. Otherway it will save nothing into the buffer.
4. You should delete the WorldPos member of the vertex shader output struct.
5. You will save a little rendering time by casting the matWorldView matrix to a float3x3 matrix, so it only rotates the normal with no traslating and scaling computations.
Out.Norm = mul ( Normal, (float3x3)matWorldView );
6. The TargetMap bitmap sampler is not needed at all.
7. The shader has no support for alpha channeled textures such leaves and so. You will need to check the texture alpha value in order to safe the opaque pixels only. These textures need to set 'AlphaBlendEnable=True;' into the technique pass to be correctly rendered.
Tips for the view space position buffer rendering shader:
1. This buffer needs more accuracy than 8bits per channel. You will need set at least a 4x16bits bitmap to the view. Otherway it will generate terribly noticeable steps. Be afraid of this kind of bitmaps because are very expensive and slow on lowend machines.
g_buffer_pos = bmap_createblack ( screen_size.x, screen_size.y, 12222 ); // 14444 for 4x32bits bitmap
2. Save the position values straight. No further computations are needed.
return float4 ( input.viewpos.xyz, 1.0f );
3. The third and the seventh tip of the normals buffer are also applicable for this buffer.
3dgs views have the stage member that lets you use the CHILD flag in order to share the transformation matrix and view fustrum clipping. The way you wrote the code will compute the visible entities for each view with its performance lost.
camera->bmap = bmap_createblack ( screen_size.x, screen_size.y, 24 ); // save the main render on a bitmap to sample it on the last stage (the ssao shader).
set ( position_buffer, CHILD | SHOW );
set ( positionb_buffer, CHILD | SHOW );
set ( normal_buffer, CHILD | SHOW );
camera->stage = position_buffer;
position_buffer->stage = positionb_buffer;
positionb_buffer->stage = normal_buffer;
On this fast try the SSAO shader did not work properly as it is. I don't know why. The screen is cut on 4 squares by the center and no one of those is correct. I will take a deeper look.
Salud!