Normal Mapping with Bones

Started by AGP, December 07, 2013, 08:23:31 AM

Previous topic - Next topic

AGP

And, by the way, I did try a shader that produced NO shadows. Yours only makes Batman black, but he is still both visible and able to cast shadows.

EgonOlsen

Animated3D extends Object3D. And each Object3D has a Mesh instance. raft is actually right when he says that it can't return null. If it would, that Object3D wouldn't be renderable at all, because there's no data attached to it. You can set Mesh to null, of course. But you can't render that Object3D then. I'm not sure what you mean with your post about an alternative shader...but have you tried the jar that i uploaded?

AGP

#32
I hadn't noticed it until just now. Unfortunately, it's still black.

I don't understand how jpct is supposed to pass the shader its normals (I don't know how one interacts with the other). Where does it try that? I guess that functions dot, cross, normalize and the variable gl_Normal, etc. are lwjgl (OpenGL) functions, right? And I see your vec4 tangent global variable on the new shader. Still, where does anything attempt to fill it? And why is it vec4 on the new shader and it was a vec3 on the old one?

EgonOlsen

The tangent vectors will be filled at render time, if two preconditions are met:


  • the shader has an attribute with that name
  • the mesh has tangents generated

...that's all. If one preconditions isn't met, the tangents will remain (0,0,0), which results in a black rendering when using normal mapping. However, looking at the code and at your log output, i'm not sure what i'm seeing there...actually, the sequence should be something like:

Quote
Compiled XXX VBO!
Shader program compiled and linked fine!
Tangent handle not found (tangents needed: false)!
Shader compiled!

In your log, all i can find is

Quote
Compiled XXX VBO!
Shader compiled!

...which makes me think that you are not using the GLSLShader class at all but the old wiki example that does everything by hand!? If that's the case, it would explain the results. Try to use GLSLShader instead...

AGP

I was. The GLSLShader class did it brilliantly. Apart from not having the imperfect normals-artifact issue, the effect itself looks sharper and better. I am impressed. Thanks a whole lot.

AGP

And here is a very nice illustration of the importance of normal-mapping. Notice that the fps counter in the upper left corner doesn't even change.