一个入门级的UV移动+材质叠加+Sin时间,形成的熔岩明暗交替流动效果
要点:
1.TextureCoordinates,纹理坐标,代码为UV=UV * 缩放+ 偏移,控制UV的缩放和偏移
2.Panner节点,UV控制器,代码为UV=UV+Speed.xy*Time,常用于UV随着时间发生变化
生成代码:
Shader "ASESampleShaders/AnimatedFire"
{
Properties
{
_Albedo("Albedo", 2D) = "white" {}
_Normals("Normals", 2D) = "bump" {}
_Mask("Mask", 2D) = "white" {}
_Specular("Specular", 2D) = "white" {}
_TileableFire("TileableFire", 2D) = "white" {}
_FireIntensity("FireIntensity", Range( 0 , 2)) = 0
_Smoothness("Smoothness", Float) = 1
_TileSpeed("TileSpeed", Vector) = (0,0,0,0)
[HideInInspector] _texcoord( "", 2D ) = "white" {}
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "IsEmissive" = "true" }
Cull Back
ZTest LEqual
CGPROGRAM
#include "UnityShaderVariables.cginc"
#pragma target 3.0
#pragma surface surf StandardSpecular keepalpha
struct Input
{
float2 uv_texcoord;
};
uniform sampler2D _Normals;
uniform sampler2D _Albedo;
uniform sampler2D _Mask;
uniform sampler2D _TileableFire;
uniform float2 _TileSpeed;
uniform float _FireIntensity;
uniform sampler2D _Specular;
uniform float _Smoothness;
void surf( Input i , inout SurfaceOutputStandardSpecular o )
{
float2 uv_TexCoord6 = i.uv_texcoord * float2( 2,1 ) + float2( 2,0 );
o.Normal = UnpackNormal( tex2D( _Normals, uv_TexCoord6 ) );
o.Albedo = tex2D( _Albedo, uv_TexCoord6 ).rgb;
float2 panner16 = ( _Time.x * _TileSpeed + uv_TexCoord6);
o.Emission = ( ( tex2D( _Mask, uv_TexCoord6 ) * tex2D( _TileableFire, panner16 ) ) * ( _FireIntensity * ( _SinTime.w + 1.5 ) ) ).rgb;
o.Specular = tex2D( _Specular, uv_TexCoord6 ).rgb;
o.Smoothness = _Smoothness;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
CustomEditor "ASEMaterialInspector"
}
来源:CSDN
作者:潜水的小懒猫
链接:https://blog.csdn.net/l364244206/article/details/103791516