Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Simple Cube Mapping on ARB_fragment_program

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2004
    Posts
    11

    Simple Cube Mapping on ARB_fragment_program

    Hello!
    I am trying to implement Simple Cube Mapping with ARB_fragment_program (not GLSL and not Cg).
    I dont know ARB_fragment_program very good. And this does not work:

    !!ARBfp1.0

    OUTPUT output = result.color;

    TEMP base;
    TEX base, fragment.texcoord[0], texture[0], CUBE;
    MOV output, base;

    END

    Any Idea? Thank you.

    <nobill>

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Location
    Silicon Valley
    Posts
    217

    Re: Simple Cube Mapping on ARB_fragment_program

    Can you be more specific about what is wrong? What do you see on the screen with this program? Have you tried

    MOV result.color.a, 1.0;

    to make sure that your color is opaque?

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2004
    Posts
    11

    Re: Simple Cube Mapping on ARB_fragment_program

    i try your code but nothing...
    the problem is that i can't see the objects that i render with the shader.
    Do you have any example of cubemapping with arb_fragment_program? I can't find anything...
    There must be a simple cube mapping fragment_program on this planet...

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2004
    Posts
    11

    Re: Simple Cube Mapping on ARB_fragment_program

    Ooops!
    My code was massy and i had an mistake a the shader setup.
    Now it works with this:

    !!ARBfp1.0
    TEX result.color, fragment.texcoord[0], texture[0], CUBE;
    END

    dut I still have the problem. The problem is the same with the problem you have when you do cubemapping with the fixed pipeline without enabling the texgens.
    How I will enable the texgens with the ARB_fragment_program?
    thank you!

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Simple Cube Mapping on ARB_fragment_program

    If you read the spec for ARB_fragment_program, you will note that TexGen is not available when a fragment program is enabled. It is up to you to write the appropriate code to generate the texture coordinates you want.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  6. #6
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,444

    Re: Simple Cube Mapping on ARB_fragment_program

    TexGen is vertex shading functionality. It's overridden by a vertex shader, not by a fragment shader. It should work fine with just a fragment program. I quickly checked the spec and didn't find anything saying otherwise.

  7. #7
    Junior Member Newbie
    Join Date
    Oct 2004
    Posts
    11

    Re: Simple Cube Mapping on ARB_fragment_program

    Humus you are right! I enable the auto tex toord generation and it works! But now i have one more problem. when I rotate the camera the cubemap rotates also! I mean... if I am over the cubemapped water and i start rotate the camera on the y-axis (looking left/right) I always have infrond the same cube map face. Maybe Need tou play with the texture matrix inside the vertex shader? But I dont know how some one can help me?

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2004
    Posts
    11

    Re: Simple Cube Mapping on ARB_fragment_program

    ok... I find the Doom3 Cube mapping shader:
    http://rafb.net/paste/results/UpSkqH43.html
    I use it And seems to work. But I have a other problem now...
    I have a Sphere (auxSolidSphere()
    I aply the cube map on it and its ok. But If I try to make it transpert enabling the GL_BLEND
    I get this strange error/artifact:
    http://briefcase.pathfinder.gr/downl...nd+Problem.JPG

    I have tried all the Blend Funcs. All have this problem.

    AnyIdea what is wrong? I guess not the Doom3 shader

  9. #9
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    883

    Re: Simple Cube Mapping on ARB_fragment_program

    Turn on backface culling. Problem is order of triangle rendering. If you render backfaces too, then if backfaces are rendered before frontfaces it will modify framebuffer and frontfaces will modify too. But if you render frontfaces first it will update depth buffer and backfaces will not be rendered.

    In case of sphere, depending on camera position, sometimes backfaces will be rendred first and produce rendering errors.

    yooyo

  10. #10
    Junior Member Newbie
    Join Date
    Oct 2004
    Posts
    11

    Re: Simple Cube Mapping on ARB_fragment_program

    well.. think I found it... A glEnable(GL_CULL_FACE) fix the problem...

Posting Permissions

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