- Home /
Using shuriken to create volumetric lights effect
Gents,
I'm trying really hard to create a volumetric effect of a flashlight in a foggy environment.
The visual effect intended is this:
I've reached two possible solutions:
-The simplest one is to have a translucent mesh goin out of the flashlight. But the angle of the light will vary and the distance of the light "hitting" the objects will vary also. So i think it generates too many issues with a poor quality effect, and thus is not worth it. Maybe it is great for some static lights.
-The other one is the particle system, but my efforts were merely tweak the massive amount of parameters, changing the material and stuff. The closest I reached of achieving success was changing the render mode to stretched billboard and play a little with speed scale and length scale. I already discovered that each particle lifetime must be 1 or less. The duration of the hole loop doesn't matter as long it is bigger than particle lifetime. And particle speed would reflect on each particle/ray length, and increasing speed will lead to more spacing between particles and then more particle count to fill the gaps.
This is where I got:
I think the particle system could respond better to the scene, as this light would be hold by the player's character, and would be walking around and lighting things up.
The biggest concerns I have right now are the performance, as this particle system would take hundreds of thousands of particles to work properly. And the collision with different objects with different distances to the particle/light source.
Any one with experience with this matter could "shed some light" to help me solve this?
Thanks in advance.
Answer by GeorgeRigato · Nov 12, 2012 at 03:28 PM
(I would post this as a comment on my own first post, but I need to post a image.)
After some work, i reached this:
But it's not quite there yet. I need more fill, but without adding an absurd amount of particles.
reaching a perfect filled cone/cilinder, with right transparency and with low particles is the goal here. Later I can worry about collision and stuff.
Any ideas?
Answer by elpierrot · Nov 12, 2012 at 04:33 PM
You should work with a cone mesh and a nice shader
I don't know if you read the beginning of the first post where I quote a mesh as an option for solution but I'd rather go with particles.
If you really want to help people you should develop better your answer or explanation.
I'm not doubting your capabilities or skills, but I'm trying to bring attention on your communication effort.
Thanks anyway for stating your $$anonymous$$d.
sorry I read too fast but that's the common solution for this kind of stuff. Shader could do the difference between a cheap solution and a nice one.
Answer by GeorgeRigato · Nov 12, 2012 at 05:41 PM
Well,
this is the latest progress after some work:
I noticed the stretched billboard have a better effect when looked sideways, and the perspective of the game (3rd person, from behind) doesn't take advantage of that. Instead of a cone of light, I'm getting more a fog/mist effect over my path of light.
Answer by lightbug · Feb 28, 2013 at 02:19 PM
very nice! I used a plane with a particle/alpha bleeding shader (with diferent lights cookies) and a script that controls the alpha depending of the distance between the player and the plane (near : alpha = 0 , far : alpha =x)
GameObject camara;
public float alpha_maximo = 0.5f;
public float distancia_critica = 15;
public float distancia_muerta = 1;
float alpha_final;
public Color color;
void Start () {
camara = Camera.mainCamera.gameObject;
}
void Update () {
//look at me
transform.rotation = Quaternion.Euler(transform.eulerAngles.x,
camara.transform.eulerAngles.y,
transform.eulerAngles.z);
//compute alpha
Vector3 distancia = camara.transform.position - transform.position;
if(Vector3.Magnitude(distancia)< distancia_critica){
alpha_final = (alpha_maximo)*(Mathf.Pow((Vector3.Magnitude(distancia))/distancia_critica,2));
if(Vector3.Magnitude(distancia)< distancia_muerta){
print ("muerta");
alpha_final = 0;
}
}else{
alpha_final = alpha_maximo;
}
//new alpha
gameObject.renderer.material.SetColor("_TintColor",
new Vector4(color.r,color.g,color.b,alpha_final));
/////////
}
}
Answer by MarkD · Apr 04, 2014 at 06:14 PM
Well there is this system https://www.assetstore.unity3d.com/#/content/13196
It uses a smart setup of planes to generate "fake" volumetric light (not actual light itself just the effect). It has different setup features, one of them is cone casting where you can setup the shape to match your spot light source, in one of the images this is shown with a projector. It works light source independent, but can also get range distance from a light source if needed (or set it manually, in your case you can use the light source).