I want a texture to emit itself by 1, not more. In Standard Shader I enable Emission and set texture to Color and Color to 1. I don't need emission to go beyond the object, I only need the texture to shine.

My shader:

Shader "Mobile/My Bumped Diffuse" {
Properties{
    _MainTex("Base (RGB)", 2D) = "white" {}
    [NoScaleOffset] _BumpMap("Normalmap", 2D) = "bump" {}
    _Color("Color", Color) = (1, 1, 1, 1)
}

    SubShader{
        Tags{ "Queue" = "Transparent" "RenderType" = "Transparency" }
        LOD 250
        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

    CGPROGRAM
    #pragma surface surf Lambert noforwardadd alpha:fade

    sampler2D _MainTex;
    sampler2D _BumpMap;
    fixed4 _Color;
    fixed4 _Emission;

    struct Input {
        float2 uv_MainTex;
    };

    void surf(Input IN, inout SurfaceOutput o) {
        fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
        o.Albedo = c.rgb;
        o.Alpha = c.a;
        o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
    }
    ENDCG
}

    FallBack "Mobile/Diffuse"

}

  • How does the result of configuring the standard shader as you describe differ from what you want? – DMGregory Nov 30 at 12:21

I added:

_Emission("Emission", float) = 0

And

o.Emission = c.rgb * tex2D(_MainTex, IN.uv_MainTex).a * _Emission;

Full code:

Shader "Mobile/My Bumped Diffuse" {
Properties{
    _MainTex("Base (RGB)", 2D) = "white" {}
    [NoScaleOffset] _BumpMap("Normalmap", 2D) = "bump" {}
    _Color("Color", Color) = (1, 1, 1, 1)
        _Emission("Emission", float) = 0
}

    SubShader{
        Tags{ "Queue" = "Transparent" "RenderType" = "Transparency" }
        LOD 250
        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

    CGPROGRAM
    #pragma surface surf Lambert noforwardadd alpha:fade

    sampler2D _MainTex;
    sampler2D _BumpMap;
    fixed4 _Color;
    float _Emission;

    struct Input {
        float2 uv_MainTex;
    };

    void surf(Input IN, inout SurfaceOutput o) {
        fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
        o.Albedo = c.rgb;
        o.Alpha = c.a;
        o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
        o.Emission = c.rgb * tex2D(_MainTex, IN.uv_MainTex).a * _Emission;
    }
    ENDCG
    }

        FallBack "Mobile/Diffuse"

}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.