molstar / molstar

A comprehensive macromolecular library
https://molstar.org
MIT License
599 stars 140 forks source link

DOF shader #1103

Closed corredD closed 1 month ago

corredD commented 1 month ago

DOF planar effect image Screenshot 2024-04-24 122900 image

dsehnal commented 1 month ago

Cool

arose commented 1 month ago

Hi, two quick comments

corredD commented 1 month ago

I use the scene bounding sphere so its easier to find the proper area to be in focus. It will be the area at distance inFocus from the scene center. PPM is the size of the area. image I am trying to use the anti-alias pass, but when I use this.antialiasing.target.texture, the texture is emtpy ? How should the target be defined ? const input = antialiasingEnabled ? this.antialiasing.target.texture : (postprocessingEnabled ? this.postprocessing.target.texture : this.drawTarget.texture); Lastly I would like to be able to pass a toggle option, where the area in focus could be either the scene center or the current selection or mark. How could I retrieve this information of current loci/mark position from the render pass ?

arose commented 1 month ago

I am trying to use the anti-alias pass, but when I use this.antialiasing.target.texture, the texture is emtpy ? How should the target be defined ? const input = antialiasingEnabled ? this.antialiasing.target.texture : (postprocessingEnabled ? this.postprocessing.target.texture : this.drawTarget.texture);

will have to have a look

Lastly I would like to be able to pass a toggle option, where the area in focus could be either the scene center or the current selection or mark. How could I retrieve this information of current loci/mark position from the render pass ?

I think that is best done via a behavior that listens to selection changes and sets the dof params accordingly

arose commented 1 month ago

One thing I notices (specifically with 1TQN or another small example) is that there is blur even in the middle of the focus region.

corredD commented 1 month ago

It should be easier now to control the position of the effect, it use either the center of the visible scene or the camera current target position. In planar mode, the blur effect is applied to the plane at distance inFocus of the center z distance with a width of PPM. In spherical mode, the blur effect is applied outside a sphere centered at center and of radius PPM. image image image image

now just need to figure out how to pass the correct inputTarget : const input = antialiasingEnabled ? this.antialiasing.target.texture : (postprocessingEnabled ?

arose commented 1 month ago

Very nice addition with he camera target. Should it be the default?

Should PPM be exponential to make it more use-friendly in UI? Or maybe we should add ParameterControl opion for that, @dsehnal?

Parts that are in focus get some blurry halo, see below. Can the halo be avoided?

image

dsehnal commented 1 month ago

Should PPM be exponential to make it more use-friendly in UI? Or maybe we should add ParameterControl opion for that, @dsehnal?

Can you be a little more specific please?

arose commented 1 month ago

Should PPM be exponential to make it more use-friendly in UI? Or maybe we should add ParameterControl opion for that, @dsehnal?

Can you be a little more specific please?

exponential step-size, so you have finer control at smaller values