Author Topic: Normal Mapping with Bones  (Read 4141 times)

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Normal Mapping with Bones
« Reply #30 on: December 11, 2013, 09:26:00 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #31 on: December 11, 2013, 09:30:34 pm »
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?

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Normal Mapping with Bones
« Reply #32 on: December 11, 2013, 09:41:42 pm »
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?
« Last Edit: December 11, 2013, 10:18:18 pm by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11749
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #33 on: December 11, 2013, 10:35:21 pm »
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...

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Normal Mapping with Bones
« Reply #34 on: December 11, 2013, 10:51:06 pm »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1520
    • View Profile
Re: Normal Mapping with Bones
« Reply #35 on: December 11, 2013, 11:06:05 pm »
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.