trying to get ssao working, too

Posted By: ello

trying to get ssao working, too - 01/24/08 21:01

here are some screenies trying to adapt the blender node technique, but well, you'll see that there is a lot of banding and bleeding issue which i was not able to fix by now...





dunno if using a 32 bit floating point texture for the depth map could be the solution, since i cant get it to work.. BMAP* depthMap = "#800x600x14"; is always plain white

does someone knows how to render a 32F depth map??
Posted By: Inestical

Re: trying to get ssao working, too - 01/24/08 21:23

Why do you try to use 32bit f, when you're GPU might not support it.. try 16bit floating point instead. 16bits should be enough floating data
Posted By: ChrisB

Re: trying to get ssao working, too - 01/24/08 21:33

Seems to be a trendy to create ssao shaders.
here is mine first try: http://geschwollene-augaepfel.org/ssao/showImage.php
Mine have many errors.
Maybe we should open a new thread where we collect all implementations and discuss different techniques?
Posted By: ello

Re: trying to get ssao working, too - 01/24/08 21:37

hey, chrisB, yours look quite good to me. well comparable to the one found over at the gamedev forum.

what's your approach?


btw, inestical from what i know the geforce6800 should be able to use 32f
Posted By: xXxGuitar511

Re: trying to get ssao working, too - 01/24/08 22:44

@ChrisB. Looks really good, only complaint is the 14.5 fps I saw in one shot
Posted By: JibbSmart

Re: trying to get ssao working, too - 01/25/08 00:47

Quote:

dunno if using a 32 bit floating point texture for the depth map could be the solution, since i cant get it to work.. BMAP* depthMap = "#800x600x14"; is always plain white


put the depth in the red channel, and you could probably just ignore the green and blue, but i put them on 0, 0, and 1.0 for alpha anyway.

julz
Posted By: xXxGuitar511

Re: trying to get ssao working, too - 01/25/08 01:08

why not store the depth in blue and green as well?

Gives you a 256*4= 1024 byte range if you used addition. Pseudo-code:
Code:

out_color.r = clamp(depth , 0, 255);
out_color.g = clamp(depth-256, 0, 255);
out_color.b = clamp(depth-512, 0, 255);
out_color.a = clamp(depth-768, 0, 255);




...or you could use multiplication? giving you a 256+512+1024+2048= 3840 range (at least).Pseudo-code:
Code:

out_color.r = clamp(depth , 0, 255); // 0 - 255
out_color.g = clamp((depth-256)/2 , 0, 255); // 255 - 768
out_color.b = clamp((depth-768)/4 , 0, 255); // 769 - 1792
out_color.a = clamp((depth-3840)/8, 0, 255); // 1793 - 3840



...I'd give it a try, but I don't have my computer anymore, so I can't do shaders. Otherwise I'd be all over SSAO & shadowmapping
Posted By: PHeMoX

Re: trying to get ssao working, too - 01/25/08 02:12

Trick seems to be to render to the alpha channels instead of rgb channels... it's 8bit per color channel vs. 24Bit alpha channel apparently:
Quote:


ello: The trick is to render to depthmap to the alpha channel and not the rgb channel. The alpha channel is 24Bit whereas the rgb channels are 8 bit each. You might want to have a look at this paper:
http://ati.amd.com/developer/gdc/Scheuermann_DepthOfField.pdf />



Cheers
Posted By: BoH_Havoc

Re: trying to get ssao working, too - 01/25/08 02:42

wow very impressive shots!

Quote:

dunno if using a 32 bit floating point texture for the depth map could be the solution, since i cant get it to work.. BMAP* depthMap = "#800x600x14"; is always plain white




Did you change your shader to only use the .r channel of the texture? A 16 or 32Bit fp texture only renders to the red channel as far as i know.

keep it up, really impressive!

[edit]
Quote:

Trick seems to be to render to the alpha channels instead of rgb channels... it's 8bit per color channel vs. 24Bit alpha channel apparently:

Quote:

ello: The trick is to render to depthmap to the alpha channel and not the rgb channel. The alpha channel is 24Bit whereas the rgb channels are 8 bit each. You might want to have a look at this paper:
http://ati.amd.com/developer/gdc/Scheuermann_DepthOfField.pdf
/>



Cheers




At the time i wrote this in my DoF thread i really thought that would be the case. But i think i was wrong. I read somewhere that an alpha channel always is 24Bit. However when you look at it that can't be the case. eg 32bit tga = 8Bit Red + 8Bit Green + 8Bit Blue + 8Bit Alpha ... 8+8+8+8 = 32. Can someone confirm this?
Posted By: JibbSmart

Re: trying to get ssao working, too - 01/25/08 02:43

no, look at the shader workshop. if you want to use a 32-bit floating point texture (such as in this case), store the depth in the red channel. the others are redundant in this case, i'm pretty sure. you have to output a float4 colour (COLOR0 semantic) but in this case only the red matters.

julz

EDIT: not @ BoH_Havoc, who said what i said before but more clearly.
Posted By: ello

Re: trying to get ssao working, too - 01/25/08 07:15

thanks for sharing your ideas, gonna check them out
Posted By: Excessus

Re: trying to get ssao working, too - 01/25/08 10:23

Could you expand a little on the technique you use? Do you simply take a depth delta between the current and surrounding pixels, or do you actually unproject some points to check for occlusion? How many samples?
Posted By: Machinery_Frank

Re: trying to get ssao working, too - 01/25/08 10:35

I hope you all can work something out together. You could found a shader-group or 3dgs-shader-foundation
And after that you expand the 3dgs templates library and sell a pro template edition for a few dollars.

Very impressive. I like this shot very much:


Posted By: Ready

Re: trying to get ssao working, too - 01/25/08 10:37

Now thats a nice idea ... I'd definitively buy it
Posted By: ello

Re: trying to get ssao working, too - 01/25/08 11:09

Excessus, yes.. its based on substracting the blurred depthmap from the unblurred one. thats why the edgebleeding is occuring,

here is the nodes image i based it on: http://mpan3.homeip.net/content/resources/ssao1.jpg

i need to find a way to prevent that damn edge bleeding... at least i'll see what happens if i get a real smooth blur. could be a nice scene effect
Posted By: bstudio

Re: trying to get ssao working, too - 01/25/08 12:22

boh_havoc did something about the edge bleeding in his DOF shader, maybe check that out. It was taken from a ATI paper I believe. Nice shader, maybe I should do some shader work too
Posted By: JibbSmart

Re: trying to get ssao working, too - 01/25/08 12:47

Quote:

Excessus, yes.. its based on substracting the blurred depthmap from the unblurred one.


exactly what i'm doing i was quite chuffed when i thought of it but as per usual i'm being beaten to the punch.

Frank's shot from ChrisB's is quite nice but looks very much like flash-photography because of the uniform soft-shadow-outline that isn't being chopped up over distance.

i spent about 10 minutes on mine today and got severely distracted, but i can always trust ello and BoH_Havoc (and ChrisB it seems) to put up some nice shader work.

julz
Posted By: BoH_Havoc

Re: trying to get ssao working, too - 01/25/08 12:59

Quote:

Excessus, yes.. its based on substracting the blurred depthmap from the unblurred one. thats why the edgebleeding is occuring,

here is the nodes image i based it on: http://mpan3.homeip.net/content/resources/ssao1.jpg

i need to find a way to prevent that damn edge bleeding... at least i'll see what happens if i get a real smooth blur. could be a nice scene effect




Hmmm...interisting. I think i have an idea on how to use your method (which seems to be the real thing instead of my sloppy method) and get rid of the edge bleeding. I'll check it out and let you know if it works out.
Posted By: ello

Re: trying to get ssao working, too - 01/25/08 13:01

i am quite curious about that.. cant await to go on myself tonight
Posted By: Slin

Re: trying to get ssao working, too - 01/25/08 13:18

It looks quite good so far, I think that I should give it a try as well

A few things I found out in the last weeks are, that TargetMap is 32bit rgba with 8bit per channel (I wasn´t able to change that-.-).
You can change a bmaps format through bmap_to_format which gives you a few more possibilities for the format.
So, if you need a high precision, you will have to render to a bmap and use that one instead of TargetMap.
Posted By: BoH_Havoc

Re: trying to get ssao working, too - 01/25/08 15:28

hmm found a strange bug:
when using a 16bit fp texture i can render the shaderresult to a rt and use it lateron in another shader as mtlSkin.
however when using a 32bit fp texture the texture gets changed on the fly o_O eg. I render the result of the depthbuffer to a tex called s_bmap_depth. Now i create a stage that blurrs the depthbuffer. Now when i want to use the unblurred texture it doesn't work, it's also blurred. This is really strange.

So when you are changing your shader to use an fp texture, first try it with a 16bit fp tex.
Posted By: frazzle

Re: trying to get ssao working, too - 01/25/08 19:59

@ ello:

I guess you'll eventually get it right with some modifications but it looks promising so far
I've done some research and there are basically three tricks:



  • 1. applying dithering to the samplers since using a low sampling rate of the occlusion will cause artifacts. In your case, this could solve the edge bleeding issue.

  • 2. blurring the AO term and storing it in an occlusion map.

  • 3. create two passes.
    3.1 pass one ; rendering the scene normally.
    3.2 pass two ; full screen quad pass to compute the ambient occlusion at each pixel and use it to modify the already computed lighting from pass one.



Might be hard to achieve though but I guess this is logic since it's a next-gen shader effect

Edit: handy article about SSAO

Cheers

Frazzle
Posted By: Excessus

Re: trying to get ssao working, too - 01/25/08 20:28

Quote:

# 1. applying dithering to the samplers since using a low sampling rate of the occlusion will cause artifacts. In your case, this could solve the edge bleeding issue.



How can dithering solve the edge bleeding issue? Maybe I don't understand, but I don't think it solves the edge bleeding issues. I think you could solve the edge bleeding issues with a smart blur. Don't blur the pixel if the depth delta with neighbours is too big.

Quote:


# 3. create two passes.
3.1 pass one ; rendering the scene normally.
3.2 pass two ; full screen quad pass to compute the ambient occlusion at each pixel and use it to modify the already computed lighting from pass one.




That's not really a trick is it? It's the whole idea of the algorithm sumarized.


I think you won't get very good results with this technique, ello (I would be happy if you proved me wrong!). I think you'll get better results when you use the technique shown in the article frazzle posted. You have to actually unproject some points (with the depth and view vector) to check for occlusion.
Posted By: frazzle

Re: trying to get ssao working, too - 01/25/08 21:04

@ Excessus:

I didn't stated it from my own experience, I actually never tried AO and I barely was up-to-date about the logarithm used within SSAO so I did some research about it. The article I posted was the fundation were on I posted the suggestions, that's why I wrote 'could'
Anyway, thanks for correcting this and I hope this article is somehow helpful to you ello

Cheers

Frazzle
Posted By: JibbSmart

Re: trying to get ssao working, too - 01/25/08 22:14

download the shader workshops. you'll see how jcl uses a R32-bit TargetMap.

@BoH_Havoc: mine doesn't have that issue. i can't imagine what's happening, but mine works quite well (not the final result, yet, but the blurring of the R32-bit depth map in a separate map and comparing the results).

are you doing separate horizontal and vertical blurring to reduce the samples? i was planning on doing that if i find time today, but at the moment my shader (in a rather un-optimised fashion) generates the difference map in the same stage as the blur, so with no need to access the depth map later. i can't imagine why it would get blurred, though, if you have it in a different bmap altogether :S

julz
Posted By: frazzle

Re: trying to get ssao working, too - 01/25/08 22:52

Quote:


download the shader workshops. you'll see how jcl uses a R32-bit TargetMap.





Well, I know how it's handled but like I mentioned in my previous post, I didn't made the statement, I quoted it in order to give a 'potential' solution for edge blurring

Cheers

Frazzle
Posted By: JibbSmart

Re: trying to get ssao working, too - 01/26/08 00:15

twasn't directed at you it was actually @ Slin, and any others who haven't got 32-bit depth maps working the easy way.

julz
Posted By: ello

Re: trying to get ssao working, too - 01/26/08 12:57

frazzle, i came along that article, too, and it seems to be a cool approach. i was just not able to understand what rgba is telling there. maybe i need to look again and again until i get it. for now i know that my approach is not getting better
Posted By: frazzle

Re: trying to get ssao working, too - 01/26/08 17:00

@ Julz:

Ah oke, well I guess I misinterpretated that ^^
The reason why I thought that you adressed it towards me is because your post has got a 'RE: frazzle'

@ ello:

I think I need to do some check up work as well since I'm not fully up-to-date about ssao yet
Anyway, I hope you'll get it right soon

Cheers

Frazzle
Posted By: JibbSmart

Re: trying to get ssao working, too - 01/26/08 23:08

Quote:

'RE: frazzle'


aha, sorry bout that. a symptom of "quick reply"

@ ello: i'd love to see screenshots using a 32-bit depth map, if there's any difference. with any luck i'll be able to have a somewhat decent ssao up soon too.

julz
© 2024 lite-C Forums