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 5 of 5

Thread: Draw a point or circle with X,Y coordinate from fragment shader

  1. #1
    Intern Contributor
    Join Date
    Sep 2014
    Location
    Tucson
    Posts
    62

    Draw a point or circle with X,Y coordinate from fragment shader

    Is there a way to draw a pixel from fragment shared at X,Y coordinates.

    I iterate thorough the texture that contains the coordinates in R and G and i will sue those numbers to draw a point in the screen. For now i use 0-255 then once i solve this problem i can move on to another level using floats or using R and G for 16 bit precision.

    Thanks

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,471
    Quote Originally Posted by lummxx View Post
    Is there a way to draw a pixel from fragment shared at X,Y coordinates.
    A fragment shader cannot modify gl_FragCoord, and cannot affect framebuffer pixels other than the one for which it is invoked (whose position is stored in gl_FragCoord).

    It can modify arbitrary pixels in an image via imageStore().

  3. #3
    Intern Contributor
    Join Date
    Sep 2014
    Location
    Tucson
    Posts
    62
    I don't think i can use imageStore() in webGL :S

    I guess i have to iterate through all the sparse texture and find if the value belongs to that pixel.

    Thanks

  4. #4
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,924
    Or you could just do the conversion from a "sparse texture" to a regular texture on the CPU and upload it. It'd almost certainly be faster than doing potentially hundreds if not thousands of texture fetches every frame.

  5. #5
    Intern Contributor
    Join Date
    Sep 2014
    Location
    Tucson
    Posts
    62
    Quote Originally Posted by Alfonse Reinheart View Post
    Or you could just do the conversion from a "sparse texture" to a regular texture on the CPU and upload it. It'd almost certainly be faster than doing potentially hundreds if not thousands of texture fetches every frame.
    Yes i have a 2k by 2k texture now and that is all i need, but i have another problem. I need to iterate through that texture that has normalized data and i need to somehow draw a pixel if the latitude and longitude in the texture are within a small delta value that i give. I have posted another question on this. https://www.opengl.org/discussion_bo...95#post1280495

    This is for a prototype in Data Viz class but this seems a research question that the professor has for such a long time and it is a hard problem as he already mentioned.

    Thanks for help guys

Posting Permissions

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