Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: how to transform the output of a fragment program to main memory

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2005
    Location
    China
    Posts
    11

    how to transform the output of a fragment program to main memory

    Recently i am studing GPGPU. my problem is how i transform the output of a fragment program to main memory.
    for example:

    float4 main(float3 Peye : TEXCOORD0,
    half3 Neye : TEXCOORD1,
    half2 uv : TEXCOORD2,
    half3 Kd : COLOR0,
    half3 Ks : COLOR1,
    uniform sampler2D diffuseMap,
    uniform float3 Plight,
    uniform half3 lightColor,
    uniform half3 shininess

    ) : COLOR0
    {....}

    i know this fragment program produce a result and then pass it to COLOR0.I want to know where COLOR0 is ?and if i want to use glreadPixels to
    transform it to main memory,what should i do?

    thanks for your concerning !

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: how to transform the output of a fragment program to main memory

    Color0 is the color output to the framebuffer (your window, pbuffer or texture - whatever you use). To get the data back to the memory you should use glReadPixels. Usually you will create a floating-point rendering target ans use it as a framebuffer via the FBO (framebuffer object) extension.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2005
    Location
    China
    Posts
    11

    Re: how to transform the output of a fragment program to main memory

    Thanks to Zengar.
    Now i can get the data back to the memory from pbuffer use glReadPixels.The new problem is the data were truncated to [0,1].

    In fact,there is only one float-point result i need,not 4 (rgba),just like this:

    fragment program:

    float main(...)
    {
    ...
    float result = 9999.999;
    return result;
    }

    you know if i use glReadPixels as usual,i get 1.0 not 9999.999.so what can i do? I read some materials said transform the data to depth buffer would be ok,but how to do it or would you like to give some other better suggestion?

    thanks to all of you!

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: how to transform the output of a fragment program to main memory

    Originally posted by Louvie:
    you know if i use glReadPixels as usual,i get 1.0 not 9999.999.so what can i do?
    As Zengar told you, you need to create floating point framebuffer. Additionally there are some vendor specific extensions that allows you to specify framebuffers with less than four channels.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •