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

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #15 on: December 10, 2013, 08:37:26 am »
I did. Same thing. Are you sure you gave me a vertex shader? Bear with me and my ignorance, but could you have given me the fragment shader instead?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #16 on: December 10, 2013, 08:57:30 am »
No, it's a vertex shader. Any log messages when compiling the shader?
« Last Edit: December 10, 2013, 08:59:04 am by EgonOlsen »

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #17 on: December 10, 2013, 08:59:04 am »
Quote
New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread main
New WorldProcessor created using 1 thread(s) and granularity of 1!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 17352/4051 vertic
es in 47ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 22500/5822 vertic
es in 46ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 23997/5037 vertic
es in 32ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 24000/5355 vertic
es in 31ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 6000/1552 vertice
s in 16ms!
Object 12/object14 compiled to 5 subobjects in 391ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 2675 vertex indices!
Creating vertex cache (64200 bytes)!
Vertex indices will be mapped!
Subobject of object 16/submesh0 compiled to indexed data using 11997/11997 verti
ces in 32ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 2728 vertex indices!
Creating vertex cache (65472 bytes)!
Vertex indices will be mapped!
Subobject of object 16/submesh0 compiled to indexed data using 11196/11196 verti
ces in 15ms!
Object 16/submesh0 compiled to 2 subobjects in 93ms!
Creating new world processor buffer for thread main
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 2413 vertex indices!
Creating vertex cache (57912 bytes)!
Vertex indices will be mapped!
Subobject of object 17/submesh1 compiled to indexed data using 11997/11997 verti
ces in 16ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 1879 vertex indices!
Creating vertex cache (45096 bytes)!
Vertex indices will be mapped!
Subobject of object 17/submesh1 compiled to indexed data using 9552/9552 vertice
s in 16ms!
Object 17/submesh1 compiled to 2 subobjects in 110ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 21/object23 compiled to indexed data using 5718/1031 vertice
s in 0ms!
Object 21/object23 compiled to 1 subobjects in 0ms!
Additional visibility list (2) created with size: 32000
Additional visibility list (3) created with size: 32000
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object23'
VBO created for object 'object14'
Compiled 6 VBO!
Shader compiled!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #18 on: December 10, 2013, 09:00:22 am »
Looks fine...except that i don't see any message about calculating the tangent vectors... ???

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #19 on: December 10, 2013, 09:01:06 am »
Quote
Compiled 6 VBO!
Shader compiled!
Tangent vectors calculated in 31ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 16ms!
Tangent vectors calculated in 31ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 16ms!
Tangent vectors calculated in 16ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 16ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 0ms!
Tangent vectors calculated in 0ms!
Visibility lists disposed!
Visibility lists disposed!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #20 on: December 10, 2013, 10:17:47 am »
It's a bit strange that the tangent vector calculation happens after object and shader compilation. Try to move it closer to the actual object creation instead. This looks like as if it happens right before rendering, which might be too late.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #21 on: December 10, 2013, 04:36:23 pm »
Still black. If I disable the shader, Batman looks right.

Quote
Tangent vectors calculated in 31ms!
Tangent vectors calculated in 0ms!
Loading file fragmentshader.glsl
Text file fragmentshader.glsl loaded...930 bytes
Loading file vertexshader.glsl
Text file vertexshader.glsl loaded...632 bytes
Joint name: BatmanBip
Joint name: Batman Pelvis
Joint name: Batman Spine
Joint name: Batman L Thigh
Joint name: Batman R Thigh
Joint name: Batman Spine1
Joint name: Batman L Calf
Joint name: Batman R Calf
Joint name: Batman Spine2
Joint name: Batman L Foot
Joint name: Batman R Foot
Joint name: Batman Spine3
Joint name: Batman L Toe0
Joint name: Batman R Toe0
Joint name: Batman Neck
Joint name: Batman Ponytail1
Joint name: Batman Ponytail2
Joint name: Capa_Helper_L
Joint name: Capa_Helper_Main
Joint name: Capa_Helper_R
Joint name: Batman L Toe0Nub
Joint name: Batman R Toe0Nub
Joint name: Batman Head
Joint name: Batman L Clavicle
Joint name: Batman R Clavicle
Joint name: Batman Ponytail11
Joint name: Batman Ponytail21
Joint name: Batman HeadNub
Joint name: Batman L UpperArm
Joint name: Batman R UpperArm
Joint name: Batman Ponytail12
Joint name: Batman Ponytail22
Joint name: Batman L Forearm
Joint name: Batman R Forearm
Joint name: Batman Ponytail13
Joint name: Batman Ponytail23
Joint name: Batman L Hand
Joint name: Batman R Hand
Joint name: Batman Ponytail1Nub
Joint name: Batman Ponytail2Nub
Joint name: Batman L Finger0
Joint name: Batman L Finger1
Joint name: Batman L Finger2
Joint name: Batman L Finger3
Joint name: Batman L Finger4
Joint name: Batman R Finger0
Joint name: Batman R Finger1
Joint name: Batman R Finger2
Joint name: Batman R Finger3
Joint name: Batman R Finger4
Joint name: Bone_LLauncher_Base
Joint name: Batman L Finger01
Joint name: Batman L Finger11
Joint name: Batman L Finger21
Joint name: Batman L Finger31
Joint name: Batman L Finger41
Joint name: Batman R Finger01
Joint name: Batman R Finger11
Joint name: Batman R Finger21
Joint name: Batman R Finger31
Joint name: Batman R Finger41
Joint name: Bone_LLauncher_A1
Joint name: Bone_LLauncher_B1
Joint name: Batman L Finger02
Joint name: Batman L Finger12
Joint name: Batman L Finger22
Joint name: Batman L Finger32
Joint name: Batman L Finger42
Joint name: Batman R Finger02
Joint name: Batman R Finger12
Joint name: Batman R Finger22
Joint name: Batman R Finger32
Joint name: Batman R Finger42
Joint name: Bone_LLauncher_A_End
Joint name: Bone_LLauncher_B_End
Joint name: Batman L Finger0Nub
Joint name: Batman L Finger1Nub
Joint name: Batman L Finger2Nub
Joint name: Batman L Finger3Nub
Joint name: Batman L Finger4Nub
Joint name: Batman R Finger0Nub
Joint name: Batman R Finger1Nub
Joint name: Batman R Finger2Nub
Joint name: Batman R Finger3Nub
Joint name: Batman R Finger4Nub
Loading Texture...V2_Batman_Cape_D2.png
Loading Texture...CapeBottom.png
[ Tue Dec 10 13:33:56 BRST 2013 ] - WARNING: Unsupported Texture height (1816).
.resizing to a height of 256 pixels!
Driver is: igdumdim64/10.18.10.3316 on Intel / Intel(R) HD Graphics 4000
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
Loading Texture...brown.png
Loading file Cape.mtl
Text file Cape.mtl loaded...336 bytes
Processing new material Cape!
Loading file Cape.obj
Text file Cape.obj loaded...156565 bytes
Processing object from OBJ-file: Cape
Object 'Cape_jPCT20' created using 1906 polygons and 1031 vertices.
Adding Lightsource: 0
Hardware supports textures up to 16384*16384 in size!



Finished shadows. Initialized properly? true


New WorldProcessor created using 1 thread(s) and granularity of 1!
Creating new world processor buffer for thread main
New WorldProcessor created using 1 thread(s) and granularity of 1!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 17352/4051 verti
es in 46ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 22500/5822 verti
es in 32ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 23997/5037 verti
es in 32ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 24000/5355 verti
es in 31ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/object14 compiled to indexed data using 6000/1552 vertic
s in 15ms!
Object 12/object14 compiled to 5 subobjects in 343ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 2675 vertex indices!
Creating vertex cache (64200 bytes)!
Vertex indices will be mapped!
Subobject of object 16/submesh0 compiled to indexed data using 11997/11997 vert
ces in 16ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 2728 vertex indices!
Creating vertex cache (65472 bytes)!
Vertex indices will be mapped!
Subobject of object 16/submesh0 compiled to indexed data using 11196/11196 vert
ces in 16ms!
Object 16/submesh0 compiled to 2 subobjects in 110ms!
Creating new world processor buffer for thread main
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 2413 vertex indices!
Creating vertex cache (57912 bytes)!
Vertex indices will be mapped!
Subobject of object 17/submesh1 compiled to indexed data using 11997/11997 vert
ces in 32ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 1879 vertex indices!
Creating vertex cache (45096 bytes)!
Vertex indices will be mapped!
Subobject of object 17/submesh1 compiled to indexed data using 9552/9552 vertic
s in 15ms!
Object 17/submesh1 compiled to 2 subobjects in 109ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 21/object23 compiled to indexed data using 5718/1031 vertic
s in 16ms!
Object 21/object23 compiled to 1 subobjects in 16ms!
Additional visibility list (2) created with size: 32000
Additional visibility list (3) created with size: 32000
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object14'
VBO created for object 'object23'
Compiled 6 VBO!
Shader compiled!
Visibility lists disposed!
Visibility lists disposed!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #22 on: December 10, 2013, 07:25:34 pm »
The tangent vectors are part of the Mesh instance. Any chance that somebody (Bones?) replaces this instance with some other? Can you load the model outside of Bones and see if that works?
Apart from that, one actually have to add some stuff to jPCT and Bones to allow proper handling of tangent vectors during an animation. But it may look good enough as it is now, so i would post-pone that step for now.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #23 on: December 10, 2013, 09:39:20 pm »
I'll make a test with Object3D now and report back. But don't you think that normal mapping is important enough to be considered a "standard" part of your engine? There should be a simple helper class for it, in my opinion.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #24 on: December 10, 2013, 10:37:09 pm »
That helper class would be either very limited or very complex, so i decided to leave it to the user for now. If everybody and his dog would be asking for direct support, i would consider it...but that's actually not the case. Only few people are explicitly using shaders and those who do, usually write their own.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #25 on: December 11, 2013, 06:25:16 am »
I have two golden retrievers. I talked it over with them, and they seem to agree with me that such a helper class would indeed be useful.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #26 on: December 11, 2013, 07:51:42 am »
Yeah, maybe. But it's simply not doable ATM.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #27 on: December 11, 2013, 06:42:58 pm »
I can't test the same model as OBJ, by the way, as the textures don't come out right and the model is exported with a different number of pieces. But can't you just assume I'm not doing anything wrong and that there's a better way to make that shader?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Normal Mapping with Bones
« Reply #28 on: December 11, 2013, 08:34:34 pm »
No, because the shader is fine. Just look at the shader in the example that is included in the zip. It should be the same thing line by line and it works fine. The only difference between your former and this one is, that this one takes the tangent vectors as an attribute. And the only problem that i can imagine in this context is that this attribute doesn't get filled correctly...most likely because the data needed for this just isn't there. Please try this jar...it also clones the tangent vectors if a mesh is being cloned. Maybe that will fix the problem: http://jpct.de/download/beta/jpct.jar

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Normal Mapping with Bones
« Reply #29 on: December 11, 2013, 09:24:10 pm »
Raft says that Animated3D.getMesh() never returns null. I think I ran into a scenario in which it did, or I wouldn't have made that post:

http://www.jpct.net/forum2/index.php/topic,3581.0.html