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

Thread: Use a texture to store information from fragment AND/OR vertex shader (Random write)

  1. #1
    Intern Contributor
    Join Date
    Jan 2018
    Posts
    51

    Use a texture to store information from fragment AND/OR vertex shader (Random write)

    No, I don't want to random write gl_FragDatas
    I want to write to an arbitrary location in a 3d texture from the fragment shader OR the vertex shader. I think I can make either work.

    I want to, while i'm drawing an object, map the fragment to a position in a 3D texture and write solid white to it to indicate that there was something at that XYZ location... Completely seperately from the normal gl_FragData[0] = vec4(*la-dee-da*);

    At the same time, i'd like to read from the last frame's 3d texture to determine if there is anything inbetween the fragment and the lights in the scene. I have figured out how to do this without branching.

    In this way, the goal would be to achieve approximately correct shadows without rendering the scene twice.

    With fragments I know there'd be the issue of fragments that were culled because they were on a backface or something, but with vertices I don't think i'd have that issue and of course I could always disable backface culling

    Is there some way I could achieve what I desire?

    -Geklmin

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,926
    Quote Originally Posted by Geklmin View Post
    I want to write to an arbitrary location in a 3d texture from the fragment shader OR the vertex shader. I think I can make either work.
    You need to use glBindImageTexture() and imageStore().

Tags for this Thread

Posting Permissions

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