1

I want to implement a blood splatter with SceneKit where the blood will persist on the floor. I'm having seceral approaches on my mind, but most of them seems to me very ineficient.

I would like to ask for an advise where/how to get started to implement an efficient blood splatter with SceneKit?

Thanks in advance.

Coldsteel48
  • 3,482
  • 4
  • 26
  • 43

1 Answers1

1

Particles.

There, that's the short answer.

Particles that well up and bleed (pun intended) then get baked into the texture on the surfaces they're hitting.

That's the middling explanation.

Use gravity and forces specific to the particles and the surfaces they hit (with physics) to make the welling up occur on virtual surfaces created where you expect the blood to hit.

This is not easy in a realtime engine that doesn't support full editor creation and testing of physics objects with particles. Lots of trial and error. Mostly error.

Also, research the creation of decals on textures.

Confused
  • 6,048
  • 6
  • 34
  • 75
  • Thanks for your answer, Google search result on decals with scene kit are very very sad, could you help me to get started ? I think about the way where I can just create a texture with embedded decal in some Cocoa framework... but I hope that I am wrong and there is a better way – Coldsteel48 Nov 06 '16 at 08:36
  • 2
    Look at the SceneKit source code from WWDC 2014 for an example of particles hitting a surface and leaving a permanent mark. Slide 46, step 9. – Hal Mueller Nov 06 '16 at 21:28
  • Sadly, you won't find much about decals and SceneKit, but the way they work in other engines can be replicated in SceneKit. You won't find much documentation and very few examples of SceneKit use, at all, actually. Rickster and @HalMueller might be its most active users. – Confused Nov 07 '16 at 04:27
  • @HalMueller Thanks for the comment, I can't quite find it, could you please link the Slide 46 – Coldsteel48 Nov 30 '16 at 10:19
  • this is all I can find: https://developer.apple.com/library/content/samplecode/SceneKitWWDC2014/Listings/Scene_Kit_Session_WWDC_2014_Sources_Slides_AAPLSlideIK_m.html#//apple_ref/doc/uid/TP40014551-Scene_Kit_Session_WWDC_2014_Sources_Slides_AAPLSlideIK_m-DontLinkElementID_56 @NSDawg, Hal might have a much better source, pun intended. – Confused Nov 30 '16 at 10:24
  • could also be one of these: https://github.com/xamarin/mac-samples/tree/master/yosemite/SceneKitSessionWWDC2014/SceneKitSessionWWDC2014/Scene%20Kit%20Presentation%20Slides/Slides – Confused Nov 30 '16 at 10:26
  • @Confused I've also found the first link, but I didn't find where is the need stuff. Thought maybe Hal can point, otherwise will just dig in it. Thanks ! – Coldsteel48 Nov 30 '16 at 10:30
  • @Confused I think from the WWDC2014 it has to be somewhere near the confetti at37:40 – Coldsteel48 Nov 30 '16 at 10:34
  • I still want to find a way to use decals – Coldsteel48 Nov 30 '16 at 10:48
  • I would to. But, as I say, it's not built into SceneKit, you have to create a recreation of how decals work in other engines and 3D applications. Which isn't fun. Nor easy. And far beyond my capabilities. I know what they are, I know how to use them when they're available, and why/where/when, but I don't stand a chance of recreating their functionality within a framework that doesn't have them builtin. – Confused Nov 30 '16 at 10:56
  • Someone like @Rickster maybe knows more than anyone about this, but you'll have to find a way to get his attention: http://stackoverflow.com/users/957768/rickster – Confused Nov 30 '16 at 10:57
  • read this: http://stackoverflow.com/questions/39643602/how-to-put-text-over-node-in-scenekit to understand the problems of SceneKit. It's got VERY FEW users, and no community, whatsoever. If you really need decals, you have to "roll your own" or use an engine that has them already. – Confused Nov 30 '16 at 10:59
  • And this, about how bad the docs are, that this guy didn't even know there were shadows: https://forums.developer.apple.com/thread/22988 – Confused Nov 30 '16 at 11:01
  • The Apple link @confused posted first is the right source. Build and run, and go to that slide in the product (use the menu bar). The slides were written in SceneKit, so each slide is its own source code example (seriously, this sample code is a total gold mine). SceneKit doc rarely follows standard 3D graphics jargon so you will have to read between the lines. You won't see the word "decal" st all. Also, it appears (some?) SceneKit particle systems are a bit broken on Sierra (see http://stackoverflow.com/questions/40803127/sprite-particle-system-animation-in-viewcontroller). – Hal Mueller Nov 30 '16 at 11:02
  • as a general rule of thumb; @HalMueller's comment: ***"SceneKit doc rarely follows standard 3D graphics jargon so you will have to read between the lines."*** is worth tattooing on the back of your hands if you're considering using SceneKit. Also remember they haven't hired anyone to write documentation, the creators of it are French and Apple has exploited them for the past 18 months or so to create the Swift Playgrounds tutorials on iPad Playgrounds... and you'll start to understand how SceneKit is neglected. – Confused Nov 30 '16 at 11:06
  • @Confused When I asked this Question I thought of recreating the decals behaviour on my own - it is not that complicated to do with some cocoa framework - it is complicated to do it in a very efficient way :-(. I mean - Ok I have 2 textures and I want to merge them in 1 no problem there is million examples to do it with `NSImage` and bitmaps - but common !!! – Coldsteel48 Nov 30 '16 at 11:21
  • Maybe not that complicated for you. Would take me about a year. Or more. I'm SLOW! – Confused Nov 30 '16 at 11:22
  • @Confused I agree with you about the problems of `SceneKit` in general - But I have almost everything working in my POC sandbox for now. Just need to find a way for blood splatters and "Animation Culling", I do not use `GamePlayKit` because for now it is just "pre alpha" and rolling my own `GKObstacleGraph` took about a week - and it works better than `GKObstacleGraph` despite I did some shortcuts for my specific game. – Coldsteel48 Nov 30 '16 at 11:28
  • @Confused I only hope that `Apple` will still invest in `SceneKit` and make it better - because it has potential. Here at my Job we Used `SceneKit` for a little 3D scene and it worked great - maybe it is a bit too premature for real games. – Coldsteel48 Nov 30 '16 at 11:30
  • I absolutely agree: SceneKit and SpriteKit have enormous potential. But Apple has blown it on both, and probably thinks there is no demand. But that's their fault. They can only blame themselves for how they rolled these out, and how they fail to service them. publicly fail to timely address bugs -- etc -- these are main reasons for them not being popular. But developers never blame themselves, nor do Apple management. So I suspect SceneKit is being left to wither and die because nobody uses it. Eerily similar to the Mac Pro Dustbin Edition. – Confused Nov 30 '16 at 11:57
  • If you look at how Apple has treated digital creatives over the last 15 years (since the iPod) you can get a strong feeling for how little Apple actually understands creative endeavour. Despite Steve Jobs constant reference to The Beatles as a demonstration of collaborative creative endeavour, Apple has never really GOT what it means to work on creating with software. Making interactive experiences (GAMES!) is a highly creative endeavour across many types of creative software. Way out of Apple's wheelhouse. This is akin to Adobe not understanding design. Thick blankets of irony everywhere. – Confused Nov 30 '16 at 12:02
  • @Confused I hope, they will continue `SceneKit` development, `SpriteKit` on other hand is really nice and fine Framework to work with, previously I made simple games and even my current game was on `SpriteKit` I just would to switch to 3D and... Boom... hello `SceneKit`:-) I also think that `SceneKit` is not to far from the goal it only needs couple of years to be a real GameEngine a bit optimisations here and there, add some trivial features - like decals for example :-). Overall it has a lot already Done. – Coldsteel48 Nov 30 '16 at 12:10
  • @HalMueller Hi Hal, I've dig in and out of everything there in that slide unfortunately I didn't find a good way to let the Particle to persist on a surface... Making the particle life span infinite is actually works - but it is very inefficient, it is still a good starter to get the position of a hitting particle, but I can't find an efficient way to add a decal to a surface :( – Coldsteel48 Dec 01 '16 at 13:45