[Solved] Shadows with AnimMesh support

Blitz3D Forums/Blitz3D Programming/[Solved] Shadows with AnimMesh support

RustyKristi(Posted 2016) [#1]
Going back to B3D, I've seen a lot of shadow techniques, including Yasha's and AShadow but all of them seem to work on static models only.

I'm not going for FastExt route as I'm now using 1.108c.

thanks


RemiD(Posted 2016) [#2]
I am not aware of Yasha shadows system, can you please show me an example ?


From my tests, you can use FastExt shadows with one direct light in the scene (the texels are considered as casters), or Devil shadow system (DSS) with one omni light in the scene (the triangles are considered as casters) (best looking shadows imo). I have not tested AShadow shadows system.

If you want to cast shadows of simple shapes (columns, containers, furnitures, machines, low details characters), i suggest DSS, but if you plan to cast shadows of complex shapes (trees with leaves, bushes, shapes with opaque texels and transparent texels), i suggest FastExt.

As always, the best way to know is to do some tests with simple scenes...

If you want to use skinned animated characters with DSS, you will have to use the addons by Bobysait (to be able to get the skinned vertices positions) and to mod the code so that you can build/update casters depending on the current shape of the skinned animated mesh.
Also with DSS, you need to have low details casters because a shadow volume is calculated each frame by considering the vertices of the caster. (so you will need to have a clean mesh without duplicated vertices)


RustyKristi(Posted 2016) [#3]
Hi RemiD,

Here is Yasha's shadow example:

https://sites.google.com/site/nangdongseng/downloads/Shadow.zip?attredirects=0&d=1

I forgot about DSS, will try this out but the only problem with it is it does not have the source dll.


RustyKristi(Posted 2016) [#4]
BTW, the animated shadows in DSS and AShadow only supports morph animation. I can see it is using the Mak robot model with morphs.

EDIT: Ok it looks like .X only animations for DSS but I have not tested it yet.


Yue(Posted 2016) [#5]



https://dl.dropboxusercontent.com/u/39767349/ombres-V01-00.zip


RustyKristi(Posted 2016) [#6]
Thanks a lot Yue, but as I was saying that is not boned animation and not even vertex animation.

That is morphed animation where the robot is divided into different parts and move around in 3d space.

3DS file like that Mak Robot does not support vertex or bone animation.

Try loading your Pawn model with walk animation and see if it works.. ;-)


RemiD(Posted 2016) [#7]

If you want to use skinned animated characters with DSS, you will have to use the addons by Bobysait (to be able to get the skinned vertices positions) and to mod the code so that you can build/update casters depending on the current shape of the skinned animated mesh.




RemiD(Posted 2016) [#8]
I will upload my version of DSS (slightly modified to make it faster) in the evening (if i find it)


RustyKristi(Posted 2016) [#9]
Thanks RemiD.


RemiD(Posted 2016) [#10]
@RustyKristi>>thanks, for the shadows example by Yasha. I have never seen this one...


Imo, devil shadows system produces the best looking shadows, especially for indoors scenes. (without trees, bushes)

However there are some limitations :
-you can't use high details casters, it is too slow to render.
-you can't use skinned animated casters (but thanks to the addons by Bobysait, now this can be done)
-you can't render several lights in the same scene (but i have an idea on how to do that, not sure if it will work well or fast enough)
-you can't cast shadows which considers transparent texels. (only the triangles of the casters are considered)
-it is glitchy on some low end computers (some netbooks)


RemiD(Posted 2016) [#11]
Can somebody share a code example of shadows with AShadow ? I never managed to make it work on my computer, maybe i don't have the right decls dll ?
Thanks,


RustyKristi(Posted 2016) [#12]
forgot the link to the site and examples but I got this one here:

Include "../AShadowBBinclude/fps.bb"
Include "../AShadowBBinclude/Ashadow.bb"
DrawProgress=0 ; disable draw progress

AGraphics3D 640,480,32,2

AmbientLight 50,50,70

SetBuffer BackBuffer()


camera=CreateCamera()
PositionEntity camera,0,25,30

light=CreateLight(2) ; create light
SetSLight(light,2)
PositionEntity light,50,80,0
Lsphere=ACreateSphere(4,light,0) ; create full-bright(not shadowing) sphere(in position of the light) 
EntityFX Lsphere,1

Center=CreatePivot()
PointEntity camera,Center


tex1=LoadTexture("wall_00.jpg")
ScaleTexture tex1,.3,.3
tex2=LoadTexture("wood_panel_00.jpg")


Cube=ACreateCube(0,2) ; create caster(Cube)
PositionEntity Cube,0,10,0
ScaleEntity Cube,5,5,5
RotateEntity Cube,91,0,0
EntityTexture Cube,tex2

cube2=ALoadMesh("cube.3DS") ; create shadowig cube
ScaleEntity cube2,50,2,50
EntityTexture cube2,tex1

MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

While Not KeyHit(1)

If KeyHit(57)
alphaS#=1-alphaS# 
ShadowVolumesAlpha(alphaS#/10); change visibility shadow (SPACE)
EndIf

If KeyHit(15) SoftSelfShading=1-SoftSelfShading ; change Soft Self Shading mode (TAB)


 TurnEntity Cube,.01,.01,0

	ARenderWorld(camera)
;PostProcess_Render(camera)
;
Text 5,5,Fps(50) ; draw fps
Text 5,20,"ShadowTris: "+ShadowTris ; draw count tris in shadow volumes
Text 5,30,"RenderTris: "+RenderTris; draw count tris in scene
Text 5,40,"TimeShadow: "+TimeShadow; draw time for building shadow volumes

Flip 0
Wend
End


Here's the full lib:
http://www.mediafire.com/download/j5vi4di1g3jvylb/5_Ashadow_1.1.0.0.rar


RustyKristi(Posted 2016) [#13]
It looks like AShadows supports B3D Animation, I just don't know how to set it up.. :/


RemiD(Posted 2016) [#14]
@RustyKristi>>I have downloaded your rar and also the archives on the official AShadow website (they have the same size), but when i try to run a sample demo i have a pop up window "Runtime error" "User Lib version (v.1089) is not correct, you must update Ashadow.dll (v.1095)"

So does anyone know where to download this Ashadow.dll (v.1095)

Thanks,


Yue(Posted 2016) [#15]
Hello, Ashadow not support animation skeleton but by vertex , the model ashadow robot is animated by vertex and not by bone and so this in 3ds format. So if you want a model in this example to encourage him to encourage him for vertex you have in 3d max.


Edit:

you downloaded the example of the shadows are bone ?




RemiD(Posted 2016) [#16]
After a quick look at the original DSS code and at the DSS + my mods code, it seems easy enough to mod it some more in order to consider skinned animated casters.
However, as i have already said, the casters will have to be low details (and closed meshes) or it will be too slow to render...

The only problem is that i know what to do but i don't have the motivation to code it, debug it, now...

But i can explain if somebody is motivated to do it...


RustyKristi(Posted 2016) [#17]
Yue, You just repeated on what I have posted and it's not even vertex, it's morph animation. there's no bone example in there because there's not even a b3d file with bone in media folder on that demo to begin with. Thanks anyway. :-)

@RemiD
that's ok, thanks. I'll have a look at other works for now. BTW, does your DSS code work now with anim casters? what does it do?


RustyKristi(Posted 2016) [#18]
Yue, it looks like the ombres demo does indeed work with B3D animated mesh, sorry for not trying it first and I made an assumption. it works great btw! :-) thanks a lot for this

Honestly I have seen this demo before but was hesitant to test it out because the same mak robot is being used. It does have limitations as any other solution but it is expected.

Problem solved! :D :D :D


Yue(Posted 2016) [#19]
Hello, Google Translate No help much in some cases , I'm glad it work.


RemiD(Posted 2016) [#20]
@Rusti>>my mods of DSS remove some useless procedures and add some functions to make it faster especially if your map is divided in different zones (like rooms), as i have mentioned it is now possible to have skinned animated casters if another mod is added (with the use of the addons by Bobysait), it is not done, but doable. I may do it in the future...


The blend between shadows of GOM shadows is ugly imo, and it seems slow with only a few casters in the scene... But if it is good enough for your project, good for you !


I am still looking for the Ashadow.dll (v.1095) or for a working example of shadows with the AShadow lib.

Thanks,


RustyKristi(Posted 2016) [#21]
Yes ok I figured the performance somehow when I used mid poly size models. I wonder how it would perform if this is done directly by c++ source or maybe optimized a bit. Obviously, the pure b3d implemenation is also a big plus.

I'm still curious though on how your DSS solution would work. BTW, you can just edit the decls/bb to match so it will look for the userlib that you got, this is what I did so I got it to work.


RemiD(Posted 2016) [#22]
Here is the fix to be able to run AShadow shadows code examples :
Open AShadow.bb
Search for these lines :
If S_AShadowDLLvers > S_GettingAShadowDLLvers
 RuntimeError "User Lib version(v."+S_GettingAShadowDLLvers+") is Not correct, you must update Ashadow.dll (v."+S_AShadowDLLvers+")"
EndIf

and put them in comments (; before each line)


RemiD(Posted 2016) [#23]
But now i get a message that there is a missing function in the dll "BBSetProjectionCorrect()", so not all examples work... There seems to be a mismatch between Ashadow.bb and the decls/dll.


RustyKristi(Posted 2016) [#24]
I cannot find the original zip file but it is labeled Ashadow 1.1.0.0 for the examples. try downloading that on the Ashadows site.


RemiD(Posted 2016) [#25]
I have downloaded all files from the AShadow website...


RemiD(Posted 2016) [#26]
If somebody has the same version for Ashadow.bb and the decls/dll, please share it. Thanks,


Yue(Posted 2016) [#27]
Here: https://www.dropbox.com/sh/z95btmjsaqki6a2/AAC_kDHvP-NQ96aSq3ZKx1pOa?dl=0


Yasha(Posted 2016) [#28]
Way late to the party, but that code I apparently wrote looks like it ought to work with animated casters, since it's based on RenderWorld. It won't do self-shadows or work for animated receivers, though, among other limitations (it's probably really slow for more objects).

There's a huge difference in difficulty between animated casters and animated receivers. The first is easy enough that not including it in a system is basically an oversight; the second is close to impossible in Blitz3D and requires deep engine hacking (or switching to a more modern renderer).


RustyKristi(Posted 2016) [#29]
@RemiD
I forgot what I have changed, I just remember editing the decls. My examples are all modified except the one that I posted above and I can't find the zip file associated with it.


RemiD(Posted 2016) [#30]
Yue>>thanks for the archives but
AShadow.bb version : 1.0.9.5
AShadow.decls AShadow.dll version : 1.0.8.9

so not the same version...

Do the shadows code examples (shadow_sameple1, shadow_sample2, shadow_sample3) work well on your computer ?


RemiD(Posted 2016) [#31]
@RustyKristi>>can you please share your version of the library (AShadow.bb, fps.bb, AShadow.decls, AShadow.dll) (the files that you have in your Blitz3D\userlibs directory)
Maybe you have found the same versions in the past (for the .bb and the decls dll)...


RustyKristi(Posted 2016) [#32]
It's the same as Yue's download but here it is..

http://www.mediafire.com/download/pdty3r9ruwa1ksb/AShadow.zip


Yue(Posted 2016) [#33]
I can not understand , it is the last version of the Ashadow , and works perfectly the theme of the shadows. Examples does not work, because you have to update and recompile the dll latter.


Yue(Posted 2016) [#34]
Web here Ashadow here: http://andreyman.ucoz.ru/


Yue(Posted 2016) [#35]



Here dll last and includes, copy and dir samples.





Touch -create the executable with the new version




RemiD(Posted 2016) [#36]
Ok, but it does not work here, when i try to run one of the shadows examples (shadow_sample1, shadow_sample2, shadow_sample3), i get an error message "User Lib version (v.1089) is not correct, you must update Ashadow.dll (v.1095)" and indeed the AShadow.bb is version 1095 but the Ashadow.decls and Ashadow.dll are version 1089...
Not sure why it works on your computers...

Whatever, i will do some tests with Devil Child shadow system to see if i manage to have skinned animated casters...


Yue(Posted 2016) [#37]
Edit last post.

Edit: The devil without funcionba animations bone system is the same principle of Ashadow .


RustyKristi(Posted 2016) [#38]
@RemiD,

I think you should probably try the guide that Yue posted above. It's the same thing that I did. The old examples runs on last version of AShadow and not matching.


Rick Nasher(Posted 2016) [#39]
Just tested it on Win10 Pro x64 and Blitz3d version 1.106.

Dumped the dll +_decls in the userlib folder and copied the example code + model & textures to the Ashadow folder: running all fine here.

Weird thing RemiD.
-Perhaps another library conflicting in your userlibs folder? make a copy and delete the non-standard ones.
-Or.. are you using the modified version of Blitz3d, if so what happens in the original?


RemiD(Posted 2016) [#40]
@Rick>>Good idea, i will remove all decls dll from the userlibs folder, and then add only the ashadow decls dll, and then add the others one by one.


RemiD(Posted 2016) [#41]
Good news concerning Devil Child shadow system (DSS) and skinned animated meshes : i have done some tests using the addons by Bobysait to get the skinned vertices position of a skinned animated mesh and it takes less than 0.5ms to get the positions of all vertices of a skinned mesh of around 1000tris (humanoid shape), which is fast enough, considering that my cpu and gpu are not powerful, and that the aim is to have around 6 skinned animated characters in the rendered zone, and that we have up to 66ms each frame (15fps) before a slowdown becomes noticeable...

I can't say if it will work or be fast enough for now, tomorrow i will continue and try to mod the DSS code. I have several ideas to improve it, one step at a time ! (especially because i don't need it, i am just curious to see if this is doable :P)


RustyKristi(Posted 2016) [#42]
Ah that's great RemiD. curious about your solution I hope we get to see some pics. :)


RemiD(Posted 2016) [#43]
I'm working on it, but not all day long, so be patient ( or do it yourself ! ;) )


RemiD(Posted 2016) [#44]
Some good news, some bad news : after some more reading of the original source code, and after some tests, it seems that some improvements are doable :
-skinned casters (for now there are only "rigid" casters or turning moving parts)
-separate renders of different zones with for each zone, its own light, lighting/shading, casters, volumes, receivers...
-one "finalvolumes" mesh/surface per zone (so you can have more casters, more shadows per zone)
-some optimisations to make it faster :
--use of handles to find an instance instead of browsing lists again and again
--if the light is static, do not recalculate the volumes of static rigid non animated casters, only recalculate the volumes of turning moving animated casters
-some optimizations to make it nicer :
--a skinned receiver does not receive the shadow of its skinned caster so that it is possible to use a low details skinned caster and a high details skinned receiver without weird coloring of the triangles (not sure if this is doable)

but i will have to rewrite the whole system in order to have these improvements.

Fortunately i can use the equations of the great "devilchild" to calculate the shadow volumes and do the stencil magic.

I also plan to add a primitive lighting/shading system using lightmesh (vertices lighting) so that each zone can be lighted/shaded without having the light go through walls in others zones.

I will try but i don't promise anything, and it will take some time !

If you have others (reasonable) suggestions, feel free to post them.


Rick Nasher(Posted 2016) [#45]
That's sounding really marvelous RemiD. Hope you can pull it off.


RustyKristi(Posted 2016) [#46]
btw, I thought maybe we could ask Martin (bytecode777) for the DLL source since he released this under BSD. The source on the site just included bb source, not the actual dll.


RemiD(Posted 2016) [#47]
@RustyKristi>>i don't need it, but if you need it...


RemiD(Posted 2016) [#48]
Bad news : i have tried to modify the code in order to update a shadow volume considering the skinned vertices of a skinned animated mesh and this was a failure and i am not sure why... (only the tpose is considered)
I have difficulties to understand 2 functions (concerning the volumes creation/update) which are separated and i am not sure why...

I will try again tomorrow but this may not be as easy as i thought...

I will try to rewrite the shadow volume creation from scratch by considering the skinned vertices coordinates and if this does not work, i think that it would be quicker to ask "DevilChild" to add these modifications (if he agrees...)

Or the alternative is to attach separate bodyparts to the same animated skeleton than your skinned animated mesh, a bit uglier but good enough. (shadows are not essential to make a good game anyway!)


NotAGamer(Posted 2016) [#49]
hi guys, just saw this ..
im using
ashadow for my game .. the one from the website..
works fine here


RemiD(Posted 2016) [#50]
I have removed all others decls dll from my Blitz3d userlibs folder, and i have put the decls dll of Ashadow that i have just downloaded from the website.
Same problem : shadow_sample1 works well, shadow_sample2 and shadow_sample3 trigger an error... I give up. I will continue with DSS.


Rick Nasher(Posted 2016) [#51]
Did you use a non default installation path for Blitz perhaps?


NotAGamer(Posted 2016) [#52]
@RemiD

want me to send my files to you so you can test it?
Ashadows working totally fine here


RemiD(Posted 2016) [#53]
Maybe it is because i use the addons by Bobysait ? Who else use them ? (it changes the Blitz3d executable)


NotAGamer>>no i don't need AShadow... I was just curious about the shadow system. But thanks anyway...


RustyKristi(Posted 2016) [#54]
Maybe it is because i use the addons by Bobysait ? Who else use them ? (it changes the Blitz3d executable)



I don't know who but right now I'm using any baked fmod version as this issue is still not solved, licensing wise. You need to contact Firelight Tech to license the game, gratis or commercial game, which is a little hassle. One title only per year, additional 1 per year.

So if you only just to release a small game, you can only release one. You need to pay 500 bucks to release another one within the same year or wait next year to release it for free.

..or get rid of fmod and replace it with another.

Fmod is an awesome (I mean really awesome) library. Unity and other engine uses it as default. If someone could confirm there's another foss contender over the quality of fmod, it's worth a try to do something and now with kfprimm made some changes by separating the device code wise with the dummy sound driver.


RemiD(Posted 2016) [#55]
So here is what i have done so far :
rd-stuff.fr/shadow-volumes-with-rigid-casters-with-skinned-animated-casters-201604082215.7z
(you need to have the addons by Bobysait installed (modified Blitz3d executable))

There are 3 methods to create the shadow volumes (2 really, as the 3rd is the same as the 2nd but uses a premade shadow volume) (these algorithms were made by "DevilChild"/"bytecode77", i have just modified them to consider skinned vertices...)
However, strangely, the skinned vertices positions are not considered and i don't know why (the code seems correct and triggers no error...)

If somebody interested in this could take a look and see if there is an error somewhere...

An alternative to modifying DSS to support skinned meshes would be to, for each skinned animated caster, premake a rigid caster clone of the skinned animated mesh, and each frame, get the positions of the skinned animated vertices and use these positions to reshape the rigid caster (by repositionning its vertices) not sure if this is fast enough... I will try tomorrow...


RustyKristi(Posted 2016) [#56]
I'd be interested to check it out or if it's not that ready you can probably just upload vids that's ok too RemiD.


RemiD(Posted 2016) [#57]
(the code in my previous post is not from DSS, but the procedure to build the shadow volume is similar, and since i had this simplified code, i wanted to try to modify this one too to see if it worked well with the same modifications that i have done for DSS, but apparently no...)

However, i know that the functions to get the skinned vertices positions of a skinned animated mesh work well, so the problem is somewhere else.

Also, considering the mstime it take to rebuild (i suppose that you can't simply update the shadow volume of a skinned animated caster because the vertices/triangles have changed position/orientation), the example above (algorithm 1 or algorithm 2) demonstrates that it is too slow to do that for a skinned animated mesh with around 1000 triangles... (at least with these algorithms)

But i see several alternatives :
-have premade volumes of rigid casters corresponding to each pose (frame) of the animation of the character (but then the problem would be to store them in memory)
-use the same skeleton with the same animation and attach similar body parts to the appropriate joints, it works well and it is fast enough since the casters (body parts) are not rendered, but the shadows are a bit weird compared to the shape of the skinned mesh (but players may not notice, especially if the character is always animated !)(demonstrated here : http://www.blitzbasic.com/gallery/view_pic.php?id=2441&gallery=hr&page=1 )


RemiD(Posted 2016) [#58]
after some calculations, the approach to premake one caster for each pose is totally doable, for this humanoid skinned caster (1014vertices, 893triangles) and for a 16frames animation, it would use only around 0.5mo of memory)
So it could be a solution for a game where there is a base skinned animated character and additional rigid clothparts, rigid armorparts, rigid weapons)
and this would be fast to render since each caster is rigid and each caster "outline" is calculated.
But then the animations would probably be less "smooth".


RemiD(Posted 2016) [#59]
After some tests with SetAnimTime(), i think that my last suggestion would work and would really decrease the mstime it takes to recalculate the "outline" of a caster.
Also since we are talking about the caster here, the player would probably not notice the less "smooth" animation...
This would also solve the skinned vertices positions issue...

What do you think ?

I will do more tests tomorrow !


RustyKristi(Posted 2016) [#60]
Hey RemiD. Not to throw you off balance or anything with this one, but I think you should also give Philip's solution a quick look and maybe see if there's room for improvement.

It's textured shadows which has some potential to be cascaded or zoned and it just works with animated meshes. morphs/bones and vertex.

It's pure bb source which means it can be translated to c++ dll OR can be optimized to make it more faster. I'm against the DLL route if it can be helped but if it makes it faster, handle more and it works then it's not an issue.

The test: I got 10 animated meshes closely playing with 3-4k polys each and the performance is not that bad (around 30fps) considering it's DX7, which has some limitations.

The reason why I think ombres (Philips) solution is better is: 1) it does not require DLLs and 2) it just plainly works as it is. It does need some optimization if you need more dynamic shadows but for a simple game i think it would be enough (for me at least).

Again I thought this was not possible with B3D and I was early ignoring Yue's suggestion to take another quick look, it turns out it was the one I'm looking for so I marked this thing solved.

Still looking forward to your test though. thank you


RustyKristi(Posted 2016) [#61]
Hey RemiD. Not to throw you off balance or anything with this one, but I think you should also give Philip's solution a quick look and maybe see if there's room for improvement.

It's textured shadows which has some potential to be cascaded or zoned and it just works with animated meshes. morphs/bones and vertex.

It's pure bb source which means it can be translated to c++ dll OR can be optimized to make it more faster. I'm against the DLL route if it can be helped but if it makes it faster, handle more and it works then it's not an issue.

The test: I got 10 animated meshes closely playing with 3-4k polys each and the performance is not that bad (around 30fps) considering it's DX7, which has some limitations and not fully uses GPU power, if I'm right.

The reason why I think ombres (Philips) solution is better is: 1) it does not require DLLs and 2) it just plainly works as it is. It does need some optimization if you need more dynamic shadows but for a simple game i think it would be enough (for me at least).

Again I thought this was not possible with B3D and I was early ignoring Yue's suggestion to take another quick look, it turns out it was the one I'm looking for so I marked this thing solved.

Still looking forward to your test though. thank you


RemiD(Posted 2016) [#62]
@RustyKristi>>good for you if GOM shadows look nice enough for your project, however the shadows will never look as good as stencil shadows, same for fastext shadows or for swift shadows (which use a method similar to GOM).

Personally i don't care, i don't plan to use shadows for any of my future projects, i am just curious if skinned animated casters could be used in DSS since Bobysait shared these addons.

I won't post again about this here since this is your thread. Sorry !


When you have some time, please post a demo or video of what you have achieved with GOM shadows, especially for an indoor scene (in a room), i am curious to see how it looks.

Thanks,


RustyKristi(Posted 2016) [#63]
Yes I would have to agree that stencil shadows looks sharper and you can have more than enough of it. I have tried stencil shadows with OpenB3d and it looks great to some extent.


Personally i don't care, i probably won't use shadows for any of my future projects, i am just curious if skinned animated casters could be used in DSS since Bobysait shared these addons.

I won't post again about this here since this is your thread. Sorry !


Nope, please do go on and I don't mind. It would be informative to compare but if you would like to showcase it to another new thread, I'm really interested to see the results.

Yes, I'm gonna try and put up a quick demo soon. no problem. :-)


RemiD(Posted 2016) [#64]
double post


RemiD(Posted 2016) [#65]
It is not that stencil shadows look sharper (even this is true and this is not necessarily an advantage), it is that you won't be able to have the same shadows with stencil shadows or with the method that GOM, fastext, swift, use.
It is especially noticeable for a column in a room, try it, make a simple demo with an indoor room (10x10units) (with floor, walls, ceiling) with columns, some containers, some furnitures, some characters. (simple models, no need for textures)

I will do the same on my side, then we will compare the shadows. I bet that we will notice the difference... (i have already done these tests in the past...)


RustyKristi(Posted 2016) [#66]
Ok, I guess it's a matter of preference. As for static shadows like illuminating a room or outside environment, for me lightmaps will do just fine. Yes, it is fake but at the same time it is more practical.


Rick Nasher(Posted 2016) [#67]
True, they give great fx, but static shadows aren't really all that flexible right? For instance in a roaming outdoor scene with day & night cycles it has limited usage.


RemiD(Posted 2016) [#68]
I discovered stencil shadows in severance: blade of darkness and later in Thief deadly shadows and in Doom3, you really can't compare the lighting/shading and shadows of others games to those of these games... It is almost part of the gameplay...


RustyKristi(Posted 2016) [#69]
@RickNasher

Yes, it depends on the game and there are pros and cons for each method. UDK and UE mostly relies on static shadows and blend in with dynamic shadows of players. ie Gears of War series/CS:GO.

game/game engines today does not use stencil shadows anymore (UE/Unity/Cry), but some indie still, like we do. :-)

@RemiD

Don't get me wrong, I like and use them both but you can't compare old and new method. The sad truth is the game industry has moved on with stencil shadows. Let's not put this up for debate and move away from topic. Lol, I'm not here to defend lightmapping or autodesk beast or UE's lightmass. XD

For me, whatever makes the game scene and lighting look better without performance impact got my vote. :)

cheers guys.


RemiD(Posted 2016) [#70]
Whatever, i am not arguing that one solution is better than the other, i just wanted to say that the resulting shadows and consequently the ambiance will not be the same... Go make a thief deadly shadows with static texels lighting/shading/shadows (lightmaps), it would remove a lot to the ambiance and not be as immersive. (but you could achieve a very similar result with per pixels lighting/shading/shadows)


Rick Nasher(Posted 2016) [#71]
Perhaps you should remove the "solved" from the topic, for it appears far from it. ;-)


RustyKristi(Posted 2016) [#72]
@RickNasher

No I got it but I was surprised it got to 60+ comments now lol.

GOM shadows is what I needed for a particular project. Just having discussions with RemiD here.


@RemiD

Yes, I did not say they are the same. That's why I said they have their own use.

BTW, I don't recall Thief the game getting into the picture. It looks immersive to you, looks normal to me, shadow or graphic wise, to each his own.

Good day. :-)


Yue(Posted 2016) [#73]




I think these shadows Ashadow look very good for my taste.


Rick Nasher(Posted 2016) [#74]
Indeed, very nice.
-What did you use to put on the decals(arrows, lines, symbols on the floor? It's looking pretty tight.


RustyKristi(Posted 2016) [#75]
The demo was nice. I was just saying I'm not in for DLLs with either method if we stick to the topic on this thread.

That is also why I choose GOM over DSS. Thank you again Yue for pointing out that GOM stuff.


RustyKristi(Posted 2016) [#76]
This is GOM with animated b3d. No DLLs and it works out of the box without any changes on the original code by the author. That is why I chose it over DSS.



babe model taken from Flanker's demo in UDPNet thead.


Yue(Posted 2016) [#77]
@Rick Nasher

Fragmotion i am using for arrows declas. :)


@RustyKristi

I'm glad to have helped you . :)


RemiD(Posted 2016) [#78]
@RustyKristi>>ok i understand that GOM is easier to use, but your example is not really a good demonstration of the quality of this shadow system. (what about the realistic projection of the shadows on others shapes ? the appropriate edge continuity of the shadows when projected on several faces ? the uniform texel size of the different projections ? the blending of several shadows ?)
At least make a simple scene like i described (room with floor, walls, ceiling + some columns + some containers/furnitures/machines + some characters + one light)

Then we will compare objectively.

Of course GOM/fastext/swift shadows are easier to use because you don't need to have a low details caster for each renderer, but the resulting shadows are not the same.

Not a big problem depending on the kind of game you make and if shadows are not an important part of the ambiance.


RustyKristi(Posted 2016) [#79]
Yes we all have different approaches so I'm not here to compare solutions, and even dynamically shadowing a room that will not be moving in game at any point is simply not practical.

That is why I only asked for animated shadows on this thread in the first place.

Apparently the only working texture/stencil solution that I see right now is GOM, 3D Engine wrappers like irrlicht and OpenB3D if you're into BMX.

thank you.


RemiD(Posted 2016) [#80]
One thing that you want to test is if GOM allows to have a shadow of one skinned animated character projected on another skinned animated character.

Another thing, is what happen if you want an omnilight which is inside an hollow shape (like a light mask) ? Are the shadows casted only in one direction or in all directions ?

Again this is not really important depending on the function of the shadows in the game, but good to know...


RustyKristi(Posted 2016) [#81]
I have not tried and I don't how to do it yet with GOM. I really just need a shadow casted on animated objects that's all.

Maybe you can have a quick look at it if you got the time.


RemiD(Posted 2016) [#82]

I really just need a shadow casted on animated objects that's all.


I suppose that you meant "by animated objects"


I am currently modeling a simple scene to do some tests with stencil shadows, then i will do some tests with GOM shadows and compare, just by curiosity...


RustyKristi(Posted 2016) [#83]
yes sorry typo there. Ok great, I'm still curious on your changes on DSS. thank you

Side question, do you think there's a possibility to do stencil with pure b3d?


RemiD(Posted 2016) [#84]

do you think there's a possibility to do stencil with pure b3d?


no because you need to access directx7 functions which are not available with Blitz3d.


(your obsession to not use external libs is unjustified and a handicap imo, but you do what you want !)

From my experience, it is ok to use an external lib if there is no major bugs and it is compatible with the target computers (you can't please everyone, that's life !)

For example, DSS works well on most modern computers but there are some artifacts with some low end graphics cards (maybe it can be fixed, it seems to be a zorder issue)

The disable bilinear filtering of textures works well on all modern and old computers that i have tested it on.

So don't be afraid of external libs, some are very useful. You just have to do some tests to determine if it is compatible with the target computers...


RustyKristi(Posted 2016) [#85]
lol slow down RemiD, it's not an obsession. :P It's just what I'm looking for on a particular project/demo. Nothing serious to be called obsessed though.

I have no problem using external libs, but not this time apparently.


RemiD(Posted 2016) [#86]
@RustyKristi>>since you said that you use lightmaps, have you managed to have a good blending between GOM shadows and the lightmaps ? Can you please show us a screenshot or video of that ?


RemiD(Posted 2016) [#87]
After more rereading of the original code, it seems that the key to calculate and make new shadows volumes fast is to have the "outline" of a rigid caster precalculated.
Therefore the support of skinned animated meshes would be too slow.
However ! My idea to extract one rigid caster for each pose of each animation of a skinned animated caster seems definitely possible !
And after further reading of the original code, it seems that there is no need to premake one rigid caster for each pose of each animation but rather to store infos about the vertices/triangles (orientation/position) for each pose.
And, after a quick calculation, for a skinned caster of around 1000 triangles, with around 1000 poses, it would take only 54mo in memory... So this is totally doable and it would result in a very very fast update of the shadows volumes (even for skinned animated casters !).
However, i am not sure how much time it would take to analyze the skinned animated mesh, in each pose, for all poses, and to get and to store the infos about its vertices and triangles and to precalculate the outline, So let's hope this will be fast enough.
More infos later...


RemiD(Posted 2016) [#88]
So after some tests :
-it is fast enough to set a skinned caster in a specific pose
-it is fast enough to get all positions of all skinned vertices of a skinned caster
-but it is too slow to precalculate the "outlines"of a rigid caster of around 1000triangles for 1000 poses (it would take 19s per character...)

And if i don't precalculate the outline, it is too slow to consider all vertices/triangles, each frame, for several animated characters in the scene...

The only way i see it would work is if the skinned character would only be the same (never change clothes/armors) and that the "oultines" are precalculated and loaded when needed.

An alternative (which works well but is annoying to setup) is to have one skinned renderer and use the same skeleton to attach body parts (rigid casters) on it.

So, end of discussion, for skinned animated casters, FastExt, GOM, Swift, wins ! (except if Martin finds a faster way to calculate the "outlines" ?)


RemiD(Posted 2016) [#89]
This explain why in Severance, Deadly Shadows, Doom 3, the skinned meshes of characters never change (body, face, hair, clothes, armors), only the weapon change (which can be rigid casters)
So my guess is that they encountered the same problem that i just did.


RemiD(Posted 2016) [#90]
after having retested the samples of the GOM system, i realize how mediocre these "projected textures shadows" look and how stencil shadows are superior in appearance...

After all, DSS is already good as it is and instead of skinned casters we can use the same skeleton + several bodyparts/hair/clothparts/armorparts (rigid casters) attached on the appropriate joints, in this way it is fast to precalculate the "outline" and to update the shadow volumes... The player will most likely not notice that the shadows are not exactly the same as the skinned renderer... (or most likely not care)


The only better looking shadows that i have seen are per pixel shadows which requires a shader...


Shadows are a pain to setup anyway. That's why i decided to not use shadows in my recent games...


RustyKristi(Posted 2016) [#91]
Yes, I agree. It depends on the method being used and if done by shaders it could be much better.

Again GOM here was my choice because of the no DLL requirement, that's all. If I'm going for wrappers anyway, irrlicht is better than DSS with more features and shader support but have to loose the B3D command set which is not good. This is why I have asked AquaLung if he can do something about it.

First thing when doing wrappers should replicate the basic command set and then extend it with other features of the engine, like what OpenB3D and SoftPixel does but some SP commands are not working when I tried it.


RemiD(Posted 2016) [#92]
Good news !

I had an idea in the evening and i have tested it, and at first view it works well and it is fast enough to precalculate the "thing" and to update the shadows volume.

In fact, what i called the "outline" was a wrong interpretation, so i thought of it the wrong way. The precalculation seems to be an analyze of how the triangles are connected by edges...
And if my current interpretation is correct (i am not a math genius), then there is only a need of one precalculation for each caster (rigid or skinned).

Now, i am not sure why my previous attempts have not worked, but i have found another way, and it seems to work well, see :


The current approach is to have one hidden skinned caster, one rigid caster with the same vertices/triangles, and each frame, after having animated the character (skinned renderer (high details) and skinned caster (low details)), get the positions of the skinned vertices of the skinned caster, and reshape the rigid caster.
Then using the rigid caster, i have modified the original source code so that the index of each triangle is kept in memory and this way i can get the new positions of the vertices fast and update the shadow volume fast ! Oh yeah !

However i have found another obstacle (with updateworld)... (so not too much enthusiasm yet...)

And also i have to find a way to remove the ugly black triangles in the shadowed areas of the renderers, see :


But the shadows look good, very good. Take that ugly projected textures ! ;)

More to come later...


RustyKristi(Posted 2016) [#93]
Looks good. What is the recommended polycount for each animmesh and animated object count?


RustyKristi(Posted 2016) [#94]
looks good RemiD. Yes, I'm really curious about framerate issues when you got more casters there. keep it up.


RemiD(Posted 2016) [#95]
if i manage to remove the ugly black triangles which are created on the shadowed areas of the caster (there seems to be the same problem with AShadow), the idea is to have a high details renderer and a low details caster.
For example for a character, you could have a 2000 or 3000 or 4000 tris renderer and a 1000 tris caster (the less tris the better...).
In this example the renderer and the caster are the same... (low details, less than 1000tris)
Note that there is no optimisation for the moment but i have several ideas to decrease the time it takes to build the shadow volumes and to render the stencil shadows. This is wip...
Also note that my computer is not powerful, so it will be faster on more powerful computers.

The only annoying thing is that you must make sure that the caster is closed (no backface visible from any angle)

But let me tell you that the shapes and blending of the shadows is beautiful, i will create a demo to demonstrate it, you will be surprised. Even Unity3d shadows are mediocre compared to this, the only better looking shadows that i have seen are those created with a shader by "Gabor" (with nuclearbasic)


RemiD(Posted 2016) [#96]
Also another advantage is that the lib is very convenient to use, you don't need to modify the structure of your code to add shadows. (unlike the GOM system)


RustyKristi(Posted 2016) [#97]
sounds great RemiD. BTW, I already contacted Martin earlier and mentioned about the request for the DLL source and your new skinned DSS project, and this is his reply back:


Hi Rusty,

how nice to hear that even 10 years later, people are still interested in the Devil-Engines. That’s why I still host them. In fact, I work as a software developer by the time and therefore I stick to C#, etc. If I had the opportunity and motivation to re-do the Devil-Engines, I would release an entire framework that wraps the Blitz3D functions altogether and I would definitely combine the Shader Engine and DSS into one functioning solution. Also I would avoid the plane used for the shadowed areas and do proper renderstates instead. But the fact that I don’t code in Blitz3D, doesn’t mean I won’t answer some questions along the way J

I did some experiments using a B3D bone reader DLL, which can access the animation frames. But I didn’t implement it in DSS, because the coordinates differed and some vertices were left out and the animations were a bit wonky. To be honest, none of the DLL’s are written by me, I just named them accordingly to provide a proper filename sorting in the decls folder. Tom (“Tomspeed”) wrote the DLL’s. He is out of reach and his website has been offline for a very long time, and I don’t have the sources. If I had, I would definitely share them with you. If you want to complete my work, go for it!




RustyKristi(Posted 2016) [#98]
As I have gathered, since the current Hardwired does not support skinned animations, the closest modern "Blitz3D" implementation without the aid of wrappers is Yasha's bOGL.

When I say modern, it's the possibility of shader support (since it's opengl), breaking out of DX7 and if we're into stencil shadow discussion, the stencil buffer is already set, no shadows yet. I'm not sure about the command set completion (but it does have essential b3d functions to make a game) and the xyz orientation if similar to b3d.

https://github.com/Leushenko/bOGL-2/search?utf8=%E2%9C%93&q=stencil


RemiD(Posted 2016) [#99]
As i already said, i don't need the source of the dlls, these are just to access directx7 functions...

However, contrary to Martin, if i had a good understanding of c++, i would create a dll decls for each system and not mix a stencil shadow system with a reflection effect or with a glow effect...

Quick test with a more detailed skinned renderer and skinned caster (2000triangles) and with a complex pose :


Seems to work well :)


RustyKristi(Posted 2016) [#100]
looking good! No worries, If you remember a few weeks ago, I just mentioned the DLL source out of my own interest. that's all.

However, contrary to Martin, if i had a good understanding of c++, i would create a dll decls for each system and not mix a stencil shadow system with a reflection effect or with a glow effect...


I can agree, I have a problem with AShadows about that. I would assume he's thinking about subsystem, more like an extension of blitz3d.


Rick Nasher(Posted 2016) [#101]
Simply: wow!
Does it work OK on animated characters?


RemiD(Posted 2016) [#102]
When you mix different unrelated systems/effects, the problem is that if one is not compatible anymore and crashes, all others can't be used anymore too. Not good...
Especially considering that a game needs specific functionalities/effects but not all.


RemiD(Posted 2016) [#103]
@Rick>>yes that's what i am working on :)


RemiD(Posted 2016) [#104]
Bad news : i have a problem because of updateworld()
i don't know exactly how it decides to update the rotation of the joints/bones and the positions of the skinned vertices depending on if the mesh is in the camera fov or is shown/hidden.
But if i try to hide the skinned caster or set its alpha to 0 the animation is not updated, and then i can't reshape the rigid caster, and then i can't update the shadow volume...
And if i always show the caster inside the camera fov, well it is not what we want :\

So i don't know what to do. I give up for now and i will wait for a new idea.


RustyKristi(Posted 2016) [#105]
aww that really sucks. :( I thought you are already testing out the shadows while animating?


RemiD(Posted 2016) [#106]
yes but the skinned caster was visible for debug purposes... But if i hide it or if i set its alpha to 0, the skinned caster skinned vertices are not updated...

I will try to take a look at the source code of updateworld() (which is a senseless function imo, there is no advantage to mix the update of skinned animated meshes and the collisions detection/response, but it is what it is...), but with my poor understanding of c++, i don't expect to find a solution quickly.

Maybe i will find a workaround with Blitz3d only...


RemiD(Posted 2016) [#107]
the problem is that behind the scene, updateworld() seems mixed with renderworld(), (which is really stupid, but works well for most cases), and so, if an animated mesh is hidden or has its alpha at 0 or is out of the camera fov, its animation and skinned vertices are not updated...


RustyKristi(Posted 2016) [#108]
But if i hide it or if i set its alpha to 0, the skinned caster skinned vertices are not updated...


For basic functionalities, I don't see any problem in regard to setting a skinned caster to alpha of 0. Are you trying to work on having a child mesh as a low poly caster for optimization?


RemiD(Posted 2016) [#109]
either my written english is bad or your reading/understanding is bad. reread my previous post, then reread your last post...


RemiD(Posted 2016) [#110]
basicly i need to modify updateworld() so that i can force the update of joints/bones and of the skinned vertices when a mesh is animated. (even if it is outside the camera fov, or hidden, or with its alpha at 0)


RustyKristi(Posted 2016) [#111]
yes maybe I'm not really understanding your whole process. So if modifying the source will help, I guess that's the way to go. Do you know where to start?

https://github.com/blitz-research/blitz3d/blob/master/bbruntime/bbblitz3d.cpp#L275-L286


RemiD(Posted 2016) [#112]
Not really, i have already asked Bobysait in the past what he has done to manage to edit the source code and to create a new executable, i will try to follow his vague recommendations...

The problem is that i have a low understanding of c++ and i am not really motivated by this kind of syntax (that's why i use Blitz3d).

I will try...


RustyKristi(Posted 2016) [#113]
Compiling the source to make an executable is a good start. You can download visual studio 2013 community edition which is free and Ploppy's VS2010-2013 blitz3d copy here.

https://github.com/ploppyman/blitz3d

There's more instruction down below the page. If you need the DX7 sdk I could upload a copy or put up some link.

It's really easy to build it, you just need some patience. :-)

The problem is that i have a low understanding of c++ and i am not really motivated by this kind of syntax (that's why i use Blitz3d).


With your logic skills, I'm sure you'll find C++ to be another perfect fit for you. Blitz3D is really C++ underneath, I think that's your whole motivation :-).


RemiD(Posted 2016) [#114]
Thanks for the compliment, but i really believe that intelligence is specialized, i can create a lot of things using Blitz3d syntax but this c++ syntax annoys me to high levels...


Have you tried to do some modifications on your side and to create a new executable ? Is it easy enough ? Any recommendations ?


RemiD(Posted 2016) [#115]
Forget about it, it is too complicated, i don't have time to understand this c++ code...

Maybe i will find a workaround in Blitz3d...


RustyKristi(Posted 2016) [#116]
Yes, Luckily I have an old visual c++ 6 installer but it's better to go with Ploppy's VS2010 version.

Nothing serious on my own so far, but what I did recently is apply Kevin's (kfprimm) "no directplay patch" to Ploppy's build, if you want to keep it up to date, IDE and compiler wise. Kevin's build is still VC6, same as original BRL.

It's fairly easy and the use of new method always is a big help and convenience like github's patch system to do some major work here even though you just need to modify a few files..

Kfprimm's Blitz3D No Direct Play Patch:
https://github.com/kfprimm/blitz3d-ng/commit/252d9131b8acea24ca883b4714e9923595749e7d.patch

Use git's own patch system rather than gnu, just download git for windows.

https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/

I would recommend building your own blitz3d exectuable from source first with no modification and if you're not using git to save your progress history, make backups when you do some changes on source.


RemiD(Posted 2016) [#117]
Maybe in many years from now when i will be old with nothing better to do with my time...

Or maybe i will outsource the creation of the modifications to an experimented c++ coder (freelancer)...

What is sure is that it will not be now.


RemiD(Posted 2016) [#118]
Can you please share a tutorial to remove the directplay functions ? It would be good if we can apply this mod and the mods made by Bobysait and have one final executable.
No more directplay, and useful new functions.


Matty(Posted 2016) [#119]
Reading a few posts up about your issue with alpha of zero not updating....why not apply a transparent texture or masked texture to the whole mesh?


RemiD(Posted 2016) [#120]
@Matty>>because the idea is not to have a transparent caster but to not have to render it (hence the use of hideentity or entityalpha 0)


RemiD(Posted 2016) [#121]
I have another idea to update the orientations of the joints/bones and the positions of the skinned vertices without having to use updateworld(), but not sure if this will work or be fast enough. I will try...


RustyKristi(Posted 2016) [#122]
@RemiD

The links I have sent you already contains the patch, the first thing you need to do is build one from source.

1) Download Git for Windows
2) create a new folder named b3d (not blitz3d, for clarity). cd to that directory and run git to clone the source from git

git clone --depth=1 https://github.com/ploppyman/blitz3d.git .

This will make a copy but just the latest source/changes.

download dx7sdk, fmod and freeimage, link on github page. unzip them beside the created blitz3d folder.

Here's the full build instruction by ploppy

Blitz3D open source release! (VS2010/2013 version)

You can grab the prebuilt free version of blitz3d from www.blitzbasic.com.

Steps to build:
1) Install directx7 sdk into same dir as blitz3d:, the foldername should be DX7_Sdk 

2) Install freeimage241 into same dir as blitz3d: http://monkeycoder.co.nz/downloads/freeimage241.zip

PLEASE NOTE - IMPORTANT
=======================
You will need to edit the freeimage.h file and modify the following line (normally should be line #206)

typedef FIBITMAP *(DLL_CALLCONV * FI_AllocateProc)(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));

to this...

typedef FIBITMAP *(DLL_CALLCONV * FI_AllocateProc)(int width, int height, int bpp, unsigned red_mask , unsigned green_mask , unsigned blue_mask);

You have to modify this line because the original line of code is not compatible with versions of visual studio that are newer than vs6.  Changing this line will remove any compile error concerning this bug

3) Install fmodapi375win into same dir as blitz3d: http://www.fmod.org/files/public/fmodapi375win.zip

4) Open blitz3d workspace in MSVC 6.0.

5) Build project 'bblaunch' using config 'Win32 Blitz3D Release'.

6) Output files should end up in _release subdir.

7) Also copy fmodapi375win/api/fmod.dll to _release/bin.


Place the patch file inside blitz3d directory, the instruction on how to apply the patch is in the tutorial link above. best you followed it so you know how it works.

let me know if encounter some problems.


RemiD(Posted 2016) [#123]
@RustyKristi>>Thanks for the explanations, but if i try to modify the Blitz3d source code i will use the original one and the modifications by Bobysait, at least i am sure that it has no errors and works well...

But for now, i have another approach to test (with rotateentity() instead of updateworld())


RustyKristi(Posted 2016) [#124]
sounds good. btw, there's no change with ploppy's version, it's the same as original only you build it with at least a modern IDE like Visual Studio 2010 unless you have visual c++ 6?


Rick Nasher(Posted 2016) [#125]
True. For convenience Ploppy first only converted it (but no enhancement/mods yet) so that the original source could be used with an up to date compiler for the original source version was hopelessly out dated and wouldn't allow it.
He then released this to the community so they wouldn't need to do all the boring work all over again.

He then used that version as a base for future enhancements/changes.

BTW: Didn't Bobysait use the same version Ploppy released as a base or did he convert the source himself for modern compilers or was he using an old VS version?


RemiD(Posted 2016) [#126]
Bobysait apparently used the original source code to create his addons, see : http://www.blitzbasic.com/Community/posts.php?topic=105408 (#50 #62)


RemiD(Posted 2016) [#127]
Bad news : my other approach works but suffers from the same problem :
if the mesh is out of the camera fov, or hidden, or alpha 0, its joints/bones and skinned vertices are not updated.
So i can't have the skinned caster with its joints at the correct positions with the correct orientations, and consequently i can't have its skinned vertices at the correct positions.
And then i can't reshape the shapable (rigid) caster correctly.
And then i can't build the shadow volume correctly.

The only way to make it work would be to modify the source code of Blitz3d and add a function to force the update of the joints/bones and of the skinned vertices after having animated a skeleton (joints/bones) or after having repositionned/reoriented some joints of a skeleton.
But since my understanding of c++ is low and i don't want to spend time on this, i will try to find a good c++ coder, but if i don't, this is the end of this project.


Rick Nasher(Posted 2016) [#128]
That's indeed unfortunate news, sorry to hear that.


RustyKristi(Posted 2016) [#129]
I'm not sure if looking at OpenB3d source would help since it's OpenGL but we appreciate your efforts RemiD either way.

I remember reading some tutorial links on how to do this directly from DX7 api, I can't find my bookmarks but doing some search found this:

http://www.gamasutra.com/view/feature/3140/inside_direct3d__stencil_buffers.php?print=1

(Under Soft Edge Shadows)
http://www.gamasutra.com/view/feature/3399/rendering_to_texture_surfaces_.php?print=1


RemiD(Posted 2016) [#130]
This is a Blitz3d problem, not a stencil shadow problem.

I have already noticed this a while ago, even if you structure your code in a certain way (instructions written in a certain order), it does not matter because behind the scene, Blitz3d runs it another way...


RemiD(Posted 2016) [#131]
There is another approach but which will be slower to render :
always display the skinned caster with an alpha of 0.01 or less (but more than 0) and at the same position/orientation than the skinned renderer, so that it is not seen by the player but is in the camera fov and is shown and thus its joints/bones and skinned vertices will be updated.
But for each character this will render one high details renderer and one low details caster.

Whereas with a mod/addon in the Blitz3d source code, only the renderer would need to be rendered.

I will try this (bad) approach anyway, just to see if this is fast enough to be usable...


RustyKristi(Posted 2016) [#132]
Good luck with that RemiD, As the old saying goes. "If There's a Problem — There's a Solution" ;-)


RemiD(Posted 2016) [#133]
Good news : the approach that i mentioned in post#131 works well (even if it is an ugly workaround) and is probably fast enough if there are only a few skinned casters (around 1000tris each) in the scene see :

(the fps is voluntarily locked at 30fps, don't worry)

If you consider that there are 66ms available before a slowdown is noticeable (then the fps becomes lower than 15fps), and if you consider that my cpu/gpu are not powerful, i say that this approach is usable for some games with zones separated by walls and passages...

However there is a problem and i don't why it happens, the code seems correct, but there is a slight offset between the "shapable" caster and the renderer... I hope that this is not due to something happening behind the scene and that i can't control... (it is as if the skinned renderer and the skinned caster, move after the shapable caster has been reshaped... Weird!)

I will reread my code later, with "new eyes". Time to go sleep.


RustyKristi(Posted 2016) [#134]
Looks good! :0 but first get some rest!


RemiD(Posted 2016) [#135]

Looks good!


not really, looks buggy... I think this is because of the use of 2 renderworld per frame (to render the stencil shadows). it is as if the renderer turns/moves/animates 2 times while the shapable caster has already been positionned/oriented/shaped with the previous position/orientation/pose, and unfortunatly i have no control over that (it is a behind the scene thing)


RemiD(Posted 2016) [#136]
after some tests, it seems that the use of 1 or 2 renderworld(s) does not change the orientation, position, pose, so the problem is somewhere else, but i have no idea where. But i know that the problem happens with the orientation, with the position, with the pose... I give up for the moment...


RustyKristi(Posted 2016) [#137]
Don't beat yourself up RemiD. I know it's a challenge but I think it is not worth the time anymore unless you will continue this as a hobby and rediscovering Blitz3D. I have moved on with GOM and maybe thinking of using the wrappers that has stencil and shader support.

You did your best, you learn new things and if you had fun doing it and makes you better at what you do after all this, I think that's all that matters. :-)


RustyKristi(Posted 2016) [#138]
Don't beat yourself up RemiD. I know it's a challenge but I think it is not worth the time anymore unless you will continue this as a hobby and rediscovering Blitz3D. I have moved on with GOM and maybe thinking of using the wrappers that has stencil and shader support.

You did your best, you learn new things and if you had fun doing it and makes you better at what you do after all this, I think that's all that matters. :-)


RemiD(Posted 2016) [#139]
Don't worry, i do it by curiosity, just to see if it is doable, and at the same time i improve my understanding and coding/debugging skills.

I have managed to remove the ugly black triangles at the back of the renderer, so this means that i can now use a different mesh for the renderer (high details) and for the caster (low details)
Next test will be to see how this looks.

However the slight offset between the orientation, position, pose of the "shapable" caster and of the renderer produces ugly artifacts. I will have to find a way to prevent that.


What this made me realizes is that Blitz3d is too limited for some things because you don't know how it runs things behind the scene and you can't change it...


RustyKristi(Posted 2016) [#140]
What this made me realizes is that Blitz3d is too limited for some things because you don't know how it runs things behind the scene and you can't change it...


Not true, the source code is always at your disposal. Think Hardwired ;-)


RemiD(Posted 2016) [#141]
By "can't change it" i mean that unless you modify the Blitz3d source code, you can't access some things and you can't force Blitz3d to run instructions in the order you want...


RemiD(Posted 2016) [#142]
Just to let you know that MeshCullbox() allows to force the update of joints/bones/skinnedvertices of a rigged skinned mesh which is out of the camera fov, but apparently the size of the cullbox takes into account the scale of the entity and that's why it didn't work in my previous attempts (my meshes are scaled down by 0.01).
So in my case, i had to put a meshcullbox of 100times the size that i wanted... (-10*100,-10*100,-10*100,20*100,20*100,20*100)

But it works well ! no need to modify the Blitz3d source code. Oh yeah :)


RustyKristi(Posted 2016) [#143]
ok understood, but hey that's some new stuff right there. Any demo or screenshots? :-)


RemiD(Posted 2016) [#144]
No demo yet, i have not finished to add all the things that i want in the scene, a wip screenshot :


It is a bit slow for the moment because i have not added the optimizations that i plan to add :
-each renderer is one mesh with one surface (currently i use several materials to color them)
-low details casters (currently they are very similar to the renderers...)
-each caster has its volume precalculated, prebuilt, and not always updated
-don't update volumes of casters which are not turning, not moving, not animating, only update volumes of casters which are turning, moving, animating
-don't update/consider volumes which are projected behind the camera
-don't update/consider volumes which are inside the shadows of another caster

and of course, to improve performance you should avoid moving the light as much as possible (a static light will not require to update the volumes of non turning, non moving, non animating casters)

However i still have a strange offset between the renderer and the reshaped caster when it turns, moves, animates and this is noticeable and ugly, i will have to find a solution about that...

Also, i am not sure that Martin's approach to render the stencil shadows is completely correct because it seems that there are ugly black triangles added on the areas in the shadows of each renderer, and i don't see how this is necessary (it seems that there is the same problem with the ashadow lib)

More later...


Flanker(Posted 2016) [#145]
Nice one, it looks neat !


RemiD(Posted 2016) [#146]
Thanks :)

However i think that i chose the wrong kind of scene to use stencil shadows, because a celebrationroom/nightclub has usually several lightsources and with this stencil shadows system i can only use one light source which is really restrictive !

I will try to finish the demo anyway, just for the fun and to see the limitations (it already takes a lot of time to render a simple scene with stencil shadows compared to the same scene without stencil shadows !)


Yue(Posted 2016) [#147]
Nice.

Here Shadow Blur on Ashadow.




RemiD(Posted 2016) [#148]
@Yue>>is this blur effect part of Ashadow or you have added it with another lib (fastext?)

This could allow to use low details casters without being noticeable if the outline of the shadow is blurred.


RustyKristi(Posted 2016) [#149]
That's an ideal shadow for Blitz3D. I have not used ashadows because of lack of bones shadow support, but how did you manage to blur it? can you share some example?


RemiD(Posted 2016) [#150]
I see a way to blur the outlines of stencil shadows by blurring the "shadows mask" texture using a fast blur routine like FastExt blur (but of course, now that we need it, it is not compatible anymore :P)


RustyKristi(Posted 2016) [#151]
haha nice one RemiD. Using Ashadows and FastExt at the same time looks like overkill. BTW, I think ashadows has blur routine too, you can check the decls. ;-P


Yue(Posted 2016) [#152]
The shadow & blurring is only possible with the false shadow , at least as I understand it .
EnableSoftStencilShadows ( 0.002 , 5, 50 ) ; customize far plane for optimal shadow bluring

repeat
ARenderWorld (camera % , 1.0 , 0.6)


This shade does not work if the features of the graphics card are maxed out , I think it has to do with the anti alias, and will not be visible shadow.


One problem I have with the devil and ashadow shadows is that EndGraphics , causes errors to exit the program in full screen mode.


RustyKristi(Posted 2016) [#153]
Ah yes I remember, with Ashadows soft shadows are possible. nice.


RemiD(Posted 2016) [#154]
I will have to find a way to test this Ashadow lib... Curious to see how the shadows system works, how the shadows look, and how fast it is compared to DSS...


Yue(Posted 2016) [#155]
To avoid artifacts strangers , the model that casts the shadow has to be fullbright and black color, in my case it worked.

:)




RemiD(Posted 2016) [#156]

To avoid artifacts strangers , the model that casts the shadow has to be fullbright and black color, in my case it worked


This is great if you have found a solution, however i have tried the same thing with DSS and it does not seem to remove the black triangles in the shadowed areas. (at least with my modded version, i will test with the original version just to see)


So now, you should be able to use even less detailed meshes for the casters. It should not be noticeable if there are no black triangles in the shadowed areas... That's what i am trying to achieve but with DSS...


Bobysait(Posted 2016) [#157]
Bad news : my other approach works but suffers from the same problem :
if the mesh is out of the camera fov, or hidden, or alpha 0, its joints/bones and skinned vertices are not updated.
So i can't have the skinned caster with its joints at the correct positions with the correct orientations, and consequently i can't have its skinned vertices at the correct positions.
And then i can't reshape the shapable (rigid) caster correctly.
And then i can't build the shadow volume correctly.



This can be fixed easily :
- add 2 vertices to your model and DON'T rigg them (they'll be static)
Put one at the left bottom back corner of your rigged mesh (use the worst case animation keyframe to set it, so any keyframes will not go farther than this vertex)
Put one vertex at the opposite -> Top-Right-Front corner
Then, blitz3d will use thoose vertices to compute the bounding box of the mesh, so that whatever the keyframe being played, the box will be accurate for the camera's frustum test.

ps : "the addons by bobysait" (damned, RemiD is my commercial agent :p), I compiled it with the original sources from the github repository, with and old MSVc 6 and the MFC add-on on a virtual OS (windows Xp on virtualbox)
Using a new visual studio version is doable, but it will probably fail using the Puppy's version. He probably modified so much things on his OS to get it compiled that you won't be abble to get anything compiled without tons of errors.
It's still doable for someone who knows what he is doing, but, I really think the blitz3d sources should be more "officially" updated with newer SDKs.

BTW : Shadows done with stencil suffer from a common problems that is : it can't deal with alpha textures.
It's also a very old technic that is probably deprecated nowadays (Karmak used them with an engine fully built around the idea of thoose stencil volumes, so it perfectly fit its game, but there is no engine currently that really support them, because it's full of constraints)

Blitz3D allows to make some nice shadows, but there are always restrictions : (one or all of the followings)
- performance cost
- no self-shadowing
- poor render
- static meshes only
All my addon can solve is the last problem, but with a high loss of framerate (the vertex coordinates for skinned and animated entity is really just done for animation tools or debug, it's not intended to be used in real time -> it will be slow as hell ^^)
Unless implementing shader stuff and defer the hard part to the GPU, there is a single way to get both self-shadowing and dynamic meshes, that is : RenderWorld from the light view with fog (to get a fake depth pass) then a computation of the depth against the camera view. And, whatever it will give nice results, it will also be slow as hell (we're talking about per pixel computation for a at least a 512*512 pixels shadowmap)

So : Dealing with shadow is always something to start with an idea in mind that is "Always consider it will be <good enough> but not accurate, and it will be <with restriction> or very slow"

For language that support shaders, it's a bit different -> the per pixel computation still exist but it's done seriously faster by the GPU, and all the magic is there.

ps 2 : And BTW, stencil volumes are really low to compute, with or without low detail meshes.

ps 3 : the modifications I 've done to the blitz3d sources does not interact in any way with what AShadows could do ... But, maybe as FastExt, AShadow uses some memory pointers to retreive some blitz3d native stuff, and as FastExt, maybe it's useable only until a specific blitz3d version -> memory pointers are not efficient, you just need to add an extra field to an object to get all the object memory pointers wrong from an offset.
So, does AShadows work with the latest blitz3d build ?


RemiD(Posted 2016) [#158]

This can be fixed easily :
- add 2 vertices to your model and DON'T rigg them (they'll be static)
Put one at the left bottom back corner of your rigged mesh (use the worst case animation keyframe to set it, so any keyframes will not go farther than this vertex)
Put one vertex at the opposite -> Top-Right-Front corner
Then, blitz3d will use thoose vertices to compute the bounding box of the mesh


i tried that and curiously it did not work, but i have found a solution to this problem, see post#142



no self-shadowing


with stencil shadows, there is self shadowing, see my screenshots... It looks very good but it is slow to render and the shadows must be from low details casters.



static meshes only


yes but a premade non skinned caster can be reshaped each loop with the pose of the skinned animated caster (thanks to your addons we can get the skinned vertices global positions), see my screenshot, the character shadow is animated.


But since i have not found a way to remove the ugly black triangles at the back of each caster (the "caps mesh"), i gave up on that (and also because i don't really need shadows in my current project)



So, does AShadows work with the latest blitz3d build ?


not sure, but maybe that's why i get an error when i try some Ashadows demos...


Bobysait(Posted 2016) [#159]

with stencil shadows, there is self shadowing, see my screenshots... It looks very good but it is slow to render and the shadows must be from low details casters.


-> "but there are always restrictions : (one or all of the followings)"

"One or all", meaning some shadow system can't do self-shadowing, some can, but won't have alpha etc...


yes but a premade non skinned caster can be reshaped each loop with the pose of the skinned animated caster (thanks to your addons we can get the skinned vertices global positions), see my screenshot, the character shadow is animated.


yep, and that's one good sample for the "performance cost". (or it has to be used on very very low detailed shadows)


RustyKristi(Posted 2016) [#160]
Thanks guys for these valuable input. I understand that adding shadows to good ol' blitz3d is a loosing battle. Maybe Ashadows is the best free one yet idk. (yes bobysait, ashadows works with latest version)

glad that this was given some attention again and would think that wrappers will solve this problem


RemiD(Posted 2016) [#161]
@RustyKristi>>with Blitz3d version 1.108 + the addons by Bobysait ? Are you sure that AShadows works well with it ? Because here i get some errors...


Bobysait(Posted 2016) [#162]
I've tested AShadow with the sample posted above (by RustyKristi on post #12) with my modified version of Blitz3D, it works like a charm.


RustyKristi(Posted 2016) [#163]
Great to know! Do you think Ashadow can be ugpraded to work with animated mesh?

@RemiD
I think he meant without his addons


Bobysait(Posted 2016) [#164]
It surely could, but the AShadow sources are really messy (and fully unindented). It makes it very confusing and it's a bit annoying to debug this kind of sources.


Juggernaut(Posted April) [#165]
@RemiD: The problem you faced while running the Ashadow examples was due to the older version of Ashadow.dll existing within the Ashadow_Samples.rar archive. By default Windows dll files are being searched from the current directory. So as Ashadow.dll already exists in the Ashadow_Samples folder/archive, the Ashadow.dll that is placed in the Userlibs folder of blitz3D installation by manually copying from the UserLibs folder of the 5_Ashadow_1.1.0.0.rar archive is getting ignored.

So if you delete the Ashadow.dll file that comes within the Ashadow_Samples.rar everything works fine. Alternatively you can replace the Ashadow.dll file existing within the Ashadow_Samples.rar with the one that comes within the UserLibs folder of the 5_Ashadow_1.1.0.0.rar archive.