WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Depth of Field (https://forum.worldviz.com/showthread.php?t=4892)

Erikvdb 12-06-2013 04:40 AM

Depth of Field
 
Hi all,
Recently I've played around with the viz.postprocess module a bit, the effects of which are applied to entire screen. However, I am now looking to exclude some foreground objects from the getting blurred. Is that possible? You could describe it as a sort of depth of field, although I don't really need an accurate gradual blurring effect; just blur or no blur (per object).

I guess I should be looking into writing shaders, but for now that seems absolute wizardry to me :D

Vaquero 08-15-2016 04:59 PM

Depth of Field giveaway
 
2 Attachment(s)
Well, this answer may come too late for Erik, but it might still be useful for somebody. I took the depth of field GLSL code from Martins Upitis and ported it to Vizard. I left out the part for blurring the depth buffer, since it just introduced undesirable effects.
Attached is the file containing the DoFEffect ShaderEffect class (ppDoF.py.txt). I would have liked to just post the code, but it has 10.000 characters too many for the allowed limit.
There's also a screenshot attached showing the effect in action. It may not be perfect, but it's a start.

You can utilize the effect by saving the ppDoF.py.txt file somewhere where Vizard can find it and removing the .txt, and then importing it to your python scene file. Here's an example:
Code:

"""
Post-Processing Demo: Depth of Field.
"""

import viz
import vizconfig
import vizfx.postprocess

# Import the script that contains the DoFEffect post-processing class.
import ppDOF as dofFX

import vizinfo
# Setup info panel
info = vizinfo.InfoPanel()

viz.go()

import vizcam
vizcam.PivotNavigate(center=[0,1,0],distance=10)

# Setup Scene
viz.add('piazza.osgb')

# clipping planes in meters
nearClip = 0.1
farClip = 200.0

# Create the DoF effect
effect = dofFX.DoFEffect(nearClip,farClip)
vizfx.postprocess.addEffect(effect)

# Make effect config window visible
vizconfig.register(effect)
vizconfig.getConfigWindow().setWindowVisible(True)

The effect has a lot of settings you can customize.

Erikvdb 08-16-2016 08:27 AM

That's awesome, thanks for sharing!


All times are GMT -7. The time now is 08:27 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC