Advertisement

56 per pixel lights in VP and FP

Started by November 01, 2005 06:23 PM
10 comments, last by AndyTX 19 years ago
It runs the same speed as if the were no lighting! on 6600GT Anyone wanna see the code? Bobby [Edited by - BGCJR on November 1, 2005 9:14:12 PM]
Game Core
if it runs the same speed on all Geforce 6xxx cards then sure show me the source but if its specific to one card its not very useful.

----------------------------

http://djoubert.co.uk
Advertisement
I would love to see this.
I'm guessing you have a very big bottleneck somewhere else in your application?
Quote: Original post by rollo
I'm guessing you have a very big bottleneck somewhere else in your application?


:D QFT

Quote: Original post by rollo
I'm guessing you have a very big bottleneck somewhere else in your application?


Yea i would agree to that, and so do i, my engine runs in allmost the same speed no matter if i use one lightsource or ten (with full zfail shadow volumes and ppl).
Advertisement

Vertex Program
!!ARBvp1.0ATTRIB iPos = vertex.position;ATTRIB iNormal = vertex.normal;PARAM mvp[4] = { state.matrix.mvp };PARAM light[56] = { program.local[5..60] };#load light positionsPARAM c0 = {0.5, -1.0, 1.0, 0.024};# w is radiusTEMP R0,R1,R2,R3,R4,R5;TEMP lit;OUTPUT oPos = result.position;# shaderDP4 oPos.x, mvp[0], iPos;DP4 oPos.y, mvp[1], iPos;DP4 oPos.z, mvp[2], iPos;DP4 oPos.w, mvp[3], iPos;MOV result.color, vertex.color;MOV result.texcoord[0],vertex.texcoord[0];MOV result.texcoord[1],vertex.texcoord[1];# light 1ADD lit, iPos, -light[1];MUL R0, c0.w, lit;MOV R1,R0;# light 0ADD lit, iPos, -light[0];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 2ADD lit, iPos, -light[2];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 3ADD lit, iPos, -light[3];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 4ADD lit, iPos, -light[4];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 5ADD lit, iPos, -light[5];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 6ADD lit, iPos, -light[6];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 7ADD lit, iPos, -light[7];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 8ADD lit, iPos, -light[8];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 9ADD lit, iPos, -light[9];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 10ADD lit, iPos, -light[10];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 11ADD lit, iPos, -light[11];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 12ADD lit, iPos, -light[12];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 13ADD lit, iPos, -light[13];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 14ADD lit, iPos, -light[14];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 15ADD lit, iPos, -light[15];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 16ADD lit, iPos, -light[16];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 17ADD lit, iPos, -light[17];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 18ADD lit, iPos, -light[18];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 19ADD lit, iPos, -light[19];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 20ADD lit, iPos, -light[20];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 21ADD lit, iPos, -light[21];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 22ADD lit, iPos, -light[22];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 23ADD lit, iPos, -light[23];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 24ADD lit, iPos, -light[24];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 25ADD lit, iPos, -light[25];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 26ADD lit, iPos, -light[26];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 27ADD lit, iPos, -light[27];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 28ADD lit, iPos, -light[28];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 29ADD lit, iPos, -light[29];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 30ADD lit, iPos, -light[30];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 31ADD lit, iPos, -light[31];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 32ADD lit, iPos, -light[32];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 33ADD lit, iPos, -light[33];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 34ADD lit, iPos, -light[34];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 35ADD lit, iPos, -light[35];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 36ADD lit, iPos, -light[36];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 37ADD lit, iPos, -light[37];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 38ADD lit, iPos, -light[38];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 39ADD lit, iPos, -light[39];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 40ADD lit, iPos, -light[40];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 41ADD lit, iPos, -light[41];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 42ADD lit, iPos, -light[42];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 43ADD lit, iPos, -light[43];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 44ADD lit, iPos, -light[44];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 45ADD lit, iPos, -light[45];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 46ADD lit, iPos, -light[46];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 47ADD lit, iPos, -light[47];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 48ADD lit, iPos, -light[48];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 49ADD lit, iPos, -light[49];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 50ADD lit, iPos, -light[50];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 51ADD lit, iPos, -light[51];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 52ADD lit, iPos, -light[52];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 53ADD lit, iPos, -light[53];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 54ADD lit, iPos, -light[54];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;# light 55ADD lit, iPos, -light[55];MUL R0, c0.w, lit;ABS R4,R0;ABS R5,R1;SLT R2,R5,R4; MUL R2,R2,R5;SLT R3,R4,R5;MUL R3,R3,R4;ADD R1,R2,R3;MOV result.texcoord[2],R1;END


Fragment Program
!!ARBfp1.0PARAM c0 = {0.3, 0, 1, 0.5};TEMP R0;TEMP R1;TEX R0, fragment.texcoord[0], texture[0], 2D;DP3 R1.x, fragment.texcoord[2], fragment.texcoord[2];POW R1.x, R1.x, c0.w;ADD R1.x, c0.z, -R1.x;MIN R1.x, c0.z, R1.x;MAX R1.x, c0.y, R1.x;ADD R1.x, R1.x, c0.x;MUL result.color.xyz, R0, R1.x;MOV result.color.a, R0.a;END# 8 instructions, 2 R-regs, 0 H-regs.# End of program
Game Core
Well, for one thing, despite being arbvp1 that vertex program is probably compiled into shader 3; it's far too long to be anything else.

More importantly, I don't think any of these computations are even correct. You don't use the normal anywhere. And adding up all the contributions in the VS and then doing a single calculation in the PS also is incorrect and won't give you the correct lighting results for the object.

Lastly, you're not seeing any performance hit because you're probably barely rendering any vertices at all. Couple that with the fact that you're not doing any real PS work (and getting the wrong results) and that pretty much kills any usefulness of this.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
What? I wrote the ARBVP1.0 not compiled!
the FRAGMENT program i did borrow for the test.

Many Lights fragment lighting or something simuliar.

And it was just to test how many simutanious lights can be rendered at a time.

besides the Fragment Lights looks good for unrealistic rendering like most wanna-be games.

Bobby ;)
Game Core
These definitely aren't per-pixel lights as advertised, and doing lots of per-vertex lights has been done...

This topic is closed to new replies.

Advertisement