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

Thread: project section of a texture

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    project section of a texture

    i have this texture:


    i only want one of those circles to been projected on the scene.
    i can offset the projection coordinates to limit it to the lower left circle:

    Code :
    vec2 p = vec2( proj.x*0.333, proj.y*0.5 );
    Attenuation *= texture2D( texture, p/proj.w ).r;



    question: how do i have to offset the projection coordinates so that the other circles are projected? i guess those are not fixed values, but depend on the projector/fragment distance..

    btw: i cannot post topics with firefox anymore, the forums always tell me that "the host from which you are accessing the board is not recognized as a valid host."

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

    Re: project section of a texture

    You essentially want a scale-bias of the texture coordinates that work under projection, right? Well, you've figured out the scale already. For the bias all you have to do is multiply your bias with .w since that's what you divide with in the end.

    For instance, clip-space to texture coordinates:
    Code :
    texCoord = clipPosition;
    texCoord.xy *= 0.5;
    texCoord.xy += 0.5 * texCoord.w;

    The last line there offsets by 0.5.

  3. #3
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    Re: project section of a texture

    works fine, thanks!

Posting Permissions

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