Normal Mapping with Bones

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

Previous topic - Next topic

AGP

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?

EgonOlsen

#16
No, it's a vertex shader. Any log messages when compiling the shader?

AGP

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!

EgonOlsen

Looks fine...except that i don't see any message about calculating the tangent vectors... ???

AGP

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!

EgonOlsen

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.

AGP

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!

EgonOlsen

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.

AGP

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.

EgonOlsen

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.

AGP

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.

EgonOlsen

Yeah, maybe. But it's simply not doable ATM.

AGP

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?

EgonOlsen

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

AGP

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