View Full Version : manipulate contrast for one eye?
Kaminski
02-16-2011, 02:37 PM
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?
farshizzo
02-22-2011, 12:17 PM
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.
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)
Kaminski
02-23-2011, 07:59 AM
Works great, thanks a lot.
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.