WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-14-2008, 06:45 AM
Joran Joran is offline
Member
 
Join Date: Jun 2006
Posts: 38
Send a message via Yahoo to Joran
Vertex shader performance problem

Hello,

I have just started experimenting with vertex shaders and I have a performance problem. Below is an example program that shows my problem:

Code:
import viz
import vizshape

viz.go()
vizshape.addGrid()
viz.MainView.setPosition(0, 1, -5)

vert = """
uniform float elapsedTime;

void main() {  
  if( gl_MultiTexCoord0.y > 0.0) {
    gl_Vertex.x += sin(gl_Vertex.x * 0.2 + elapsedTime * 1.0) * gl_MultiTexCoord0.y * 0.2;
    gl_Vertex.z += sin(gl_Vertex.y * 0.2 + elapsedTime * 1.0) * gl_MultiTexCoord0.y * 0.2;    
  }
  
  gl_FrontColor = gl_Color;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
"""

shape = vizshape.addQuad()
elapsedTime = viz.addUniformFloat('elapsedTime', viz.tick())
shader = viz.addShader(vert = vert, uniforms = [elapsedTime])
shape.apply(shader)

def onUpdate(e):
	elapsedTime.set(viz.tick())

viz.callback(viz.UPDATE_EVENT,onUpdate)
My problem is that when you check the statistics the Draw time is 15.00 (On my system), while it should be something like 0.02. If I do not update the elapsedTime uniform every frame, the performance is fine (but I have no animation). What am I doing wrong?

Greetings, Joran.
Reply With Quote
 

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
fps performance caused by garbage collection? Mike Konstant Vizard 7 09-03-2012 12:44 PM
Improve performance with large number of onthefly objects? Fox5 Vizard 7 04-28-2008 05:19 PM
5DT Data Glove 5 Ultra Problem bjgold Vizard 1 08-08-2006 04:08 PM
problem with female animations vmonkey Vizard 1 10-07-2005 10:36 AM
sound problem alaa Vizard 7 09-02-2005 01:13 PM


All times are GMT -7. The time now is 06:44 PM.


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