Ssao

I finally had some time to continue with this shader :slight_smile: Now I've implemented what I think is a cross bilateral upsampling filter that prevents bluring over large differences in depth but doesnt care about normals for now. I first blur in X and then in Y. I render the SSAO to 512 and upsample it to 1024.



The drawbacks in the current implementation:

  • Horrible performance (25 fps at 1024) 
  • Ugly artifacts from the cross filter (probably because i only run it once in each direction)
  • Some edges are not blured at all (I've read somewhere that you need to blur them separately)
  • Something seems to be wrong with the SSAO shader or the normals of the model (the very black parts…)



    I’m not sure if it’s worth it to use a bilateral filter. Maybe it’s better to render to full resolution and do a normal blur filter.



    Some images:

What’s the point of upsampling it after blurring?



The blur definitely looks wrong, it bleeds over to various parts of the model, and seems to blur more on the X than on the Y… There are some links to tutorials about SSAO here which you might want to read.



It looked fine before, I think you just have to tweak the blur and fix the bleeding and then it’ll be good for use :slight_smile:

I'm not upsampling it after bluring. I upsample it while bluring.


  1. Render Depth, Normals (and later on material and color) to texture size 1024
  2. SSAO to texture size 512
  3. Blur the "SSAO texture" in X, to texture size 1024
  4. Blur the "Blured SSAO texture"in Y, to texture size 1024

    (later on, 5. Deferred lightning at size 1024)



    Isn't this how you do upsampling?



    The bluring is inspired by the BloomRenderPass, but I don't understand it completely so my implementation is probably different. For example I don't know how jME can handle this part correctly:


ts.setTexture(secondTexture, 0);
 fullScreenQuad.states[RenderState.RS_GLSL_SHADER_OBJECTS] = blurShaderHorizontal;
ts.setTexture(mainTexture, 0);
fullScreenQuad.states[RenderState.RS_GLSL_SHADER_OBJECTS] = blurShaderVertical;
                   



How can you attach two shaders to one node like that?

You thought it blured more in X than in Y? You'r correct, I had a typo ;) So I was taken four more blur samples in the X-direction...

i just used the poisson disc blur from the bloom effect which is extremely fast compared to the super slow ssao shader, so you should gain alot by going half size and upsampling