Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Dynamic Shadows on a Bones Animated Model

Author
Message
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 1st Feb 2015 21:16
How can I make a dynamic shadow on a bone animated model?
DBPro shadows don't work with bones animated model, I ve tried to work with evolved shadows with no results, the only way I know so far probably is using a lower poly character colored black and made plane setting it at the base of the character (and offset it depending on where the light source come from), but that will works only on flat grounds and is not that good looking
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Feb 2015 21:26
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 00:54 Edited at: 2nd Feb 2015 00:55
Ok, trying to implement (again) these shadows in my project, I launch my game and i get en error (vector does not exist at line xxx), the line is this one:

multiply matrix4 3,1,2

I do not know why that happens, that command use Matrix only and not vectors, which i have initialized copying your code:

Null=make matrix4(1)
Null=make matrix4(2)
Null=make matrix4(3)
Null=make vector4(6)
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 01:12 Edited at: 2nd Feb 2015 01:27
this is really frustrating when you can't understand what's wrong, I did it all right, damn evolved shaders I can't get 1 to work properly, even the water shader doesn't work properly
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 04:58 Edited at: 2nd Feb 2015 05:06
Opened again dbpro, if I launch it the error line is another one:

view matrix4 1:projection matrix4 2


the editor doesn't help at all when you need to fix something

edit: splitting the 2 commands, the one that seems to have the "vector does not exist" error, is the 1st command "view matrix4 1"
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 05:29
Apparently there was a vector I created to change the lightposition for the normal and relief map who was conflicting with the matrix4 number 1, I thought they were different as 1 is vector and the other is matrix4.

By the way, even loading my character in the demo you provided, my character is completely mess up, I ve made it with makehuman, aprox 30-35k triangles total, but subdivided in different limbs (base object, shirt, jeans, shoes, eyes, teeth and tongue)
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 05:35 Edited at: 2nd Feb 2015 05:41
even trying with a low poly model from another character I have made, the mesh is f***ed up the same way (this model has 600-800 triangles I do not remember, used for LOD).


I attach here an image so you understand what happens to the mesh
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 09:25
Update:

After making some tests, I have tried to export a model from makehuman with different rigs, exporting with rigs with less than 60 bones will give no problems when loaded in your demo.
The mesh start to brakes when the bones are more than 60, I tend to use the 71 bones rig model to export because it allows me to move every finger of the hand as I want, plus I can move eyes, mouth and tongue. If I am not wrong there is a parameter on your shaders set to 60, can it be higher than that value, up to 120 for example? (a couple of models I have still has something like 110 bones, I discovered later than I could work with just the 71 bones rig)
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Feb 2015 11:05
This is just a general idea rather than a solution specifically aimed at use with Evolved's shaders (see Green Gandalf's link for that), but isn't the whole thing you need to get done to make sure that your animation is applied by the vertex shader used by your depth map render pass as well (and of course to synchronize the animation sequence between that and the final scene render)?

Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 19:17
I don't know what you mean, what I know is that the mesh brakes if the total limbs are over 60 (bones/dummies are seen as limb in DBPro), If I try to edit the shader writing 120 instead of 60 the mesh doesn't broke but there is no animation anymore, plus for some reason the character has a different rotation, and seems also that textures are not applied
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 2nd Feb 2015 20:17
I think you are limited to ~80 bones with shader model 3 due to the limited amount of memory that is available to store shader constants. Since you may also need shader constants for other settings than bones, you might be looking at an even more restricted number of supported bones.

The breakage may be due to a vertex being influenced by 3 bones, but only 2 of those are accounted for in the animation or similar.

Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Feb 2015 20:25
Sadly the only rig that fit my needs is the 73 bones one (in makehuman), I do not know how to rig a model and even if I would be able to it takes a huge amount of time, which is very important when you develope a game alone.
Lower rig models has no bones for mouth or no bones for hands, which are both required on my game
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Feb 2015 00:11
Yes, as Rudolpho says, 60 bones is already pushing the limits of what shader models 2 and 3 can handle so you'll need to find another way of doing what you want.



Powered by Free Banners
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 3rd Feb 2015 00:57
Will it be possible to make a lower rig and lower poly model, without textures (they are useless for casting a shadow i think), appending to that object the animations from the main model (bones/dummies I move/rotate are also in the lower rig, for the hands and mouth shadow who cares, is not that important for the shadow), then moving/rotating/animating that model the same as the main model, then before the shadow calculations I could hide the main object and show the "shadow model", then at the end of the shadow calculations show the main model and hide the "shadow model"?
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Feb 2015 01:29
If you are indeed able to render your model with the bone animations working in your screen pass I don't see why it shouldn't be possible to do so in the depth pass as well - if anything it would stand to reason that there are less constant registers in use in the depth mapping shaders than in the final render ones.

Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 3rd Feb 2015 02:23
How this works with multiple objects, for example multiple characters in different positions, what do I have to change on the code? just adding the 1st shader on each character and the calculation on the do-loop cycle will be 1 only? also what about the 2nd object (the floor), if I apply that effect just to the floor it would reflect the shadow only on that object, so that I have to apply the 2nd shader also to for example walls? In terms of performance will be heavier? both to use multiple shadows and different areas where to project the shadows
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Feb 2015 09:16
Quote: "If you are indeed able to render your model with the bone animations working in your screen pass I don't see why it shouldn't be possible to do so in the depth pass as well - if anything it would stand to reason that there are less constant registers in use in the depth mapping shaders than in the final render ones."


Quite true! Thanks for the reminder.

The only downside is a loss of performance because doing the animations in the shader results in a performance boost - but that means nothing if the object is too complex for the shader! So, yes, you should be able to get dynamic shadows very easily using a simpler version of the shader which relies on CPU animation.

Quote: "How this works with multiple objects, for example multiple characters in different positions, what do I have to change on the code? just adding the 1st shader on each character and the calculation on the do-loop cycle will be 1 only? also what about the 2nd object (the floor), if I apply that effect just to the floor it would reflect the shadow only on that object, so that I have to apply the 2nd shader also to for example walls? In terms of performance will be heavier? both to use multiple shadows and different areas where to project the shadows"


You may need only one shader - and apply it to each object in the scene. The shader doesn't care whether it's a character or a wall or floor.

You'll only need more than one shader if the main render pass of the scene uses more than one. In that case you'd need a shadow technique in each shader. Depending on how complex your scene is you may need more than one shadow map - but that's another matter.



Powered by Free Banners
Cescano
11
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 4th Feb 2015 09:55
Ok thank you guys, I will test what I said probably in a few weeks (using a 2nd low rig/low poly character for the shadow), as I am still developing some more important things on the game right now.

By the way, talking about shaders, I have finally managed to let work properly the water shader (evolved shader in his project called WaterTerrain or something like that):

- 1 st of all, now I am using just 1 camera, the reflect one, I have removed the refract camera and the refract part code for 2 reasons, 1 to save some fps (quite a lot, this tecnique is very heavy, and removing 1 of the 2 cameras eat half fps i think), 2 because it was just giving me weird artifacts on the water, also I have never seen any difference enabling or disabling the refraction (removing the code or remming it)

- Second, fixing some objects size so that they don't go below the water, if part of them go below the water it will give some weird reflections, also, hiding the objects completely below the water level for the same reason (then showing them again after the reflect code)


I think these problems are not seen in the evolved example just because the water is "inside" the ground, on my game I am using the water as a real ocean, so having it outside seems to give these problems.

For the "water lag" part I have also write on another post, seems that happens when you do not restart the pc for some time (very weird)

I Hope I will be able to implement the shadows too, after that, my only problem with shaders is the line that appears in the relief map (same evolved one), I still didn't manage to fix it as it doesn't happen to every texture but just in some and just in some part of the game world

Login to post a reply

Server time is: 2026-07-05 03:50:47
Your offset time is: 2026-07-05 03:50:47