Results 1 to 4 of 4

Thread: ATI pont light attenuation

  1. #1
    Member Contributor
    Join Date
    Feb 2003
    Location
    Brazil
    Posts
    93

    ATI pont light attenuation

    Hi all;
    i've implemented a point light attenuation program for NV (using register combiners), and i wanna know if its possible to do that for ATI (7500 and better). I did it in software, but the results were very bad when my geometry gets more complex...
    thanx

  2. #2
    Member Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: ATI pont light attenuation

    i'm quite shure that there is no need in using of register combiners for that!
    you can use subtractive blending(see ext_blend_seperate) or use pregenerated 3d attenuation texture!
    how to do using blend? here's that
    1. do same things for texgen as you do for nv(you could also use vp instead to pregenerate texcoords)
    1.5. attenuation math: Intensity = 1 - (Texture0 + Texture 1)
    2. add 1d tex with 2d tex using glTexEnv(they look like gradients done in photoshop but it should be black inside and white at borders (the result will be inverted using blending))
    3. render object
    4. and the last part: (i'm not quite shure that it done correctly, but it works on my gf2 without register combiners)
    // like this:
    glBlendColor(1,1,1,1);
    glBlendEquation(GL_FUNC_SUBTRACT_EXT);
    gl->EnableBlending(GL_CONSTANT_COLOR_EXT, GL_ONE);
    glColor3f(lclr.x,lclr.y,lclr.z);
    object.Render();
    gl->DisableBlending();

    that's all!!!

    [This message has been edited by gvm (edited 09-03-2003).]

  3. #3
    Member Contributor
    Join Date
    Feb 2003
    Location
    Brazil
    Posts
    93

    Re: ATI pont light attenuation

    thanks for replying...do u have some code to generate the texcoords? i dont know if im doing in the right way...

  4. #4
    Member Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: ATI pont light attenuation

    you've said that you "implemented a point light attenuation program", aren't you?
    that's same way!
    how you've done updating of texture position on polygons then?
    you could use glTexGenf[v]();
    or simple vertex-program!
    here is how i done: (not good, but it works)

    float op1[] = {1,0,0,0}; float op2[] = {0,1,0,0}; float op3[] = {0,0,1,0};
    glActiveTexture(GL_TEXTURE0_ARB);
    glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, phong2d.GetId());

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    glEnable(GL_TEXTURE_GEN_S); glTexGenfv(GL_S, GL_OBJECT_PLANE, op1); glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
    glEnable(GL_TEXTURE_GEN_T); glTexGenfv(GL_T, GL_OBJECT_PLANE, op2); glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(.5,.5,.5);
    glTranslatef(-pos.x,-pos.y,0);
    glMatrixMode(GL_MODELVIEW);
    glActiveTexture(GL_TEXTURE1_ARB);
    glEnable(GL_TEXTURE_1D); glBindTexture(GL_TEXTURE_1D, phong1d.GetId());
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

    glEnable(GL_TEXTURE_GEN_R); glTexGenf(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv(GL_R, GL_OBJECT_PLANE, op3);

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(.5,.5,.5);
    glRotatef(90, 0, 1, 0);
    glTranslatef(0,0,-pos.z);
    glMatrixMode(GL_MODELVIEW);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);

    o.Render();

    glActiveTexture(GL_TEXTURE0_ARB);
    glDisable(GL_TEXTURE_GEN_S);
    glDisable(GL_TEXTURE_GEN_T);
    glDisable(GL_TEXTURE_2D);
    glActiveTexture(GL_TEXTURE1_ARB);
    glDisable(GL_TEXTURE_GEN_R);
    glDisable(GL_TEXTURE_1D);
    glActiveTexture(GL_TEXTURE0_ARB);

    glBlendColor(1,1,1,1); glBlendEquation(GL_FUNC_SUBTRACT_EXT);

    glEnable(GL_BLEND); glBlendFunc(GL_CONSTANT_COLOR_EXT, GL_ONE);
    glColor3f(lclr.x,lclr.y,lclr.z);
    o.Render();
    glDisable(GL_BLEND);
    glBlendEquation(GL_FUNC_ADD_EXT);

    // i'm not shure that last step is right and fast! maybe someone know how to do same with arb_texture_combine?

Similar Threads

  1. Help with 2D Light Attenuation
    By Falcdawg21 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-20-2010, 08:45 PM
  2. attenuation-independent light intensity
    By Vexator in forum OpenGL: GLSL
    Replies: 3
    Last Post: 09-03-2006, 10:53 AM
  3. light + attenuation + scissor
    By confy in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-06-2003, 08:11 AM
  4. Light attenuation
    By Csquared in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-08-2000, 08:36 PM
  5. Positional Light Attenuation w/ voodoo?
    By JMaynard in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 06-14-2000, 04:06 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