如何在精灵上添加阴影发光效果? [英] How to add a shadow glow effect on my sprites?

查看:148
本文介绍了如何在精灵上添加阴影发光效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Unity团队一起制作关于神话的游戏.手动制作效果是游戏美术人员要做的许多工作,因此我需要在游戏的恶魔上呈现暗淡的发光效果.

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.

恶魔:

它必须是这样的:

(请参见相应的 YouTube视频.)

黑色发光的阴影效果对黑色装甲的战斗机Lancelot Berserker产生了影响.我已经尝试过使用粒子系统,但是它必须是基于我目前的知识,因此我需要一些有关如何执行此操作的指导.

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.

推荐答案

最好的办法是编写一个自定义着色器,以便您可以完全控制模型的显示方式.我认为这是一个非常好的HLSL/着色器教程,尽管它不是基于Unity的,但大多数原理仍然适用. http://rbwhitaker.wikidot.com/intro-to-shaders . 这是可以帮助您入门的东西...

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.

这篇关于如何在精灵上添加阴影发光效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆