WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-16-2011, 02:37 PM
Kaminski Kaminski is offline
Member
 
Join Date: Nov 2010
Posts: 36
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?
Reply With Quote
  #2  
Old 02-22-2011, 12:17 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #3  
Old 02-23-2011, 07:59 AM
Kaminski Kaminski is offline
Member
 
Join Date: Nov 2010
Posts: 36
Works great, thanks a lot.
Reply With Quote
Reply

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
Better way to manipulate vcc that uses a ppt. vEsotu Vizard 1 10-17-2008 05:49 PM


All times are GMT -7. The time now is 05:10 PM.


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