7
\$\begingroup\$

I am trying to create blood effects, where the characters being killed are on an uneven terrain. The simple way is to instantiate a prefab with texture, which uses a plane mesh, on the raycast hit point. But, in this case, this looks quite odd as the terrain has height variance within the bounds of the plane of the blood splatter prefab.

I tried using the projector in Unity, but the issue with using that is that the projector shaders are very simple. In particular, I don't want them to blend into the terrain texture, and wanted to add specularity (to make it look like a liquid).

What is my best option?

\$\endgroup\$
  • \$\begingroup\$ I don't know the Unity specific way of doing this, but the technique you are looking for is called Decals. :) \$\endgroup\$ – János Turánszki Feb 23 '17 at 13:47
  • \$\begingroup\$ I tried using decals, and the problem I faced while going the usual way is what I have described in the first paragraph. \$\endgroup\$ – Aman Feb 24 '17 at 18:51
1
\$\begingroup\$

What you're looking for is a decal system.

I don't know quite how they work in the general sense of "how do you make a decal system" (and each system might be built in different ways) but the way it works from a usability standpoint is exactly what you want: textures overlaid on a target surface conforming to its contours. They're generally fast and inexpensive (on system resources) the same way particle systems are, which is why they're used for detail in all sorts of ways (those bits of paper trash on the street in Half Life and Left 4 Dead? Those are also decals).

There's quite a few decal systems available on the asset store and I'm pretty sure I've worked with this one before. It might fill your needs, or one of the others might work better, do a little research.

\$\endgroup\$
  • 1
    \$\begingroup\$ I have a diagram giving a bit of an intro to screenspace decals, one of the popular techniques for this, in this answer. That uses scene depth to conform each sample of the decal to the underlying geometry, while the actual rendered decal volume is simpler. The other popular way involves copying & clipping the triangles of mesh around the decal site create a tightly-fitted skin, onto which the decal can be drawn with normal texture mapping. \$\endgroup\$ – DMGregory Feb 12 '18 at 2:37
  • \$\begingroup\$ @DMGregory That's neat. I am unfamiliar with that technique entirely! \$\endgroup\$ – Draco18s Feb 12 '18 at 4:15
0
\$\begingroup\$

I am no expert with projectors as I haven't used them a lot myself, but however to achieve what you seek, especially at the uneven terrain part, you'd want to use a projector or at least something similar. While decals can do a lot a projector will achieve the same effect with less efforts. That is where projectors dominate. The material used for the projector can use a shader you like to for example use the standard specular shader with modified values.

You might want to write your own shader with shaderlab or CG depending on what you prefer. But I honestly think that a projector will achieve what you are looking for. By creating a material with the texture and shader you like you can modify a lot values to make each of them look unique.

Projector tutorial: http://talarian.blogspot.nl/p/unity-tutorial.html

Unity docs for projector: https://docs.unity3d.com/Manual/class-Projector.html

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.