Unity, unlit surface shader (Texcolor only surface shader)

Source: Internet
Author: User

To achieve two-sided transparent no light only texture-colored surface shader.

Wrong wording: (resulting in exposure)

Shader "Custom/doublefacetransptexcolor" {
Properties {
_color ("Color", color) = (1,1,1,1)
_maintex ("Albedo (RGB)", 2D) = "White" {}
}
Subshader {
Tags {"Rendertype" = "Transparent"}
LOD 200

Cull OFF

Blend srcalpha Oneminussrcalpha//Alpha Blending

Cgprogram
Physically based standard lighting model, and enable shadows on all light types
#pragma surface surf Mytexcolor alpha:fade

Half4 Lightingmytexcolor (surfaceoutput s, Half3 lightdir, half atten) {
Half4 C;
C.rgb=s.albedo;
C.a=s.alpha;
return C;

}
Use Shader Model 3.0 target, to get nicer looking lighting
#pragma target 3.0

Sampler2d _maintex;

struct Input {
FLOAT2 Uv_maintex;
};

Fixed4 _color;

void Surf (Input in, InOut surfaceoutput o) {
Albedo comes from a texture tinted by color
Fixed4 C = tex2d (_maintex, In.uv_maintex) * _COLOR;
O.albedo = C.rgb;
O.alpha = C.A;
}
Endcg
}
FallBack "Diffuse"
}

The correct wording:

Shader "Custom/doublefacetransptexcolor" {
Properties {
_color ("Color", color) = (1,1,1,1)
_maintex ("Albedo (RGB)", 2D) = "White" {}
}
Subshader {
Tags {"Rendertype" = "Transparent" "renderqueue" = "Transparent"}
LOD 200

Cull OFF
Lighting OFF
Blend srcalpha Oneminussrcalpha//Alpha Blending

Cgprogram
Physically based standard lighting model, and enable shadows on all light types
#pragma surface surf Mytexcolor noforwardadd Alpha:fade

Half4 Lightingmytexcolor (surfaceoutput s, Half3 lightdir, half atten) {
Half4 C;
C.RGB=HALF3 (0,0,0);
C.a=s.alpha;
return C;

}
Use Shader Model 3.0 target, to get nicer looking lighting
#pragma target 3.0



Sampler2d _maintex;

struct Input {
FLOAT2 Uv_maintex;
};

Fixed4 _color;

void Surf (Input in, InOut surfaceoutput o) {
Albedo comes from a texture tinted by color
Fixed4 C = tex2d (_maintex, In.uv_maintex) * _COLOR;
O.emission = C.rgb;
O.albedo = Fixed3 (0,0,0);
O.alpha = C.A;
}
Endcg
}
FallBack "Diffuse"
}

Reference: http://answers.unity3d.com/questions/272749/how-to-write-unlit-surface-shader.html

Unity, unlit surface shader (Texcolor only surface shader)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.