- Home /
Fading off texture and multiple instances
Hello, I am developing a game in which the gameplay is strongly based on decals. Those decals will be dynamic and the best would be to make them self-illuminated.
So I think to proceed with:
Texture with alpha + Transparent/Cutout/Soft Edge Unlit Shader
Change dynamically the Main Color from White to Black for the decay (this is only good if I have a completely dark scene)
I also found on the internet some custom shader developed by the community Self-Illuminated and taking into account Alpha.
Any other Shader+Texture suggestion to achieve the same is well accepted.
For the Footprint I found a nice script with a pool of data to be used to be assigned to a Mesh. The problem is that I think if I update the Material, the MeshRenderer will apply the same texture to the mesh.
My idea is to have a Footprint or Decal "Factory" that will instantiate a Footprint with a set of settings (position, direction, material, etc...) and make it evolve independently from the other instances. Those objects will have a Time to Live and then will be Destroyed (or reused).
For the TTL and "decay", depending on the law of decay, I can use:
Update() and use the time or an internal counter as parameter of the function
InvokeRepeating() or yield WaitFor* if I want discrete changes
Coroutines...
Since Footprint will not be the only decal to behave like that, I would like to ask you for some help.
The best would be to have a factory class to instantiate GameObjects (or get them from a pool). Each GameObject has its own mesh and material. The GameObject will be initialized with the decay settings and the mesh properly instantiated in the correct position & orientation. The GameObject will be self updating the values for making itself fade off until Destruction or reuse.
Is it the right approach?
This is more of a design discussion that is more appropriate to the Unity Forums than to Unity Answers. For things like lots of decals, usually you want to display them in a single mesh. Each quad of the mesh represents one 'footprint'. The uv coordinates of that quad control what gets displayed from a texture atlas, so you can switch between left or right foot, or even have a set each with different amounts of fade. If you have a shader that supports uv colors, you may be able to control the fade as well by the assignment of colors in the mesh colors array. Here is one post on UA that you may be interested in:
http://answers.unity3d.com/questions/475795/rendering-permanent-trails-such-as-footsteps.html
I don't believe you want separate game object for each decal. That's were you are headed when you write about 'update the $$anonymous$$aterial'. If possible, you want to modify the mesh, and leave the material alone.
hello, yes this is the script I was talking about.
The problem is that the tradeoff is between:
a huge texture with all shades * each kind of footstep + update at each decay trigger to change the uv mapping of the correct footstep shade
a texture with only the different kind of footsteps and change the shade by some change in color or alpha in the shader
I tried with the following:
An empty object with a Footprint$$anonymous$$anager script: it Instantiates a copy of a Footprint prefab, creates a new mesh and adds this mesh to the new instantiated object
The Footprint prefab starts to fade off thanks to a script which updates the material settings
Any idea on how to optimize draw calls?
Your answer
Follow this Question
Related Questions
Project vertices on surface, make a shape 1 Answer
Shader to paint at coords? 1 Answer
How do you set the UVs for a decal texture? 0 Answers
Decal Alpha Blend 0 Answers
How do I build A texture from decals? 0 Answers