WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
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
  #2  
Old 04-05-2013, 11:37 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Your code is applying the shader to all objects in the scene. It seems like you should be applying the shader to the quad that is rendering the rendered texture instead:
Code:
quad1.apply(InvShader)
quad1.apply(viz.addUniformInt('InputTex',0))
Also, you might want to consider using the vizfx.postprocess library. For example, here is your script converted to use the library with the built-in inverse color effect applied:
Code:
import viz
viz.go()

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

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

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

#Apply inverse post-process effect
import vizfx.postprocess
from vizfx.postprocess.color import InvertColorEffect
vizfx.postprocess.addEffect(InvertColorEffect())
Reply With Quote
  #3  
Old 04-05-2013, 10:10 PM
goro goro is offline
Member
 
Join Date: May 2012
Posts: 33
Render Node is a node; so my assumption was, we can apply shader to Render Node. Please correct me if I am wrong. We haven't applied InvShader to quad1, because we were planning to apply some other shader to quad1. So our process was:
Render Scene2 on Render node --> Apply InvShader on Render node and use it as a texture on quad1 --> apply SomeShader to quad1.

As per our knowledge vizfx.postprocess can be applied to window. We don't know how to apply it on scenes. Please let us know if there is any way.

Thanks!
Reply With Quote
Reply

Tags
multi pass, multi-pass, multipass, rendering

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
Rendering order? vOliver Vizard 3 09-29-2010 02:07 PM
rendering level shahramy Vizard 1 07-26-2010 12:12 PM
how to control vizard rendering shahramy Vizard 0 07-23-2010 10:50 PM
Any way to increase rendering resolution v-Salik Vizard 3 09-12-2007 04:57 PM
Texture map rendering problem JRichizzle Vizard 4 03-04-2004 07:20 AM


All times are GMT -7. The time now is 03:22 AM.


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