WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-06-2006, 10:47 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Panning Textures across a plane.

Helllo,

I'm attempting to create an old school environment by creating a clouds plane to put up in my sky.

I'm perfectly capable of getting the clouds to just sit there on my plane through a texture file, however what I want to know is if I can
move the texture over the plane in a direction so that it seems like they
are moving.

Thanks,
George

P.S. Is there a way to define a set color on a texure to be transparent? So that I can have multiple cloud cover layers to give things some depth?
Reply With Quote
  #2  
Old 04-06-2006, 11:29 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I've attached a sample script that shows how to move a texture across a surface:
Code:
import viz
viz.go()

viz.clearcolor(viz.SKYBLUE)

#Create a quad to display texture
quad = viz.add(viz.TEXQUAD)
quad.translate(0,1.8,3)

CLOUD_SPEED = 0.1

#Create texture with repeating wrap mode
tex = viz.add('ball.jpg')
tex.wrap(viz.WRAP_S,viz.REPEAT)
tex.wrap(viz.WRAP_T,viz.REPEAT)
tex.pos = 0

#Apply texture to quad
quad.texture(tex)

def ontimer(num):
	#Increment texture position
	tex.pos += CLOUD_SPEED * viz.elapsed()
	
	#Create transform for texture
	mat = viz.Transform()
	mat.setTrans(tex.pos,0,0)
	
	#Apply transform to texture
	quad.texmat(mat)

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0,viz.FOREVER)
There is no built-in command to set a transparent color on a texture. You can set the transparent level on an object though. If you want only a certain color to be transparent then you will have to use a shader or simply edit the image with a program like Photoshop and save it to a format that supports transparency (png,tiff,etc..).

Also, I've attached a sample script that uses shaders to creating a moving sky with two cloud layers. I think it might be usefull for you.
Attached Files
File Type: zip SkyTexture.zip (167.7 KB, 1244 views)
Reply With Quote
  #3  
Old 04-07-2006, 07:14 AM
halley halley is offline
Member
 
Join Date: Oct 2005
Posts: 27
farshizzo,

Thanks for the specific shader example (I don't think there's an example of this in the manuals). I will also put it to work in a couple outdoor scenarios I have.

Am I understanding it right that the .vp is a "vertex program" OpenGL shader, and the .fp is a "face program" or "fragment program"? You grab the timestamp of the frame, and give it to the .vp code as a parameter. The .vp chooses the appropriate coordinates in the texture to correspond to the frame time, for each vertex. The .fp chooses the appropriate pseudocoloring for a pixel inside a textured triangle face (or fragment) from the given monochrome texture.

Does Vizard parse and compile the .vp/.fp content, or does the underlying OpenGL graphics system?

[I noted you had some Unix line endings in your scripts when I viewed them in Notepad. If anyone else sees that, just replace the little box characters into line breaks. The Vizard editor itself doesn't mind the difference.]
Reply With Quote
  #4  
Old 04-07-2006, 08:45 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Quote:
Originally Posted by halley
Am I understanding it right that the .vp is a "vertex program" OpenGL shader, and the .fp is a "face program" or "fragment program"?
Yes, these are standard OpenGL vertex/fragment programs. Vizard 3.0 will support the higher level OpenGL shading language, which has a more C like syntax.

Quote:
Originally Posted by halley
Does Vizard parse and compile the .vp/.fp content, or does the underlying OpenGL graphics system?
Your OpenGL driver is in charge of compiling the program and uploading it to the graphics card.
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


All times are GMT -7. The time now is 03:23 PM.


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