Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

DP4 in GLSL

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am converting my VP to a vertex shader under GLSL and not sure but I can't find any DP4 functions like in a vertex program? All I see is dot() which only take single variable and not a vec4? Any ideas on that? Also I have a question on result.position in a vertex program under GLSL. What is the equivalent? I have to send some data to result.position... Thanks

Share this post


Link to post
Share on other sites
Advertisement
errm.. I dont know where you saw that but the Orange book as the dot() function able to take 2 float, vec2,vec3 and vec4 args.

gl_Position is the vertex position output variable

Share this post


Link to post
Share on other sites
Quote:
Original post by _the_phantom_
errm.. I dont know where you saw that but the Orange book as the dot() function able to take 2 float, vec2,vec3 and vec4 args.

gl_Position is the vertex position output variable


Oops my bad, dot() is overloaded I guess I will need to cast my float to a vec4... so gl_Position == result.position in a vertex program?

Thanks Phantom

Share this post


Link to post
Share on other sites
Also a quick question about gl_ModelViewProjectionMatrix. Is gl_ModelViewProjectionMatrix a mat4 variable? If so how do I access 4 floats at a time in GLSL? gl_ModelViewProjectionMatrix[0], gl_ModelViewProjectionMatrix[1], gl_ModelViewProjectionMatrix[2], gl_ModelViewProjectionMatrix[3]??? I am also using RenderMonkey and the syntax coloring doesn't work for gl_TextureMatrix[0]? So is gl_TextureMatrix a mat4 also? and do I access it the same way as ModelViewProjectionMatrix?

Sorry if this all seems noobish but I am new to GLSL and getting into porting over and not sure about somethings...

Share this post


Link to post
Share on other sites
yep, its a mat4 and you can access it via subscripts as you would a vector, each subscript returns a vec4 (in this case, if it was a mat3 it would be a vec3 and so on) of that column.

gl_TextureMatrix works the same way.

The spec tells you how big each matrix is(see the OpenGL.org site to download), however it might be worth getting hold of a copy of the Orange Book to really learn GLSL (or More OpenGL Game Programming when its published next month/October, as the GLSL section in that is damned good as well [grin])

Share this post


Link to post
Share on other sites
Quote:
Original post by _the_phantom_
yep, its a mat4 and you can access it via subscripts as you would a vector, each subscript returns a vec4 (in this case, if it was a mat3 it would be a vec3 and so on) of that column.

gl_TextureMatrix works the same way.

The spec tells you how big each matrix is(see the OpenGL.org site to download), however it might be worth getting hold of a copy of the Orange Book to really learn GLSL (or More OpenGL Game Programming when its published next month/October, as the GLSL section in that is damned good as well [grin])


So this should work???


mat4 mvp = gl_ModelViewProjectionMatrix;
mat4 mtx = gl_TextureMatrix[0];

//is this correct??? Should be but I have seen
//gl_ModelViewProjectionMatrix[0][0][0]????
vec4 temp = gl_ModelViewProjectionMatrix[0];



Share this post


Link to post
Share on other sites
Please excuse me for highjacking your thread, but is your shader by any chance a conversion of Michael Horsch's water shader (this one)?
I'm desperatly looking for a GLSL conversion of his shader and while trying to find one via google I've hit this thread ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by Hydrael
Please excuse me for highjacking your thread, but is your shader by any chance a conversion of Michael Horsch's water shader (this one)?
I'm desperatly looking for a GLSL conversion of his shader and while trying to find one via google I've hit this thread ;)

Yes it is. I am not able to get on my computer as of now. So email me

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!