WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-25-2014, 08:08 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can add textures through the uniforms attribute of the effect class within the _createUniforms method. Here is a simple example:

Code:
class WarpEffect(vizfx.postprocess.BaseShaderEffect):

	def _getFragmentCode(self):
		return """
		uniform sampler2D vizpp_InputTex;
		uniform sampler2D redTex;
		uniform sampler2D blueTex;
		uniform sampler2D greenTex;
		void main()
		{
			vec2 uv = gl_TexCoord[0].st;
			vec4 color = vec4(1.0);
			color.r = texture2D(vizpp_InputTex, texture2D(redTex, uv).rg).r;
			color.g = texture2D(vizpp_InputTex, texture2D(greenTex, uv).rg).g;
			color.b = texture2D(vizpp_InputTex, texture2D(blueTex, uv).rg).b;
			gl_FragColor = color;
		}
		"""

	def _createUniforms(self):
		
		# Create texture objects
		redTex = viz.addTexture(...)
		greenTex = viz.addTexture(...)
		blueTex = viz.addTexture(...)
		
		# Apply textures to effect (automatically assigns uniform IDs)
		self.uniforms.addTexture('redTex', redTex)
		self.uniforms.addTexture('greenTex', greenTex)
		self.uniforms.addTexture('blueTex', blueTex)

Have a look at the Post-Process basics page in the documentation for more info:

http://docs.worldviz.com/vizard/postprocess_basics.htm
Reply With Quote
 


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
Texture Coordinate Generation (TexGen) using Shader goro Vizard 1 05-31-2013 01:44 AM
How to render a texture of the transparent object and then blur it whj Vizard 1 09-25-2012 03:15 PM
Avatar texture swaping sleiN13 Vizard 5 06-24-2011 12:48 AM
How to apply shader and render texture to an object whj Vizard 0 04-23-2010 12:23 PM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 12:14 PM


All times are GMT -7. The time now is 04:21 AM.


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