Results 1 to 8 of 8

Thread: Two textures on one sphere.

  1. #1
    Guest

    Two textures on one sphere.

    I've got a sphere texturized with one texture, now I'm trying to add another over top of the first and make it transparent. Sorta like a cloud layer over a plant texture.
    how do I do this?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    B.C., Canada
    Posts
    367

    Re: Two textures on one sphere.

    Either use the ARB_multitexture extension, or draw the sphere twice, using blending the second time.

    j

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Caracas/Venezuela
    Posts
    182

    Re: Two textures on one sphere.

    well, a little more detailed explanation whould be to do something like this:

    -clearbuffers
    -prepare matrices

    -glDisable(GL_BLENDING);

    -setup texture 1
    -render sphere

    -glDepthFunc(GL_LEQUAL);
    -glEnable(GL_BLENDING);

    -setup texture 2
    -if (texture 2 has alpha channel) then
    - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    -else // do aditive
    - glBlendFunc(GL_ONE,GL_ONE);
    -endif
    -render sphere

    -swapbuffers


    Those blending functions are just two examples, but should be the two most common.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Apr 2000
    Location
    Redlands, CA, USA
    Posts
    233

    Re: Two textures on one sphere.

    > if (texture 2 has alpha channel)
    then - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    Yes, this function is the most common.
    But IMHO, in this way you are just wasting useful computational resources! (j/k)

    You can create your texture with premultiplied pixels. In this case you can put an additive (for example - gloss map) part into the very same texture:

    At = A; // dest. alpha value.
    RGBt = (A * RGB) + RGBadd

    glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );

  5. #5
    Guest

    Re: Two textures on one sphere.

    Originally posted by coco:
    well, a little more detailed explanation whould be to do something like this:

    -clearbuffers
    -prepare matrices

    -glDisable(GL_BLENDING);

    -setup texture 1
    -render sphere

    -glDepthFunc(GL_LEQUAL);
    -glEnable(GL_BLENDING);

    -setup texture 2
    -if (texture 2 has alpha channel) then
    - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    -else // do aditive
    - glBlendFunc(GL_ONE,GL_ONE);
    -endif
    -render sphere

    -swapbuffers


    Those blending functions are just two examples, but should be the two most common.
    OK. this sorta worked. I have no idea what you mean by alpha channel for a texture, I assume its somewhat similiar to how a gif has one color that is transparent. anyhow,
    I create the one texturized sphere, and then created the cloud sphere surrounding the first sphere, and slightly larger. I then textured it, and did the blending, with the GL_ONE, GL_ONE blendfunc and got a semi- transparent texture with quad lines visible in the non-transparent part of the second texture.. am I making any sense? So, basically it did work, but why are the polygon lines showing up in the second texture? If any of you guys could send me a simple sample (w/code) on how to do this, it would help alot.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Caracas/Venezuela
    Posts
    182

    Re: Two textures on one sphere.

    Serge K:
    Well, that's right. I'm not sure how many hardware implementations will benefit from something like this, but in theory it's more optimizable by the driver.

    dex44:
    alpha channel is like a Red channel, or a Green or a Blue channel, but instead of containing color information it contains transparency implementation, where the lower the alpha for a pixel the more translucent it is. For example, in 8bit alpha, alpha=64 will give you 25% opaque pixel, where alpha=192 will give you a 75% opaque pixel (25% translucent). Anyway, the final pixel color depends in other factors, such as alpha testing and blending functions.
    An RGBA image differs from a RGB image in that it uses four bytes per pixel instead of three in order to fit the alpha channel.


    [This message has been edited by coco (edited 01-11-2001).]

  7. #7
    Senior Member Regular Contributor
    Join Date
    Apr 2000
    Location
    Redlands, CA, USA
    Posts
    233

    Re: Two textures on one sphere.

    Originally posted by coco:
    Well, that's right. I'm not sure how many hardware implementations will benefit from something like this, but in theory it's more optimizable by the driver.

    It's not about hardware implementations...
    I just wanted to say that one can minimize number of the rendering passes with the smart blending function.

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    Tetova, MK, Macedonia
    Posts
    3

    Re: Two textures on one sphere.

    Does anyone has some exemple about this !
    If anyone has , please send it in aceka@yahoo.com

    Thanks !

Similar Threads

  1. Applying textures to a sphere. I know nothing about textures.
    By ElFlautas in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-28-2018, 03:47 AM
  2. Textures on and instances of a sphere
    By mountainoflight in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-18-2008, 06:47 AM
  3. Detail textures on a sphere
    By Freelancer in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 03-18-2006, 02:03 AM
  4. How to make textures mapping to sphere..
    By shellee in forum OpenGL ES
    Replies: 8
    Last Post: 10-27-2004, 08:38 PM
  5. Sphere textures and rotation.
    By Rhaegar in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-23-2003, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean