Skip to main content
GameDev.net gamedev.net
🔒 Locked

ssao - error on results. hidden parts are showing up

Started by murderv Oct 9, 2009 at 6:43 AM 11 replies 2.6k views
Original Post
murderv
murderv
hi there. im trying out the SSAO shader from www.gamerendering.com and i'm having some problems on the result image. back faces or hidden geometry show up and look really weird. i have transformed the normals by the matViewIT matrix and i also have transformed to screen space by the WVP matrix, either way i always get the same problems.. the target i render into to get normals and depth are set to compare_R_to_texture, its a 32bit float texture. have a look at this screens. Free Image Hosting at www.ImageShack.us Free Image Hosting at www.ImageShack.us steps im doing: render scene to texture and return screen-space normals in RGB channels and normalized linear depth at A channel. pass that texture and a noise texture to the SSAO shader and thats the result is that image there. any ideas? thanks in advance
b_thangvn
b_thangvn
Hi,

I'm not sure what causes this problem. Maybe it has something to do with your alpha and cullMode? I think you need to post some more code so everyone can understand your process better.
KRIGSSVIN
KRIGSSVIN
I'm sure you overwrite depth values everywhere. Drop more code.
murderv
murderv
ok, this is my texture and Render Target creation:


// this texture is 32bit float. CLAMP_TO_EDGE and filter set to NEAREST
_sceneNormalTex = new Texture( GL.GL_TEXTURE_2D );
_sceneNormalTex.createGLFloat( GL.GL_RGBA_FLOAT32_ATI, GL.GL_RGBA, sizeX, sizeY );

// this is the render target. i create a RT with color+depth components. and attach the above texture to it.
_sceneNormalRT = new FBO( _sceneNormalTex, GL.GL_TEXTURE_2D, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_DEPTH_COMPONENT );




this is the shader used to render the scene normals and linear depth to the Texture above



------------------------
vertexDepthOutput VS_DepthMap( in vertexDepthInput IN )
{
vertexDepthOutput OUT = (vertexDepthOutput)0;

float4 pos = float4( IN.position, 1.0 );
OUT.position = mul( worldViewProj, pos );

OUT.viewPos = mul( matModelView, float4(IN.position,1.0) );

OUT.normal = mul( worldViewProj, float4(IN.normal, 1) ).xyz;

return OUT;
}

float4 PS_NormalMap( in vertexDepthOutput IN ) : COLOR
{
//float depth = -IN.viewPos.z / farPlane;
//float depth = (-IN.viewPos.z * IN.viewPos.w) / farPlane;
float depth = length(IN.viewPos) / farPlane;

//float3 norm = normalize( IN.normal );
float3 norm = 0.5f * (normalize(IN.normal) + 1.0f);

return float4( norm.x, norm.y, norm.z, depth );
}

technique Technique_NormalMap
{
pass P0
{
VertexProgram = compile arbvp1 VS_DepthMap();
FragmentProgram = compile arbfp1 PS_NormalMap();
}
}

-----------------------


after i get this texture with normals and depth i pass it to the SSAO shader.

the SSAO shader comes from GAMERENDERING

its said to pass the normals in screen space and to pass a noise texture which i got from the website aswell.. well the results are what you can see above..

hope this is enough information..

thanks in advance for your help.
chrisATI
chrisATI
It looks like this is a problem with your render state. Double check that your depth test state is setup correctly.
RDragon1
RDragon1
Yep, looks like either you have depth test and/or write turned off
murderv
murderv
hi, i also thought so, but i have enabled depthtest and depthwrite when i render to the texture (this is the only time where i need z-buffer)

it shouldn't be the depth testing, coz when i set the texture alpha to 1.0 everything renders just fine. This problems seem related to the depth in the alpha channel. seems like for some weird reason it is using the texture's A channel (depth) for alpha.. if you look at the code you'll see i don't do that at all, anywhere.


i have found one weird thing.

i was using one texture for Normals+Depth in the example above. Just for testing, i have created 2 different textures, NormalTexture and DepthTexture and rendered seperately to each of them.

i have found that by doing this i actually got it to work without the problems above, BUT it only works right if i set the Alpha channel of the NormalTexture with the depth value anyway. If i set it to 1.0 as to make it competely opaque (since i shouldn't need the A-channel anymore) the results of the SSAO are different. looks more like omni-lighting effect other than ambient occlusion.

it's really weird effect and the changes needed to get it to look right have no sense..
chrisATI
chrisATI
Quote:
Original post by murderv
when i set the texture alpha to 1.0 everything renders just fine.


Oh, in that case then maybe you accidentally have alpha blend or test enabled?

murderv
murderv
eesh. that was correct. i had blending enabled when rendering to texture :/
thanks for your help..


one other thing, i get some wrapping problems with AO. it seems in the top and right borders of the screen it gets darker or whiter. seems like it fetches from the side of the texture with normals na depth.

how do you guys usually handle this problem ?
Schrompf
Schrompf
Set texture addressing mode to CLAMP.
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
murderv
murderv
hi, yes i thought of that and tried it. did not work that well. i get the same problems
b_thangvn
b_thangvn
Hi,

I think you have to set all textures that you sample from to CLAMP as long as they are involved in the SSAO calculation process.
murderv
murderv
yes, i have tried that.
i have set every rendertarget to clamp and even clamp_to_edge, i have set the random noise texture to clamp aswell, but the errors on image caused by this last change are very strange. i don't think noise texture should be clamped. i still get the problems with closed ambients like the sponza model. the lighting moves around, seems like it wraps. i'm not sure.

everything seems just like everyone does and still i've been having alot of problems..

thanks everyone for your help. i'll see what i can do from here

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.