ASE实例1-熔岩效果

旧城冷巷雨未停 提交于 2020-01-29 00:37:44

 

一个入门级的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"
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!