View Single Post
  #6  
Old 04-05-2013, 02:13 AM
goro goro is offline
Member
 
Join Date: May 2012
Posts: 33
We are sticking to same logic as above. We have wrote a code using the same logic which is discussed above. This program is working fine as no shader is applied. The program is as below:

Code:
import viz
viz.go()

#Adding WebCam
video = viz.add('VideoCamera.dle')
cam = video.addWebcam() 

#Adding & setting quad to Scene 1
quad1 = viz.addTexQuad(viz.WORLD,1)
quad1.setScale(2,1.5)
quad1.setPosition(0,1.8,2)

#linking quad to MainView to get Constant 3D
link = viz.link(viz.MainView,quad1)
link.preTrans([0,0,2])

#Adding piazza environment to Scene2
piazza = viz.addChild('piazza.osgb',viz.WORLD,2)

#Adding & setting quad to Scene 2
quad2 = viz.addTexQuad(viz.WORLD,2)
quad2.setScale(2,1.5)
quad2.setPosition(0,2,6)
quad2.texture(cam)

#Adding Render Texture to Scene2 & setting it as a Texture to quad1
CamScene = viz.addRenderTexture()
quad1.texture(CamScene)

#Adding Render Node in Scene2
rn = viz.addRenderNode(size=(1280,720))
rn.setScene(2)
rn.setFov(60.0,1280/720.0,0.1,1000.0)
rn.attachTexture(CamScene)
rn.setRenderLimit(viz.RENDER_LIMIT_FRAME)

viz.scene(1)
The output is as below:


The center quad is webcam image.

But when we add shader program to the above code

Code:
InvFragCode = """
		uniform sampler2D InputTex;
		void main()
		{
			vec4 color = texture2D(InputTex,gl_TexCoord[0].st);
			gl_FragColor = vec4(1.0-color.r,1.0-color.g,1.0-color.b,1);
		}"""

InvShader = viz.addShader(frag = InvFragCode)

rn.apply(InvShader)
rn.apply(viz.addUniformInt('InputTex',0))
it works well for the rest of the environment but the webcam image gets blackout as below:



We don't know why this is happening?! Please help us to solve this issue..
Thanks!
Reply With Quote