3

In my unity project, I got a gun. And when I shoot, a bullet (with a color red trail) from the barrel come out. I noticed, the trail is dark red, sometimes light red, I don't know why...

How can I do like this image? (this game in the image is called superhot created using unity)

Bright bullet trails Triangle or Square-like trail

The last image, the bullet's trail is like square or triangle...

newbieguy
  • 658
  • 2
  • 11
  • 29

1 Answers1

3

This is a kind of volumetric line rendering.

You can find a reference about it in here : https://www.assetstore.unity3d.com/kr/#!/content/29160

Usually it cost a lot because it needs multi-pass rendering in a shader. And trail renderer is a low polygon(just triangle strips), the result is not good if you apply a fake glow shader like this.

Shader "Test/Glow" {
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
    }
    SubShader {
        Tags { "Queue"="Transparent" }
        LOD 200
        ZTest Always
        Cull Off
        Blend One One

        CGPROGRAM
        #pragma surface surf Lambert

        float4 _Color;

        struct Input {
            float3 viewDir;
            float3 worldNormal;
        };

        void surf (Input IN, inout SurfaceOutput o) {
            o.Alpha = _Color.a * pow(abs(dot(normalize(IN.viewDir),
                normalize(IN.worldNormal))),4.0);
            o.Emission = _Color.rgb * o.Alpha;
        }
        ENDCG
    }
    FallBack "Diffuse"
}

(another glow shader : http://qiita.com/edo_m18/items/b5ad2490b73126489c07)

I think a cheapest way to mimic this rendering is

1) create or find a Additive Transparent Shader.
2) create a light texture (center is red and edge is gradient)
3) attach the shader to a material.
4) apply the material to the trail renderer.

Jinbom Heo
  • 7,248
  • 14
  • 52
  • 59
  • where could i find additive transparent shader? – newbieguy May 20 '15 at 08:32
  • is it a possible to make a round/circle trail? or depending on the shape? – newbieguy May 20 '15 at 08:35
  • Additive transparent shader is included in Unity by default. A sample is in 'Mobile/Particles/Additive'. And you can make cylinder-like trail if you use GL function in Unity. But in default, Unity do not give alternative option. – Jinbom Heo May 20 '15 at 08:56