RubendeBruin / DAVE

DAVE - Design Analysis Visualization and Engineering
Mozilla Public License 2.0
29 stars 7 forks source link

AA not working in combination with SSAO #155

Closed RubendeBruin closed 6 months ago

RubendeBruin commented 6 months ago

See the vtk forum:

def add_SSAO(ren):

    bounds = np.asarray(ren.ComputeVisiblePropBounds())

    b_r = np.linalg.norm([bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]])

    occlusion_radius = b_r * 0.1 # tune to your preference
    occlusion_bias = 0.04 # not actually sure what this does

    passes = vtk.vtkRenderPassCollection()
    passes.AddItem(vtk.vtkRenderStepsPass())

    seq = vtk.vtkSequencePass()
    seq.SetPasses(passes)

    ssao = vtk.vtkSSAOPass()
    ssao.SetRadius(occlusion_radius)
    ssao.SetDelegatePass(seq)
    ssao.SetBias(occlusion_bias)
    ssao.SetBlur(True)
    ssao.SetKernelSize(256) # if this is too low the AO is inaccurate

    fxaaP = vtk.vtkOpenGLFXAAPass() # Anti-Aliasing isn't included in the default
    fxaaP.SetDelegatePass(ssao)

    ren.SetPass(fxaaP)

    ren.SetUseDepthPeeling(True)
    ren.SetOcclusionRatio(0.1)
    ren.SetMaximumNumberOfPeels(100)

    return ren