WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-04-2009, 04:57 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is a sample script. The shader simply averages the image from each pass, you will need to replace that with your own shader code.
Code:
import viz
viz.go()

FRAG = """
uniform sampler2D Pass1;
uniform sampler2D Pass2;
uniform sampler2D Pass3;
uniform sampler2D Pass4;

void main()
{ 
	vec4 p1 = texture2D(Pass1, gl_TexCoord[0].xy);
	vec4 p2 = texture2D(Pass2, gl_TexCoord[0].xy);
	vec4 p3 = texture2D(Pass3, gl_TexCoord[0].xy);
	vec4 p4 = texture2D(Pass4, gl_TexCoord[0].xy);
	
	//TODO: Combine texture from each pass
	gl_FragColor = (p1+p2+p3+p4) * 0.25;
}
"""

def CreateRenderPasses():
	
	renderPass = []
	uniforms = []
	
	#Create post render pass that combines all passes
	postRenderPass = viz.addRenderNode()
	postRenderPass.setHUD(-1,1,-1,1,renderQuad=True)
	postRenderPass.setOrder(viz.POST_RENDER,-1)
	
	#Create each pass
	for x in range(4):
		
		#Create render texture
		renderTexture = viz.addRenderTexture()
		
		#Apply to post render pass
		postRenderPass.texture(renderTexture,unit=x)
		
		#Create uniform for texture unit
		uniforms.append(viz.addUniformInt('Pass'+str(x+1),x))
		
		#Create render node to render texture
		renderNode = viz.addRenderNode()
		renderNode.attachTexture(renderTexture)
		renderPass.append(renderNode)
		
	#Apply shader
	shader = viz.addShader(frag=FRAG,uniforms=uniforms)
	postRenderPass.apply(shader)

	#Set rotation offset of each render pass
	renderPass[0].setEuler(-30,0,0)
	renderPass[1].setEuler(-10,0,0)
	renderPass[2].setEuler(10,0,0)
	renderPass[3].setEuler(30,0,0)
	
viz.add('gallery.ive')

CreateRenderPasses()
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
View nlfrnassimi Vizard 0 03-17-2009 02:01 AM
View nlfrnassimi Vizard 4 03-12-2009 05:25 AM
problem with stereo mode shivanangel Vizard 3 10-17-2006 09:58 AM
keeping a 3d object in front of the view tavaksai Vizard 1 07-07-2004 09:33 AM
SEOS HMD 120/67 compatability John Vizard 18 05-28-2004 11:13 AM


All times are GMT -7. The time now is 09:35 AM.


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