游戏中冰冻效果与毒球效果制作实战

75 篇文章 2 订阅
7 篇文章 1 订阅

接着改造一个稍微复杂些的冰冻、毒球的shader,游戏中比较通用,可通过改造参数实现一些被击打后的效果特效。shader 代码如下:
Shader “Effects/Ice/IceFront” {
Properties {
_Color (“Main Color”, Color) = (1,1,1,1)
_SpecColor (“Specular Color”, Color) = (0.5,0.5,0.5,1)
_Shininess (“Shininess”, Range (0.01, 1)) = 0.078125
_ReflectColor (“Reflection Color”, Color) = (1,1,1,0.5)
_ReflectionStrength (“ReflectionStrength”, Range (1, 20)) = 1
_MainTex (“Base (RGB) Emission Tex (A)”, 2D) = “white” {}
_Opacity (“Material opacity”, Range (-1, 1)) = 0.5
_Cube (“Reflection Cubemap”, Cube) = “” { TexGen CubeReflect }
_BumpMap (“Normalmap”, 2D) = “bump” {}
_FPOW(“FPOW Fresnel”, Float) = 5.0
_R0(“R0 Fresnel”, Float) = 0.05
_Cutoff (“Cutoff”, Range (0, 1)) = 0.5
_LightStr (“Light strength”, Range (0, 1)) = 1
}

SubShader {
Tags { “Queue”=“Transparent+1” “RenderType”=“Transperent” }
LOD 200

CGPROGRAM
#pragma surface surf BlinnPhong alpha
#pragma target 3.0
#pragma glsl

sampler2D _MainTex;
sampler2D _BumpMap;
samplerCUBE _Cube;a

float4 _Color;
float4 _ReflectColor;
float _ReflectionStrength;
float _Shininess;
float _FPOW;
float _R0;
float _Opacity;
float _Cutoff;
float _LightStr;

struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
float3 viewDir;
float3 worldRefl;
INTERNAL_DATA
};

void surf (Input IN, inout SurfaceOutput o) {
half4 tex = tex2D(_MainTex, IN.uv_MainTex);
half4 c = tex * _Color;
o.Albedo = _Color;

    o.Gloss = tex.a;
    o.Specular = _Shininess;
   
    o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
   
    float3 worldRefl = WorldReflectionVector (IN, o.Normal);

    half4 reflcol = texCUBE (_Cube, worldRefl);
    reflcol *= tex.a;     

    half fresnel = saturate(1.0 - dot(o.Normal, normalize(IN.viewDir)));
    fresnel = pow(fresnel, _FPOW);
    fresnel = _R0 + (1.0 - _R0) * fresnel;
    reflcol = lerp(c, reflcol, fresnel);

    o.Emission = (reflcol.rgb * _ReflectColor.rgb * _ReflectionStrength) + 

_LightStr;
o.Alpha = saturate(_Cutoff > tex.a ? tex.a+_Opacity : 0);
}
ENDCG
}

FallBack “Reflective/Bumped Diffuse”
}

改造后的shader graph如下:
完整shader graph
有需要的可以留言。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值