Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

blood splatter

Discussion in 'Non Commercial Collaboration' started by antenna-tree, Aug 19, 2006.

  1. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    I didn't have a bad day or anything, but for some reason figuring out a method for making blood splatters seemed very appealing today. So here's a little demo of one way to make blood splatter all over surrounding walls.

    Take a look here... point/click to splatter blood. I don't know how efficient this method would be for in game use so it would be neat to see other people's ideas on how to do this better. Attaching Unity package...

    Enjoy,
    Ethan
     

    Attached Files:

  2. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,210
    So very appetizing.

    (Random raycasts?)
     
  3. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Yummy, reminds me of the F.E.A.R game.

    -Jeremy
     
  4. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    It's Raycasts spraying out using Random.onUnitSphere. It uses decals for the splatters, but I think using projectors would look better because it would distort the splatters outward from the source point. I know it's a little morose, but I was interested in figuring out how to spray multiple images onto other geometry. This could be a good way to decal damage marks for a grenade explosion or something too.
     
  5. Aras

    Aras

    Graphics Plumber Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,522
    This looks really good. You might want to fade out the decals instead of just making them disappear though.
     
  6. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Yeah, Lerping the alpha would be the next step... also using the Mesh Interface to merge all the decals together would be a good move.
     
  7. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,210
    I get what you mean about projectors adding a nice stretch.

    To take that further: what if the ray knows its angle of incidence, and thus chooses a different (naturally longer and dribblier, not just stretched) image when it hits more obliquely? There could be 2 or 3 "angle zones." (I know it would also have to calculate its rotation to "point" away from the source too.)
     
  8. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,494
    Hey its Really cool Ethan. I guess I could follow the fps tut and where the projectiles hit the surface, and spark, I could instantiate the thing youve done. However that would only make sense if the projectile hit a biological entity(one with blood in it) Do you know how I would set up culling so that if projectiles hit metal-sparks appear, and if projectile hits enemy-blood splatter appears?

    Little unity packages like this are awesome, it would be great to somehow collate a bunch of shortcuts to all that have been posted

    Thanks again!
    A
     
  9. pete

    pete

    Joined:
    Jul 21, 2005
    Posts:
    1,648
    >>Do you know how I would set up culling so that if projectiles hit metal-sparks appear, and if projectile hits enemy-blood splatter appears?

    i'd use tags or create "classes" in my scripts if i needed tags for something else. simply make a variable that if n = blood spatter, n1 = sparks, n2 = whatever.

    cool stuff ethan!
     
  10. harrio

    harrio

    Joined:
    Apr 25, 2006
    Posts:
    31
    paintball anyone? :wink:
     
  11. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    408
    the only real problem i can se with it is that the blood splats are cut off in the corner
     
  12. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Absolutely, this would make it look so much more realistic. I have the Raycast direction to the RaycastHit.normal to calculate the angle using Vector3.Angle, but the rotation facing away from the splatter source point on the hit.normal axis is giving me trouble. I'll get it eventually. This was just a fun experiment I did in a couple hours initially, but now you have me curious if we can make it really look nasty :wink: I'll have to make a little mess in my apartment to get the angled paint splatters for the alpha textures.

    Yeah, for decals like this I think the only solution would be to reduce the size of the decal and spawn a lot more of them. This would hide the cut offs you see in corners and edges a little better, but not perfectly.

    I learn best from little examples like this where I can dissect how they were put together (code, assets, relationships). I didn't know where to post this exactly... it's not a "Showcase" thing so I put it in collaboration thinking maybe people could improve upon the initial idea and post their improvements. But it might be cool to have a "Unity Package" section where people could post basic gaming construction blocks like this all in one place. There's dozens of packages like this scattered throughout the forum, and they can be hard to find when you're looking for a specific example of how to accomplish something. Maybe meta tags in the post? Or of course posting them to the WIKI... something I never do but should.
     
  13. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,210
    Just keep yourself out of the evening news.

    What about using projectors like you first suggested--which solves the cutoff issue... but ALSO using multiple "angle zones" so that projectors aiming at a shallow angle project a different image? A hybrid approach?
     
  14. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Yep, projectors would solve that if we could get their Far clip plane to work properly... all the scenes I've done with projectors I've never gotten them to stop projecting past their far clip plane (bug or user error?). The projector smears I've gotten before might actually look cool as blood though :wink:

    Unfortunately projectors seem to be performance hogs.

    I noticed, or maybe hallucinated, that Yoggy's portal game clipped off the portal decals at corners. If this is true Yoggy I'd love to know how you did it.
     
  15. dacloo

    dacloo

    Joined:
    Jun 30, 2005
    Posts:
    469
    NICE!
     
  16. gon

    gon

    Joined:
    Jul 6, 2006
    Posts:
    53
    hi, waw what a great great quality in terms of texture realism and interaction! love it *
    I am trying to implement the same for logoparc, can anyone give me the steps of how to integrate the package files into my scene. (where to put which script or prefab)
    The next step will be to script the texture in such a way that it picks a random texture (seems like the blood is also "changing" somehow, no?

    thanks a bunch, eager to try this out! cheers -

    gon
     
  17. gon

    gon

    Joined:
    Jul 6, 2006
    Posts:
    53
    here's up till where i got :
    so it works, but the texture isn't showing... any idea why?
    i basically copied 1 by 1 each object and where the scripts go, but probably there's a more practical error-free way to do it.. thx !
     

    Attached Files:

  18. gon

    gon

    Joined:
    Jul 6, 2006
    Posts:
    53
    it works now !!
    cool,
    anyone an idea how to make it randomly shift between textures to be shot (so each time for ex another graffiti is shot at the walls or something is written on the floor -here indeed we might want to "recognize" as someone suggested with tags between different materials that are shot at)..
    thanks allot and let's have fun !!

    gon
     
  19. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,494
    Hey Ethan, do you mind if I use this in my 3du entry?
    Aaron
     
  20. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    5,833
    Another potential issue with projectors would be if another entity moved in between the splatter origin point and the wall. Could that be solved using a mask? I haven't used projectors but I'm guessing so...

    Also, if the splatter occurs on a movable object, it wouldn't move with it, whereas the decal method could simply set the decal's parent to the collided object.

    While a projector may be a little easier, the decals would be more versatile.
     
  21. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    You could mask the projectors to only display on one layer. You could also mask the raycasts so they only hit a specified geometry layer that doesn't move. Or you could parent the projectors just like you could parent the decals.

    @Targos

    Of course you can use it. The only thing that makes this look any good at the moment is the paint texture I made for it and it's up for grabs.

    @gon

    Look through the Material Script References.
     
  22. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    85
    As far as the look of this goes, a variation is to do the blood with subtractive blend mode. Start by inverting the texture so that it is blue (you might need to tinker with the look), fading to pure black at the edges. Then set your polys to draw subtractively (I just found Unity today and don't know anything abou it but I'm sure you can do it).

    What this will yield is a more Doom3 bloody look that accumulates to black.... it looks a bit more disgusting. :)
     
  23. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    5,833
    Very clever! And yes, you can do that in Unity, though it would require a custom shader. To my knowledge there's not a built-in subtractive shader.
     
  24. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Actually, Unity doesn't allow you to do subtractive shaders. It's an extension to the normal OpenGL blending, and not widely supported on older hardware.

    Not saying it shouldn't be there, we just never really saw a need for it ;-)
     
  25. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,325
    Mmmm, coagulated blood drippings... drool :wink:

    Yeah, having that darkened effect on the edges of the blood would be sweet and I think it could be done easily enough with a multiply shader (I just used an alpha for this). It just requires the photoshop work to add a darkened radial gradient to every single dripping in the source texture.
     
  26. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    408
    Doesnt want doom3 blood, wants cellfactor blood =/ ;)
     
  27. morgansaysthis

    morgansaysthis

    Joined:
    Jan 12, 2007
    Posts:
    245
    that looks great,awsome job
     
  28. bluechro

    bluechro

    Joined:
    Nov 24, 2008
    Posts:
    1
    Sorry for reviving an old thread, but does anybody have an example of spawning this when, for example, a rocket explodes against a wall? Any help would be greatly appreciated.

    Thanks
    Andrew
     
  29. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    5,833
    I too am going to perform a bit of thread necromancy here. Two years ago Unity didn't support subtractive shaders. Is this still the case, or have the numerous changes to ShaderLab in the intervening time included subtractive support?
     
  30. kheng

    kheng

    Joined:
    Oct 22, 2008
    Posts:
    126
    I was wondering how would I get this to work for the iphone? Is it even possible?
     
  31. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    if you want a fluid game then no
     
  32. kheng

    kheng

    Joined:
    Oct 22, 2008
    Posts:
    126
    Well what I meant is there a way to combine the splat so its only 1 draw call and not roughly 80?
     
  33. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    particle system / sprite manager on the iphone board
    Both thought directly imply that you can not use the projector
     
  34. thecreatrix

    thecreatrix

    Joined:
    Dec 19, 2008
    Posts:
    94
  35. cherub

    cherub

    Joined:
    Apr 26, 2006
    Posts:
    487
    this script is very cool.

    I thought to myself, can I use bullet decals for a painterly look?

    i modified the script and image in this example. its pretty slow, but it looks like candle light with shadows an all in a charcoal style.

    http://www.renderstyles.com/tmp/painterly.html

    ~C
     
  36. edplane

    edplane

    Joined:
    Jul 13, 2009
    Posts:
    485
    How could I implement this to use on an exploding barrel? :?
     
  37. Disati

    Disati

    Joined:
    Oct 5, 2009
    Posts:
    111
    Simple but awesome in some sort of way. Thanks for this!
     
  38. Charles-Van-Norman

    Charles-Van-Norman

    Joined:
    Aug 10, 2010
    Posts:
    84
    Does anybody have a Blood Splatter package, like the one posted in this thread, that works with Unity 3.2? I tried importing that old package but got errors .... I want to see BLOOD DAMNIT! *Ahem* It would be nice. :-D
     
  39. MortenK

    MortenK

    Joined:
    Sep 26, 2010
    Posts:
    21
    I'm also interested if someone saved the bloodspatter package, as the original file is no longer available.
     
  40. Inkognito

    Inkognito

    Joined:
    Aug 29, 2009
    Posts:
    60
    Ahm, I might have this one somewhere one my hard drive. I'll search for it tomorrow and upload it if I find but BUT wasn't there a new free decals script released just a few days ago?
     
  41. Afisicos

    Afisicos

    Joined:
    Nov 13, 2010
    Posts:
    326
    very nice i'll try it
     
  42. nebula2012

    nebula2012

    Joined:
    May 20, 2011
    Posts:
    8
    nice work ,take a look first
     
  43. Fat Fatty

    Fat Fatty

    Joined:
    Nov 8, 2010
    Posts:
    5
    Shallow said:

    "the only real problem i can se with it is that the blood splats are cut off in the corner"

    A quick and cheap 90% solution to that problem:

    each time you place one, trace a ray "back" from the four corners of the decal, to the original ray starting point. go as far as about the width of the decal.

    If you strike another wall while doing so, just paint in a decal at that new point. (Be sure NOT to iterate again!)

    It won't literally be the same decal bending around the corner, but, it will fully eliminate "stops at corners" - it's the 90% solution.

    Ideally tune the solution in this way: instead of departing "from the corners" come inwards Tune% towards the centre (this sort of sloppily allows for the decal not being just a square-filling square).
     
  44. super3

    super3

    Joined:
    Nov 14, 2011
    Posts:
    10
    so cool!;)
     
  45. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    731
    Good start. Here's a suggestion to make it even better:

    If the blood is clung to a wall it could slide slowly down, I think you can calculate this by comparing the angle of the blood to the global gravity direction and set the "sliding" speed along the wall accordingly.

    Keep it up!