WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-01-2015, 02:37 PM
lklab lklab is offline
Member
 
Join Date: Mar 2015
Posts: 20
Multiple post-process effects with oculus rift

I am using vizard 4 to interface with the oculus rift and am having problems using multiple post-process effects. When the main window is linked to the oculus, turning on a second post-process effect causes the effect to be applied to a new window. This is not a problem when the oculus is not linked to the screen.

Code:
from viz import *
import viz
import vizact
import oculus
import vizfx.postprocess 
from vizfx.postprocess.color import BrightnessEffect
from vizfx.postprocess.composite import BlendMaskEffect
from vizfx.postprocess.color import SaturationEffect
from vizfx.postprocess.effect import BaseShaderEffect


ground = viz.addChild('piazza.osgb')


#set up oculus rift
hmd = oculus.Rift()
sensor = hmd.getSensor()
viz.link(hmd.getSensor(), viz.MainView) 
vizact.onkeydown('r',sensor.reset)
viz.setMultiSample(8)
viz.go(viz.FULLSCREEN)



#fog
viz.fog(0.1)
viz.fogcolor(0.15,.20,.28)

#water postprocess effect
class UnderwaterEffect(BaseShaderEffect):
    def __init__(self, speed=1.9, scale=1.5, density=30.0, **kw): 
        self._speed = speed
        self._scale = scale
        self._density = density
        BaseShaderEffect.__init__(self,**kw)
    def _getFragmentCode(self):
        return """
        uniform sampler2D vizpp_InputTex;
        uniform float osg_FrameTime;
        uniform float speed;
        uniform float scale;
        uniform float density;
        void main()
        {
            vec2 uv = gl_TexCoord[0].xy;

            //bumpUV.y = fract(bumpUV.y - osg_FrameTime*0.1);
            vec2 dt;
            dt.x = sin(speed*osg_FrameTime+uv.y*density)*0.001*scale;
            dt.y = cos(0.7+0.7*speed*osg_FrameTime+uv.x*density)*0.001*scale;

            gl_FragColor = texture2D(vizpp_InputTex,uv+dt);
        }
        """
    def _createUniforms(self):
        self.uniforms.addFloat('speed',self._speed)
        self.uniforms.addFloat('scale',self._scale)
        self.uniforms.addFloat('density',self._density)
    def setSpeed(self,speed):
        self._speed = speed
        self.uniforms.setValue('speed',speed)
    def getSpeed(self):
        return self._speed
    def setScale(self,scale):
        self._scale = scale
        self.uniforms.setValue('scale',scale)
    def getScale(self):
        return self._scale
    def setDensity(self,density):
        self._density = density
        self.uniforms.setValue('density',density)
    def getDensity(self):
        return self._density
uweffect = UnderwaterEffect()
vizfx.postprocess.addEffect(uweffect)


flash = BrightnessEffect(brightness = .8)

urmask = viz.addTexture('urblendmask.jpg')
ulmask = viz.addTexture('ulblendmask.jpg')
drmask = viz.addTexture('drblendmask.jpg')
dlmask = viz.addTexture('dlblendmask.jpg')
stimeffects = [] 

ulstimeffect = BlendMaskEffect(ulmask,black=flash)
vizfx.postprocess.addEffect(ulstimeffect,window=viz.MainWindow)
ulstimeffect.setEnabled(viz.OFF)
stimeffects.append(ulstimeffect)
urstimeffect = BlendMaskEffect(urmask,black=flash)
vizfx.postprocess.addEffect(urstimeffect,window=viz.MainWindow)
urstimeffect.setEnabled(viz.OFF)
stimeffects.append(urstimeffect)
dlstimeffect = BlendMaskEffect(dlmask,black=flash)
vizfx.postprocess.addEffect(dlstimeffect,window=viz.MainWindow)
dlstimeffect.setEnabled(viz.OFF)
stimeffects.append(dlstimeffect)
drstimeffect = BlendMaskEffect(drmask,black=flash)
vizfx.postprocess.addEffect(drstimeffect,window=viz.MainWindow)
drstimeffect.setEnabled(viz.OFF)
stimeffects.append(drstimeffect)


vizact.onkeydown('1',ulstimeffect.setEnabled,viz.TOGGLE)
vizact.onkeydown('2',urstimeffect.setEnabled,viz.TOGGLE)
vizact.onkeydown('3',dlstimeffect.setEnabled,viz.TOGGLE)
vizact.onkeydown('4',drstimeffect.setEnabled,viz.TOGGLE)
vizact.onkeydown( '#', viz.window.screenCapture, 'image.bmp' )
Specifying the window does not appear to solve the problem, though I may be doing this incorrectly.

Is there a different way of interfacing with the oculus in vizard 4 (i.e. not using vizconnect) that will allow multiple post-process effects to be used at once?

If not, is there a way of creating a composite effect that could include both of these effects at once and allow me to update it and turn one of them off and on?
Reply With Quote
 

Tags
oculus, post-process, vizard 4, vizfx, window

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Oculus Rift Drift teklab Vizard 20 04-01-2016 07:57 AM
Oculus Rift and 360 Panorama with Vizard Lite Edition mshukun Vizard 4 11-10-2015 11:17 AM
Oculus Rift connection problem mshukun Vizard 1 10-01-2014 12:15 PM
Oculus Rift Fullscreen teklab Vizard 6 05-21-2014 06:11 AM
oculus rift and inertia cube interaction problems apboone Vizard 4 03-13-2014 10:45 AM


All times are GMT -7. The time now is 01:15 PM.


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