C# 要将发射贴图功能添加到此着色器,我到底需要编写什么
我试图理解用代码编写的着色器,这是为统一的3D世界中的精灵而设计的着色器,它对3D照明做出反应,并具有发射贴图。稍后我将使用shader graph,但我想看看如何使用代码添加一个非常基本的发射贴图,因为我对着色器不太熟悉,也不确定在哪里写什么,我认为这将帮助我更好地理解着色器C# 要将发射贴图功能添加到此着色器,我到底需要编写什么,c#,unity3d,shader,C#,Unity3d,Shader,我试图理解用代码编写的着色器,这是为统一的3D世界中的精灵而设计的着色器,它对3D照明做出反应,并具有发射贴图。稍后我将使用shader graph,但我想看看如何使用代码添加一个非常基本的发射贴图,因为我对着色器不太熟悉,也不确定在哪里写什么,我认为这将帮助我更好地理解着色器 { Properties { [PerRendererData] _MainTex("Sprite Texture", 2D) = "white"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
[PerRenderData] _EmissionMap("Emission Map", 2D) = "white" {}
[HDR] _EmissionColor("Color", Color) = (1,1,1)
_Color("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
[HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
[HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
[PerRendererData] _AlphaTex("External Alpha", 2D) = "white" {}
[PerRendererData] _EnableExternalAlpha("Enable External Alpha", Float) = 0
_Cutoff("Alpha Cutoff", Range(0,1)) = 0.5
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
"CanUseSpriteAtlas" = "True"
}
Cull Off
Lighting Off
ZWrite Off
Blend One OneMinusSrcAlpha
CGPROGRAM
#pragma surface surf Lambert vertex:vert alphatest:_Cutoff addshadow nofog nolightmap nodynlightmap keepalpha noinstancing
#pragma multi_compile_local _ PIXELSNAP_ON
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
#include "UnitySprites.cginc"
struct Input
{
float2 uv_MainTex;
fixed4 color;
};
void vert(inout appdata_full v, out Input o)
{
v.vertex = UnityFlipSprite(v.vertex, _Flip);
#if defined(PIXELSNAP_ON)
v.vertex = UnityPixelSnap(v.vertex);
#endif
UNITY_INITIALIZE_OUTPUT(Input, o);
o.color = v.color * _Color * _RendererColor;
}
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c = SampleSpriteTexture(IN.uv_MainTex) * IN.color;
o.Albedo = c.rgb * c.a;
o.Alpha = c.a;
//o.Emission =
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
这是我目前的代码,我想知道我到底需要写什么,因为我一直有问题或错误,我希望这个问题可以在这里得到回答