![]() |
|
#1
|
|||
|
|||
|
manipulate contrast for one eye?
Hi all,
I am thinking of the best way to manipulate the contrast of a scene, but only for the rendering in one eye. I was able to edit the vizblur.py module to achieve this effect for resolution. Would a GLSL module be the best way to do this? Does anyone know of an easier way? |
|
#2
|
|||
|
|||
|
The following scripts shows how to use the post-process module to apply a contrast shader to the right eye. Let me know if anything is unclear.
Code:
import viz
viz.go(viz.STEREO_HORZ)
viz.add('gallery.ive')
import vizpp
left_frag = """
uniform sampler2D vizpp_InputTex;
void main()
{
gl_FragColor = texture2D(vizpp_InputTex,gl_TexCoord[0].xy);
}
"""
right_frag = """
uniform sampler2D vizpp_InputTex;
uniform float contrast;
void main()
{
vec4 color = texture2D(vizpp_InputTex,gl_TexCoord[0].xy);
gl_FragColor.rgb = mix(vec3(0.5,0.5,0.5),color.rgb,contrast);
gl_FragColor.a = color.a;
}
"""
class StereoEffect(vizpp.PostProcessEffect):
def _setupEffect(self):
self._contrast = viz.addUniformFloat('contrast',1.0)
self._leftShader = viz.addShader(frag=left_frag)
self._rightShader = viz.addShader(frag=right_frag)
self._rightShader.attach(self._contrast)
def _applyEffect(self,data):
if data.eye == viz.RIGHT_EYE:
data.overlay.apply(self._rightShader)
else:
data.overlay.apply(self._leftShader)
def setContrast(self,value):
self._contrast.set(value)
def getContrast(self):
return self._contrast.get()
effect = StereoEffect()
effect.setContrast(2.0)
vizpp.addEffect(effect)
|
|
#3
|
|||
|
|||
|
Works great, thanks a lot.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Better way to manipulate vcc that uses a ppt. | vEsotu | Vizard | 1 | 10-17-2008 06:49 PM |