blender

07-14-2004, 04:05 AM

I've run into troubles in making per-pixel lighting in Cg. First of all, here's the shaders I have written so far:

http://www.nomorepasting.com/paste.php?pasteID=16351

I think the problem must be in the shaders. The tangent space vectors should be ok, I think. Here's a shot so you can see them rendered over vertices:

http://koti.mbnet.fi/blender/poista/basis.jpg

I calculate the BiNormal in the vp atm, though I use VBO so it might be wiser to pre-calculate it too.

I also used the normalization cubemap to normalize the interpolated light and half vectors, but to exclude the possibility for the error to be in the cubemaps, I just normalize per-pixel until this problem is solved.

So... the actual problem. First of all, I can't see any specular hilights. I've tried everything but it just won't work. I hoped that maybe the solution is too obvious for mee to see after all this struggling and you could notice it.

In addition, isn't it right, that e.g. the light vector should be LightPosition-VertexPosition?

However, by doing this, the object is illuminated from the opposite side relative to light position.

Also, I took that object-to-tangent space code from some tutorial, which said that (0, 0, 1) is staring up. Does it matter, that in my code (which provides the light and viewer positions), (0, 1, 0) is straight up in object space?

Huh, if you consider my overview of the problem too confusing, just tell me about it. -Thanks.

http://www.nomorepasting.com/paste.php?pasteID=16351

I think the problem must be in the shaders. The tangent space vectors should be ok, I think. Here's a shot so you can see them rendered over vertices:

http://koti.mbnet.fi/blender/poista/basis.jpg

I calculate the BiNormal in the vp atm, though I use VBO so it might be wiser to pre-calculate it too.

I also used the normalization cubemap to normalize the interpolated light and half vectors, but to exclude the possibility for the error to be in the cubemaps, I just normalize per-pixel until this problem is solved.

So... the actual problem. First of all, I can't see any specular hilights. I've tried everything but it just won't work. I hoped that maybe the solution is too obvious for mee to see after all this struggling and you could notice it.

In addition, isn't it right, that e.g. the light vector should be LightPosition-VertexPosition?

However, by doing this, the object is illuminated from the opposite side relative to light position.

Also, I took that object-to-tangent space code from some tutorial, which said that (0, 0, 1) is staring up. Does it matter, that in my code (which provides the light and viewer positions), (0, 1, 0) is straight up in object space?

Huh, if you consider my overview of the problem too confusing, just tell me about it. -Thanks.