I’m a complete noob when it comes to the ShaderLab. Anyway I’m trying to put a logo on the back of a unit in my strategy game, but its messed up. I based the whole thing off from the blob shadow projector.
Ok, I fixed the decal rendering in front by putting a falloff.
Now my problem is the decal doesn’t respond to lighting effects. It renders full lit in gray. I want it to get rendered according to the scene’s lights. In here I made the light red, but the decal doesn’t turn red:
As much progress as you’ve made, I don’t think that a projector is the righ tool for this job. Even with correct lighting, the projection will look weird as the cape moves or deforms, and anything that gets too close to the cape will get projected on, as well. I recommend duplicating the cape mesh and moving the duplicate out slightly to avoid Z fighting. Then just apply a transparent shader, and make sure that the duplicate mesh moves in the same way as the original.
Yes, I know. I’m aware of the problems with using a projector, but using a duplicate mesh requires using UV coords. The problem is I want the logos to be user-submitted pictures of logos the players want to use for their units in the strategy game.
Doing it in uv would mean they have to know the uv coords so the picture would fit in the spot the logo is intended to be displayed. Plus, the picture would have to be different for each in-game unit since each unit’s 3d model uv’s are different.
With projectors they just submit a square-sized picture with the logo on it.
I’ve tested it while the unit is running. The cape doesn’t deform too much, so its fine. Plus, I parented the projector to the 3d model’s skeleton, in the chest, so when the unit animates, the projector follows accordingly.
I’ll just have to make sure that my units’ collider has enough space in it so no object can get too close. If only I can set the projector to ignore everything but the unit’s 3d model itself.
So its really just the lighting that’s the most prominent problem.
Ok, now I tried a different approach, using multiple UVs on the unit’s mesh to display a logo.
It eliminates the problems with using a projector, however my shader code seems to have a problem: white areas don’t show, they get considered as transparent: