75 lines
1.8 KiB
Plaintext
75 lines
1.8 KiB
Plaintext
Shader "Custom/GlowStoneShader"
|
|
{
|
|
Properties
|
|
{
|
|
_Color ("Main Color", Color) = (1, 1, 1, 1) // 主颜色(矿石的基本颜色)
|
|
_EmissionColor ("Emission Color", Color) = (1, 1, 1, 1) // 发光颜色
|
|
_MainTex ("Base Texture", 2D) = "white" { } // 基本纹理
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags { "RenderType"="Opaque" }
|
|
|
|
Pass
|
|
{
|
|
Name "FORWARD"
|
|
Tags { "LightMode"="ForwardBase" }
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma multi_compile_fog
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 pos : POSITION;
|
|
float3 normal : TEXCOORD0;
|
|
float2 uv : TEXCOORD1;
|
|
float4 fog : FOG;
|
|
};
|
|
|
|
uniform float4 _Color;
|
|
uniform float4 _EmissionColor;
|
|
sampler2D _MainTex;
|
|
float4 _MainTex_ST;
|
|
|
|
v2f vert(appdata v)
|
|
{
|
|
v2f o;
|
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
o.normal = v.normal;
|
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
|
return o;
|
|
}
|
|
|
|
half4 frag(v2f i) : SV_Target
|
|
{
|
|
// 基本纹理采样
|
|
half4 texColor = tex2D(_MainTex, i.uv) * _Color;
|
|
|
|
// 计算发光颜色
|
|
half4 emission = _EmissionColor;
|
|
|
|
// 将发光颜色与基础纹理颜色合成
|
|
half4 finalColor = texColor + emission;
|
|
|
|
// 输出最终颜色
|
|
return finalColor;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
|
|
FallBack "Diffuse"
|
|
}
|