PDA

View Full Version : Slug Production : Per Pixel Lighting demos released



Leyder Dylan
10-14-2003, 07:34 PM
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

2. 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/

gator
10-15-2003, 03:16 PM
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.

Leyder Dylan
10-15-2003, 04:38 PM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

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.

gator
10-15-2003, 04:47 PM
Another question. http://www.opengl.org/discussion_boards/ubb/smile.gif 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.

Leyder Dylan
10-16-2003, 03:17 AM
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).]

Coluna
10-16-2003, 08:42 AM
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....

gator
10-16-2003, 10:54 AM
Originally posted by Leyder Dylan:
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



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?

Leyder Dylan
10-16-2003, 11:40 AM
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 ...

gator
10-16-2003, 12:39 PM
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.

Leyder Dylan
10-16-2003, 07:12 PM
Yes, excellent idea, I'll do that tonight.

jra101
10-16-2003, 08:01 PM
Or you can always just use Fraps (www.fraps.com) http://www.opengl.org/discussion_boards/ubb/smile.gif

Leyder Dylan
10-26-2003, 08:09 AM
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);

gator
10-26-2003, 01:19 PM
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).]

Leyder Dylan
10-27-2003, 12:28 PM
Oups, for the fps counter, not done yet !!! (kick me if u want http://www.opengl.org/discussion_boards/ubb/smile.gif )

For the link :

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