Slug Production : Per Pixel Lighting demos released

Slug Production has released 8 demos using Per Pixel Lighting.
Every demo has been released with the source code.

There are 2 sections for lighting a scene.

  1. Section : Per Pixel Lighting using a 2D Texture
    Here’re the 4 differents demos for the Per Pixel Lighting
  • ARB Vertex Program
  • Dynamic LightMapping
  • NVIDIA Vertex Program
  • NVIDIA Vertex Program with Register Combiners
  1. Section : Per Pixel Lighting using a 3D Texture
    Here’re the 4 differents demos for the Per Pixel Lighting
  • ARB Vertex Program
  • Dynamic LightMapping
  • NVIDIA Vertex Program
  • NVIDIA Vertex Program with Register Combiners

LEYDER Dylan
Slug Production - http://www.slug-production.be.tf/

Just wanted to say your demos are looking better.

Just a question. I see that you are rendering the lightmap first, then the floor
texture. You do this in both your 2D and 3D lightmapping demos. The problem with
this for me is that when you turn off the lightmap, you’re blending the floor texture
with the background color again, like last time. Set your background color to all
green and you will see what I mean.

Is there any reason why you can’t switch those two passes, and draw the floor
texture first, then draw the lightmap? And still get the same effect?
This makes more sense to me.

Just a question. I see that you are rendering the lightmap first, then the floor
texture. You do this in both your 2D and 3D lightmapping demos. The problem with
this for me is that when you turn off the lightmap, you’re blending the floor texture
with the background color again, like last time. Set your background color to all
green and you will see what I mean.

Yes I tryed and it’s ugly man

In my engine, I use the PPL as this :

 // 1 Pass :
	if (Per_Pixel_Lighting)
		T3D_Render_Engine->Map_Display_Per_Pixel_Lightning(true);

// 2 Pass :
T3D_Render_Engine->Map_Display(false);

And I’ve got no trouble with that.

Is there any reason why you can’t switch those two passes, and draw the floor
texture first, then draw the lightmap? And still get the same effect?
This makes more sense to me.

I’ve not tryed but I think that’s it’s possible.

Another question. What’s the purpose of the ARB Vertex Program in your 2D and 3D demos?

They look the same as the dynamic lightmapping demos. I don’t use vertex programs,
and don’t know much about them, but to me it doesn’t look like they serve any purpose.

First :

They are not mainly there to speed up. and on NVIDIA cards they won’t by default mean a possible speedup, as they all have the fixed function wich can, or can not, depending on situation, outperform the vs…

Second : 90% of the time, the T&L part is NOT the bottleneck of your rendering. It’s 90% of the time the fillrate, or sending data over the busses.

Third : They are made to replace the fixed function by something flexible. You can do there in what ever you want. Thats their feature. They extend the capabilities of openGL.

You can read this :

PDF :

http://developer.nvidia.com/docs/IO/8230/GDC2003_OGL_ARBVertexProgram.pdf

Power Point Presentation :

http://developer.nvidia.com/docs/IO/8230/GDC2003_OGL_ARBVertexProgram.ppt

[This message has been edited by Leyder Dylan (edited 10-16-2003).]

Thanx for the code of the DL…but how do i configure the 2 tex units matrix to call only glDrawElement()?
Im doing

//binding shader…
static float op1[] = {1,0,0,0};
static float op2[] = {0,1,0,0};
static float op3[] = {0,0,1,0};

glActiveTexture(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex_light2d);

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, op3);
glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

glActiveTexture(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, tex_light1d);
glEnable(GL_TEXTURE_GEN_S);
glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, op2);

//rendering
//first i translate and rotate the object and then enter here
//tex unit 0, tex 2d
glMatrixMode(GL_TEXTURE);
glTranslatef(.5,.5,.5);
glScalef(1/radius,1/radius,1/radius);
glTranslatef(-light_pos.x,-light_pos.z,0);
//tex 1 , 1d texture
glActiveTexture(GL_TEXTURE1_ARB);
glMatrixMode(GL_TEXTURE);
glTranslatef(.5,.5,.5);
glScalef(1/radius,1/radius,1/radius);
glRotatef(90, 1,0, 0); //should i rotate to turn y values to z values?
glTranslatef(0,0,-lp.y);
glMatrixMode(GL_MODELVIEW);

but its not working…somebody help me, please…

Originally posted by Leyder Dylan:
[b]First :

They are not mainly there to speed up. and on NVIDIA cards they won’t by default mean a possible speedup, as they all have the fixed function wich can, or can not, depending on situation, outperform the vs…

Second : 90% of the time, the T&L part is NOT the bottleneck of your rendering. It’s 90% of the time the fillrate, or sending data over the busses.

Third : They are made to replace the fixed function by something flexible. You can do there in what ever you want. Thats their feature. They extend the capabilities of openGL.

You can read this :

PDF :

http://developer.nvidia.com/docs/IO/8230/GDC2003_OGL_ARBVertexProgram.pdf

Power Point Presentation :

http://developer.nvidia.com/docs/IO/8230/GDC2003_OGL_ARBVertexProgram.ppt
[/b]

So, if I understand you correctly, adding in these four lines:

glEnable(GL_VERTEX_PROGRAM_ARB);
glGenProgramsARB(1, &ARB_Vextex_Program);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, ARB_Vextex_Program);
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen((const char*)ARBVP), ARBVP);

is only there to improve performance? Everything else remains the same?

No, that was for introduce the ARB program. You can use it as a vertex array program and for the moment, I’m working to convert a vertex array program into a ARB vertex program.

Please wait …

You know, if you put a fps counter in your demos, people would at least have
something to gauge performance. I have a fast card, so I can’t visually compare
how fast it is compared to your demos.

Yes, excellent idea, I’ll do that tonight.

Or you can always just use Fraps (www.fraps.com)

Gator,

The conversion is done, you can check on my website for the source code.

In fact, you can use the ARB Vertex Program for lighting a scene because you use only 1 light texture so it will be easy and fast to use that instead of a display list, a simple loop …

// Bind your texture
glBindTexture(GL_TEXTURE_2D, Texture_TGA[0].Texture_ID);

// Draw the scene with lightmap
glDrawArrays(GL_QUADS, 0, 24);

Thanks, do you have a direct link? I looked at a few, but I didn’t see a fps counter.

[This message has been edited by gator (edited 10-26-2003).]

Oups, for the fps counter, not done yet !!! (kick me if u want )

For the link :

http://www.slug-production.be.tf/