Decalery (aka Bakery Decals)

Thank you for answering! Do you think you could ever include this as a demo in the future or is it a private project? I’m not really good with shaders however your support has helped me with an idea already :smiley:

The deformation system is rather complex and it’s kinda out of scope of the decal system. Maybe I can release it separately. But it’s also fairly limited, as I’m using hemispherical displacement projection for cars, and it’s not enough for anything that’s not mostly convex and mostly glued to ground.

Thank you for the support, I have a car deformation system (which just creates a runtime mesh then deforms it) and yet have to implement the decal systems into it which is why I was asking how you did it as it looks very good

Also, Is there anyway to use LODs with Decalery or is it optimized enough? Because I’m going to use it for a few models (LOD 0 is 35k triangles) and wondering if I’ll run into any troubles

Ah, then you should be able to just use Decalery the same way as with any other mesh :slight_smile:
If you want to know the logic I use to decide if a decal should be applied, then it’s just OnCollisionEnter() and using some average hit point/direction:

		int numContacts = collision.GetContacts(contacts);
		Vector3 contactPosSum = Vector3.zero;
		Vector3 contactNrmSum = Vector3.zero;
		for(int i=0; i<numContacts; i++)
		{
			var wpos = contacts[i].point;
			var wnormal = contacts[i].normal;
			wpos += wnormal * contacts[i].separation;
			contactPosSum += wpos;
			contactNrmSum += wnormal;
		}

		var contactNrmSumNormalized = contactNrmSum.normalized;
		var contactTestPoint = contactPosSum / numContacts;

Currently you need to apply a separate decal to every LOD mesh. Perhaps it should be automatic :thinking:

2 Likes

Thank you (and I apologize for the delays in me contacting back), I’m also wondering how much cost applying the decals to 3 models (being LODs) would be on peformance, would it cause a lag spike or not? I still have not tried it due to me being busy with work and did not have enough free time to experiment

In GPU runtime mode I don’t think it’ll be noticeable at all. In CPU mode it highly depends on your mesh detail. If it’s not really high-poly, it should be fine.

I also have built-in methods for stretching decal spawning over multiple frames (see AddDecalToQueue/UpdateQueue: Decalery manual - Bakery GPU Lightmapper: Wiki), they’re used in the example scene. I.e. you can add 100 decals to the queue but only spawn 10 each frame. Seen a similar optimization in HL1 :slight_smile:

Hi @guycalledfrank
I upgraded my unity version to 2022.3.45f1 (URP) and it seems that decalry is broken
image

Opening up the shader shows this error

And it seems that the issue is coming from here:

Any suggestions on how to get this working??

Some extra details:
I have bakery installed and working and I am working with URP.

Hmm are you on URP 14? Seems to work for me. Make sure that you’ve imported BOTH DecaleryURP and Bakery_ShaderGraphURP packages (the only difference between ExtendedPBR and BasicPBR is Bakery feature support). If that doesn’t work, please try my latest github patch.

BTW, I’m going to release a new store version probably… tomorrow!

Thats correct.
image

But that sounds good. I’ll grab the changes from the new store version tomorrow and report back if i have issues. Thanks!

1 Like

Decalery was updated to v1.1!

image

Changelog:

  • Terrains are now supported and can be used as receivers in all CPU/GPU modes:

See more details about terrain usage: Decalery manual - Bakery GPU Lightmapper: Wiki

  • Shaders now have better UI:

image

  • “Create mesh asset” option which I previously mentioned here, that serializes decal meshes, so they’re usable across scenes/from prefabs.

  • Bakery Lightmapped Prefab support. When applying decal to an object inside such prefab, Decalery will ask if you want the resulting decal mesh to be a part of the prefab. It will link decal lightmap references to the prefab storage, not scene storage.

  • Instead of “Link to parent” there are now 3 different options:

image

  • Shaders: fixed stereo rendering.

  • Shaders: fixed some deferred blending issues (previously discussed in this thread).

  • Shaders: fixed build error on Switch where it tried to compile the shader it wasn’t supposed to compile.

2 Likes

Re: lightmapped prefabs, I’m trying right now, but BakeryLightmappedPrefab is always detecting a change and won’t let me save the bake, because the mesh for the generated decals does not exist as an asset. What is the proper workflow here?

EDIT: nevermind! I see the generate mesh asset thing, I’m a dummy :slight_smile:

1 Like

@guycalledfrank so when using generate mesh asset and applying the decal across multiple receivers, generate mesh asset only generates one of them, so it breaks

EDIT: i figured this out. its because the two receivers had the exact same name. This is probably going to happen when using modular prefabs across multiple scenes. Can you append a random hash or something to the mesh names?

One more question, this is purely selfish. I think Faded might be one of the best looking games I’ve ever seen. Can we get some insight into how you used decals in a scene like this?

Is that breakup all decals and tiling textures? Or is it a combination of photo sourced facades and decals? Where do you get your decals? It looks absolutely stunning, btw.

1 Like

Ahhh, bummer. Made it a bit better now:

  • It will append prefab name if the decal is inside a Lightmapped Prefab.
  • It will append additional characters if there are identically named receivers for the same decal.

Can you check it with the latest github patch?

Also, a bonus:

I’ve added some normal modification options:

“Vertex welding” used to be “Optimize”.

  • “Off” and “Weld and keep normals” is what you previously got by checking “Optimize”.
  • “Weld and smooth normals inside receivers” basically smoothens all hard edges on the decal. But it won’t smooth disconnected edges, such as between different objects intersecting each other.
  • “Weld and average normals” averages all decal normals. Can be useful if you’re using small decals to hide seams between intersecting objects.

Thanks! :face_holding_back_tears: :heart:

Here are the decals I used here:

There are some cracks, muddy puddles and manhole covers on the floor; plus a bunch of decals on the buildings which just hide seams between different textures. A door on one building is also a decal (the handle on top of it is 3D though). Some dirty leaks under windows also.

Here is a funny one, because window shape was different on the photo-based texture: