Results 1 to 6 of 6

Thread: Can shader programs return values?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Can shader programs return values?

    Hello,

    i want to perform some matrix multiplications on the GPU with no relation to graphics rendering.
    I know i can pass data to the shader with glBindBuffer and glBufferData and manipulate it there... but is it somehow possible to get data back to my program?

    I thought of calling a function like "glGetBufferData" after running the shaderprogram... but i couldn't find something like this.

    Is there a way to do this?

    Thank you for your effort

  2. #2
    V-man
    Guest

    Re: Can shader programs return values?

    tranform feedback

    or use another lib like opencl or cuda.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,655

    Re: Can shader programs return values?

    In addition to those, can render to a float texture or renderbuffer and read that back.

    Are your matrices of large size? Are they sparse or dense?

    It'd be worth thinking carefully about the multiply technique you use to minimize memory bandwidth. Often these kind of algs can use shared memory on the GPU to great advantage. To do so you'll need to use OpenCL or CUDA. And there's already matrix multiply code in these (CUDA at least) that you can just pick up and use.

    I'd start here:

    * http://www.google.com/search?q=matrix+multiply+%28cuda|opencl%29&ie= utf-8&oe=utf-8
    * http://www.google.com/search?q=matri...8&oe=utf-8

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Re: Can shader programs return values?

    Hi there,

    i should have said that i'm using WebGL and so there is no CUDA or something, just OpenGL2
    i just want to shift some matrix multiplications from javascript to the shaders

  5. #5
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675

    Re: Can shader programs return values?

    just OpenGL2
    There's no OpenGL 2 there either. There is OpenGL ES 2.0, but that's different from OpenGL 2.0.

    i just want to shift some matrix multiplications from javascript to the shaders
    Unless you are doing lots of matrix multiplications (like, tens of thousands per frame), you don't want to do this.

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    5

    Re: Can shader programs return values?

    Yes i think the overhead for few matrix multiplications is too big...

    But another use case would be to change an objects vertex model (for example with displacement mapping + height maps) and return the transformed object vertex buffer to the program

Similar Threads

  1. gluUnproject return values depend on cam rotation
    By increator in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 09-18-2011, 03:10 AM
  2. GL_SAMPLE_POSITION return null values
    By vkMarco in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-24-2011, 03:26 PM
  3. shadow2DProj return values
    By RenderBuffer in forum OpenGL: GLSL
    Replies: 3
    Last Post: 11-07-2008, 11:24 AM
  4. Keyboard return values
    By Bill Stanley in forum OpenGL: Windows
    Replies: 1
    Last Post: 10-24-2004, 03:25 AM
  5. glReadPixels() doesnt return exact values
    By okapota in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 01-30-2001, 12:43 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