WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-23-2012, 11:55 PM
leoaered leoaered is offline
Member
 
Join Date: Sep 2012
Posts: 5
Unhappy Shader Trouble

I'm trying to send the model view projection matrix from the CPU side into my shader, but it's not working as expected. I have two objects loaded into my scene, without any transformations: 'box.wrl' and 'ground.osgb'.

1) Sending over the projection matrix seems to mess up the order of rendering.
Code:
uniform vec4 S1, S2, S3, S4;
void main()
{
	gl_Position =  mat4(S1, S2, S3, S4) * gl_ModelViewMatrix * gl_Vertex;
	//gl_Position = ftransform();
}
When I pass in viz.MainWindow.getProjectionMatrix(), the scene looks OK, just the ground is rendered on top of the box. I don't really understand why, since if I use ftransform() or the inbuilt gl_ProjectionMatrix/gl_ModelViewProjectionMatrix the problem goes away. I also don't think there is a problem with the way I'm sending over the matrix, because I tried hardcoding the projection matrix into the vertex shader and had the same issue.

2) I can't get the view matrix to work, or I don't understand how to get it.
Code:
uniform vec4 S1, S2, S3, S4;
void main()
{
	gl_Position =  gl_ProjectionMatrix *  mat4(S1, S2, S3, S4) * gl_Vertex;
	//gl_Position = ftransform();
}
I tried passing viz.MainView.getMatrix() / viz.MainWindow.getMatrix() to no avail. The box doesn't show up properly. What am I missing? The model matrix should be identity because I didn't have any transforms on the objects.

*Sorry for the double post in Vizard 3.0 forum. I realized I posted on the wrong forum, and also have more useful information this time.
Attached Files
File Type: txt test.txt (1.3 KB, 976 views)
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 03:13 AM.


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