WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 04-02-2013, 12:04 AM
goro goro is offline
Member
 
Join Date: May 2012
Posts: 33
Hello all! We have developed further of our own and found one solution. We are sharing the code with you.

Code:
import viz
viz.go()

#Adding Models to two different scenes
piazza = viz.addChild('piazza.osgb',viz.WORLD,2)
pit = viz.addChild('pit.osgb',viz.WORLD,3)

#Creating render node & adding Render Texture for Scene 2
video1 = viz.addRenderTexture()
cam1 = viz.addRenderNode(size=(1280,720))
cam1.setScene(2)
cam1.setFov(60.0,1280/720.0,0.1,1000.0)
cam1.attachTexture(video1)
cam1.setRenderLimit(viz.RENDER_LIMIT_FRAME)

#Creating render node & adding Render Texture for Scene 3
video2 = viz.addRenderTexture()
cam2 = viz.addRenderNode(size=(1280,720))
cam2.setScene(3)
cam2.setFov(60.0,1280/720.0,0.1,1000.0)
cam2.attachTexture(video2)
cam2.setRenderLimit(viz.RENDER_LIMIT_FRAME)

# Adding quad to Main Scene & scaling & positioning it to occupy whole screen
quad = viz.addTexQuad(viz.WORLD,1)
quad.setPosition(0,1.8,4.1)
quad.setScale(4,3)

#Applying textures from outputs of Scene2 & Scene3
quad.texture(video1,unit = 0)
quad.texture(video2,unit = 1)

viz.scene(1) # Setting Scene 1 as main scene

#Applying post process shaders to Render Nodes 

#------------- Post Process Effects on Scene2--------------------#

fragCode = """
		uniform sampler2D InputTex;
		void main()
		{
			vec4 color = texture2D(InputTex,gl_TexCoord[0].st);
			gl_FragColor.r = dot(color.rgb, vec3(.393, .769, .189));
			gl_FragColor.g = dot(color.rgb, vec3(.349, .686, .168));
			gl_FragColor.b = dot(color.rgb, vec3(.272, .534, .131));
			gl_FragColor.a = color.a;
		}
		"""
		
SepiaEffectShader = viz.addShader(frag = fragCode)

ui_inputTex = viz.addUniformInt('InputTex',0)

cam1.apply(SepiaEffectShader)
cam1.apply(ui_inputTex)

#------------- Post Process Effects on Scene3--------------------#

fragCode = """
		uniform sampler2D vizpp_InputTex;
		void main()
		{
			vec4 color = texture2D(vizpp_InputTex,gl_TexCoord[0].st);
			gl_FragColor = vec4(1.0-color.r,1.0-color.g,1.0-color.b,1);
		}
		"""
		
InvertColorShader = viz.addShader(frag = fragCode)

ui_inputTex = viz.addUniformInt('InputTex',0)

cam2.apply(InvertColorShader)
cam2.apply(ui_inputTex)

#Applying Final Blending on quad

#------------------- Final Texure blend Effect -----------------------------#

VertCode = """
		void main()
		{
			gl_Position = ftransform();
			gl_TexCoord[0] = gl_MultiTexCoord0;
		}
		"""
		
FragCode = """
		uniform sampler2D tex1;
		uniform sampler2D tex2;
		void main(void)

		{
			vec4 texture1 = texture2D(tex1,gl_TexCoord[0].st);
			vec4 texture2 = texture2D(tex2,gl_TexCoord[0].st);

		   gl_FragColor = texture1* texture2;
		}
				"""

BlendShader = viz.addShader(vert = VertCode,frag = FragCode)


ui_tex1 = viz.addUniformInt('tex1',0)
ui_tex2 = viz.addUniformInt('tex2',1)


quad.apply(BlendShader)
quad.apply(ui_tex1)
quad.apply(ui_tex2)

#Locking mouse navigation as quad is 2D & objective is Augmented Reality & Not Virtual Reality
viz.mouse(viz.OFF)
And the output is:


We are getting the desired result. Our question is, is there any other much appropriate method or much optimized method to get the same?
Reply With Quote
 

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 02:44 AM.


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