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 3 123 LastLast
Results 1 to 10 of 22

Thread: Reg Combiners ... Clueless

  1. #1
    Member Regular Contributor
    Join Date
    Aug 2001
    Location
    England
    Posts
    291

    Reg Combiners ... Clueless

    OK - this is the first time I've used register combiners, and I'm stuck.

    I want to take an RBG texture and occasionally convert it to gray scale. But I haven't got a clue how to do it quite frankly.

    I know that I need to ...
    input RGBA

    and output
    R = (R * 0.3) + (G * 0.59) + (B * 0.11)
    G = (R * 0.3) + (G * 0.59) + (B * 0.11)
    B = (R * 0.3) + (G * 0.59) + (B * 0.11)
    A = A

    But I'm looking at sample code which seems to bear no resmeblence to the spec. I think I've confused myself here. Or maybe getting up at 3am didn't help!!!

    My code so far is ...

    glEnable(GL_REGISTER_COMBINERS_NV);
    glDisable(GL_REGISTER_COMBINERS_NV);


    Impressive huh? All I need is the bits in the middle. Can anyone help? Please?

    Regards

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    Beloit, Wisconsin
    Posts
    562

    Re: Reg Combiners ... Clueless

    Originally posted by Shag:
    OK - this is the first time I've used register combiners, and I'm stuck.

    I want to take an RBG texture and occasionally convert it to gray scale. But I haven't got a clue how to do it quite frankly.

    I know that I need to ...
    input RGBA

    and output
    R = (R * 0.3) + (G * 0.59) + (B * 0.11)
    G = (R * 0.3) + (G * 0.59) + (B * 0.11)
    B = (R * 0.3) + (G * 0.59) + (B * 0.11)
    A = A

    But I'm looking at sample code which seems to bear no resmeblence to the spec. I think I've confused myself here. Or maybe getting up at 3am didn't help!!!

    My code so far is ...

    glEnable(GL_REGISTER_COMBINERS_NV);
    glDisable(GL_REGISTER_COMBINERS_NV);


    Impressive huh? All I need is the bits in the middle. Can anyone help? Please?

    Regards
    Ok, I've never used the registry combiners before, but what you want is (using NVParse):

    const0 = (0.3, 0.59, 0.11, 1);
    out.rgb = tex0.const0

    I think that's right...

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    Beloit, Wisconsin
    Posts
    562

    Re: Reg Combiners ... Clueless

    Nope, that's not right...

    Code :
    const0 = (0.3, 0.59, 0.11, 1);
    {
        rgb
        {
            spare0 = tex0.const0
        }
    }
    out.rgb = spare0
    That should work.


    [This message has been edited by NitroGL (edited 03-07-2002).]

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2001
    Location
    England
    Posts
    291

    Re: Reg Combiners ... Clueless

    And in terms of

    glCombinerInputNV()
    glCombinerOutputNV()
    etc

    Regards

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    748

    Re: Reg Combiners ... Clueless

    Using the spec and sample code to understand RC's is probably not the easiest way. Have a look at the RC presentations on NVIDIA's site, these contain invaluable diagrams.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Feb 2000
    Location
    France
    Posts
    1,118

    Re: Reg Combiners ... Clueless

    Funny, that was actually the purpose of an Effect I submitted to the nVIDIA contest that took place some time ago (no wonder why I didn't win a thing...).

    Actually, I did two versions: one with texture shaders (which was the aim !) and then one with the register combiners (after I realised that it was the most obvious and simple solution...).

    Anyway, here is the snippet that sets the RC up:

    Code :
      // Texture 0 - Normal texture//
      glActiveTextureARB(GL_TEXTURE0_ARB);
      glBindTexture(GL_TEXTURE_2D,1);
      glEnable(GL_TEXTURE_2D);
      glEnable(GL_REGISTER_COMBINERS_NV);
      glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV,2);
      float fGreyscale[4]={0.3,0.59,0.11,1};
      glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,fGreyscale);
      float fAlpha[4]={0,0,0,fFade};
      glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,fAlpha);
      // Combiner 0 calculates the grey texture //
      glCombinerInputNV(GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE0_ARB,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
      glCombinerInputNV(GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_B_NV,GL_CONSTANT_COLOR0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
      glCombinerOutputNV(GL_COMBINER0_NV,GL_RGB,GL_SPARE0_NV,GL_DISCARD_NV,GL_DISCARD_NV,GL_NONE,GL_NONE,GL_TRUE,GL_FALSE,GL_FALSE);
      // Combiner 1 interpolates between grey and color //
      glCombinerInputNV(GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE0_ARB,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
      glCombinerInputNV(GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_B_NV,GL_CONSTANT_COLOR1_NV,GL_UNSIGNED_IDENTITY_NV,GL_ALPHA);
      glCombinerInputNV(GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_C_NV,GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
      glCombinerInputNV(GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_D_NV,GL_CONSTANT_COLOR1_NV,GL_UNSIGNED_INVERT_NV,GL_ALPHA);
      glCombinerOutputNV(GL_COMBINER1_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE1_NV,GL_NONE,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
      glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_SPARE1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    Hopefully this is enough for you to go on (I don't remember the effect itself very well but I can have a look if something is missing).

    If you want the full source code, I can e-mail it to you.

    Regards.

    Eric

    EDIT: Just remembered that this actually more than you need ! This piece of code also interpolates between the greyscale version and the colored one according to the alpha value of GL_CONSTANT_COLOR1_NV... Anyway, you should be able to remove the useless part !

    [This message has been edited by Eric (edited 03-07-2002).]

  7. #7
    Member Regular Contributor
    Join Date
    Aug 2001
    Location
    England
    Posts
    291

    Re: Reg Combiners ... Clueless

    Cheers Eric/Opla, much appreciated.

    The spec implies

    glCombinerInputNV(GL_COMBINER0_NV, GL_RGB
    should be ...
    glCombinerInputNV(GL_RGB, GL_COMBINER0_NV

    or am I just reading this wrong?

    *Head spinning* lol

    Thanks again

    [This message has been edited by Shag (edited 03-07-2002).]

  8. #8
    Senior Member OpenGL Pro
    Join Date
    Feb 2000
    Location
    France
    Posts
    1,118

    Re: Reg Combiners ... Clueless

    The specs says:

    Code :
    GLvoid glCombinerInputNV(GLenum stage,GLenum portion,GLenum variable,GLenum input,GLenum mapping,GLenum componentUsage);
    Stage is GL_COMBINERi_NV and portion is GL_RGB or GL_ALPHA.

    Why do you say that the specs imply the opposite ?

    Regards.

    Eric

  9. #9
    Junior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    London, UK (but from France)
    Posts
    217

    Re: Reg Combiners ... Clueless

    it's glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, ...

  10. #10
    Junior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    London, UK (but from France)
    Posts
    217

    Re: Reg Combiners ... Clueless

    Arghh, Eric was faster ...

    Eric, je n'ai toujours pas reussi a t'envoyer d'email. a chaque fois j'ai un message d'erreur. peut-etre un filtre anti-spam ...

Posting Permissions

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