![]() |
|
#1
|
|||
|
|||
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 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)) ![]() We don't know why this is happening?! Please help us to solve this issue.. Thanks! |
#2
|
|||
|
|||
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)) 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()) |
#3
|
|||
|
|||
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! |
![]() |
Tags |
multi pass, multi-pass, multipass, rendering |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
![]() |
||||
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 |