Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Pixel Corruption From Neighboring Pixels with gl_FragCoord

  1. #11
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Quote Originally Posted by Rennie Johnson View Post
    Everything works great! Just the way you told me to do. However, I've got a new problem:

    Apparently, moving up to OpenGL 1.3 (Wow, I'm state-of-the-art now!) has obsoleted my drawing code which......NO LONGER WORKS!!!!
    Yeah, that's what I meant by "the built-in identifiers go away" in GLSL 1.3. Which is why I suggested:

    Alternatively, you'll probably just get it with the #extension GL_EXT_gpu_shader4 : enable you've got in there now, though you'll likely need to call texelFetch2D() instead of texelFetch() (for 2D textures anyway). GLSL 1.3 did away with all the sampler type suffixes from the names of the sampling functions, eliminating a lot of needless function list bloat.

    The issue with declaring 1.3 right now if you're using 1.2 (the default IIRC) is that the built-in identifiers (fixed-function shader shims) go away. Which may or may not be more code rework than you want to bite off right now.
    p.s to Cy Bo Rg:I met Mel Brooks at Metrocolor lab in 1986 when he was color timing the negative on SPACEBALLS.
    Ah yes! Der Schwartz lives on!

    No, it's not what you think. It's much, much worse!

    Yogurt! Yogurt! I hate Yogurt! Even with Strawberries.

    Ah, buckle this! LUDICROUS SPEED! *GO!*

  2. #12
    Intern Contributor
    Join Date
    Sep 2007
    Southern California
    Thanks again. texelFetch2D() is very happy, but I still have the transformation problem.

    Is it possible that by using textureFetch2D() I have circumvented the transformation by not using glFragCoord[0]?

    This is getty verrrry weird! It seems if I declare OpenGL 1.3 in one shader, it screws up other shaders, AND I'm not even getting paid for this project. So much for having your own business!

    Even after I solve this crap, I can see there will be a new issue:

    In order for the Fragment shader I've just created (with Dark Photon's help) to work properly, there cannot be any geometric transformation applied in advance. I have to work directly on the original host buffer pixels.

    Soooo, is there an way to apply a scale/translate/rotate operation to the target rFBO render texture after the Fragment shader has completed it's work.

    I don't ever attach multiple shaders, but can you attach a vertex shader after a Fragment shader and transform the output of the Fragment shader.

    May the Farce be with you!

    "You'll laugh. You'll cry. YOU'LL KISS THREE BUCKS GOODBYE."

  3. #13
    Intern Contributor
    Join Date
    Sep 2007
    Southern California
    Well, I've discovered that I can attach a Vertex Shader after the Fragment Shader, but all it does it manipulate a black matte over a non-moving image:

    Just a test shader:

    Code :
    void main(void)
    float offsetX = 0.0;
    float offsetY = 0.0;
    float xScale = 2.0;
    float yScale = 1.0;
    float rotation = 0.0;
    vec4 scale;
    vec4 offset;
    float rotationRadians = rotation  -0.0174532925 ;
    offset.x = offsetX;
    offset.y = offsetY;
    offset.z = 0.0;
    offset.w = 0.0;
    scale.x = xScale;
    scale.y = yScale;
    scale.z = 1.0;
    scale.w = 1.0;
    mat3 rotationMatrix = mat3( vec3( cos(rotationRadians), sin(rotationRadians), 0.0), vec3(-sin(rotationRadians), cos(rotationRadians), 0.0), vec3( 0.0, 0.0, 1.0) );
    gl_Position = gl_ModelViewProjectionMatrix  gl_Vertex;
    gl_Position += offset;
    gl_Position *= scale; *= rotationMatrix;

    How can I get the post-fragment vertex shader to scale the image? Or am I taking a stupid approach and should go to bed?

    p.s. I just figured out that your photo is from SPACEBALLS. I catch on fast, don't I????
    Last edited by Rennie Johnson; 10-06-2012 at 07:24 PM.

  4. #14
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Well, I've discovered that I can attach a Vertex Shader after the Fragment Shader
    That's not possible. Not in the way you seem to think it means, at least.

    The order you call glAttachShader is irrelevant; the vertex shader happens first. It always happens first. You can attach two vertex shader objects to a program at the same time and link them; if both of them have a `main` function, the linker will complain, but otherwise, the vertex shader will still happen first.

    So it's not clear what it is that you actually did. Show us the code you use to "attach a Vertex Shader after the Fragment Shader".

  5. #15
    Intern Contributor
    Join Date
    Sep 2007
    Southern California
    Well that explains the behavior. No need to post the code.Can you answer me:1) Is there a way to apply translate/rotate/scale transformations from the output of a fragent shader? I'm just doing a texture accessed render to FBO texture. Would that require two separate shader operations?2) If I'm using texelFetch2D() instead of texture2d(), do I lose the effects of glScalef() ,glTranslatef() and glRotatef() in a glBegin(GL_QUADS) drawing routine?If you require code, I'll try to organize that thoughtfully and post tomorrow.Thanks very much.

Posting Permissions

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