How to add a shadow glow effect on my sprites?

2019-08-19 12:23发布

I'm creating a game about mythology with my team in Unity. It'll be a lot of work for the artist of my game to manually do the effects, so I need a dark glowing effect on the demon of the game.

Demon:

demon

It needs to be something like this:

enter image description here

(See corresponding YouTube video.)

The black glowing shadow effect on Lancelot Berserker, the fighter in black armor. I've attempted with the particle system, but it must be out of my current knowledge so I'd like some guidance on how to do it.

标签: unity3d
1条回答
Juvenile、少年°
2楼-- · 2019-08-19 12:40

Your best bet is to write a custom shader so that you have complete control over how the model is displayed. I think that this is a very good HLSL / shader tutorial even though it is not Unity based, most of the principles still apply. http://rbwhitaker.wikidot.com/intro-to-shaders. Here is something that could get you started though...

Shader "Custom/GlowEffect" {
    Properties {
        _ColourTint("Colour Tint", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _BumpMap("Normal Map", 2D) = "bump" {}
        _RimColour("Rim Colour",Color) = (0.078,0.695,0.184,1)
        _RimPower("Rim Power", Range(1.0,6.0)) = 3.0
    }
    SubShader {
        Tags { "RenderType"="Opaque" }

        CGPROGRAM
        #pragma surface surf Lambert


        struct Input {
            float4 color : Color;
            float2 uv_MainTex;
            float2 uv_BumpMap;
            float3 viewDir;
        };

        float4 _ColourTint;
        sampler2D _MainTex;
        sampler2D _BumpMap;
        float4 _RimColour;
        float _RimPower;

        void surf (Input IN, inout SurfaceOutput o) {
            IN.color = _ColourTint;
            o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * IN.color;
            o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));

            half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
            o.Emission = _RimColour.rgb * pow(rim, _RimPower);
        }
        ENDCG
    } 
    FallBack "Diffuse"
}

The only downside is that this will need to be applied to each mesh group of your object.

Cheers and hope this helped.

查看更多
登录 后发表回答