In this article*, the developer explains how he makes decals: basically copy the triangles under a projector, cut away the edges, then apply the projected texture. Dunno how he handles z-fighting or if he does any kind of combination though.
… is that the way Unity’s projectors work?
I remember at Unite lots of people asking for decals during the wishlist session… why? what would they expect different from the current projectors? Is it “only” a matter of tool manipulation, making the level design easier?
for those who don’t know Wolfire, the blog this article is taken from, definitely check it out, it’s a goldmine. Basically, a bunch of boy geniuses are making an engine mostly from scratch, and they describe every step in a very readable manner.
Well, from my little experience with them, current projectors use a shader to combine the texture you are projecting with the one on the surface you’re projecting on. Not the best approach if you want for example, to create hundreds of bullet holes on many walls. It can be done, but is it the best way?
Should you really create lots of projectors, and play around with dozens of layers just to create this effect? Remember - a projector will project on anything in its view unless that object is in a layer that the projector ignores.
I imagine there are other reasons like maybe draw calls that are added when you’re projecting on multiple objects that have multiple materials, the accuracy and resolution of the projection that sometimes can be lacking, or the fact that you’re dealing with shaders - which means that you need to make sure all the other shaders you use in your project work well with the shader you use in your projector. On large scale projects it’s not a trivial task…
How about maybe because the projectors on the iPhone are a little tricky to work with and need exactly the right parameters to work?
Or maybe I’m talking out of my ass here and the real reason is that “All the rest of the game engines have them. We must have them as well!!!”
You are aware that you have 2 arguments in that are mutualy exclusive:
“projectors use shaders”
“projectors on the iPhone”
because the iphone has no shader support at all.
Also the projectors on the iphone are pretty simple, assign a correct compressed texture to it and it will work.
I think he was talking about “Unity shaders”. Which can be purely fixed function. Anyway, iPhone is not really relevant here.
@benblo: Projectors work by rendering all objects they “touch” with the Projector’s material. What the projector’s material does is completely open; the Projector just also provides some matrices so that the material+shader could project some texture, for example. But it could just as well just render object in pure red.
So yeah, the major difference from “decals” is that projector renders full object, even if it touches a very small part. Pros of this approach: the only cost on the CPU is the draw calls. Cons of this approach: much more filrate consumed, especially if model is very large.
Ah, thanks Aras, indeed the technique is completely different from that of the article! Which could be implemented manually is suppose, although doing it in scripting would probably be a big hit on performance…?