Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: What commands shall we use for a vecter array multiplies a matrix?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296

    Question What commands shall we use for a vecter array multiplies a matrix?

    I have an array of 2lines and 3 columns, and a matrix of 3x3, which were read into gpu mem in way of VAO.
    which command shall I use in vertex shader to get their product?
    #version 330
    in vec3 VertexPosition;
    in vec3 VertexColor;
    out vec3 Color;

    void main()
    {
    Color =VertexColor;
    //gl_Position = vec4(VertexPosition,1);
    gl_Position = vec4(dot(VertexPosition,VertexColor),1);
    }
    I use dot command, but nothing happened, except no color rendering.

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    I don't see any matrix in that code. Also, I'm not sure what you mean by "an array of 2lines and 3 columns." In any case, if you want to multiply a vector with a matrix, you just use *.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by Alfonse Reinheart View Post
    I don't see any matrix in that code. Also, I'm not sure what you mean by "an array of 2lines and 3 columns." In any case, if you want to multiply a vector with a matrix, you just use *.
    You are not good the answer,1, the dot product will result a value, but the shader requres a vec. 2. if use vex*mat format, can glsl accepts this formula? 3, if the mat includes triangles function, how shll we lead an argument in glsl?

    Well, in math, we have an array c,
    ( x1,y1,z1, x2,y2,z2)
    we have a 3x3 matrix A
    | a11 a12 a13 |
    | a21 a22 a23 |
    | a31 a32 a33 |
    if we think this c is also a matrix, we can get their product by two matrix multiplied,
    c.A = D;

    if a?? is a function of cos wt, tan nwt... how shall we transmit the arguements n, w, t at glsl? or in a word, how shall we calculate the complex mat in GPU part?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,658
    Quote Originally Posted by reader1 View Post
    You are not good the answer
    This doesn't mean what you think it does. Alfonse is trying to help you, and your response (though you might not realize it) verges on being rude.

    Please spend more time composing your posts in English.

    1, the dot product will result a value, but the shader requres a vec.
    You determine what your shaders require. You wrote it to require 2 vectors, so it does. That is not a fundamental requirement of shaders in general.

    2. if use vex*mat format, can glsl accepts this formula?
    Yes. For instance:

    * Uniform (GLSL) (OpenGL wiki)
    * GLSL Tutorial (Lighthouse3D)

    Search for "uniform mat4".

    3, if the mat includes triangles function, how shll we lead an argument in glsl?
    What's a triangles function?

    Well, in math, we have an array c,
    ( x1,y1,z1, x2,y2,z2)
    we have a 3x3 matrix A
    | a11 a12 a13 |
    | a21 a22 a23 |
    | a31 a32 a33 |
    if we think this c is also a matrix, we can get their product by two matrix multiplied,
    c.A = D;

    if a?? is a function of cos wt, tan nwt... how shall we transmit the arguements n, w, t at glsl?
    However you want. As individual floats, as a vector, a matrix, some other form, or not at all!

    You could just compute A on the CPU and pass it to the GPU shader as a "mat3". This is most common. Often times you don't care how the matrix was computed on the CPU. You just need it on the GPU to have it to transform vectors.

    or in a word, how shall we calculate the complex mat in GPU part?
    First, do you need to compute the matrix components on the GPU? If not, don't. Compute A once on the CPU, and then just pass the matrix to the GPU, for it to use across many vertices.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by Dark Photon View Post
    You are not good the answer This doesn't mean what you think it does. Alfonse is trying to help you, and your response (though you might not realize it) verges on being rude.
    .
    Eh, what does it mean in English according to the English speaking thinking? well, how to comment a guy in humor, who answered the question, but hit not the point?
    I shall use that next if you would put down and avoid making such critical point miatake.

    Please spend more time composing your posts in English.
    as soon as you don't understand what we said, pls ask, then we can explain further more in order to sync idea.
    if readers don't point out, who know where is mistake?

  6. #6
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    Quote Originally Posted by reader1 View Post
    Eh, what does it mean in English according to the English speaking thinking?
    It doesn't mean anything; according to English grammar rules, it's gibberish. Informally, we can guess that you didn't think the reply was helpful. But that's about all.

    Quote Originally Posted by reader1 View Post
    well, how to comment a guy in humor, who answered the question, but hit not the point?
    If there's a language barrier, it's usually a good idea to not attempt humor. If you don't translate it well, it only creates confusion.

    Quote Originally Posted by reader1 View Post
    as soon as you don't understand what we said, pls ask, then we can explain further more in order to sync idea.
    Here's the problem.

    It takes you maybe 3 minutes to compose your question. At some point, we read it, and because it was not clear, we have to take time to ask, "I don't understand what you meant by X." Then you read that and provide clarification. Followed by us asking for more clarification. This continues until it becomes clear what you're actually asking about.

    That's a waste of everyone's time, yours and ours alike. Instead, you should try to make your initial post as clear as possible, providing all relevant information and a firm understanding of what you're talking about.

    That will require taking more time in writing your posts.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Yes. For instance:
    That's enough, so simple, why many people can not reply like this? instead of many longer words.
    What's a triangles function?
    trigonometric function. that's really my mistake, means sin, cos...
    as if this were impossible
    You could just compute A on the CPU and pass it to the GPU shader as a "mat3". This is most common. Often times you don't care how the matrix was computed on the CPU. You just need it on the GPU to have it to transform vectors.
    I can do this on the cpu, but I try to implement it on the gpu for its high speed float calculation. ofcuase, if there would be too many vertices, the efficiency will be low. I get ride of it at present.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by Alfonse Reinheart View Post
    It doesn't mean anything; according to English grammar rules, it's gibberish. Informally, we can guess that you didn't think the reply was helpful. But that's about all.
    according to grammar? you maybe kidding. You are not good the answer Does it very ambiguous? or differnt meaning to cause rude concept?
    enlarge it infinitely?
    If there's a language barrier, it's usually a good idea to not attempt humor. If you don't translate it well, it only creates confusion.
    Language is an odd thing, once man repeats a good word for three times, you may feeel upset down.
    at this forum, we dont know each other, we have no basic interest conflict, why do we speak a rude word?
    barrier can be conquered, but if someone wish to mock, or to make a practice joke, that will be another matter.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    It takes you maybe 3 minutes to compose your question. At some point, we read it, and because it was not clear, we have to take time to ask, "I don't understand what you meant by X." Then you read that and provide clarification. Followed by us asking for more clarification. This continues until it becomes clear what you're actually asking about.
    That's a waste of everyone's time, yours and ours alike. Instead, you should try to make your initial post as clear as possible, providing all relevant information and a firm understanding of what you're talking about.
    That will require taking more time in writing your posts.
    That's really ridiculous. I couldn't imagine from where you take up this words.
    english maybe your mother tongue, I can also find grammar matter in your words. fo cause, sometimes theyare typo, other times you may get use to it without notice that.

    I remember said to a guy once, this is free forum, if you would be an enthusiast, you could help other by your capability.
    none enforces you to reply this or that. if we don't think you are right, we can argue until we reach a solution.

    Where is time-waste? are you sure you understand every words in the forum which is spoken out by english speaking guys?

  10. #10
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    Quote Originally Posted by reader1 View Post
    according to grammar? you maybe kidding. You are not good the answer Does it very ambiguous?
    Yes, it is ambiguous. You could mean, "Your answer is not good." Or you could mean "I don't think you are a good answerer."

    The difference between these two should be obvious.

    Quote Originally Posted by reader1 View Post
    That's really ridiculous. I couldn't imagine from where you take up this words.
    english maybe your mother tongue, I can also find grammar matter in your words. fo cause, sometimes theyare typo, other times you may get use to it without notice that.
    Everyone makes mistakes. Making an error in spelling or grammar happens every now and then. But that's not you. For you, it's far harder to find a sentence that's correct than to find one that's incorrect.

    Most of your statements are difficult to understand, either due to poor word choice, poor grammar, or just not providing sufficient information to understand what you're talking about. That makes deciphering your posts take longer.

    Quote Originally Posted by reader1 View Post
    I remember said to a guy once, this is free forum, if you would be an enthusiast, you could help other by your capability.
    none enforces you to reply this or that. if we don't think you are right, we can argue until we reach a solution.

    Where is time-waste?
    The "time-waste" would be the "we can argue until we reach a solution" part. You know, what we're doing right now. That's not productive.

    Here's an example of a good question from a non-native English speaker. He provides enough information to know what he's talking about in his initial post. He clearly took the time to make sure that his English was reasonably correct. And he attempted to understand the problem on his own before asking us about it, with a handy link to the subject of discussion.

    There was no need to have a back-and-forth discussion to discover what he's talking about. Nobody had to ask him for additional information. He asked a good, solid question, and therefore, he could get a good, solid answer (I hope) without people having to spend time asking him to clarify what he's talking about.

    That's a productive use of time.

    By comparison, here is one of your threads. It takes 8 posts and a full day of time before it has become clear what you're even asking for. If you'd just asked the question better to begin with, all of that could have been avoided.

    Therefore, it was not a productive use of time.

Page 1 of 2 12 LastLast

Similar Threads

  1. Modelview matrix -- which multiplies which?
    By jkj2000 in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 03-20-2009, 11:23 AM
  2. any trick to accelerate vecter normalize?
    By wycwang in forum OpenGL ES
    Replies: 12
    Last Post: 09-18-2007, 09:12 PM
  3. Performance : sqrt vs acos vs multiplies
    By David Spilling in forum OpenGL: GLSL
    Replies: 5
    Last Post: 02-24-2006, 03:57 AM
  4. Matrix Commands
    By plates in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-27-2001, 02:54 PM
  5. Faster Matrix Multiplies
    By Succinct in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 12-12-2000, 06:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean