toji / webgl-source

WebGL renderer for Source Engine levels
240 stars 23 forks source link

Diffuse lighting seems to be broken. #2

Closed jbauman42 closed 12 years ago

jbauman42 commented 12 years ago

Looking at the demo, it seems that diffuse lighting is either 0 or 1, not in between. It seems like there's an issue with tangentLightDir in the vertex shader, as the y and z components are always 0.

toji commented 12 years ago

I assume that you're referring to the lighting on prop meshes, such as the ammo cabinets and haystacks, etc. If so, yes. I'm aware that the lighting algorithm is messed up. I've tinkered with it off and on but didn't have the time to fix it before the initial showing that I did. :(

If people are actually trying to use the code, I'll take another peek. It was one of those bugs that was driving me crazy.

toji commented 12 years ago

(The "Comment" button is very close to the "Comment & Close" button. Did you know?)

divergentdave commented 12 years ago

I think the issue may be with the "normal" vertex attribute. Coming into the mesh vertex shader, normal is always (0, 0, 0), whereas position, texture, and tangent all look fine. This in turn causes all the tangent space calculations to fall apart.

toji commented 12 years ago

Fixed by pull request from divergentdave. (Thank you!)