# 3D lighting + 3D Verlet Integration physics [Source]

### » Fri Dec 31, 2010 5:54 pm

for lighting I used two edges of the cube as vectors per face found the cross product to get a 3rd vector that gave me the normal of the cubes face, and then found the dot product of that normal vector and an unchanging "light direction vector" (specified with the variables 'Lx' 'Ly' and 'Lz') that belong to the object L (L is just an object i use to store variables, because its faster to write L than global('etc') all the time), anyways, i find the dot product using the components of the two vectors, then i find the norm of those vectors with distance formula sqrt(x^2+y^2+z^2), the norm of the light is precomputed in the variable ('Ln'). with the norms and the dot product i can get the angle between the vectors that they form in their unique plane, by dividing the dot product by the product of the two norms, and then finding the arccosine of that value. the lighting from therein is just setting the filter of the face to a scaled value of that angle difference. R=G=B=('Anglebetween'/180)*255
B
53
S
7
G
6
Posts: 1,948
Reputation: 7,641

### » Fri Dec 31, 2010 6:19 pm

I understood completely though I don't know where I'll be using it for.

Still, thanks for explaining
B
9
S
3
G
3
Posts: 366
Reputation: 2,301

### » Mon Jan 10, 2011 6:06 pm

What everyone else said. Beyond impressive! I won't go ahead and pretend that I do understand those events though...
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

### » Mon Jan 10, 2011 10:13 pm

[quote="PixelRebirth":3ofq8uaf]What everyone else said. Beyond impressive! I won't go ahead and pretend that I do understand those events though... [/quote:3ofq8uaf]

nobody actually understood those events
btw I talking about the explanation about the lighting systems quazi gave, felt like clarifying
B
9
S
3
G
3
Posts: 366
Reputation: 2,301

### » Tue Jan 11, 2011 2:55 pm

WTF Quazi, you gotta stop doing this. You're making us all look bad. Go finnish up a game or something else productive, and stop making me feel like a 4 year old.

The worst part is: You're good at the graphics-part as well.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

### » Sun May 22, 2011 12:07 am

I just stumbled upon this wonderful work of brilliance!
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

### » Sun May 22, 2011 10:59 am

You Sir, Are a genius.
B
22
S
3
G
6
Posts: 1,356
Reputation: 7,141

### » Sun May 22, 2011 9:01 pm

I didn't comment on this back then? You don't want to know what I thought back then as 99% was curse words! Still the same now. I can repeat one word though - "awesome"!
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Previous