WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 09-24-2012, 09:18 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
By default, Vizard will automatically compute the near/far clipping planes based on what geometry is in view. The clip planes in the matrix returned by viz.MainWindow.getProjectionMatrix() won't match the clip planes that will be used to perform the rendering. This is why the ground shows up on top of the box.

You can use the viz.MainWindow.clip command to specify static clip planes. This will ensure the projection matrix is the same as the one being used to render the scene.

Here is an updated version of the script:
Code:
import viz, vizcam, vizshape, vizfx.postprocess, vizact

vizcam.PivotNavigate(center=[0, 0.1, 0], distance=5)
viz.go()

box = viz.addChild('box.wrl')
ground = viz.addChild('ground.osgb')

vertCode = """
uniform vec4 S1, S2, S3, S4;
void main()
{
	gl_Position =  mat4(S1, S2, S3, S4) * gl_ModelViewMatrix * gl_Vertex;
}
"""
fragCode = """
void main()
{
	gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
"""

shader = viz.addShader(vert=vertCode, frag=fragCode)
box.apply(shader)

# Use static clip plane so projection matrix doesn't change
viz.MainWindow.clip(0.1,100)
m = viz.MainWindow.getProjectionMatrix()

S1 = viz.addUniformFloat('S1', m[0:4])
S2 = viz.addUniformFloat('S2', m[4:8])
S3 = viz.addUniformFloat('S3', m[8:12])
S4 = viz.addUniformFloat('S4', m[12:16])
box.apply(S1)
box.apply(S2)
box.apply(S3)
box.apply(S4)
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
Vizard Headlight in Shader shivanangel Vizard 1 06-27-2012 01:19 PM
SSAO Shader Implementation FranciscoPeters Vizard 2 10-08-2011 04:19 AM
How to apply shader and render texture to an object whj Vizard 0 04-23-2010 12:23 PM
Multiple Textures for Diffuse and Specularity Shader Issue shivanangel Vizard 1 05-11-2009 10:44 AM
Specular Shader Issue shivanangel Vizard 2 05-06-2009 11:08 AM


All times are GMT -7. The time now is 05:00 PM.


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