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

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).]

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

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 glTexGenfv;
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?